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" |
59 #include "chrome/browser/prefs/browser_prefs.h" | 60 #include "chrome/browser/prefs/browser_prefs.h" |
60 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 61 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
61 #include "chrome/browser/prerender/prerender_manager_factory.h" | 62 #include "chrome/browser/prerender/prerender_manager_factory.h" |
62 #include "chrome/browser/profiles/chrome_version_service.h" | 63 #include "chrome/browser/profiles/chrome_version_service.h" |
63 #include "chrome/browser/profiles/gaia_info_update_service.h" | 64 #include "chrome/browser/profiles/gaia_info_update_service.h" |
64 #include "chrome/browser/profiles/profile_dependency_manager.h" | 65 #include "chrome/browser/profiles/profile_dependency_manager.h" |
65 #include "chrome/browser/profiles/profile_destroyer.h" | 66 #include "chrome/browser/profiles/profile_destroyer.h" |
66 #include "chrome/browser/profiles/profile_info_cache.h" | 67 #include "chrome/browser/profiles/profile_info_cache.h" |
67 #include "chrome/browser/profiles/profile_manager.h" | 68 #include "chrome/browser/profiles/profile_manager.h" |
68 #include "chrome/browser/search_engines/template_url_fetcher.h" | 69 #include "chrome/browser/search_engines/template_url_fetcher.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // Determine if prefetch is enabled for this profile. | 279 // Determine if prefetch is enabled for this profile. |
279 // 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. |
280 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 281 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
281 predictor_ = chrome_browser_net::Predictor::CreatePredictor( | 282 predictor_ = chrome_browser_net::Predictor::CreatePredictor( |
282 !command_line->HasSwitch(switches::kDisablePreconnect), | 283 !command_line->HasSwitch(switches::kDisablePreconnect), |
283 g_browser_process->profile_manager() == NULL); | 284 g_browser_process->profile_manager() == NULL); |
284 | 285 |
285 session_restore_enabled_ = | 286 session_restore_enabled_ = |
286 !command_line->HasSwitch(switches::kDisableRestoreSessionState); | 287 !command_line->HasSwitch(switches::kDisableRestoreSessionState); |
287 #if defined(ENABLE_CONFIGURATION_POLICY) | 288 #if defined(ENABLE_CONFIGURATION_POLICY) |
288 policy_service_.reset( | 289 // TODO(atwilson): Change these to ProfileKeyedServices once PrefService is |
289 g_browser_process->browser_policy_connector()->CreatePolicyService(this)); | 290 // a ProfileKeyedService (policy must be initialized before PrefService |
| 291 // because PrefService depends on policy loading to get overridden pref |
| 292 // values). |
| 293 cloud_policy_manager_ = |
| 294 g_browser_process->browser_policy_connector()->CreateCloudPolicyManager( |
| 295 this); |
| 296 policy_service_ = |
| 297 g_browser_process->browser_policy_connector()->CreatePolicyService(this); |
290 #else | 298 #else |
291 policy_service_.reset(new policy::PolicyServiceStub()); | 299 policy_service_.reset(new policy::PolicyServiceStub()); |
292 #endif | 300 #endif |
293 if (create_mode == CREATE_MODE_ASYNCHRONOUS) { | 301 if (create_mode == CREATE_MODE_ASYNCHRONOUS) { |
294 prefs_.reset(PrefService::CreatePrefService( | 302 prefs_.reset(PrefService::CreatePrefService( |
295 GetPrefFilePath(), | 303 GetPrefFilePath(), |
296 policy_service_.get(), | 304 policy_service_.get(), |
297 new ExtensionPrefStore( | 305 new ExtensionPrefStore( |
298 ExtensionPrefValueMapFactory::GetForProfile(this), false), | 306 ExtensionPrefValueMapFactory::GetForProfile(this), false), |
299 true)); | 307 true)); |
300 // Wait for the notification that prefs has been loaded (successfully or | 308 // Wait for the notification that prefs has been loaded (successfully or |
301 // not). | 309 // not). |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 ChromeVersionService::OnProfileLoaded(prefs_.get(), is_new_profile); | 644 ChromeVersionService::OnProfileLoaded(prefs_.get(), is_new_profile); |
637 DoFinalInit(is_new_profile); | 645 DoFinalInit(is_new_profile); |
638 } | 646 } |
639 | 647 |
640 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { | 648 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { |
641 Version profile_version(ChromeVersionService::GetVersion(prefs_.get())); | 649 Version profile_version(ChromeVersionService::GetVersion(prefs_.get())); |
642 Version arg_version(version); | 650 Version arg_version(version); |
643 return (profile_version.CompareTo(arg_version) >= 0); | 651 return (profile_version.CompareTo(arg_version) >= 0); |
644 } | 652 } |
645 | 653 |
| 654 policy::UserCloudPolicyManager* ProfileImpl::GetUserCloudPolicyManager() { |
| 655 return cloud_policy_manager_.get(); |
| 656 } |
| 657 |
646 policy::PolicyService* ProfileImpl::GetPolicyService() { | 658 policy::PolicyService* ProfileImpl::GetPolicyService() { |
647 DCHECK(policy_service_.get()); // Should explicitly be initialized. | 659 DCHECK(policy_service_.get()); // Should explicitly be initialized. |
648 return policy_service_.get(); | 660 return policy_service_.get(); |
649 } | 661 } |
650 | 662 |
651 PrefService* ProfileImpl::GetPrefs() { | 663 PrefService* ProfileImpl::GetPrefs() { |
652 DCHECK(prefs_.get()); // Should explicitly be initialized. | 664 DCHECK(prefs_.get()); // Should explicitly be initialized. |
653 return prefs_.get(); | 665 return prefs_.get(); |
654 } | 666 } |
655 | 667 |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 if (!path.empty()) | 1097 if (!path.empty()) |
1086 *cache_path = path; | 1098 *cache_path = path; |
1087 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1099 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
1088 prefs_->GetInteger(prefs::kDiskCacheSize); | 1100 prefs_->GetInteger(prefs::kDiskCacheSize); |
1089 } | 1101 } |
1090 | 1102 |
1091 base::Callback<ChromeURLDataManagerBackend*(void)> | 1103 base::Callback<ChromeURLDataManagerBackend*(void)> |
1092 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { | 1104 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { |
1093 return io_data_.GetChromeURLDataManagerBackendGetter(); | 1105 return io_data_.GetChromeURLDataManagerBackendGetter(); |
1094 } | 1106 } |
OLD | NEW |