Merge pull request #152 from atom/register-prefs

Fix RegisterPrefs not working in subclass.
This commit is contained in:
Cheng Zhao 2015-10-06 22:44:32 +08:00
commit 43bfdace86
2 changed files with 4 additions and 0 deletions

View file

@ -88,6 +88,7 @@ scoped_refptr<BrowserContext> BrowserContext::From(
return make_scoped_refptr(browser_context_map_[key].get()); return make_scoped_refptr(browser_context_map_[key].get());
auto browser_context = BrowserContext::Create(partition, in_memory); auto browser_context = BrowserContext::Create(partition, in_memory);
browser_context->InitPrefs();
browser_context_map_[key] = browser_context->weak_factory_.GetWeakPtr(); browser_context_map_[key] = browser_context->weak_factory_.GetWeakPtr();
return browser_context; return browser_context;
} }
@ -105,7 +106,9 @@ BrowserContext::BrowserContext(const std::string& partition, bool in_memory)
if (!in_memory_ && !partition.empty()) if (!in_memory_ && !partition.empty())
path_ = path_.Append(FILE_PATH_LITERAL("Partitions")) path_ = path_.Append(FILE_PATH_LITERAL("Partitions"))
.Append(base::FilePath::FromUTF8Unsafe(MakePartitionName(partition))); .Append(base::FilePath::FromUTF8Unsafe(MakePartitionName(partition)));
}
void BrowserContext::InitPrefs() {
auto prefs_path = GetPath().Append(FILE_PATH_LITERAL("Preferences")); auto prefs_path = GetPath().Append(FILE_PATH_LITERAL("Preferences"));
base::PrefServiceFactory prefs_factory; base::PrefServiceFactory prefs_factory;
prefs_factory.SetUserPrefsFile(prefs_path, prefs_factory.SetUserPrefsFile(prefs_path,

View file

@ -64,6 +64,7 @@ class BrowserContext : public base::RefCounted<BrowserContext>,
return url_request_getter_.get(); return url_request_getter_.get();
} }
void InitPrefs();
PrefService* prefs() { return prefs_.get(); } PrefService* prefs() { return prefs_.get(); }
protected: protected: