diff --git a/application/basilisk/components/nsBrowserGlue.js b/application/basilisk/components/nsBrowserGlue.js index 0250909bbf..b53536a0e5 100644 --- a/application/basilisk/components/nsBrowserGlue.js +++ b/application/basilisk/components/nsBrowserGlue.js @@ -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(); }, diff --git a/application/basilisk/components/preferences/in-content/main.js b/application/basilisk/components/preferences/in-content/main.js index 967c72fda4..9c2a512c7a 100644 --- a/application/basilisk/components/preferences/in-content/main.js +++ b/application/basilisk/components/preferences/in-content/main.js @@ -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); } }, }; diff --git a/application/basilisk/components/shell/nsIWindowsShellService.idl b/application/basilisk/components/shell/nsIWindowsShellService.idl index 57ed370555..d7a91d7d70 100644 --- a/application/basilisk/components/shell/nsIWindowsShellService.idl +++ b/application/basilisk/components/shell/nsIWindowsShellService.idl @@ -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. diff --git a/application/basilisk/components/shell/nsWindowsShellService.cpp b/application/basilisk/components/shell/nsWindowsShellService.cpp index cb13c09106..71af37672f 100644 --- a/application/basilisk/components/shell/nsWindowsShellService.cpp +++ b/application/basilisk/components/shell/nsWindowsShellService.cpp @@ -369,6 +369,31 @@ IsDefaultBrowserWin8(bool aCheckAllTypes, bool* aIsDefaultBrowser) } } +NS_IMETHODIMP +nsWindowsShellService::CancelPortableMode() +{ + nsresult rv; + + nsCOMPtr 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 diff --git a/application/basilisk/installer/windows/nsis/installer.nsi b/application/basilisk/installer/windows/nsis/installer.nsi index de11975113..dc8742c1bb 100644 --- a/application/basilisk/installer/windows/nsis/installer.nsi +++ b/application/basilisk/installer/windows/nsis/installer.nsi @@ -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} diff --git a/application/basilisk/locales/en-US/chrome/browser/shellservice.properties b/application/basilisk/locales/en-US/chrome/browser/shellservice.properties index e3dc14b7e3..1ff2489493 100644 --- a/application/basilisk/locales/en-US/chrome/browser/shellservice.properties +++ b/application/basilisk/locales/en-US/chrome/browser/shellservice.properties @@ -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… diff --git a/application/basilisk/locales/en-US/installer/custom.properties b/application/basilisk/locales/en-US/installer/custom.properties index 0f86f55283..d6d1ac7904 100644 --- a/application/basilisk/locales/en-US/installer/custom.properties +++ b/application/basilisk/locales/en-US/installer/custom.properties @@ -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. diff --git a/application/palemoon/components/nsBrowserGlue.js b/application/palemoon/components/nsBrowserGlue.js index 1ebb760f5e..fd76fe2bf5 100644 --- a/application/palemoon/components/nsBrowserGlue.js +++ b/application/palemoon/components/nsBrowserGlue.js @@ -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) { diff --git a/application/palemoon/components/preferences/advanced.js b/application/palemoon/components/preferences/advanced.js index 08dc5ac9d2..079352afde 100644 --- a/application/palemoon/components/preferences/advanced.js +++ b/application/palemoon/components/preferences/advanced.js @@ -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 }; diff --git a/application/palemoon/components/shell/nsIWindowsShellService.idl b/application/palemoon/components/shell/nsIWindowsShellService.idl index 57ed370555..d7a91d7d70 100644 --- a/application/palemoon/components/shell/nsIWindowsShellService.idl +++ b/application/palemoon/components/shell/nsIWindowsShellService.idl @@ -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. diff --git a/application/palemoon/components/shell/nsWindowsShellService.cpp b/application/palemoon/components/shell/nsWindowsShellService.cpp index c4039b95a3..40cefe2c8d 100644 --- a/application/palemoon/components/shell/nsWindowsShellService.cpp +++ b/application/palemoon/components/shell/nsWindowsShellService.cpp @@ -402,6 +402,31 @@ nsWindowsShellService::IsDefaultBrowserVista(bool aCheckAllTypes, return true; } +NS_IMETHODIMP +nsWindowsShellService::CancelPortableMode() +{ + nsresult rv; + + nsCOMPtr 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, diff --git a/application/palemoon/installer/windows/nsis/installer.nsi b/application/palemoon/installer/windows/nsis/installer.nsi index 66f341ab74..072081e79e 100644 --- a/application/palemoon/installer/windows/nsis/installer.nsi +++ b/application/palemoon/installer/windows/nsis/installer.nsi @@ -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} diff --git a/application/palemoon/locales/en-US/chrome/browser/shellservice.properties b/application/palemoon/locales/en-US/chrome/browser/shellservice.properties index d4f449f41c..534da1a010 100644 --- a/application/palemoon/locales/en-US/chrome/browser/shellservice.properties +++ b/application/palemoon/locales/en-US/chrome/browser/shellservice.properties @@ -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 diff --git a/application/palemoon/locales/en-US/installer/custom.properties b/application/palemoon/locales/en-US/installer/custom.properties index 8f95a194b4..c2785f040e 100644 --- a/application/palemoon/locales/en-US/installer/custom.properties +++ b/application/palemoon/locales/en-US/installer/custom.properties @@ -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. diff --git a/dom/system/OSFileConstants.cpp b/dom/system/OSFileConstants.cpp index 641fe9019b..abe613a350 100644 --- a/dom/system/OSFileConstants.cpp +++ b/dom/system/OSFileConstants.cpp @@ -302,14 +302,14 @@ nsresult InitOSFileConstants() // some platforms or in non-Firefox embeddings of Gecko). GetPathToSpecialDir(NS_OS_TEMP_DIR, paths->tmpDir); - GetPathToSpecialDir(NS_OS_HOME_DIR, paths->homeDir); +/* GetPathToSpecialDir(NS_OS_HOME_DIR, paths->homeDir); GetPathToSpecialDir(NS_OS_DESKTOP_DIR, paths->desktopDir); GetPathToSpecialDir(XRE_USER_APP_DATA_DIR, paths->userApplicationDataDir); #if defined(XP_WIN) GetPathToSpecialDir(NS_WIN_APPDATA_DIR, paths->winAppDataDir); GetPathToSpecialDir(NS_WIN_PROGRAMS_DIR, paths->winStartMenuProgsDir); -#endif // defined(XP_WIN) +#endif // defined(XP_WIN)*/ #if defined(XP_MACOSX) GetPathToSpecialDir(NS_MAC_USER_LIB_DIR, paths->macUserLibDir); diff --git a/toolkit/mozapps/installer/windows/nsis/common.nsh b/toolkit/mozapps/installer/windows/nsis/common.nsh index 44b59a5002..f3a746cf1a 100644 --- a/toolkit/mozapps/installer/windows/nsis/common.nsh +++ b/toolkit/mozapps/installer/windows/nsis/common.nsh @@ -4972,6 +4972,10 @@ !define INSTALLTYPE_CUSTOM 2 !endif +!ifndef INSTALLTYPE_PORTABLE + !define INSTALLTYPE_PORTABLE 3 +!endif + /** * Checks whether to display the current page (e.g. if not performing a custom * install don't display the custom pages). @@ -5649,6 +5653,7 @@ Push $R9 IntCmp $InstallType ${INSTALLTYPE_CUSTOM} end +1 +1 + IntCmp $InstallType ${INSTALLTYPE_PORTABLE} end +1 +1 ${CanWriteToInstallDir} $R9 StrCmp "$R9" "false" end +1 ${CheckDiskSpace} $R9 diff --git a/toolkit/profile/content/createProfileWizard.js b/toolkit/profile/content/createProfileWizard.js index aa87eacd71..e206861a6f 100644 --- a/toolkit/profile/content/createProfileWizard.js +++ b/toolkit/profile/content/createProfileWizard.js @@ -24,9 +24,14 @@ function initWizard() try { gProfileService = C[ToolkitProfileService].getService(I.nsIToolkitProfileService); gProfileManagerBundle = document.getElementById("bundle_profileManager"); - + var pathProp="DefProfRt" var dirService = C["@mozilla.org/file/directory_service;1"].getService(I.nsIProperties); - gDefaultProfileParent = dirService.get("DefProfRt", I.nsIFile); + var profService = C["@mozilla.org/toolkit/profile-service;1"].getService(I.nsIToolkitProfileService); + if (profService.portable()>0){ + pathProp="CurProcD"; + gDefaultProfileParent = dirService.get(pathProp, I.nsIFile).parent; + } + else gDefaultProfileParent = dirService.get(pathProp, I.nsIFile); // Initialize the profile location display. gProfileDisplay = document.getElementById("profileDisplay").firstChild; diff --git a/toolkit/profile/nsIToolkitProfileService.idl b/toolkit/profile/nsIToolkitProfileService.idl index 46a5b3cbc1..a1455c130c 100644 --- a/toolkit/profile/nsIToolkitProfileService.idl +++ b/toolkit/profile/nsIToolkitProfileService.idl @@ -101,6 +101,8 @@ interface nsIToolkitProfileService : nsISupports * Flush the profiles list file. */ void flush(); + + uint32_t portable(); }; %{C++ diff --git a/toolkit/profile/nsToolkitProfileService.cpp b/toolkit/profile/nsToolkitProfileService.cpp index 2fe51b2853..774b7952a4 100644 --- a/toolkit/profile/nsToolkitProfileService.cpp +++ b/toolkit/profile/nsToolkitProfileService.cpp @@ -112,7 +112,7 @@ public: private: friend class nsToolkitProfile; friend class nsToolkitProfileFactory; - friend nsresult NS_NewToolkitProfileService(nsIToolkitProfileService**); + friend nsresult NS_NewToolkitProfileService(nsIToolkitProfileService**,uint32_t); nsToolkitProfileService() : mDirty(false), @@ -126,7 +126,7 @@ private: gService = nullptr; } - nsresult Init(); + nsresult Init(uint32_t portable); nsresult CreateTimesInternal(nsIFile *profileDir); @@ -382,16 +382,30 @@ NS_IMPL_ISUPPORTS(nsToolkitProfileService, nsIToolkitProfileService) nsresult -nsToolkitProfileService::Init() +nsToolkitProfileService::Init(uint32_t portable) { + NS_ASSERTION(gDirServiceProvider, "No dirserviceprovider!"); nsresult rv; - rv = gDirServiceProvider->GetUserAppDataDirectory(getter_AddRefs(mAppData)); - NS_ENSURE_SUCCESS(rv, rv); + if(portable>0){ + nsCOMPtr appFile; + bool per = false; + rv = gDirServiceProvider->GetFile(XRE_EXECUTABLE_FILE, &per, getter_AddRefs(appFile)); + NS_ENSURE_SUCCESS(rv, rv); + rv = appFile->GetParent(getter_AddRefs(mAppData)); + NS_ENSURE_SUCCESS(rv, rv); + rv = appFile->GetParent(getter_AddRefs(mTempData)); + NS_ENSURE_SUCCESS(rv, rv); - rv = gDirServiceProvider->GetUserLocalDataDirectory(getter_AddRefs(mTempData)); - NS_ENSURE_SUCCESS(rv, rv); + } + else{ + rv = gDirServiceProvider->GetUserAppDataDirectory(getter_AddRefs(mAppData)); + NS_ENSURE_SUCCESS(rv, rv); + + rv = gDirServiceProvider->GetUserLocalDataDirectory(getter_AddRefs(mTempData)); + NS_ENSURE_SUCCESS(rv, rv); + } rv = mAppData->Clone(getter_AddRefs(mListFile)); NS_ENSURE_SUCCESS(rv, rv); @@ -969,6 +983,13 @@ nsToolkitProfileService::Flush() return NS_OK; } + +NS_IMETHODIMP +nsToolkitProfileService::Portable(uint32_t *aResult) +{ + return gDirServiceProvider->Portable(aResult); +} + NS_IMPL_ISUPPORTS(nsToolkitProfileFactory, nsIFactory) NS_IMETHODIMP @@ -981,7 +1002,7 @@ nsToolkitProfileFactory::CreateInstance(nsISupports* aOuter, const nsID& aIID, nsCOMPtr profileService = nsToolkitProfileService::gService; if (!profileService) { - nsresult rv = NS_NewToolkitProfileService(getter_AddRefs(profileService)); + nsresult rv = NS_NewToolkitProfileService(getter_AddRefs(profileService),0); if (NS_FAILED(rv)) return rv; } @@ -1006,12 +1027,12 @@ NS_NewToolkitProfileFactory(nsIFactory* *aResult) } nsresult -NS_NewToolkitProfileService(nsIToolkitProfileService* *aResult) +NS_NewToolkitProfileService(nsIToolkitProfileService* *aResult,uint32_t portable) { nsToolkitProfileService* profileService = new nsToolkitProfileService(); if (!profileService) return NS_ERROR_OUT_OF_MEMORY; - nsresult rv = profileService->Init(); + nsresult rv = profileService->Init(portable); if (NS_FAILED(rv)) { NS_ERROR("nsToolkitProfileService::Init failed!"); delete profileService; diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index e1f2eb939c..8cbc04bd7c 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -205,6 +205,7 @@ char **gRestartArgv; bool gIsGtest = false; nsString gAbsoluteArgv0Path; +uint32_t portable; #if defined(MOZ_WIDGET_GTK) #include @@ -1984,6 +1985,14 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n return NS_LockProfilePath(lf, localDir, nullptr, aResult); } + nsCOMPtr exeFile; + nsIFile* rootDir=nullptr; + if (portable>0){ + XRE_GetBinaryPath(gArgv[0], getter_AddRefs(exeFile)); + exeFile->GetParent(&rootDir); + rootDir->AppendNative(NS_LITERAL_CSTRING("Profile")); + } + ar = CheckArg("profile", true, &arg); if (ar == ARG_BAD) { PR_fprintf(PR_STDERR, "Error: argument --profile requires a path\n"); @@ -2040,7 +2049,15 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n // main profile directory. rv = aProfileSvc->CreateProfile(lf, nsDependentCSubstring(arg, delim), getter_AddRefs(profile)); - } else { + } + else if(portable>0) { + nsCOMPtr lf; + rootDir->GetParent(getter_AddRefs(lf)); + lf->AppendNative(nsDependentCString(arg)); + rv = aProfileSvc->CreateProfile(lf, nsDependentCString(arg), + getter_AddRefs(profile)); + } + else { rv = aProfileSvc->CreateProfile(nullptr, nsDependentCString(arg), getter_AddRefs(profile)); } @@ -2168,7 +2185,7 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n // create a default profile nsCOMPtr profile; - nsresult rv = aProfileSvc->CreateProfile(nullptr, // choose a default dir for us + nsresult rv = aProfileSvc->CreateProfile(rootDir, // choose a default dir for us NS_LITERAL_CSTRING("default"), getter_AddRefs(profile)); if (NS_SUCCEEDED(rv)) { @@ -3061,6 +3078,12 @@ XREMain::XRE_mainInit(bool* aExitFlag) } else if (ar == ARG_FOUND) { SaveToEnv("MOZ_NO_REMOTE=1"); } + //MYPAL CODE + //lstrcmpW(L"Teest",L"Teest"); + + mDirProvider.Portable(&portable); + + if (portable==1) SaveToEnv("MOZ_NO_REMOTE=1"); ar = CheckArg("new-instance", true); if (ar == ARG_BAD) { @@ -3435,7 +3458,7 @@ XREMain::XRE_mainStartup(bool* aExitFlag) } #endif - rv = NS_NewToolkitProfileService(getter_AddRefs(mProfileSvc)); + rv = NS_NewToolkitProfileService(getter_AddRefs(mProfileSvc),portable); if (rv == NS_ERROR_FILE_ACCESS_DENIED) { PR_fprintf(PR_STDERR, "Error: Access was denied while trying to open files in " \ "your profile directory.\n"); diff --git a/toolkit/xre/nsAppRunner.h b/toolkit/xre/nsAppRunner.h index b8d9553190..fb296289a7 100644 --- a/toolkit/xre/nsAppRunner.h +++ b/toolkit/xre/nsAppRunner.h @@ -65,7 +65,7 @@ extern bool gIsGtest; nsresult NS_CreateNativeAppSupport(nsINativeAppSupport* *aResult); nsresult -NS_NewToolkitProfileService(nsIToolkitProfileService* *aResult); +NS_NewToolkitProfileService(nsIToolkitProfileService* *aResult,uint32_t portable); nsresult NS_NewToolkitProfileFactory(nsIFactory* *aResult); diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp index 6bbbc2e43b..df9eea91af 100644 --- a/toolkit/xre/nsXREDirProvider.cpp +++ b/toolkit/xre/nsXREDirProvider.cpp @@ -276,6 +276,26 @@ GetSystemParentDirectory(nsIFile** aFile) } #endif +nsresult +nsXREDirProvider::Portable(uint32_t *aResult) +{ + bool portable; + nsCOMPtr portmodemark; + GetAppDir()->Clone(getter_AddRefs(portmodemark)); + portmodemark->AppendNative(NS_LITERAL_CSTRING("pmprt.mod")); + portmodemark->Exists(&portable); + if (portable){ + *aResult=1; + return NS_OK; + } + GetAppDir()->Clone(getter_AddRefs(portmodemark)); + portmodemark->AppendNative(NS_LITERAL_CSTRING("pmundprt.mod")); + portmodemark->Exists(&portable); + if (portable) *aResult=2; + else *aResult=0; + return NS_OK; +} + NS_IMETHODIMP nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent, nsIFile** aFile) @@ -1359,8 +1379,8 @@ nsXREDirProvider::GetSysUserExtensionsDirectory(nsIFile** aFile) nsresult rv = GetUserDataDirectoryHome(getter_AddRefs(localDir), false); NS_ENSURE_SUCCESS(rv, rv); - rv = AppendSysUserExtensionPath(localDir); - NS_ENSURE_SUCCESS(rv, rv); + //rv = AppendSysUserExtensionPath(localDir); + //NS_ENSURE_SUCCESS(rv, rv); rv = EnsureDirectoryExists(localDir); NS_ENSURE_SUCCESS(rv, rv); diff --git a/toolkit/xre/nsXREDirProvider.h b/toolkit/xre/nsXREDirProvider.h index 655f664e6d..b21c3e64ba 100644 --- a/toolkit/xre/nsXREDirProvider.h +++ b/toolkit/xre/nsXREDirProvider.h @@ -37,6 +37,8 @@ public: static nsXREDirProvider* GetSingleton(); + nsresult Portable(uint32_t *aResult); + nsresult GetUserProfilesRootDir(nsIFile** aResult, const nsACString* aProfileName, const nsACString* aAppName, diff --git a/xpcom/io/moz.build b/xpcom/io/moz.build index 43ce517c45..405b505759 100644 --- a/xpcom/io/moz.build +++ b/xpcom/io/moz.build @@ -132,6 +132,8 @@ include('/ipc/chromium/chromium-config.mozbuild') FINAL_LIBRARY = 'xul' +DEFINES['MOZ_APP_BASENAME'] = '"%s"' % CONFIG['MOZ_APP_BASENAME'] + if CONFIG['OS_ARCH'] == 'Linux' and 'lib64' in CONFIG['libdir']: DEFINES['HAVE_USR_LIB64_DIR'] = True