diff --git a/application/basilisk/components/nsBrowserGlue.js b/application/basilisk/components/nsBrowserGlue.js index 47b2a5801..6a39b38a1 100644 --- a/application/basilisk/components/nsBrowserGlue.js +++ b/application/basilisk/components/nsBrowserGlue.js @@ -1145,9 +1145,8 @@ BrowserGlue.prototype = { isDefaultError = true; } - //CENTAURY PORTABLE CODE - let isPortable= winShellService.isPortableMode(); - if (!isPortable) { + 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); diff --git a/application/basilisk/components/preferences/in-content/main.js b/application/basilisk/components/preferences/in-content/main.js index 64c77308c..ba640e877 100644 --- a/application/basilisk/components/preferences/in-content/main.js +++ b/application/basilisk/components/preferences/in-content/main.js @@ -632,7 +632,8 @@ var gMainPane = { defaultBrowserBox.hidden = true; return; } - if (shellSvc.isPortableMode()) 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; @@ -651,13 +652,15 @@ var gMainPane = { let alwaysCheckPref = document.getElementById("browser.shell.checkDefaultBrowser"); alwaysCheckPref.value = true; + let shellSvc = getShellService(); - let sPortable; + var profService = Components.classes["@mozilla.org/toolkit/profile-service;1"].getService(Components.interfaces.nsIToolkitProfileService); + let isPortable; if (!shellSvc) return; try { - isPortable = shellSvc.isPortableMode(); - if (isPortable) { + isPortable = profService.portable(); + if (isPortable==1) { Components.utils.import("resource:///modules/RecentWindow.jsm"); var win = RecentWindow.getMostRecentBrowserWindow(); var brandBundle = win.document.getElementById("bundle_brand"); diff --git a/application/basilisk/components/shell/nsIShellService.idl b/application/basilisk/components/shell/nsIShellService.idl index 6958921fa..3e7e94b00 100644 --- a/application/basilisk/components/shell/nsIShellService.idl +++ b/application/basilisk/components/shell/nsIShellService.idl @@ -11,8 +11,6 @@ interface nsIFile; [scriptable, uuid(2d1a95e4-5bd8-4eeb-b0a8-c1455fd2a357)] interface nsIShellService : nsISupports { - boolean isPortableMode(); - void cancelPortableMode(); /** * Determines whether or not Firefox is the "Default Browser." * This is simply whether or not Firefox is registered to handle diff --git a/application/basilisk/components/shell/nsIWindowsShellService.idl b/application/basilisk/components/shell/nsIWindowsShellService.idl index 57ed37055..d7a91d7d7 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 7a474b760..178207d0b 100644 --- a/application/basilisk/components/shell/nsWindowsShellService.cpp +++ b/application/basilisk/components/shell/nsWindowsShellService.cpp @@ -394,35 +394,6 @@ nsWindowsShellService::CancelPortableMode() return NS_OK; } -NS_IMETHODIMP -nsWindowsShellService::IsPortableMode(bool* aIsPortable) -{ - nsresult rv; - *aIsPortable=false; - - 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); - -// nsAutoString path1; -// rv = portmodemark->GetPath(path1); -// ::MessageBoxW(NULL,path1.get(),L"Teest",MB_OKCANCEL); - - if (fileExists){ - *aIsPortable=true; - } - 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/palemoon/components/nsBrowserGlue.js b/application/palemoon/components/nsBrowserGlue.js index 2a6ec3e2c..9aa7c9bc3 100644 --- a/application/palemoon/components/nsBrowserGlue.js +++ b/application/palemoon/components/nsBrowserGlue.js @@ -600,9 +600,9 @@ BrowserGlue.prototype = { } catch (ex) { isDefaultError = true; } - //MYPAL PORTABLE CODE - let isPortable= winShellService.isPortableMode(); - if (!isPortable) { + + 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); diff --git a/application/palemoon/components/preferences/advanced.js b/application/palemoon/components/preferences/advanced.js index 01acad03b..1dfe638bd 100644 --- a/application/palemoon/components/preferences/advanced.js +++ b/application/palemoon/components/preferences/advanced.js @@ -722,7 +722,8 @@ var gAdvancedPane = { document.getElementById("alwaysCheckDefault").disabled = true; return; } - if (winShellSvc.isPortableMode()) 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; @@ -733,14 +734,14 @@ var gAdvancedPane = { */ setDefaultBrowser: function() { - //MYPAL PORTABLE CODE let shellSvc = getShellService(); - let sPortable; + var profService = Components.classes["@mozilla.org/toolkit/profile-service;1"].getService(Components.interfaces.nsIToolkitProfileService); + let isPortable; if (!shellSvc) return; try { - isPortable = winShellSvc.isPortableMode(); - if (isPortable) { + isPortable = profService.portable(); + if (isPortable==1) { Components.utils.import("resource:///modules/RecentWindow.jsm"); var win = RecentWindow.getMostRecentBrowserWindow(); var brandBundle = win.document.getElementById("bundle_brand"); diff --git a/application/palemoon/components/shell/nsIWindowsShellService.idl b/application/palemoon/components/shell/nsIWindowsShellService.idl index 9bd23cbcb..d7a91d7d7 100644 --- a/application/palemoon/components/shell/nsIWindowsShellService.idl +++ b/application/palemoon/components/shell/nsIWindowsShellService.idl @@ -8,8 +8,6 @@ [scriptable, uuid(f8a26b94-49e5-4441-8fbc-315e0b4f22ef)] interface nsIWindowsShellService : nsIShellService { - //MYPAL PORTABLE CODE - boolean isPortableMode(); void cancelPortableMode(); /** * Provides the shell service an opportunity to do some Win7+ shortcut diff --git a/application/palemoon/components/shell/nsWindowsShellService.cpp b/application/palemoon/components/shell/nsWindowsShellService.cpp index a8623bcb0..40cefe2c8 100644 --- a/application/palemoon/components/shell/nsWindowsShellService.cpp +++ b/application/palemoon/components/shell/nsWindowsShellService.cpp @@ -402,7 +402,6 @@ nsWindowsShellService::IsDefaultBrowserVista(bool aCheckAllTypes, return true; } -//MYPAL PORTABLE CODE NS_IMETHODIMP nsWindowsShellService::CancelPortableMode() { @@ -428,36 +427,6 @@ nsWindowsShellService::CancelPortableMode() return NS_OK; } -NS_IMETHODIMP -nsWindowsShellService::IsPortableMode(bool* aIsPortable) -{ - nsresult rv; - *aIsPortable=false; - - 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); - -// nsAutoString path1; -// rv = portmodemark->GetPath(path1); -// ::MessageBoxW(NULL,path1.get(),L"Teest",MB_OKCANCEL); - - if (fileExists){ - *aIsPortable=true; - } - return NS_OK; -} - NS_IMETHODIMP nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck, bool aForAllTypes, diff --git a/extensions/spellcheck/hunspell/glue/mozHunspellDirProvider.cpp b/extensions/spellcheck/hunspell/glue/mozHunspellDirProvider.cpp index 00758b0c3..202b5223e 100644 --- a/extensions/spellcheck/hunspell/glue/mozHunspellDirProvider.cpp +++ b/extensions/spellcheck/hunspell/glue/mozHunspellDirProvider.cpp @@ -44,6 +44,7 @@ NS_IMPL_ISUPPORTS(mozHunspellDirProvider, nsIDirectoryServiceProvider, nsIDirectoryServiceProvider2) + NS_IMETHODIMP mozHunspellDirProvider::GetFile(const char *aKey, bool *aPersist, nsIFile* *aResult) diff --git a/toolkit/profile/content/createProfileWizard.js b/toolkit/profile/content/createProfileWizard.js index 14d006b31..cfd9361f2 100644 --- a/toolkit/profile/content/createProfileWizard.js +++ b/toolkit/profile/content/createProfileWizard.js @@ -26,9 +26,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 46a5b3cbc..a1455c130 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 d31461d9a..de2177385 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**,int); + friend nsresult NS_NewToolkitProfileService(nsIToolkitProfileService**,uint32_t); nsToolkitProfileService() : mDirty(false), @@ -126,7 +126,7 @@ private: gService = nullptr; } - nsresult Init(int portable); + nsresult Init(uint32_t portable); nsresult CreateTimesInternal(nsIFile *profileDir); @@ -382,19 +382,30 @@ NS_IMPL_ISUPPORTS(nsToolkitProfileService, nsIToolkitProfileService) nsresult -nsToolkitProfileService::Init(int portable) +nsToolkitProfileService::Init(uint32_t portable) { - //MYPAL CODE - if(portable>0) return NS_OK; 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); @@ -1015,6 +1026,13 @@ nsToolkitProfileService::Flush() return NS_OK; } + +NS_IMETHODIMP +nsToolkitProfileService::Portable(uint32_t *aResult) +{ + return gDirServiceProvider->Portable(aResult); +} + NS_IMPL_ISUPPORTS(nsToolkitProfileFactory, nsIFactory) NS_IMETHODIMP @@ -1052,7 +1070,7 @@ NS_NewToolkitProfileFactory(nsIFactory* *aResult) } nsresult -NS_NewToolkitProfileService(nsIToolkitProfileService* *aResult,int portable) +NS_NewToolkitProfileService(nsIToolkitProfileService* *aResult,uint32_t portable) { nsToolkitProfileService* profileService = new nsToolkitProfileService(); if (!profileService) diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 2a281762d..30e5f1c50 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -211,6 +211,7 @@ char **gRestartArgv; bool gIsGtest = false; nsString gAbsoluteArgv0Path; +uint32_t portable; #if defined(MOZ_WIDGET_GTK) #include @@ -1920,7 +1921,7 @@ static nsAutoCString gResetOldProfileName; // 6) display the profile-manager UI static nsresult SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, nsINativeAppSupport* aNative, - bool* aStartOffline, nsACString* aProfileName,int prt) + bool* aStartOffline, nsACString* aProfileName) { StartupTimeline::Record(StartupTimeline::SELECT_PROFILE); @@ -2010,6 +2011,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"); @@ -2044,39 +2053,6 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n return ProfileLockedDialog(lf, lf, unlocker, aNative, aResult); } - //MYPAL PORTABLE CODE START - if (prt>0) { - //lstrcmpW(L"Teest",L"Teest"); - - nsCOMPtr exeFile; - rv = XRE_GetBinaryPath(gArgv[0], getter_AddRefs(exeFile)); - rv = exeFile->GetParent(getter_AddRefs(lf)); - lf->AppendNative(*aProfileName); - -// nsAutoString path1; -// rv = lf->GetPath(path1); -// ::MessageBoxW(NULL,path1.get(),L"Teest",MB_OKCANCEL); - - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr unlocker; - - bool exists; - lf->Exists(&exists); - if (!exists) { - rv = lf->Create(nsIFile::DIRECTORY_TYPE, 0700); - NS_ENSURE_SUCCESS(rv, rv); - } - - // If a profile path is specified directory on the command line, then - // assume that the temp directory is the same as the given directory. - rv = NS_LockProfilePath(lf, lf, getter_AddRefs(unlocker), aResult); - if (NS_SUCCEEDED(rv)) - return rv; - return ProfileLockedDialog(lf, lf, unlocker, aNative, aResult); - } - //MYPAL PORTABLE CODE END - ar = CheckArg("createprofile", true, &arg); if (ar == ARG_BAD) { PR_fprintf(PR_STDERR, "Error: argument --createprofile requires a profile name\n"); @@ -2099,7 +2075,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)); } @@ -2228,7 +2212,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 #ifdef MOZ_DEV_EDITION NS_LITERAL_CSTRING("dev-edition-default"), #else @@ -2761,7 +2745,6 @@ public: int XRE_main(int argc, char* argv[], const nsXREAppData* aAppData); int XRE_mainInit(bool* aExitFlag); int XRE_mainStartup(bool* aExitFlag); - int portable(); nsresult XRE_mainRun(); nsCOMPtr mNativeApp; @@ -2793,21 +2776,6 @@ public: #endif }; -//MYPAL CODE -int XREMain::portable(){ - bool portable; - nsCOMPtr portmodemark; - mDirProvider.GetAppDir()->Clone(getter_AddRefs(portmodemark)); - portmodemark->AppendNative(NS_LITERAL_CSTRING("pmprt.mod")); - portmodemark->Exists(&portable); - if (portable) return 1; - mDirProvider.GetAppDir()->Clone(getter_AddRefs(portmodemark)); - portmodemark->AppendNative(NS_LITERAL_CSTRING("pmundprt.mod")); - portmodemark->Exists(&portable); - if (portable) return 2; - else return 0; -} - /* * XRE_mainInit - Initial setup and command line parameter processing. * Main() will exit early if either return value != 0 or if aExitFlag is @@ -3126,7 +3094,10 @@ XREMain::XRE_mainInit(bool* aExitFlag) } //MYPAL CODE //lstrcmpW(L"Teest",L"Teest"); - if (portable()==1) SaveToEnv("MOZ_NO_REMOTE=1"); + + mDirProvider.Portable(&portable); + + if (portable==1) SaveToEnv("MOZ_NO_REMOTE=1"); ar = CheckArg("new-instance", true); if (ar == ARG_BAD) { @@ -3519,11 +3490,8 @@ XREMain::XRE_mainStartup(bool* aExitFlag) return 0; } #endif - //MYPAL CODE - int prt=portable(); - if (prt>0) mProfileName.Assign("\Profile"); - rv = NS_NewToolkitProfileService(getter_AddRefs(mProfileSvc),prt); + 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"); @@ -3535,7 +3503,7 @@ XREMain::XRE_mainStartup(bool* aExitFlag) } rv = SelectProfile(getter_AddRefs(mProfileLock), mProfileSvc, mNativeApp, &mStartOffline, - &mProfileName,prt); + &mProfileName); if (rv == NS_ERROR_LAUNCHED_CHILD_PROCESS || rv == NS_ERROR_ABORT) { *aExitFlag = true; diff --git a/toolkit/xre/nsAppRunner.h b/toolkit/xre/nsAppRunner.h index 03b2e9cfc..fb296289a 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,int portable); +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 fddcf37e1..557ce8d88 100644 --- a/toolkit/xre/nsXREDirProvider.cpp +++ b/toolkit/xre/nsXREDirProvider.cpp @@ -279,6 +279,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) diff --git a/toolkit/xre/nsXREDirProvider.h b/toolkit/xre/nsXREDirProvider.h index 655f664e6..b21c3e64b 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,