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