mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 16:58:38 +09:00
Mypal portable mode
This commit is contained in:
parent
32c50fd018
commit
633ef1c426
24 changed files with 299 additions and 25 deletions
|
|
@ -16,7 +16,8 @@ Cu.import("resource://gre/modules/AsyncPrefs.jsm");
|
|||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "WindowsUIUtils", "@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils");
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "AlertsService", "@mozilla.org/alerts-service;1", "nsIAlertsService");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "winShellService",
|
||||
"@mozilla.org/browser/shell-service;1","nsIWindowsShellService");
|
||||
// lazy module getters
|
||||
[
|
||||
["AboutHome", "resource:///modules/AboutHome.jsm"],
|
||||
|
|
@ -1029,6 +1030,8 @@ BrowserGlue.prototype = {
|
|||
isDefaultError = true;
|
||||
}
|
||||
|
||||
var profService = Cc["@mozilla.org/toolkit/profile-service;1"].getService(Ci.nsIToolkitProfileService);
|
||||
if (profService.portable()!=1) {
|
||||
if (isDefault) {
|
||||
let now = (Math.floor(Date.now() / 1000)).toString();
|
||||
Services.prefs.setCharPref("browser.shell.mostRecentDateSetAsDefault", now);
|
||||
|
|
@ -1059,7 +1062,7 @@ BrowserGlue.prototype = {
|
|||
DefaultBrowserCheck.prompt(RecentWindow.getMostRecentBrowserWindow());
|
||||
}.bind(this), Ci.nsIThread.DISPATCH_NORMAL);
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
E10SAccessibilityCheck.onWindowsRestored();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -550,6 +550,8 @@ var gMainPane = {
|
|||
defaultBrowserBox.hidden = true;
|
||||
return;
|
||||
}
|
||||
var profService = Components.classes["@mozilla.org/toolkit/profile-service;1"].getService(Components.interfaces.nsIToolkitProfileService);
|
||||
if (profService.portable()==1) return;
|
||||
let setDefaultPane = document.getElementById("setDefaultPane");
|
||||
let isDefault = shellSvc.isDefaultBrowser(false, true);
|
||||
setDefaultPane.selectedIndex = isDefault ? 1 : 0;
|
||||
|
|
@ -568,10 +570,34 @@ var gMainPane = {
|
|||
let alwaysCheckPref = document.getElementById("browser.shell.checkDefaultBrowser");
|
||||
alwaysCheckPref.value = true;
|
||||
|
||||
|
||||
let shellSvc = getShellService();
|
||||
var profService = Components.classes["@mozilla.org/toolkit/profile-service;1"].getService(Components.interfaces.nsIToolkitProfileService);
|
||||
let isPortable;
|
||||
if (!shellSvc)
|
||||
return;
|
||||
try {
|
||||
isPortable = profService.portable();
|
||||
if (isPortable==1) {
|
||||
Components.utils.import("resource:///modules/RecentWindow.jsm");
|
||||
var win = RecentWindow.getMostRecentBrowserWindow();
|
||||
var brandBundle = win.document.getElementById("bundle_brand");
|
||||
var shellBundle = win.document.getElementById("bundle_shell");
|
||||
|
||||
var brandShortName = brandBundle.getString("brandShortName");
|
||||
var promptTitle = shellBundle.getString("PortablemodeTitle");
|
||||
var promptMessage = shellBundle.getFormattedString("PortablemodeMessage",
|
||||
[brandShortName]);
|
||||
// var checkEveryTime = { value: shouldCheck };
|
||||
var ps = Services.prompt;
|
||||
var rv = ps.confirmEx(win, promptTitle, promptMessage,
|
||||
ps.STD_YES_NO_BUTTONS,
|
||||
null, null, null, null, { });//, checkboxLabel, checkEveryTime);
|
||||
if (rv == 0) {
|
||||
shellSvc.cancelPortableMode();
|
||||
isPortable=28;
|
||||
} else return;
|
||||
}
|
||||
shellSvc.setDefaultBrowser(true, false);
|
||||
} catch (ex) {
|
||||
Cu.reportError(ex);
|
||||
|
|
@ -580,6 +606,7 @@ var gMainPane = {
|
|||
|
||||
let selectedIndex = shellSvc.isDefaultBrowser(false, true) ? 1 : 0;
|
||||
document.getElementById("setDefaultPane").selectedIndex = selectedIndex;
|
||||
if (isPortable==28) Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestartNotSameProfile);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
[scriptable, uuid(f8a26b94-49e5-4441-8fbc-315e0b4f22ef)]
|
||||
interface nsIWindowsShellService : nsIShellService
|
||||
{
|
||||
void cancelPortableMode();
|
||||
/**
|
||||
* Provides the shell service an opportunity to do some Win7+ shortcut
|
||||
* maintenance needed on initial startup of the browser.
|
||||
|
|
|
|||
|
|
@ -369,6 +369,31 @@ IsDefaultBrowserWin8(bool aCheckAllTypes, bool* aIsDefaultBrowser)
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::CancelPortableMode()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIFile> portmodemark;
|
||||
|
||||
rv = NS_GetSpecialDirectory(NS_OS_CURRENT_PROCESS_DIR,
|
||||
getter_AddRefs(portmodemark));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = portmodemark->AppendNative(NS_LITERAL_CSTRING("pmprt.mod"));
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool fileExists;
|
||||
rv = portmodemark->Exists(&fileExists);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (fileExists)
|
||||
portmodemark->Remove(false);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Query's the AAR for the default status.
|
||||
* This only checks for BasiliskURL and if aCheckAllTypes is set, then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue