OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
40 #include "chrome/browser/favicon/favicon_service.h" | 40 #include "chrome/browser/favicon/favicon_service.h" |
41 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" | 41 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
42 #include "chrome/browser/history/history.h" | 42 #include "chrome/browser/history/history.h" |
43 #include "chrome/browser/history/shortcuts_backend.h" | 43 #include "chrome/browser/history/shortcuts_backend.h" |
44 #include "chrome/browser/history/top_sites.h" | 44 #include "chrome/browser/history/top_sites.h" |
45 #include "chrome/browser/instant/instant_controller.h" | 45 #include "chrome/browser/instant/instant_controller.h" |
46 #include "chrome/browser/metrics/metrics_service.h" | 46 #include "chrome/browser/metrics/metrics_service.h" |
47 #include "chrome/browser/net/chrome_url_request_context.h" | 47 #include "chrome/browser/net/chrome_url_request_context.h" |
48 #include "chrome/browser/net/gaia/token_service.h" | 48 #include "chrome/browser/net/gaia/token_service.h" |
49 #include "chrome/browser/net/net_pref_observer.h" | 49 #include "chrome/browser/net/net_pref_observer.h" |
50 #include "chrome/browser/net/predictor.h" | |
50 #include "chrome/browser/net/pref_proxy_config_service.h" | 51 #include "chrome/browser/net/pref_proxy_config_service.h" |
51 #include "chrome/browser/net/ssl_config_service_manager.h" | 52 #include "chrome/browser/net/ssl_config_service_manager.h" |
52 #include "chrome/browser/password_manager/password_store_default.h" | 53 #include "chrome/browser/password_manager/password_store_default.h" |
53 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 54 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
54 #include "chrome/browser/prefs/browser_prefs.h" | 55 #include "chrome/browser/prefs/browser_prefs.h" |
55 #include "chrome/browser/prefs/pref_value_store.h" | 56 #include "chrome/browser/prefs/pref_value_store.h" |
56 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 57 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
57 #include "chrome/browser/prerender/prerender_manager.h" | 58 #include "chrome/browser/prerender/prerender_manager.h" |
58 #include "chrome/browser/profiles/profile_dependency_manager.h" | 59 #include "chrome/browser/profiles/profile_dependency_manager.h" |
59 #include "chrome/browser/profiles/profile_manager.h" | 60 #include "chrome/browser/profiles/profile_manager.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 host_zoom_map_(NULL), | 300 host_zoom_map_(NULL), |
300 history_service_created_(false), | 301 history_service_created_(false), |
301 favicon_service_created_(false), | 302 favicon_service_created_(false), |
302 created_web_data_service_(false), | 303 created_web_data_service_(false), |
303 created_password_store_(false), | 304 created_password_store_(false), |
304 created_download_manager_(false), | 305 created_download_manager_(false), |
305 start_time_(Time::Now()), | 306 start_time_(Time::Now()), |
306 #if defined(OS_WIN) | 307 #if defined(OS_WIN) |
307 checked_instant_promo_(false), | 308 checked_instant_promo_(false), |
308 #endif | 309 #endif |
309 delegate_(delegate) { | 310 delegate_(delegate), |
311 predictor_(NULL) { | |
310 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 312 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
311 "profile files to the root directory!"; | 313 "profile files to the root directory!"; |
312 | 314 |
313 create_session_service_timer_.Start( | 315 create_session_service_timer_.Start( |
314 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, | 316 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
315 &ProfileImpl::EnsureSessionServiceCreated); | 317 &ProfileImpl::EnsureSessionServiceCreated); |
316 | 318 |
319 // Determine if prefetch is enabled for this profile. | |
320 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
321 predictor_ = chrome_browser_net::Predictor::CreatePredictor( | |
322 !command_line->HasSwitch(switches::kDisablePreconnect), | |
323 g_browser_process->profile_manager() == NULL); | |
Miranda Callahan
2011/08/17 08:45:56
nit: can you add a comment here like "If no Profil
rpetterson
2011/08/17 16:28:25
Done.
| |
324 | |
317 if (delegate_) { | 325 if (delegate_) { |
318 prefs_.reset(PrefService::CreatePrefService( | 326 prefs_.reset(PrefService::CreatePrefService( |
319 GetPrefFilePath(), | 327 GetPrefFilePath(), |
320 new ExtensionPrefStore(GetExtensionPrefValueMap(), false), | 328 new ExtensionPrefStore(GetExtensionPrefValueMap(), false), |
321 true)); | 329 true)); |
322 // Wait for the notifcation that prefs has been loaded (successfully or | 330 // Wait for the notifcation that prefs has been loaded (successfully or |
323 // not). | 331 // not). |
324 registrar_.Add(this, chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED, | 332 registrar_.Add(this, chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED, |
325 Source<PrefService>(prefs_.get())); | 333 Source<PrefService>(prefs_.get())); |
326 } else { | 334 } else { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
427 media_cache_path = GetMediaCachePath(media_cache_path); | 435 media_cache_path = GetMediaCachePath(media_cache_path); |
428 | 436 |
429 FilePath extensions_cookie_path = GetPath(); | 437 FilePath extensions_cookie_path = GetPath(); |
430 extensions_cookie_path = | 438 extensions_cookie_path = |
431 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename); | 439 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename); |
432 | 440 |
433 FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname); | 441 FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname); |
434 | 442 |
435 // Make sure we initialize the ProfileIOData after everything else has been | 443 // Make sure we initialize the ProfileIOData after everything else has been |
436 // initialized that we might be reading from the IO thread. | 444 // initialized that we might be reading from the IO thread. |
445 | |
437 io_data_.Init(cookie_path, origin_bound_cert_path, cache_path, | 446 io_data_.Init(cookie_path, origin_bound_cert_path, cache_path, |
438 cache_max_size, media_cache_path, media_cache_max_size, | 447 cache_max_size, media_cache_path, media_cache_max_size, |
439 extensions_cookie_path, app_path); | 448 extensions_cookie_path, app_path, predictor_, |
449 g_browser_process->local_state(), | |
450 g_browser_process->io_thread()); | |
440 | 451 |
441 // Creation has been finished. | 452 // Creation has been finished. |
442 if (delegate_) | 453 if (delegate_) |
443 delegate_->OnProfileCreated(this, true); | 454 delegate_->OnProfileCreated(this, true); |
444 | 455 |
445 NotificationService::current()->Notify( | 456 NotificationService::current()->Notify( |
446 chrome::NOTIFICATION_PROFILE_CREATED, | 457 chrome::NOTIFICATION_PROFILE_CREATED, |
447 Source<Profile>(this), | 458 Source<Profile>(this), |
448 NotificationService::NoDetails()); | 459 NotificationService::NoDetails()); |
449 } | 460 } |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
888 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), | 899 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), |
889 GetExtensionPrefValueMap())); | 900 GetExtensionPrefValueMap())); |
890 | 901 |
891 extension_settings_ = new ExtensionSettings( | 902 extension_settings_ = new ExtensionSettings( |
892 GetPath().AppendASCII(ExtensionService::kSettingsDirectoryName)); | 903 GetPath().AppendASCII(ExtensionService::kSettingsDirectoryName)); |
893 | 904 |
894 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); | 905 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); |
895 | 906 |
896 DCHECK(!net_pref_observer_.get()); | 907 DCHECK(!net_pref_observer_.get()); |
897 net_pref_observer_.reset( | 908 net_pref_observer_.reset( |
898 new NetPrefObserver(prefs_.get(), GetPrerenderManager())); | 909 new NetPrefObserver(prefs_.get(), GetPrerenderManager(), predictor_)); |
899 | 910 |
900 DoFinalInit(); | 911 DoFinalInit(); |
901 } | 912 } |
902 | 913 |
903 PrefService* ProfileImpl::GetPrefs() { | 914 PrefService* ProfileImpl::GetPrefs() { |
904 DCHECK(prefs_.get()); // Should explicitly be initialized. | 915 DCHECK(prefs_.get()); // Should explicitly be initialized. |
905 return prefs_.get(); | 916 return prefs_.get(); |
906 } | 917 } |
907 | 918 |
908 PrefService* ProfileImpl::GetOffTheRecordPrefs() { | 919 PrefService* ProfileImpl::GetOffTheRecordPrefs() { |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1711 this, g_browser_process->prerender_tracker())); | 1722 this, g_browser_process->prerender_tracker())); |
1712 #if defined(OS_CHROMEOS) | 1723 #if defined(OS_CHROMEOS) |
1713 prerender_manager_->AddCondition( | 1724 prerender_manager_->AddCondition( |
1714 new chromeos::PrerenderConditionNetwork( | 1725 new chromeos::PrerenderConditionNetwork( |
1715 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); | 1726 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); |
1716 #endif | 1727 #endif |
1717 } | 1728 } |
1718 return prerender_manager_.get(); | 1729 return prerender_manager_.get(); |
1719 } | 1730 } |
1720 | 1731 |
1732 chrome_browser_net::Predictor* ProfileImpl::GetNetworkPredictor() { | |
1733 return predictor_; | |
1734 } | |
1735 | |
1721 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { | 1736 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { |
1722 if (!spellcheck_profile_.get()) | 1737 if (!spellcheck_profile_.get()) |
1723 spellcheck_profile_.reset(new SpellCheckProfile()); | 1738 spellcheck_profile_.reset(new SpellCheckProfile()); |
1724 return spellcheck_profile_.get(); | 1739 return spellcheck_profile_.get(); |
1725 } | 1740 } |
OLD | NEW |