Index: chrome/browser/profiles/profile.cc |
diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc |
index 0302bf875d437f6ceda8c39dab9a17f89340d8d5..fac7caba40df8e3a2aa98cc98dbc3c24c732fc73 100644 |
--- a/chrome/browser/profiles/profile.cc |
+++ b/chrome/browser/profiles/profile.cc |
@@ -8,11 +8,13 @@ |
#include "base/prefs/pref_service.h" |
#include "build/build_config.h" |
-#include "chrome/browser/prefs/pref_registry_syncable.h" |
#include "chrome/browser/sync/profile_sync_service.h" |
#include "chrome/browser/sync/sync_prefs.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/pref_names.h" |
+#include "components/user_prefs/pref_registry_syncable.h" |
+#include "components/user_prefs/user_prefs.h" |
+#include "components/user_prefs/user_prefs_delegate.h" |
#include "content/public/browser/notification_service.h" |
#include "content/public/browser/notification_source.h" |
#include "content/public/browser/web_contents.h" |
@@ -23,10 +25,40 @@ |
#include "chrome/common/chrome_switches.h" |
#endif |
+namespace { |
+ |
+// Used to initialize the UserPrefs component. |
+class ChromeUserPrefsDelegate : public components::UserPrefsDelegate { |
+ public: |
+ ChromeUserPrefsDelegate() {} |
+ virtual ~ChromeUserPrefsDelegate() {} |
+ |
+ virtual PrefService* PrefServiceFromBrowserContext( |
+ content::BrowserContext* context) OVERRIDE { |
+ return static_cast<Profile*>(context)->GetPrefs(); |
+ } |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ChromeUserPrefsDelegate); |
+}; |
+ |
+} // namespace |
+ |
Profile::Profile() |
: restored_last_session_(false), |
sent_destroyed_notification_(false), |
accessibility_pause_level_(0) { |
+ // One-time initialization of UserPrefs. This is the safest to do |
+ // it, since there can be no PrefService for user preferences unless |
+ // there is a Profile, and even test code will create a Profile |
+ // object if it uses a Profile at all, although it may bypass |
+ // e.g. BrowserProcess or ProfileManager or |
+ // chrome_prefs::CreateProfilePrefs. |
+ components::UserPrefs* user_prefs = components::UserPrefs::GetInstance(); |
Elliot Glaysher
2013/02/28 21:58:57
You mentioned ContetnClient. If this is supposed t
|
+ if (!user_prefs->IsInitialized()) { |
+ user_prefs->Initialize(scoped_ptr<components::UserPrefsDelegate>( |
+ new ChromeUserPrefsDelegate).Pass()); |
+ } |
} |
// static |