OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/profiles/profile_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "chrome/browser/net/predictor.h" | 53 #include "chrome/browser/net/predictor.h" |
54 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 54 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
55 #include "chrome/browser/net/proxy_service_factory.h" | 55 #include "chrome/browser/net/proxy_service_factory.h" |
56 #include "chrome/browser/net/ssl_config_service_manager.h" | 56 #include "chrome/browser/net/ssl_config_service_manager.h" |
57 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 57 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
58 #include "chrome/browser/plugins/plugin_prefs.h" | 58 #include "chrome/browser/plugins/plugin_prefs.h" |
59 #include "chrome/browser/policy/profile_policy_connector.h" | 59 #include "chrome/browser/policy/profile_policy_connector.h" |
60 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 60 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
61 #include "chrome/browser/prefs/browser_prefs.h" | 61 #include "chrome/browser/prefs/browser_prefs.h" |
62 #include "chrome/browser/prefs/chrome_pref_service_factory.h" | 62 #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
| 63 #include "chrome/browser/prefs/pref_hash_store_impl.h" |
63 #include "chrome/browser/prefs/pref_service_syncable.h" | 64 #include "chrome/browser/prefs/pref_service_syncable.h" |
64 #include "chrome/browser/prerender/prerender_manager_factory.h" | 65 #include "chrome/browser/prerender/prerender_manager_factory.h" |
65 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" | 66 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" |
66 #include "chrome/browser/profiles/chrome_version_service.h" | 67 #include "chrome/browser/profiles/chrome_version_service.h" |
67 #include "chrome/browser/profiles/gaia_info_update_service_factory.h" | 68 #include "chrome/browser/profiles/gaia_info_update_service_factory.h" |
68 #include "chrome/browser/profiles/profile_destroyer.h" | 69 #include "chrome/browser/profiles/profile_destroyer.h" |
69 #include "chrome/browser/profiles/profile_info_cache.h" | 70 #include "chrome/browser/profiles/profile_info_cache.h" |
70 #include "chrome/browser/profiles/profile_manager.h" | 71 #include "chrome/browser/profiles/profile_manager.h" |
71 #include "chrome/browser/profiles/profile_metrics.h" | 72 #include "chrome/browser/profiles/profile_metrics.h" |
72 #include "chrome/browser/search_engines/template_url_fetcher.h" | 73 #include "chrome/browser/search_engines/template_url_fetcher.h" |
(...skipping 13 matching lines...) Expand all Loading... |
86 #include "components/user_prefs/pref_registry_syncable.h" | 87 #include "components/user_prefs/pref_registry_syncable.h" |
87 #include "components/user_prefs/user_prefs.h" | 88 #include "components/user_prefs/user_prefs.h" |
88 #include "content/public/browser/browser_thread.h" | 89 #include "content/public/browser/browser_thread.h" |
89 #include "content/public/browser/dom_storage_context.h" | 90 #include "content/public/browser/dom_storage_context.h" |
90 #include "content/public/browser/host_zoom_map.h" | 91 #include "content/public/browser/host_zoom_map.h" |
91 #include "content/public/browser/notification_service.h" | 92 #include "content/public/browser/notification_service.h" |
92 #include "content/public/browser/render_process_host.h" | 93 #include "content/public/browser/render_process_host.h" |
93 #include "content/public/browser/storage_partition.h" | 94 #include "content/public/browser/storage_partition.h" |
94 #include "content/public/browser/user_metrics.h" | 95 #include "content/public/browser/user_metrics.h" |
95 #include "content/public/common/content_constants.h" | 96 #include "content/public/common/content_constants.h" |
| 97 #include "grit/browser_resources.h" |
96 #include "grit/chromium_strings.h" | 98 #include "grit/chromium_strings.h" |
97 #include "grit/generated_resources.h" | 99 #include "grit/generated_resources.h" |
98 #include "ui/base/l10n/l10n_util.h" | 100 #include "ui/base/l10n/l10n_util.h" |
99 | 101 |
100 #if defined(ENABLE_CONFIGURATION_POLICY) | 102 #if defined(ENABLE_CONFIGURATION_POLICY) |
101 #include "chrome/browser/policy/browser_policy_connector.h" | 103 #include "chrome/browser/policy/browser_policy_connector.h" |
102 #include "chrome/browser/policy/schema_registry_service.h" | 104 #include "chrome/browser/policy/schema_registry_service.h" |
103 #include "chrome/browser/policy/schema_registry_service_factory.h" | 105 #include "chrome/browser/policy/schema_registry_service_factory.h" |
104 #if defined(OS_CHROMEOS) | 106 #if defined(OS_CHROMEOS) |
105 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 107 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
106 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 108 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
107 #else | 109 #else |
108 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" | 110 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" |
109 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" | 111 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" |
110 #endif | 112 #endif |
111 #endif | 113 #endif |
112 | 114 |
113 #if defined(ENABLE_MANAGED_USERS) | 115 #if defined(ENABLE_MANAGED_USERS) |
114 #include "chrome/browser/managed_mode/managed_user_settings_service.h" | 116 #include "chrome/browser/managed_mode/managed_user_settings_service.h" |
115 #include "chrome/browser/managed_mode/managed_user_settings_service_factory.h" | 117 #include "chrome/browser/managed_mode/managed_user_settings_service_factory.h" |
116 #endif | 118 #endif |
117 | 119 |
118 #if defined(OS_WIN) | 120 #if defined(OS_WIN) |
119 #include "chrome/browser/profiles/file_path_verifier_win.h" | 121 #include "chrome/browser/profiles/file_path_verifier_win.h" |
120 #include "chrome/installer/util/install_util.h" | 122 #include "chrome/installer/util/install_util.h" |
| 123 #if defined(ENABLE_RLZ) |
| 124 #include "rlz/lib/machine_id.h" |
| 125 #endif |
121 #endif | 126 #endif |
122 | 127 |
123 #if defined(OS_CHROMEOS) | 128 #if defined(OS_CHROMEOS) |
124 #include "chrome/browser/chromeos/locale_change_guard.h" | 129 #include "chrome/browser/chromeos/locale_change_guard.h" |
125 #include "chrome/browser/chromeos/login/user_manager.h" | 130 #include "chrome/browser/chromeos/login/user_manager.h" |
126 #include "chrome/browser/chromeos/preferences.h" | 131 #include "chrome/browser/chromeos/preferences.h" |
127 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 132 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
128 #endif | 133 #endif |
129 | 134 |
130 using base::Time; | 135 using base::Time; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 #if defined(OS_WIN) | 255 #if defined(OS_WIN) |
251 // Only do prefs file verification on Windows. | 256 // Only do prefs file verification on Windows. |
252 const int kVerifyPrefsFileDelaySeconds = 60; | 257 const int kVerifyPrefsFileDelaySeconds = 60; |
253 BrowserThread::GetBlockingPool()->PostDelayedTask( | 258 BrowserThread::GetBlockingPool()->PostDelayedTask( |
254 FROM_HERE, | 259 FROM_HERE, |
255 base::Bind(&VerifyPreferencesFile, prefs_file), | 260 base::Bind(&VerifyPreferencesFile, prefs_file), |
256 base::TimeDelta::FromSeconds(kVerifyPrefsFileDelaySeconds)); | 261 base::TimeDelta::FromSeconds(kVerifyPrefsFileDelaySeconds)); |
257 #endif | 262 #endif |
258 } | 263 } |
259 | 264 |
| 265 scoped_ptr<PrefHashStore> GetPrefHashStore(Profile* profile) { |
| 266 // TODO(erikwright): Enable this on Android when race condition is sorted out. |
| 267 #if defined(OS_ANDROID) |
| 268 return scoped_ptr<PrefHashStore>(); |
| 269 #else |
| 270 std::string seed = ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 271 IDR_PREF_HASH_SEED_BIN).as_string(); |
| 272 std::string device_id; |
| 273 |
| 274 #if defined(OS_WIN) && defined(ENABLE_RLZ) |
| 275 // This is used by |
| 276 // chrome/browser/extensions/api/music_manager_private/device_id_win.cc |
| 277 // but that API is private (http://crbug.com/276485) and other platforms are |
| 278 // not available synchronously. |
| 279 // As part of improving pref metrics on other platforms we may want to find |
| 280 // ways to defer preference loading until the device ID can be used. |
| 281 rlz_lib::GetMachineId(&device_id); |
| 282 #endif |
| 283 |
| 284 return scoped_ptr<PrefHashStore>(new PrefHashStoreImpl( |
| 285 profile->GetPath().AsUTF8Unsafe(), |
| 286 seed, |
| 287 device_id, |
| 288 g_browser_process->local_state())); |
| 289 #endif |
| 290 } |
| 291 |
260 } // namespace | 292 } // namespace |
261 | 293 |
262 // static | 294 // static |
263 Profile* Profile::CreateProfile(const base::FilePath& path, | 295 Profile* Profile::CreateProfile(const base::FilePath& path, |
264 Delegate* delegate, | 296 Delegate* delegate, |
265 CreateMode create_mode) { | 297 CreateMode create_mode) { |
266 TRACE_EVENT0("browser", "Profile::CreateProfile") | 298 TRACE_EVENT0("browser", "Profile::CreateProfile") |
267 // Get sequenced task runner for making sure that file operations of | 299 // Get sequenced task runner for making sure that file operations of |
268 // this profile (defined by |path|) are executed in expected order | 300 // this profile (defined by |path|) are executed in expected order |
269 // (what was previously assured by the FILE thread). | 301 // (what was previously assured by the FILE thread). |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 { | 485 { |
454 // On startup, preference loading is always synchronous so a scoped timer | 486 // On startup, preference loading is always synchronous so a scoped timer |
455 // will work here. | 487 // will work here. |
456 startup_metric_utils::ScopedSlowStartupUMA | 488 startup_metric_utils::ScopedSlowStartupUMA |
457 scoped_timer("Startup.SlowStartupPreferenceLoading"); | 489 scoped_timer("Startup.SlowStartupPreferenceLoading"); |
458 prefs_ = chrome_prefs::CreateProfilePrefs( | 490 prefs_ = chrome_prefs::CreateProfilePrefs( |
459 GetPrefFilePath(), | 491 GetPrefFilePath(), |
460 sequenced_task_runner, | 492 sequenced_task_runner, |
461 profile_policy_connector_->policy_service(), | 493 profile_policy_connector_->policy_service(), |
462 managed_user_settings, | 494 managed_user_settings, |
| 495 GetPrefHashStore(this), |
463 new ExtensionPrefStore( | 496 new ExtensionPrefStore( |
464 ExtensionPrefValueMapFactory::GetForBrowserContext(this), false), | 497 ExtensionPrefValueMapFactory::GetForBrowserContext(this), false), |
465 pref_registry_, | 498 pref_registry_, |
466 async_prefs).Pass(); | 499 async_prefs).Pass(); |
467 // Register on BrowserContext. | 500 // Register on BrowserContext. |
468 user_prefs::UserPrefs::Set(this, prefs_.get()); | 501 user_prefs::UserPrefs::Set(this, prefs_.get()); |
469 } | 502 } |
470 | 503 |
471 startup_metric_utils::ScopedSlowStartupUMA | 504 startup_metric_utils::ScopedSlowStartupUMA |
472 scoped_timer("Startup.SlowStartupFinalProfileInit"); | 505 scoped_timer("Startup.SlowStartupFinalProfileInit"); |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { | 1283 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { |
1251 #if defined(OS_CHROMEOS) | 1284 #if defined(OS_CHROMEOS) |
1252 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 1285 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
1253 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 1286 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
1254 g_browser_process->local_state()); | 1287 g_browser_process->local_state()); |
1255 } | 1288 } |
1256 #endif // defined(OS_CHROMEOS) | 1289 #endif // defined(OS_CHROMEOS) |
1257 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 1290 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
1258 GetPrefs(), g_browser_process->local_state()); | 1291 GetPrefs(), g_browser_process->local_state()); |
1259 } | 1292 } |
OLD | NEW |