From 73632d4189744ac05f658b75e32e6dd6262a992a Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 6 Oct 2015 15:19:38 +0800 Subject: [PATCH] Fix RegisterPrefs not working in subclass. Don't call virtual function in subclass's constructor. --- brightray/browser/browser_context.cc | 3 +++ brightray/browser/browser_context.h | 1 + 2 files changed, 4 insertions(+) diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index f5d6effdeba0..a0349809f778 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -88,6 +88,7 @@ scoped_refptr BrowserContext::From( return make_scoped_refptr(browser_context_map_[key].get()); auto browser_context = BrowserContext::Create(partition, in_memory); + browser_context->InitPrefs(); browser_context_map_[key] = browser_context->weak_factory_.GetWeakPtr(); return browser_context; } @@ -105,7 +106,9 @@ BrowserContext::BrowserContext(const std::string& partition, bool in_memory) if (!in_memory_ && !partition.empty()) path_ = path_.Append(FILE_PATH_LITERAL("Partitions")) .Append(base::FilePath::FromUTF8Unsafe(MakePartitionName(partition))); +} +void BrowserContext::InitPrefs() { auto prefs_path = GetPath().Append(FILE_PATH_LITERAL("Preferences")); base::PrefServiceFactory prefs_factory; prefs_factory.SetUserPrefsFile(prefs_path, diff --git a/brightray/browser/browser_context.h b/brightray/browser/browser_context.h index 836d17c84bf1..abfa860003cc 100644 --- a/brightray/browser/browser_context.h +++ b/brightray/browser/browser_context.h @@ -62,6 +62,7 @@ class BrowserContext : public base::RefCounted, return url_request_getter_.get(); } + void InitPrefs(); PrefService* prefs() { return prefs_.get(); } protected: