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 // If not profile_manager is present, it means we are in a unittest. |
| 321 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 322 predictor_ = chrome_browser_net::Predictor::CreatePredictor( |
| 323 !command_line->HasSwitch(switches::kDisablePreconnect), |
| 324 g_browser_process->profile_manager() == NULL); |
| 325 |
317 if (delegate_) { | 326 if (delegate_) { |
318 prefs_.reset(PrefService::CreatePrefService( | 327 prefs_.reset(PrefService::CreatePrefService( |
319 GetPrefFilePath(), | 328 GetPrefFilePath(), |
320 new ExtensionPrefStore(GetExtensionPrefValueMap(), false), | 329 new ExtensionPrefStore(GetExtensionPrefValueMap(), false), |
321 true)); | 330 true)); |
322 // Wait for the notifcation that prefs has been loaded (successfully or | 331 // Wait for the notifcation that prefs has been loaded (successfully or |
323 // not). | 332 // not). |
324 registrar_.Add(this, chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED, | 333 registrar_.Add(this, chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED, |
325 Source<PrefService>(prefs_.get())); | 334 Source<PrefService>(prefs_.get())); |
326 } else { | 335 } else { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 media_cache_path = GetMediaCachePath(media_cache_path); | 436 media_cache_path = GetMediaCachePath(media_cache_path); |
428 | 437 |
429 FilePath extensions_cookie_path = GetPath(); | 438 FilePath extensions_cookie_path = GetPath(); |
430 extensions_cookie_path = | 439 extensions_cookie_path = |
431 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename); | 440 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename); |
432 | 441 |
433 FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname); | 442 FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname); |
434 | 443 |
435 // Make sure we initialize the ProfileIOData after everything else has been | 444 // Make sure we initialize the ProfileIOData after everything else has been |
436 // initialized that we might be reading from the IO thread. | 445 // initialized that we might be reading from the IO thread. |
| 446 |
437 io_data_.Init(cookie_path, origin_bound_cert_path, cache_path, | 447 io_data_.Init(cookie_path, origin_bound_cert_path, cache_path, |
438 cache_max_size, media_cache_path, media_cache_max_size, | 448 cache_max_size, media_cache_path, media_cache_max_size, |
439 extensions_cookie_path, app_path); | 449 extensions_cookie_path, app_path, predictor_, |
| 450 g_browser_process->local_state(), |
| 451 g_browser_process->io_thread()); |
440 | 452 |
441 // Creation has been finished. | 453 // Creation has been finished. |
442 if (delegate_) | 454 if (delegate_) |
443 delegate_->OnProfileCreated(this, true); | 455 delegate_->OnProfileCreated(this, true); |
444 | 456 |
445 NotificationService::current()->Notify( | 457 NotificationService::current()->Notify( |
446 chrome::NOTIFICATION_PROFILE_CREATED, | 458 chrome::NOTIFICATION_PROFILE_CREATED, |
447 Source<Profile>(this), | 459 Source<Profile>(this), |
448 NotificationService::NoDetails()); | 460 NotificationService::NoDetails()); |
449 } | 461 } |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), | 900 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), |
889 GetExtensionPrefValueMap())); | 901 GetExtensionPrefValueMap())); |
890 | 902 |
891 extension_settings_ = new ExtensionSettings( | 903 extension_settings_ = new ExtensionSettings( |
892 GetPath().AppendASCII(ExtensionService::kSettingsDirectoryName)); | 904 GetPath().AppendASCII(ExtensionService::kSettingsDirectoryName)); |
893 | 905 |
894 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); | 906 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); |
895 | 907 |
896 DCHECK(!net_pref_observer_.get()); | 908 DCHECK(!net_pref_observer_.get()); |
897 net_pref_observer_.reset( | 909 net_pref_observer_.reset( |
898 new NetPrefObserver(prefs_.get(), GetPrerenderManager())); | 910 new NetPrefObserver(prefs_.get(), GetPrerenderManager(), predictor_)); |
899 | 911 |
900 DoFinalInit(); | 912 DoFinalInit(); |
901 } | 913 } |
902 | 914 |
903 PrefService* ProfileImpl::GetPrefs() { | 915 PrefService* ProfileImpl::GetPrefs() { |
904 DCHECK(prefs_.get()); // Should explicitly be initialized. | 916 DCHECK(prefs_.get()); // Should explicitly be initialized. |
905 return prefs_.get(); | 917 return prefs_.get(); |
906 } | 918 } |
907 | 919 |
908 PrefService* ProfileImpl::GetOffTheRecordPrefs() { | 920 PrefService* ProfileImpl::GetOffTheRecordPrefs() { |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1711 this, g_browser_process->prerender_tracker())); | 1723 this, g_browser_process->prerender_tracker())); |
1712 #if defined(OS_CHROMEOS) | 1724 #if defined(OS_CHROMEOS) |
1713 prerender_manager_->AddCondition( | 1725 prerender_manager_->AddCondition( |
1714 new chromeos::PrerenderConditionNetwork( | 1726 new chromeos::PrerenderConditionNetwork( |
1715 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); | 1727 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); |
1716 #endif | 1728 #endif |
1717 } | 1729 } |
1718 return prerender_manager_.get(); | 1730 return prerender_manager_.get(); |
1719 } | 1731 } |
1720 | 1732 |
| 1733 chrome_browser_net::Predictor* ProfileImpl::GetNetworkPredictor() { |
| 1734 return predictor_; |
| 1735 } |
| 1736 |
1721 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { | 1737 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { |
1722 if (!spellcheck_profile_.get()) | 1738 if (!spellcheck_profile_.get()) |
1723 spellcheck_profile_.reset(new SpellCheckProfile()); | 1739 spellcheck_profile_.reset(new SpellCheckProfile()); |
1724 return spellcheck_profile_.get(); | 1740 return spellcheck_profile_.get(); |
1725 } | 1741 } |
OLD | NEW |