diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index bf8e503f65..9889c93012 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -100,7 +100,7 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition, #endif partition_(partition) { if (in_memory) { - original_context_ = AtomBrowserContext::From(partition, false); + original_context_ = AtomBrowserContext::From(partition, false).get(); original_context()->otr_context_ = this; } } @@ -125,8 +125,10 @@ AtomBrowserContext::~AtomBrowserContext() { if (otr_context_.get()) { // destroy the otr profile - otr_context()->user_prefs()->ClearMutableValues(); - otr_context_.swap(nullptr); + auto user_prefs = user_prefs::UserPrefs::Get(otr_context_.get()); + if (user_prefs) + user_prefs->ClearMutableValues(); + otr_context_ = NULL; } else { ExtensionPrefValueMapFactory::GetForBrowserContext(this)-> ClearAllIncognitoSessionOnlyPreferences(); @@ -145,7 +147,7 @@ AtomBrowserContext* AtomBrowserContext::original_context() { if (!IsOffTheRecord()) { return this; } - return static_cast(original_context_.get()); + return static_cast(original_context_); } AtomBrowserContext* AtomBrowserContext::otr_context() { @@ -314,7 +316,7 @@ void AtomBrowserContext::RegisterUserPrefs() { new JsonPrefStore(filepath, task_runner, std::unique_ptr()); // prepare factory - bool async = false; + bool async = true; syncable_prefs::PrefServiceSyncableFactory factory; factory.set_async(async); factory.set_extension_prefs(extension_prefs); diff --git a/atom/browser/atom_browser_context.h b/atom/browser/atom_browser_context.h index 0a1ffb521b..89e3ffb865 100644 --- a/atom/browser/atom_browser_context.h +++ b/atom/browser/atom_browser_context.h @@ -93,7 +93,7 @@ class AtomBrowserContext : public brightray::BrowserContext { AtomCertVerifier* cert_verifier_; AtomNetworkDelegate* network_delegate_; - scoped_refptr original_context_; + brightray::BrowserContext* original_context_; scoped_refptr otr_context_; const std::string partition_;