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_calculator.h" |
| 64 #include "chrome/browser/prefs/pref_hash_store_impl.h" |
63 #include "chrome/browser/prefs/pref_service_syncable.h" | 65 #include "chrome/browser/prefs/pref_service_syncable.h" |
64 #include "chrome/browser/prerender/prerender_manager_factory.h" | 66 #include "chrome/browser/prerender/prerender_manager_factory.h" |
65 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" | 67 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" |
66 #include "chrome/browser/profiles/chrome_version_service.h" | 68 #include "chrome/browser/profiles/chrome_version_service.h" |
67 #include "chrome/browser/profiles/gaia_info_update_service_factory.h" | 69 #include "chrome/browser/profiles/gaia_info_update_service_factory.h" |
68 #include "chrome/browser/profiles/profile_destroyer.h" | 70 #include "chrome/browser/profiles/profile_destroyer.h" |
69 #include "chrome/browser/profiles/profile_info_cache.h" | 71 #include "chrome/browser/profiles/profile_info_cache.h" |
70 #include "chrome/browser/profiles/profile_manager.h" | 72 #include "chrome/browser/profiles/profile_manager.h" |
71 #include "chrome/browser/search_engines/template_url_fetcher.h" | 73 #include "chrome/browser/search_engines/template_url_fetcher.h" |
72 #include "chrome/browser/sessions/session_service_factory.h" | 74 #include "chrome/browser/sessions/session_service_factory.h" |
(...skipping 12 matching lines...) Expand all Loading... |
85 #include "components/user_prefs/pref_registry_syncable.h" | 87 #include "components/user_prefs/pref_registry_syncable.h" |
86 #include "components/user_prefs/user_prefs.h" | 88 #include "components/user_prefs/user_prefs.h" |
87 #include "content/public/browser/browser_thread.h" | 89 #include "content/public/browser/browser_thread.h" |
88 #include "content/public/browser/dom_storage_context.h" | 90 #include "content/public/browser/dom_storage_context.h" |
89 #include "content/public/browser/host_zoom_map.h" | 91 #include "content/public/browser/host_zoom_map.h" |
90 #include "content/public/browser/notification_service.h" | 92 #include "content/public/browser/notification_service.h" |
91 #include "content/public/browser/render_process_host.h" | 93 #include "content/public/browser/render_process_host.h" |
92 #include "content/public/browser/storage_partition.h" | 94 #include "content/public/browser/storage_partition.h" |
93 #include "content/public/browser/user_metrics.h" | 95 #include "content/public/browser/user_metrics.h" |
94 #include "content/public/common/content_constants.h" | 96 #include "content/public/common/content_constants.h" |
| 97 #include "grit/browser_resources.h" |
95 #include "grit/chromium_strings.h" | 98 #include "grit/chromium_strings.h" |
96 #include "grit/generated_resources.h" | 99 #include "grit/generated_resources.h" |
97 #include "ui/base/l10n/l10n_util.h" | 100 #include "ui/base/l10n/l10n_util.h" |
98 | 101 |
99 #if defined(ENABLE_CONFIGURATION_POLICY) | 102 #if defined(ENABLE_CONFIGURATION_POLICY) |
100 #include "chrome/browser/policy/browser_policy_connector.h" | 103 #include "chrome/browser/policy/browser_policy_connector.h" |
101 #include "chrome/browser/policy/schema_registry_service.h" | 104 #include "chrome/browser/policy/schema_registry_service.h" |
102 #include "chrome/browser/policy/schema_registry_service_factory.h" | 105 #include "chrome/browser/policy/schema_registry_service_factory.h" |
103 #if defined(OS_CHROMEOS) | 106 #if defined(OS_CHROMEOS) |
104 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 107 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
105 #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" |
106 #else | 109 #else |
107 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" | 110 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" |
108 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" | 111 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" |
109 #endif | 112 #endif |
110 #endif | 113 #endif |
111 | 114 |
112 #if defined(ENABLE_MANAGED_USERS) | 115 #if defined(ENABLE_MANAGED_USERS) |
113 #include "chrome/browser/managed_mode/managed_user_settings_service.h" | 116 #include "chrome/browser/managed_mode/managed_user_settings_service.h" |
114 #include "chrome/browser/managed_mode/managed_user_settings_service_factory.h" | 117 #include "chrome/browser/managed_mode/managed_user_settings_service_factory.h" |
115 #endif | 118 #endif |
116 | 119 |
117 #if defined(OS_WIN) | 120 #if defined(OS_WIN) |
118 #include "chrome/browser/profiles/file_path_verifier_win.h" | 121 #include "chrome/browser/profiles/file_path_verifier_win.h" |
119 #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 |
120 #endif | 126 #endif |
121 | 127 |
122 #if defined(OS_CHROMEOS) | 128 #if defined(OS_CHROMEOS) |
123 #include "chrome/browser/chromeos/locale_change_guard.h" | 129 #include "chrome/browser/chromeos/locale_change_guard.h" |
124 #include "chrome/browser/chromeos/login/user_manager.h" | 130 #include "chrome/browser/chromeos/login/user_manager.h" |
125 #include "chrome/browser/chromeos/preferences.h" | 131 #include "chrome/browser/chromeos/preferences.h" |
126 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 132 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
127 #endif | 133 #endif |
128 | 134 |
129 using base::Time; | 135 using base::Time; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 #if defined(OS_WIN) | 255 #if defined(OS_WIN) |
250 // Only do prefs file verification on Windows. | 256 // Only do prefs file verification on Windows. |
251 const int kVerifyPrefsFileDelaySeconds = 60; | 257 const int kVerifyPrefsFileDelaySeconds = 60; |
252 BrowserThread::GetBlockingPool()->PostDelayedTask( | 258 BrowserThread::GetBlockingPool()->PostDelayedTask( |
253 FROM_HERE, | 259 FROM_HERE, |
254 base::Bind(&VerifyPreferencesFile, prefs_file), | 260 base::Bind(&VerifyPreferencesFile, prefs_file), |
255 base::TimeDelta::FromSeconds(kVerifyPrefsFileDelaySeconds)); | 261 base::TimeDelta::FromSeconds(kVerifyPrefsFileDelaySeconds)); |
256 #endif | 262 #endif |
257 } | 263 } |
258 | 264 |
| 265 scoped_ptr<PrefHashStore> GetPrefHashStore(Profile* profile) { |
| 266 std::string seed = ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 267 IDR_PREF_HASH_SEED_BIN).as_string(); |
| 268 std::string device_id; |
| 269 |
| 270 #if defined(OS_WIN) && defined(ENABLE_RLZ) |
| 271 // This is used by |
| 272 // chrome/browser/extensions/api/music_manager_private/device_id_win.cc |
| 273 // but that API is private and other platforms are not available |
| 274 // synchronously. |
| 275 // As part of improving pref metrics on other platforms we may want to find |
| 276 // ways to defer preference loading until the device ID can be used. |
| 277 rlz_lib::GetMachineId(&device_id); |
| 278 #endif |
| 279 |
| 280 return scoped_ptr<PrefHashStore>(new PrefHashStoreImpl( |
| 281 PrefHashCalculator(seed, device_id), |
| 282 g_browser_process->local_state(), |
| 283 profile->GetPath().AsUTF8Unsafe())); |
| 284 } |
| 285 |
259 } // namespace | 286 } // namespace |
260 | 287 |
261 // static | 288 // static |
262 Profile* Profile::CreateProfile(const base::FilePath& path, | 289 Profile* Profile::CreateProfile(const base::FilePath& path, |
263 Delegate* delegate, | 290 Delegate* delegate, |
264 CreateMode create_mode) { | 291 CreateMode create_mode) { |
265 TRACE_EVENT0("browser", "Profile::CreateProfile") | 292 TRACE_EVENT0("browser", "Profile::CreateProfile") |
266 // Get sequenced task runner for making sure that file operations of | 293 // Get sequenced task runner for making sure that file operations of |
267 // this profile (defined by |path|) are executed in expected order | 294 // this profile (defined by |path|) are executed in expected order |
268 // (what was previously assured by the FILE thread). | 295 // (what was previously assured by the FILE thread). |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 { | 472 { |
446 // On startup, preference loading is always synchronous so a scoped timer | 473 // On startup, preference loading is always synchronous so a scoped timer |
447 // will work here. | 474 // will work here. |
448 startup_metric_utils::ScopedSlowStartupUMA | 475 startup_metric_utils::ScopedSlowStartupUMA |
449 scoped_timer("Startup.SlowStartupPreferenceLoading"); | 476 scoped_timer("Startup.SlowStartupPreferenceLoading"); |
450 prefs_.reset(chrome_prefs::CreateProfilePrefs( | 477 prefs_.reset(chrome_prefs::CreateProfilePrefs( |
451 GetPrefFilePath(), | 478 GetPrefFilePath(), |
452 sequenced_task_runner, | 479 sequenced_task_runner, |
453 profile_policy_connector_->policy_service(), | 480 profile_policy_connector_->policy_service(), |
454 managed_user_settings, | 481 managed_user_settings, |
| 482 GetPrefHashStore(this), |
455 new ExtensionPrefStore( | 483 new ExtensionPrefStore( |
456 ExtensionPrefValueMapFactory::GetForBrowserContext(this), false), | 484 ExtensionPrefValueMapFactory::GetForBrowserContext(this), false), |
457 pref_registry_, | 485 pref_registry_, |
458 async_prefs)); | 486 async_prefs)); |
459 // Register on BrowserContext. | 487 // Register on BrowserContext. |
460 user_prefs::UserPrefs::Set(this, prefs_.get()); | 488 user_prefs::UserPrefs::Set(this, prefs_.get()); |
461 } | 489 } |
462 | 490 |
463 startup_metric_utils::ScopedSlowStartupUMA | 491 startup_metric_utils::ScopedSlowStartupUMA |
464 scoped_timer("Startup.SlowStartupFinalProfileInit"); | 492 scoped_timer("Startup.SlowStartupFinalProfileInit"); |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { | 1269 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { |
1242 #if defined(OS_CHROMEOS) | 1270 #if defined(OS_CHROMEOS) |
1243 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 1271 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
1244 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 1272 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
1245 g_browser_process->local_state()); | 1273 g_browser_process->local_state()); |
1246 } | 1274 } |
1247 #endif // defined(OS_CHROMEOS) | 1275 #endif // defined(OS_CHROMEOS) |
1248 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 1276 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
1249 GetPrefs(), g_browser_process->local_state()); | 1277 GetPrefs(), g_browser_process->local_state()); |
1250 } | 1278 } |
OLD | NEW |