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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #include "chrome/browser/instant/instant_controller.h" | 49 #include "chrome/browser/instant/instant_controller.h" |
50 #include "chrome/browser/metrics/metrics_service.h" | 50 #include "chrome/browser/metrics/metrics_service.h" |
51 #include "chrome/browser/net/chrome_url_request_context.h" | 51 #include "chrome/browser/net/chrome_url_request_context.h" |
52 #include "chrome/browser/net/net_pref_observer.h" | 52 #include "chrome/browser/net/net_pref_observer.h" |
53 #include "chrome/browser/net/predictor.h" | 53 #include "chrome/browser/net/predictor.h" |
54 #include "chrome/browser/net/proxy_service_factory.h" | 54 #include "chrome/browser/net/proxy_service_factory.h" |
55 #include "chrome/browser/net/ssl_config_service_manager.h" | 55 #include "chrome/browser/net/ssl_config_service_manager.h" |
56 #include "chrome/browser/net/url_fixer_upper.h" | 56 #include "chrome/browser/net/url_fixer_upper.h" |
57 #include "chrome/browser/plugin_prefs.h" | 57 #include "chrome/browser/plugin_prefs.h" |
58 #include "chrome/browser/policy/policy_service.h" | 58 #include "chrome/browser/policy/policy_service.h" |
59 #include "chrome/browser/policy/user_cloud_policy_manager.h" | |
60 #include "chrome/browser/prefs/browser_prefs.h" | 59 #include "chrome/browser/prefs/browser_prefs.h" |
61 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 60 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
62 #include "chrome/browser/prerender/prerender_manager_factory.h" | 61 #include "chrome/browser/prerender/prerender_manager_factory.h" |
63 #include "chrome/browser/profiles/chrome_version_service.h" | 62 #include "chrome/browser/profiles/chrome_version_service.h" |
64 #include "chrome/browser/profiles/gaia_info_update_service.h" | 63 #include "chrome/browser/profiles/gaia_info_update_service.h" |
65 #include "chrome/browser/profiles/profile_dependency_manager.h" | 64 #include "chrome/browser/profiles/profile_dependency_manager.h" |
66 #include "chrome/browser/profiles/profile_destroyer.h" | 65 #include "chrome/browser/profiles/profile_destroyer.h" |
67 #include "chrome/browser/profiles/profile_info_cache.h" | 66 #include "chrome/browser/profiles/profile_info_cache.h" |
68 #include "chrome/browser/profiles/profile_manager.h" | 67 #include "chrome/browser/profiles/profile_manager.h" |
69 #include "chrome/browser/search_engines/template_url_fetcher.h" | 68 #include "chrome/browser/search_engines/template_url_fetcher.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 // Determine if prefetch is enabled for this profile. | 279 // Determine if prefetch is enabled for this profile. |
281 // If not profile_manager is present, it means we are in a unittest. | 280 // If not profile_manager is present, it means we are in a unittest. |
282 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 281 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
283 predictor_ = chrome_browser_net::Predictor::CreatePredictor( | 282 predictor_ = chrome_browser_net::Predictor::CreatePredictor( |
284 !command_line->HasSwitch(switches::kDisablePreconnect), | 283 !command_line->HasSwitch(switches::kDisablePreconnect), |
285 g_browser_process->profile_manager() == NULL); | 284 g_browser_process->profile_manager() == NULL); |
286 | 285 |
287 session_restore_enabled_ = | 286 session_restore_enabled_ = |
288 !command_line->HasSwitch(switches::kDisableRestoreSessionState); | 287 !command_line->HasSwitch(switches::kDisableRestoreSessionState); |
289 #if defined(ENABLE_CONFIGURATION_POLICY) | 288 #if defined(ENABLE_CONFIGURATION_POLICY) |
290 // TODO(atwilson): Change these to ProfileKeyedServices once PrefService is | 289 policy_service_.reset( |
291 // a ProfileKeyedService (policy must be initialized before PrefService | 290 g_browser_process->browser_policy_connector()->CreatePolicyService(this)); |
292 // because PrefService depends on policy loading to get overridden pref | |
293 // values). | |
294 cloud_policy_manager_ = | |
295 g_browser_process->browser_policy_connector()->CreateCloudPolicyManager( | |
296 this); | |
297 policy_service_ = | |
298 g_browser_process->browser_policy_connector()->CreatePolicyService(this); | |
299 #else | 291 #else |
300 policy_service_.reset(new policy::PolicyServiceStub()); | 292 policy_service_.reset(new policy::PolicyServiceStub()); |
301 #endif | 293 #endif |
302 if (create_mode == CREATE_MODE_ASYNCHRONOUS) { | 294 if (create_mode == CREATE_MODE_ASYNCHRONOUS) { |
303 prefs_.reset(PrefService::CreatePrefService( | 295 prefs_.reset(PrefService::CreatePrefService( |
304 GetPrefFilePath(), | 296 GetPrefFilePath(), |
305 policy_service_.get(), | 297 policy_service_.get(), |
306 new ExtensionPrefStore( | 298 new ExtensionPrefStore( |
307 ExtensionPrefValueMapFactory::GetForProfile(this), false), | 299 ExtensionPrefValueMapFactory::GetForProfile(this), false), |
308 true)); | 300 true)); |
309 // Wait for the notification that prefs has been loaded (successfully or | 301 // Wait for the notification that prefs has been loaded (successfully or |
310 // not). | 302 // not). |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 ChromeVersionService::OnProfileLoaded(prefs_.get(), is_new_profile); | 642 ChromeVersionService::OnProfileLoaded(prefs_.get(), is_new_profile); |
651 DoFinalInit(is_new_profile); | 643 DoFinalInit(is_new_profile); |
652 } | 644 } |
653 | 645 |
654 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { | 646 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { |
655 Version profile_version(ChromeVersionService::GetVersion(prefs_.get())); | 647 Version profile_version(ChromeVersionService::GetVersion(prefs_.get())); |
656 Version arg_version(version); | 648 Version arg_version(version); |
657 return (profile_version.CompareTo(arg_version) >= 0); | 649 return (profile_version.CompareTo(arg_version) >= 0); |
658 } | 650 } |
659 | 651 |
660 policy::UserCloudPolicyManager* ProfileImpl::GetUserCloudPolicyManager() { | |
661 return cloud_policy_manager_.get(); | |
662 } | |
663 | |
664 policy::PolicyService* ProfileImpl::GetPolicyService() { | 652 policy::PolicyService* ProfileImpl::GetPolicyService() { |
665 DCHECK(policy_service_.get()); // Should explicitly be initialized. | 653 DCHECK(policy_service_.get()); // Should explicitly be initialized. |
666 return policy_service_.get(); | 654 return policy_service_.get(); |
667 } | 655 } |
668 | 656 |
669 PrefService* ProfileImpl::GetPrefs() { | 657 PrefService* ProfileImpl::GetPrefs() { |
670 DCHECK(prefs_.get()); // Should explicitly be initialized. | 658 DCHECK(prefs_.get()); // Should explicitly be initialized. |
671 return prefs_.get(); | 659 return prefs_.get(); |
672 } | 660 } |
673 | 661 |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 if (!path.empty()) | 1091 if (!path.empty()) |
1104 *cache_path = path; | 1092 *cache_path = path; |
1105 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1093 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
1106 prefs_->GetInteger(prefs::kDiskCacheSize); | 1094 prefs_->GetInteger(prefs::kDiskCacheSize); |
1107 } | 1095 } |
1108 | 1096 |
1109 base::Callback<ChromeURLDataManagerBackend*(void)> | 1097 base::Callback<ChromeURLDataManagerBackend*(void)> |
1110 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { | 1098 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { |
1111 return io_data_.GetChromeURLDataManagerBackendGetter(); | 1099 return io_data_.GetChromeURLDataManagerBackendGetter(); |
1112 } | 1100 } |
OLD | NEW |