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/plugin_prefs.h" | 54 #include "chrome/browser/plugin_prefs.h" |
54 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 55 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
55 #include "chrome/browser/prefs/browser_prefs.h" | 56 #include "chrome/browser/prefs/browser_prefs.h" |
56 #include "chrome/browser/prefs/pref_value_store.h" | 57 #include "chrome/browser/prefs/pref_value_store.h" |
57 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 58 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
58 #include "chrome/browser/prerender/prerender_manager.h" | 59 #include "chrome/browser/prerender/prerender_manager.h" |
59 #include "chrome/browser/profiles/profile_dependency_manager.h" | 60 #include "chrome/browser/profiles/profile_dependency_manager.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 host_zoom_map_(NULL), | 302 host_zoom_map_(NULL), |
302 history_service_created_(false), | 303 history_service_created_(false), |
303 favicon_service_created_(false), | 304 favicon_service_created_(false), |
304 created_web_data_service_(false), | 305 created_web_data_service_(false), |
305 created_password_store_(false), | 306 created_password_store_(false), |
306 created_download_manager_(false), | 307 created_download_manager_(false), |
307 start_time_(Time::Now()), | 308 start_time_(Time::Now()), |
308 #if defined(OS_WIN) | 309 #if defined(OS_WIN) |
309 checked_instant_promo_(false), | 310 checked_instant_promo_(false), |
310 #endif | 311 #endif |
311 delegate_(delegate) { | 312 delegate_(delegate), |
| 313 predictor_(NULL) { |
312 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 314 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
313 "profile files to the root directory!"; | 315 "profile files to the root directory!"; |
314 | 316 |
315 create_session_service_timer_.Start(FROM_HERE, | 317 create_session_service_timer_.Start(FROM_HERE, |
316 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, | 318 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
317 &ProfileImpl::EnsureSessionServiceCreated); | 319 &ProfileImpl::EnsureSessionServiceCreated); |
318 | 320 |
| 321 // Determine if prefetch is enabled for this profile. |
| 322 // If not profile_manager is present, it means we are in a unittest. |
| 323 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 324 predictor_ = chrome_browser_net::Predictor::CreatePredictor( |
| 325 !command_line->HasSwitch(switches::kDisablePreconnect), |
| 326 g_browser_process->profile_manager() == NULL); |
| 327 |
319 if (delegate_) { | 328 if (delegate_) { |
320 prefs_.reset(PrefService::CreatePrefService( | 329 prefs_.reset(PrefService::CreatePrefService( |
321 GetPrefFilePath(), | 330 GetPrefFilePath(), |
322 new ExtensionPrefStore(GetExtensionPrefValueMap(), false), | 331 new ExtensionPrefStore(GetExtensionPrefValueMap(), false), |
323 true)); | 332 true)); |
324 // Wait for the notifcation that prefs has been loaded (successfully or | 333 // Wait for the notifcation that prefs has been loaded (successfully or |
325 // not). | 334 // not). |
326 registrar_.Add(this, chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED, | 335 registrar_.Add(this, chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED, |
327 Source<PrefService>(prefs_.get())); | 336 Source<PrefService>(prefs_.get())); |
328 } else { | 337 } else { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 media_cache_path = GetMediaCachePath(media_cache_path); | 438 media_cache_path = GetMediaCachePath(media_cache_path); |
430 | 439 |
431 FilePath extensions_cookie_path = GetPath(); | 440 FilePath extensions_cookie_path = GetPath(); |
432 extensions_cookie_path = | 441 extensions_cookie_path = |
433 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename); | 442 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename); |
434 | 443 |
435 FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname); | 444 FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname); |
436 | 445 |
437 // Make sure we initialize the ProfileIOData after everything else has been | 446 // Make sure we initialize the ProfileIOData after everything else has been |
438 // initialized that we might be reading from the IO thread. | 447 // initialized that we might be reading from the IO thread. |
| 448 |
439 io_data_.Init(cookie_path, origin_bound_cert_path, cache_path, | 449 io_data_.Init(cookie_path, origin_bound_cert_path, cache_path, |
440 cache_max_size, media_cache_path, media_cache_max_size, | 450 cache_max_size, media_cache_path, media_cache_max_size, |
441 extensions_cookie_path, app_path); | 451 extensions_cookie_path, app_path, predictor_, |
| 452 g_browser_process->local_state(), |
| 453 g_browser_process->io_thread()); |
442 | 454 |
443 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( | 455 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
444 PluginPrefs::GetForProfile(this), &GetResourceContext()); | 456 PluginPrefs::GetForProfile(this), &GetResourceContext()); |
445 | 457 |
446 // Creation has been finished. | 458 // Creation has been finished. |
447 if (delegate_) | 459 if (delegate_) |
448 delegate_->OnProfileCreated(this, true); | 460 delegate_->OnProfileCreated(this, true); |
449 | 461 |
450 NotificationService::current()->Notify( | 462 NotificationService::current()->Notify( |
451 chrome::NOTIFICATION_PROFILE_CREATED, | 463 chrome::NOTIFICATION_PROFILE_CREATED, |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), | 926 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), |
915 GetExtensionPrefValueMap())); | 927 GetExtensionPrefValueMap())); |
916 | 928 |
917 extension_settings_ = new ExtensionSettings( | 929 extension_settings_ = new ExtensionSettings( |
918 GetPath().AppendASCII(ExtensionService::kSettingsDirectoryName)); | 930 GetPath().AppendASCII(ExtensionService::kSettingsDirectoryName)); |
919 | 931 |
920 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); | 932 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); |
921 | 933 |
922 DCHECK(!net_pref_observer_.get()); | 934 DCHECK(!net_pref_observer_.get()); |
923 net_pref_observer_.reset( | 935 net_pref_observer_.reset( |
924 new NetPrefObserver(prefs_.get(), GetPrerenderManager())); | 936 new NetPrefObserver(prefs_.get(), GetPrerenderManager(), predictor_)); |
925 | 937 |
926 DoFinalInit(); | 938 DoFinalInit(); |
927 } | 939 } |
928 | 940 |
929 PrefService* ProfileImpl::GetPrefs() { | 941 PrefService* ProfileImpl::GetPrefs() { |
930 DCHECK(prefs_.get()); // Should explicitly be initialized. | 942 DCHECK(prefs_.get()); // Should explicitly be initialized. |
931 return prefs_.get(); | 943 return prefs_.get(); |
932 } | 944 } |
933 | 945 |
934 PrefService* ProfileImpl::GetOffTheRecordPrefs() { | 946 PrefService* ProfileImpl::GetOffTheRecordPrefs() { |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 this, g_browser_process->prerender_tracker())); | 1743 this, g_browser_process->prerender_tracker())); |
1732 #if defined(OS_CHROMEOS) | 1744 #if defined(OS_CHROMEOS) |
1733 prerender_manager_->AddCondition( | 1745 prerender_manager_->AddCondition( |
1734 new chromeos::PrerenderConditionNetwork( | 1746 new chromeos::PrerenderConditionNetwork( |
1735 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); | 1747 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); |
1736 #endif | 1748 #endif |
1737 } | 1749 } |
1738 return prerender_manager_.get(); | 1750 return prerender_manager_.get(); |
1739 } | 1751 } |
1740 | 1752 |
| 1753 chrome_browser_net::Predictor* ProfileImpl::GetNetworkPredictor() { |
| 1754 return predictor_; |
| 1755 } |
| 1756 |
1741 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { | 1757 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { |
1742 if (!spellcheck_profile_.get()) | 1758 if (!spellcheck_profile_.get()) |
1743 spellcheck_profile_.reset(new SpellCheckProfile()); | 1759 spellcheck_profile_.reset(new SpellCheckProfile()); |
1744 return spellcheck_profile_.get(); | 1760 return spellcheck_profile_.get(); |
1745 } | 1761 } |
OLD | NEW |