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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 // Determine if prefetch is enabled for this profile. | 280 // Determine if prefetch is enabled for this profile. |
280 // If not profile_manager is present, it means we are in a unittest. | 281 // If not profile_manager is present, it means we are in a unittest. |
281 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 282 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
282 predictor_ = chrome_browser_net::Predictor::CreatePredictor( | 283 predictor_ = chrome_browser_net::Predictor::CreatePredictor( |
283 !command_line->HasSwitch(switches::kDisablePreconnect), | 284 !command_line->HasSwitch(switches::kDisablePreconnect), |
284 g_browser_process->profile_manager() == NULL); | 285 g_browser_process->profile_manager() == NULL); |
285 | 286 |
286 session_restore_enabled_ = | 287 session_restore_enabled_ = |
287 !command_line->HasSwitch(switches::kDisableRestoreSessionState); | 288 !command_line->HasSwitch(switches::kDisableRestoreSessionState); |
288 #if defined(ENABLE_CONFIGURATION_POLICY) | 289 #if defined(ENABLE_CONFIGURATION_POLICY) |
289 policy_service_.reset( | 290 // TODO(atwilson): Change these to ProfileKeyedServices once PrefService is |
290 g_browser_process->browser_policy_connector()->CreatePolicyService(this)); | 291 // a ProfileKeyedService (policy must be initialized before PrefService |
| 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); |
291 #else | 299 #else |
292 policy_service_.reset(new policy::PolicyServiceStub()); | 300 policy_service_.reset(new policy::PolicyServiceStub()); |
293 #endif | 301 #endif |
294 if (create_mode == CREATE_MODE_ASYNCHRONOUS) { | 302 if (create_mode == CREATE_MODE_ASYNCHRONOUS) { |
295 prefs_.reset(PrefService::CreatePrefService( | 303 prefs_.reset(PrefService::CreatePrefService( |
296 GetPrefFilePath(), | 304 GetPrefFilePath(), |
297 policy_service_.get(), | 305 policy_service_.get(), |
298 new ExtensionPrefStore( | 306 new ExtensionPrefStore( |
299 ExtensionPrefValueMapFactory::GetForProfile(this), false), | 307 ExtensionPrefValueMapFactory::GetForProfile(this), false), |
300 true)); | 308 true)); |
301 // Wait for the notification that prefs has been loaded (successfully or | 309 // Wait for the notification that prefs has been loaded (successfully or |
302 // not). | 310 // not). |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 ChromeVersionService::OnProfileLoaded(prefs_.get(), is_new_profile); | 650 ChromeVersionService::OnProfileLoaded(prefs_.get(), is_new_profile); |
643 DoFinalInit(is_new_profile); | 651 DoFinalInit(is_new_profile); |
644 } | 652 } |
645 | 653 |
646 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { | 654 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { |
647 Version profile_version(ChromeVersionService::GetVersion(prefs_.get())); | 655 Version profile_version(ChromeVersionService::GetVersion(prefs_.get())); |
648 Version arg_version(version); | 656 Version arg_version(version); |
649 return (profile_version.CompareTo(arg_version) >= 0); | 657 return (profile_version.CompareTo(arg_version) >= 0); |
650 } | 658 } |
651 | 659 |
| 660 policy::UserCloudPolicyManager* ProfileImpl::GetUserCloudPolicyManager() { |
| 661 return cloud_policy_manager_.get(); |
| 662 } |
| 663 |
652 policy::PolicyService* ProfileImpl::GetPolicyService() { | 664 policy::PolicyService* ProfileImpl::GetPolicyService() { |
653 DCHECK(policy_service_.get()); // Should explicitly be initialized. | 665 DCHECK(policy_service_.get()); // Should explicitly be initialized. |
654 return policy_service_.get(); | 666 return policy_service_.get(); |
655 } | 667 } |
656 | 668 |
657 PrefService* ProfileImpl::GetPrefs() { | 669 PrefService* ProfileImpl::GetPrefs() { |
658 DCHECK(prefs_.get()); // Should explicitly be initialized. | 670 DCHECK(prefs_.get()); // Should explicitly be initialized. |
659 return prefs_.get(); | 671 return prefs_.get(); |
660 } | 672 } |
661 | 673 |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 if (!path.empty()) | 1103 if (!path.empty()) |
1092 *cache_path = path; | 1104 *cache_path = path; |
1093 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1105 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
1094 prefs_->GetInteger(prefs::kDiskCacheSize); | 1106 prefs_->GetInteger(prefs::kDiskCacheSize); |
1095 } | 1107 } |
1096 | 1108 |
1097 base::Callback<ChromeURLDataManagerBackend*(void)> | 1109 base::Callback<ChromeURLDataManagerBackend*(void)> |
1098 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { | 1110 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { |
1099 return io_data_.GetChromeURLDataManagerBackendGetter(); | 1111 return io_data_.GetChromeURLDataManagerBackendGetter(); |
1100 } | 1112 } |
OLD | NEW |