Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #648 from brave/fix-15191
Browse files Browse the repository at this point in the history
Update incognito session initialization
  • Loading branch information
darkdh authored Sep 13, 2018
2 parents d9620b3 + d57534a commit a712524
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 29 deletions.
36 changes: 18 additions & 18 deletions atom/browser/api/atom_api_user_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,51 +60,51 @@ Profile* UserPrefs::profile() {
}

void UserPrefs::RegisterStringPref(const std::string& path,
const std::string& default_value, bool overlay) {
const std::string& default_value, bool persist) {
profile()->pref_registry()->RegisterStringPref(path, default_value);
if (overlay)
profile()->AddOverlayPref(path);
if (persist)
profile()->RegisterPersistentPref(path);
}

void UserPrefs::RegisterDictionaryPref(const std::string& path,
const base::DictionaryValue& default_value, bool overlay) {
const base::DictionaryValue& default_value, bool persist) {
std::unique_ptr<base::DictionaryValue> copied(
default_value.CreateDeepCopy());
profile()->pref_registry()->
RegisterDictionaryPref(path, std::move(copied));
if (overlay)
profile()->AddOverlayPref(path);
if (persist)
profile()->RegisterPersistentPref(path);
}

void UserPrefs::RegisterListPref(const std::string& path,
const base::ListValue& default_value, bool overlay) {
const base::ListValue& default_value, bool persist) {
std::unique_ptr<base::ListValue> copied(
default_value.CreateDeepCopy());
profile()->pref_registry()->
RegisterListPref(path, std::move(copied));
if (overlay)
profile()->AddOverlayPref(path);
if (persist)
profile()->RegisterPersistentPref(path);
}

void UserPrefs::RegisterBooleanPref(const std::string& path,
bool default_value, bool overlay) {
bool default_value, bool persist) {
profile()->pref_registry()->RegisterBooleanPref(path, default_value);
if (overlay)
profile()->AddOverlayPref(path);
if (persist)
profile()->RegisterPersistentPref(path);
}

void UserPrefs::RegisterIntegerPref(const std::string& path,
int default_value, bool overlay) {
int default_value, bool persist) {
profile()->pref_registry()->RegisterIntegerPref(path, default_value);
if (overlay)
profile()->AddOverlayPref(path);
if (persist)
profile()->RegisterPersistentPref(path);
}

void UserPrefs::RegisterDoublePref(const std::string& path,
double default_value, bool overlay) {
double default_value, bool persist) {
profile()->pref_registry()->RegisterDoublePref(path, default_value);
if (overlay)
profile()->AddOverlayPref(path);
if (persist)
profile()->RegisterPersistentPref(path);
}

std::string UserPrefs::GetStringPref(const std::string& path) {
Expand Down
11 changes: 4 additions & 7 deletions brave/browser/brave_browser_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -532,21 +532,18 @@ void BraveBrowserContext::CreateProfilePrefs(
bool async = false;

if (IsOffTheRecord()) {
overlay_pref_names_.push_back("app_state");
overlay_pref_names_.push_back(extensions::pref_names::kPrefContentSettings);
overlay_pref_names_.push_back(prefs::kPartitionPerHostZoomLevels);
std::unique_ptr<PrefValueStore::Delegate> delegate = nullptr;
user_prefs_ =
original_context()->user_prefs()->CreateIncognitoPrefService(
extension_prefs, overlay_pref_names_, std::move(delegate));
extension_prefs, persistent_pref_names_, std::move(delegate));
user_prefs::UserPrefs::Set(this, user_prefs_.get());
} else if (HasParentContext()) {
// overlay pref names only apply to incognito
// persistent pref names only apply to incognito
std::unique_ptr<PrefValueStore::Delegate> delegate = nullptr;
std::vector<const char*> overlay_pref_names;
std::vector<const char*> persistent_pref_names;
user_prefs_ =
original_context()->user_prefs()->CreateIncognitoPrefService(
extension_prefs, overlay_pref_names, std::move(delegate));
extension_prefs, persistent_pref_names, std::move(delegate));
user_prefs::UserPrefs::Set(this, user_prefs_.get());
} else {
pref_registry_->RegisterDictionaryPref("app_state");
Expand Down
6 changes: 3 additions & 3 deletions brave/browser/brave_browser_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class BraveBrowserContext : public Profile {
std::string partition_with_prefix();
base::WaitableEvent* ready() { return ready_.get(); }

void AddOverlayPref(const std::string name) override {
overlay_pref_names_.push_back(name.c_str()); }
void RegisterPersistentPref(const std::string name) override {
persistent_pref_names_.push_back(name.c_str()); }

scoped_refptr<autofill::AutofillWebDataService>
GetAutofillWebdataService() override;
Expand Down Expand Up @@ -178,7 +178,7 @@ class BraveBrowserContext : public Profile {
scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry_;
std::unique_ptr<sync_preferences::PrefServiceSyncable> user_prefs_;
std::unique_ptr<PrefChangeRegistrar> user_prefs_registrar_;
std::vector<const char*> overlay_pref_names_;
std::vector<const char*> persistent_pref_names_;

std::unique_ptr<content::HostZoomMap::Subscription> track_zoom_subscription_;
std::unique_ptr<ChromeZoomLevelPrefs::DefaultZoomLevelSubscription>
Expand Down
2 changes: 1 addition & 1 deletion chromium_src/chrome/browser/profiles/profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class Profile : public atom::AtomBrowserContext {

virtual user_prefs::PrefRegistrySyncable* pref_registry() const = 0;

virtual void AddOverlayPref(const std::string name) = 0;
virtual void RegisterPersistentPref(const std::string name) = 0;

virtual scoped_refptr<autofill::AutofillWebDataService>
GetAutofillWebdataService() = 0;
Expand Down

0 comments on commit a712524

Please sign in to comment.