Mypal portable mode

This commit is contained in:
K4sum1 2025-03-24 16:06:08 -07:00
commit 633ef1c426
24 changed files with 299 additions and 25 deletions

View file

@ -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();
},

View file

@ -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);
}
},
};

View file

@ -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.

View file

@ -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

View file

@ -40,6 +40,7 @@ Var AddDesktopSC
Var InstallMaintenanceService
Var PageName
Var PreventRebootRequired
Var PrtChkb
; By defining NO_STARTMENU_DIR an installer that doesn't provide an option for
; an application's Start Menu PROGRAMS directory and doesn't define the
@ -289,6 +290,15 @@ Section "-Application" APP_IDX
"$(ERROR_CREATE_DIRECTORY_PREFIX)" \
"$(ERROR_CREATE_DIRECTORY_SUFFIX)"
${If} $InstallType == ${INSTALLTYPE_PORTABLE}
${If} $PrtChkb == 1
FileOpen $0 "$INSTDIR\browser\pmprt.mod" w
FileClose $0
${Else}
FileOpen $0 "$INSTDIR\browser\pmundprt.mod" w
FileClose $0
${EndIf}
${Else}
; Register DLLs
; XXXrstrong - AccessibleMarshal.dll can be used by multiple applications but
; is only registered for the last application installed. When the last
@ -538,6 +548,7 @@ Section "-Application" APP_IDX
${EndIf}
${EndUnless}
${EndIf}
${EndIf}
SectionEnd
; Cleanup operations to perform at the end of the installation.
@ -856,6 +867,12 @@ Function leaveOptions
${MUI_INSTALLOPTIONS_READ} $R0 "options.ini" "Field 3" "State"
StrCmp $R0 "1" +1 +2
StrCpy $InstallType ${INSTALLTYPE_CUSTOM}
${MUI_INSTALLOPTIONS_READ} $R0 "options.ini" "Field 6" "State"
StrCmp $R0 "1" +1 +2
StrCpy $InstallType ${INSTALLTYPE_PORTABLE}
${MUI_INSTALLOPTIONS_READ} $R0 "options.ini" "Field 7" "State"
StrCmp $R0 "1" +1 +2
StrCpy $PrtChkb 1
${LeaveOptionsCommon}
@ -945,6 +962,7 @@ Function preSummary
DeleteINISec "$PLUGINSDIR\summary.ini" "Field 4"
; Check if it is possible to write to HKLM
${If} $InstallType != ${INSTALLTYPE_PORTABLE}
ClearErrors
WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" "Write Test"
${Unless} ${Errors}
@ -991,6 +1009,7 @@ Function preSummary
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Left "0"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Right "-1"
${EndIf}
${EndIf}
!insertmacro MUI_HEADER_TEXT "$(SUMMARY_PAGE_TITLE)" "$(SUMMARY_PAGE_SUBTITLE)"
@ -1113,7 +1132,7 @@ Function .onInit
!insertmacro InitInstallOptionsFile "shortcuts.ini"
!insertmacro InitInstallOptionsFile "summary.ini"
WriteINIStr "$PLUGINSDIR\options.ini" "Settings" NumFields "5"
WriteINIStr "$PLUGINSDIR\options.ini" "Settings" NumFields "7"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Type "label"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Text "$(OPTIONS_SUMMARY)"
@ -1139,6 +1158,14 @@ Function .onInit
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Bottom "65"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" State "0"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Type "RadioButton"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Text "$(OPTION_PORTABLE_RADIO)"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Left "0"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Right "-1"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Top "85"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Bottom "95"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" State "0"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Type "label"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Text "$(OPTION_STANDARD_DESC)"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Left "15"
@ -1153,6 +1180,14 @@ Function .onInit
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Top "67"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Bottom "87"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 7" Type "checkbox"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 7" Text "$(OPTION_PORTABLE_DESC)"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 7" Left "15"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 7" Right "-1"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 7" Top "97"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 7" Bottom "117"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 7" State "0"
; Setup the shortcuts.ini file for the Custom Shortcuts Page
; Don't offer to install the quick launch shortcut on Windows 7
${If} ${AtLeastWin7}

View file

@ -25,6 +25,8 @@ setDefaultBrowserMessage=%S is not currently set as your default browser. Would
setDefaultBrowserDontAsk=Always perform this check when starting %S.
setDefaultBrowserAlertConfirm.label=Use %S as my default browser
setDefaultBrowserAlertNotNow.label=Not now
PortablemodeTitle=Portable Mode
PortablemodeMessage=By pressing Yes you switch %S into standart non-portable mode, and browser will restart.
desktopBackgroundLeafNameWin=Desktop Background.bmp
DesktopBackgroundDownloading=Saving Picture…

View file

@ -73,6 +73,8 @@ OPTION_STANDARD_RADIO=&Standard
# Two lines
OPTION_CUSTOM_DESC=You may choose individual options to be installed. Recommended for experienced users.
OPTION_CUSTOM_RADIO=&Custom
OPTION_PORTABLE_DESC=Fully portable, disable system integration functionality (no-remote).
OPTION_PORTABLE_RADIO=&Portable
# LOCALIZATION NOTE:
# The following text replaces the Install button text on the summary page.

View file

@ -17,6 +17,9 @@ Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "AlertsService",
"@mozilla.org/alerts-service;1", "nsIAlertsService");
XPCOMUtils.defineLazyServiceGetter(this, "winShellService",
"@mozilla.org/browser/shell-service;1","nsIWindowsShellService");
// Define Lazy Module Getters
[
["AddonManager", "resource://gre/modules/AddonManager.jsm"],
@ -735,6 +738,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);
@ -778,7 +783,7 @@ BrowserGlue.prototype = {
ShellService.shouldCheckDefaultBrowser = checkEveryTime.value;
}.bind(this), Ci.nsIThread.DISPATCH_NORMAL);
}
}
}}
},
_onQuitRequest: function(aCancelQuit, aQuitType) {

View file

@ -9,6 +9,9 @@ Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/LoadContextInfo.jsm");
Components.utils.import("resource://gre/modules/BrowserUtils.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "winShellSvc",
"@mozilla.org/browser/shell-service;1","nsIWindowsShellService");
var gAdvancedPane = {
_inited: false,
@ -745,6 +748,8 @@ var gAdvancedPane = {
document.getElementById("alwaysCheckDefault").disabled = true;
return;
}
var profService = Components.classes["@mozilla.org/toolkit/profile-service;1"].getService(Components.interfaces.nsIToolkitProfileService);
if (profService.portable()==1) return;
let selectedIndex =
shellSvc.isDefaultBrowser(false, true) ? 1 : 0;
setDefaultPane.selectedIndex = selectedIndex;
@ -756,9 +761,32 @@ var gAdvancedPane = {
setDefaultBrowser: function()
{
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) {
winShellSvc.cancelPortableMode();
isPortable=28;
} else return;
}
let claimAllTypes = true;
#ifdef XP_WIN
// In Windows 8+, the UI for selecting default protocol is much
@ -776,6 +804,7 @@ var gAdvancedPane = {
let selectedIndex =
shellSvc.isDefaultBrowser(false, true) ? 1 : 0;
document.getElementById("setDefaultPane").selectedIndex = selectedIndex;
if (isPortable==28) Application.quit();
}
#endif
};

View file

@ -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.

View file

@ -402,6 +402,31 @@ nsWindowsShellService::IsDefaultBrowserVista(bool aCheckAllTypes,
return true;
}
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;
}
NS_IMETHODIMP
nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
bool aForAllTypes,

View file

@ -39,6 +39,7 @@ Var AddDesktopSC
Var InstallMaintenanceService
Var PageName
Var PreventRebootRequired
Var PrtChkb
; By defining NO_STARTMENU_DIR an installer that doesn't provide an option for
; an application's Start Menu PROGRAMS directory and doesn't define the
@ -287,6 +288,15 @@ Section "-Application" APP_IDX
"$(ERROR_CREATE_DIRECTORY_PREFIX)" \
"$(ERROR_CREATE_DIRECTORY_SUFFIX)"
${If} $InstallType == ${INSTALLTYPE_PORTABLE}
${If} $PrtChkb == 1
FileOpen $0 "$INSTDIR\browser\pmprt.mod" w
FileClose $0
${Else}
FileOpen $0 "$INSTDIR\browser\pmundprt.mod" w
FileClose $0
${EndIf}
${Else}
; Register DLLs
; XXXrstrong - AccessibleMarshal.dll can be used by multiple applications but
; is only registered for the last application installed. When the last
@ -532,6 +542,7 @@ Section "-Application" APP_IDX
${EndIf}
${EndUnless}
${EndIf}
${EndIf}
SectionEnd
; Cleanup operations to perform at the end of the installation.
@ -850,6 +861,12 @@ Function leaveOptions
${MUI_INSTALLOPTIONS_READ} $R0 "options.ini" "Field 3" "State"
StrCmp $R0 "1" +1 +2
StrCpy $InstallType ${INSTALLTYPE_CUSTOM}
${MUI_INSTALLOPTIONS_READ} $R0 "options.ini" "Field 6" "State"
StrCmp $R0 "1" +1 +2
StrCpy $InstallType ${INSTALLTYPE_PORTABLE}
${MUI_INSTALLOPTIONS_READ} $R0 "options.ini" "Field 7" "State"
StrCmp $R0 "1" +1 +2
StrCpy $PrtChkb 1
${LeaveOptionsCommon}
@ -939,6 +956,7 @@ Function preSummary
DeleteINISec "$PLUGINSDIR\summary.ini" "Field 4"
; Check if it is possible to write to HKLM
${If} $InstallType != ${INSTALLTYPE_PORTABLE}
ClearErrors
WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" "Write Test"
${Unless} ${Errors}
@ -985,6 +1003,7 @@ Function preSummary
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Left "0"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Right "-1"
${EndIf}
${EndIf}
!insertmacro MUI_HEADER_TEXT "$(SUMMARY_PAGE_TITLE)" "$(SUMMARY_PAGE_SUBTITLE)"
@ -1076,7 +1095,7 @@ Function .onInit
!insertmacro InitInstallOptionsFile "shortcuts.ini"
!insertmacro InitInstallOptionsFile "summary.ini"
WriteINIStr "$PLUGINSDIR\options.ini" "Settings" NumFields "5"
WriteINIStr "$PLUGINSDIR\options.ini" "Settings" NumFields "7"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Type "label"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Text "$(OPTIONS_SUMMARY)"
@ -1102,6 +1121,14 @@ Function .onInit
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Bottom "65"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" State "0"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Type "RadioButton"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Text "$(OPTION_PORTABLE_RADIO)"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Left "0"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Right "-1"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Top "85"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Bottom "95"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" State "0"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Type "label"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Text "$(OPTION_STANDARD_DESC)"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Left "15"
@ -1116,6 +1143,14 @@ Function .onInit
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Top "67"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Bottom "87"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 7" Type "checkbox"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 7" Text "$(OPTION_PORTABLE_DESC)"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 7" Left "15"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 7" Right "-1"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 7" Top "97"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 7" Bottom "117"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 7" State "0"
; Setup the shortcuts.ini file for the Custom Shortcuts Page
; Don't offer to install the quick launch shortcut on Windows 7
${If} ${AtLeastWin7}

View file

@ -8,6 +8,8 @@ setDefaultBrowserTitle=Default Browser
setDefaultBrowserMessage=%S is not currently set as your default browser. Would you like to make it your default browser?
setDefaultBrowserDontAsk=Always perform this check when starting %S.
alreadyDefaultBrowser=%S is already set as your default browser.
PortablemodeTitle=Portable Mode
PortablemodeMessage=By pressing Yes you switch %S into standart non-portable mode, and browser will quit.
desktopBackgroundLeafNameWin=Desktop Background.bmp
DesktopBackgroundDownloading=Saving Picture…
DesktopBackgroundSet=Set Desktop Background

View file

@ -77,6 +77,8 @@ OPTION_STANDARD_RADIO=&Standard
# Two lines
OPTION_CUSTOM_DESC=You may choose individual options to be installed. Recommended for experienced users.
OPTION_CUSTOM_RADIO=&Custom
OPTION_PORTABLE_DESC=Fully portable, disable system integration functionality (no-remote).
OPTION_PORTABLE_RADIO=&Portable
# LOCALIZATION NOTE:
# The following text replaces the Install button text on the summary page.