Bug 1493202: Don't store offline startup state in nsIToolkitProfileService. r=florian
authorDave Townsend <dtownsend@oxymoronical.com>
Fri, 21 Sep 2018 16:50:02 +0000
changeset 480083 96b91a8c2bcf9fb28e50a48117f0c9aab9e79427
parent 480082 3ea2713d067e4753c275a62b576c1e9ec7fdd9ba
child 480084 267392b7c6929a93632be711d9a1d3044ae88b07
push idunknown
push userunknown
push dateunknown
reviewersflorian
bugs1493202
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1493202: Don't store offline startup state in nsIToolkitProfileService. r=florian Differential Revision: https://phabricator.services.mozilla.com/D6503
toolkit/profile/content/profileSelection.js
toolkit/profile/nsIToolkitProfileService.idl
toolkit/profile/nsToolkitProfileService.cpp
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/profile/content/profileSelection.js
+++ b/toolkit/profile/content/profileSelection.js
@@ -93,34 +93,33 @@ function acceptDialog() {
   }
   gDialogParams.objects.insertElementAt(profileLock.nsIProfileLock, 0);
 
   gProfileService.selectedProfile = selectedProfile.profile;
   gProfileService.defaultProfile = selectedProfile.profile;
   updateStartupPrefs();
 
   gDialogParams.SetInt(0, 1);
+  /* Bug 257777 */
+  gDialogParams.SetInt(1, document.getElementById("offlineState").checked ? 1 : 0);
 
   gDialogParams.SetString(0, selectedProfile.profile.name);
 
   return true;
 }
 
 function exitDialog() {
   updateStartupPrefs();
 
   return true;
 }
 
 function updateStartupPrefs() {
   var autoSelectLastProfile = document.getElementById("autoSelectLastProfile");
   gProfileService.startWithLastProfile = autoSelectLastProfile.checked;
-
-  /* Bug 257777 */
-  gProfileService.startOffline = document.getElementById("offlineState").checked;
 }
 
 // handle key event on listboxes
 function onProfilesKey(aEvent) {
   switch ( aEvent.keyCode ) {
   case KeyEvent.DOM_VK_BACK_SPACE:
     if (AppConstants.platform != "macosx")
       break;
--- a/toolkit/profile/nsIToolkitProfileService.idl
+++ b/toolkit/profile/nsIToolkitProfileService.idl
@@ -9,17 +9,16 @@ interface nsISimpleEnumerator;
 interface nsIFile;
 interface nsIToolkitProfile;
 interface nsIProfileLock;
 
 [scriptable, uuid(1947899b-f369-48fa-89da-f7c37bb1e6bc)]
 interface nsIToolkitProfileService : nsISupports
 {
     attribute boolean startWithLastProfile;
-    attribute boolean startOffline;
 
     readonly attribute nsISimpleEnumerator /*nsIToolkitProfile*/ profiles;
 
     /**
      * The currently selected profile (the one used or about to be used by the
      * browser).
      */
     attribute nsIToolkitProfile selectedProfile;
--- a/toolkit/profile/nsToolkitProfileService.cpp
+++ b/toolkit/profile/nsToolkitProfileService.cpp
@@ -114,18 +114,17 @@ public:
     NS_DECL_NSITOOLKITPROFILESERVICE
 
 private:
     friend class nsToolkitProfile;
     friend class nsToolkitProfileFactory;
     friend nsresult NS_NewToolkitProfileService(nsIToolkitProfileService**);
 
     nsToolkitProfileService() :
-        mStartWithLast(true),
-        mStartOffline(false)
+        mStartWithLast(true)
     {
         gService = this;
     }
     ~nsToolkitProfileService()
     {
         gService = nullptr;
     }
 
@@ -135,17 +134,16 @@ private:
 
     RefPtr<nsToolkitProfile>  mFirst;
     nsCOMPtr<nsIToolkitProfile> mChosen;
     nsCOMPtr<nsIToolkitProfile> mDefault;
     nsCOMPtr<nsIFile>           mAppData;
     nsCOMPtr<nsIFile>           mTempData;
     nsCOMPtr<nsIFile>           mListFile;
     bool mStartWithLast;
-    bool mStartOffline;
 
     static nsToolkitProfileService *gService;
 
     class ProfileEnumerator final : public nsSimpleEnumerator
     {
     public:
         NS_DECL_NSISIMPLEENUMERATOR
 
@@ -569,30 +567,16 @@ nsToolkitProfileService::SetStartWithLas
 NS_IMETHODIMP
 nsToolkitProfileService::GetStartWithLastProfile(bool *aResult)
 {
     *aResult = mStartWithLast;
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsToolkitProfileService::GetStartOffline(bool *aResult)
-{
-    *aResult = mStartOffline;
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsToolkitProfileService::SetStartOffline(bool aValue)
-{
-    mStartOffline = aValue;
-    return NS_OK;
-}
-
-NS_IMETHODIMP
 nsToolkitProfileService::GetProfiles(nsISimpleEnumerator* *aResult)
 {
     *aResult = new ProfileEnumerator(this->mFirst);
     if (!*aResult)
         return NS_ERROR_OUT_OF_MEMORY;
 
     NS_ADDREF(*aResult);
     return NS_OK;
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2114,16 +2114,17 @@ static ReturnAbortOnError
 ShowProfileManager(nsIToolkitProfileService* aProfileSvc,
                    nsINativeAppSupport* aNative)
 {
   nsresult rv;
 
   nsCOMPtr<nsIFile> profD, profLD;
   char16_t* profileNamePtr;
   nsAutoCString profileName;
+  bool offline = false;
 
   {
     ScopedXPCOMStartup xpcom;
     rv = xpcom.Initialize();
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Initialize the graphics prefs, some of the paths need them before
     // any other graphics is initialized (e.g., showing the profile chooser.)
@@ -2167,16 +2168,20 @@ ShowProfileManager(nsIToolkitProfileServ
       NS_ENSURE_SUCCESS_LOG(rv, rv);
 
       aProfileSvc->Flush();
 
       int32_t dialogConfirmed;
       rv = ioParamBlock->GetInt(0, &dialogConfirmed);
       if (NS_FAILED(rv) || dialogConfirmed == 0) return NS_ERROR_ABORT;
 
+      int32_t startOffline;
+      rv = ioParamBlock->GetInt(1, &startOffline);
+      offline = NS_SUCCEEDED(rv) && startOffline == 1;
+
       nsCOMPtr<nsIProfileLock> lock;
       rv = dlgArray->QueryElementAt(0, NS_GET_IID(nsIProfileLock),
                                     getter_AddRefs(lock));
       NS_ENSURE_SUCCESS_LOG(rv, rv);
 
       rv = lock->GetDirectory(getter_AddRefs(profD));
       NS_ENSURE_SUCCESS(rv, rv);
 
@@ -2192,18 +2197,16 @@ ShowProfileManager(nsIToolkitProfileServ
       lock->Unlock();
     }
   }
 
   SaveFileToEnv("XRE_PROFILE_PATH", profD);
   SaveFileToEnv("XRE_PROFILE_LOCAL_PATH", profLD);
   SaveWordToEnv("XRE_PROFILE_NAME", profileName);
 
-  bool offline = false;
-  aProfileSvc->GetStartOffline(&offline);
   if (offline) {
     SaveToEnv("XRE_START_OFFLINE=1");
   }
   if (gRestartedByOS) {
     // Re-add this argument when actually starting the application.
     char** newArgv = (char**) realloc(gRestartArgv, sizeof(char*) * (gRestartArgc + 2));
     NS_ENSURE_TRUE(newArgv, NS_ERROR_OUT_OF_MEMORY);
     gRestartArgv = newArgv;