Chromium Code Reviews| 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/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 #endif | 333 #endif |
| 334 | 334 |
| 335 // Determine if prefetch is enabled for this profile. | 335 // Determine if prefetch is enabled for this profile. |
| 336 // If not profile_manager is present, it means we are in a unittest. | 336 // If not profile_manager is present, it means we are in a unittest. |
| 337 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 337 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 338 predictor_ = chrome_browser_net::Predictor::CreatePredictor( | 338 predictor_ = chrome_browser_net::Predictor::CreatePredictor( |
| 339 !command_line->HasSwitch(switches::kDisablePreconnect), | 339 !command_line->HasSwitch(switches::kDisablePreconnect), |
| 340 g_browser_process->profile_manager() == NULL); | 340 g_browser_process->profile_manager() == NULL); |
| 341 | 341 |
| 342 #if defined(ENABLE_CONFIGURATION_POLICY) | 342 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 343 // TODO(atwilson): Change these to ProfileKeyedServices once PrefService is | |
| 344 // a ProfileKeyedService (policy must be initialized before PrefService | |
| 345 // because PrefService depends on policy loading to get overridden pref | |
| 346 // values). | |
| 347 policy::BrowserPolicyConnector* connector = | |
| 348 g_browser_process->browser_policy_connector(); | |
| 349 // If we are creating the profile synchronously, then we should load the | 343 // If we are creating the profile synchronously, then we should load the |
| 350 // policy data immediately. | 344 // policy data immediately. |
| 351 bool force_immediate_policy_load = (create_mode == CREATE_MODE_SYNCHRONOUS); | 345 bool force_immediate_policy_load = (create_mode == CREATE_MODE_SYNCHRONOUS); |
| 352 cloud_policy_manager_ = | 346 |
| 353 connector->CreateCloudPolicyManager(this, force_immediate_policy_load); | 347 // TODO(atwilson): Change |cloud_policy_manager_| and |
| 354 if (cloud_policy_manager_) | 348 // |managed_mode_policy_provider_| to proper ProfileKeyedServices once |
| 349 // PrefService is a ProfileKeyedService (policy must be initialized before | |
| 350 // PrefService because PrefService depends on policy loading to get overridden | |
| 351 // pref values). | |
| 352 #if !defined(OS_CHROMEOS) | |
| 353 if (command_line->HasSwitch(switches::kLoadCloudPolicyOnSignin)) { | |
| 354 cloud_policy_manager_ = | |
|
Andrew T Wilson (Slow)
2012/11/23 15:04:20
Yeah, this is a little weird (having creation happ
Mattias Nissler (ping if slow)
2012/11/23 17:36:06
I've now moved creation to the factory.
| |
| 355 policy::UserCloudPolicyManager::Create( | |
| 356 this, force_immediate_policy_load); | |
| 355 cloud_policy_manager_->Init(); | 357 cloud_policy_manager_->Init(); |
| 358 } | |
| 359 #endif | |
| 356 managed_mode_policy_provider_ = | 360 managed_mode_policy_provider_ = |
| 357 policy::ManagedModePolicyProvider::Create(this, | 361 policy::ManagedModePolicyProvider::Create(this, |
| 358 sequenced_task_runner, | 362 sequenced_task_runner, |
| 359 force_immediate_policy_load); | 363 force_immediate_policy_load); |
| 360 managed_mode_policy_provider_->Init(); | 364 managed_mode_policy_provider_->Init(); |
| 361 policy_service_ = connector->CreatePolicyService(this); | 365 policy_service_ = |
| 366 g_browser_process->browser_policy_connector()->CreatePolicyService(this); | |
| 362 #else | 367 #else |
| 363 policy_service_.reset(new policy::PolicyServiceStub()); | 368 policy_service_.reset(new policy::PolicyServiceStub()); |
| 364 #endif | 369 #endif |
| 365 | 370 |
| 366 if (create_mode == CREATE_MODE_ASYNCHRONOUS) { | 371 if (create_mode == CREATE_MODE_ASYNCHRONOUS) { |
| 367 prefs_.reset(PrefService::CreatePrefService( | 372 prefs_.reset(PrefService::CreatePrefService( |
| 368 GetPrefFilePath(), | 373 GetPrefFilePath(), |
| 369 sequenced_task_runner, | 374 sequenced_task_runner, |
| 370 policy_service_.get(), | 375 policy_service_.get(), |
| 371 new ExtensionPrefStore( | 376 new ExtensionPrefStore( |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 599 if (top_sites_.get()) | 604 if (top_sites_.get()) |
| 600 top_sites_->Shutdown(); | 605 top_sites_->Shutdown(); |
| 601 | 606 |
| 602 if (pref_proxy_config_tracker_.get()) | 607 if (pref_proxy_config_tracker_.get()) |
| 603 pref_proxy_config_tracker_->DetachFromPrefService(); | 608 pref_proxy_config_tracker_->DetachFromPrefService(); |
| 604 | 609 |
| 605 if (host_content_settings_map_) | 610 if (host_content_settings_map_) |
| 606 host_content_settings_map_->ShutdownOnUIThread(); | 611 host_content_settings_map_->ShutdownOnUIThread(); |
| 607 | 612 |
| 608 #if defined(ENABLE_CONFIGURATION_POLICY) | 613 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 609 if (cloud_policy_manager_) | |
| 610 cloud_policy_manager_->Shutdown(); | |
| 611 if (managed_mode_policy_provider_) | 614 if (managed_mode_policy_provider_) |
| 612 managed_mode_policy_provider_->Shutdown(); | 615 managed_mode_policy_provider_->Shutdown(); |
| 613 #endif | 616 #endif |
| 614 | 617 |
| 615 // This causes the Preferences file to be written to disk. | 618 // This causes the Preferences file to be written to disk. |
| 616 if (prefs_loaded) | 619 if (prefs_loaded) |
| 617 SetExitType(EXIT_NORMAL); | 620 SetExitType(EXIT_NORMAL); |
| 618 } | 621 } |
| 619 | 622 |
| 620 std::string ProfileImpl::GetProfileName() { | 623 std::string ProfileImpl::GetProfileName() { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 745 } | 748 } |
| 746 } | 749 } |
| 747 | 750 |
| 748 Profile::ExitType ProfileImpl::GetLastSessionExitType() { | 751 Profile::ExitType ProfileImpl::GetLastSessionExitType() { |
| 749 // last_session_exited_cleanly_ is set when the preferences are loaded. Force | 752 // last_session_exited_cleanly_ is set when the preferences are loaded. Force |
| 750 // it to be set by asking for the prefs. | 753 // it to be set by asking for the prefs. |
| 751 GetPrefs(); | 754 GetPrefs(); |
| 752 return last_session_exit_type_; | 755 return last_session_exit_type_; |
| 753 } | 756 } |
| 754 | 757 |
| 755 policy::UserCloudPolicyManager* ProfileImpl::GetUserCloudPolicyManager() { | |
| 756 #if defined(ENABLE_CONFIGURATION_POLICY) | |
| 757 return cloud_policy_manager_.get(); | |
| 758 #else | |
| 759 return NULL; | |
| 760 #endif | |
| 761 } | |
| 762 | |
| 763 policy::ManagedModePolicyProvider* ProfileImpl::GetManagedModePolicyProvider() { | 758 policy::ManagedModePolicyProvider* ProfileImpl::GetManagedModePolicyProvider() { |
| 764 #if defined(ENABLE_CONFIGURATION_POLICY) | 759 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 765 return managed_mode_policy_provider_.get(); | 760 return managed_mode_policy_provider_.get(); |
| 766 #else | 761 #else |
| 767 return NULL; | 762 return NULL; |
| 768 #endif | 763 #endif |
| 769 } | 764 } |
| 770 | 765 |
| 771 policy::PolicyService* ProfileImpl::GetPolicyService() { | 766 policy::PolicyService* ProfileImpl::GetPolicyService() { |
| 772 DCHECK(policy_service_.get()); // Should explicitly be initialized. | 767 DCHECK(policy_service_.get()); // Should explicitly be initialized. |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1153 if (!path.empty()) | 1148 if (!path.empty()) |
| 1154 *cache_path = path; | 1149 *cache_path = path; |
| 1155 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1150 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
| 1156 prefs_->GetInteger(prefs::kDiskCacheSize); | 1151 prefs_->GetInteger(prefs::kDiskCacheSize); |
| 1157 } | 1152 } |
| 1158 | 1153 |
| 1159 base::Callback<ChromeURLDataManagerBackend*(void)> | 1154 base::Callback<ChromeURLDataManagerBackend*(void)> |
| 1160 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { | 1155 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { |
| 1161 return io_data_.GetChromeURLDataManagerBackendGetter(); | 1156 return io_data_.GetChromeURLDataManagerBackendGetter(); |
| 1162 } | 1157 } |
| OLD | NEW |