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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 #include "content/public/browser/storage_partition.h" | 85 #include "content/public/browser/storage_partition.h" |
86 #include "content/public/browser/user_metrics.h" | 86 #include "content/public/browser/user_metrics.h" |
87 #include "content/public/common/content_constants.h" | 87 #include "content/public/common/content_constants.h" |
88 #include "grit/chromium_strings.h" | 88 #include "grit/chromium_strings.h" |
89 #include "grit/generated_resources.h" | 89 #include "grit/generated_resources.h" |
90 #include "ui/base/l10n/l10n_util.h" | 90 #include "ui/base/l10n/l10n_util.h" |
91 | 91 |
92 #if defined(ENABLE_CONFIGURATION_POLICY) | 92 #if defined(ENABLE_CONFIGURATION_POLICY) |
93 #include "chrome/browser/policy/browser_policy_connector.h" | 93 #include "chrome/browser/policy/browser_policy_connector.h" |
94 #include "chrome/browser/policy/managed_mode_policy_provider.h" | 94 #include "chrome/browser/policy/managed_mode_policy_provider.h" |
95 #include "chrome/browser/policy/user_cloud_policy_manager.h" | 95 #include "chrome/browser/policy/user_cloud_policy_manager.h" |
Joao da Silva
2012/11/23 10:08:12
Not included in gyp when OS_CHROMEOS...
Mattias Nissler (ping if slow)
2012/11/23 17:36:06
Done.
| |
96 #else | 96 #else |
97 #include "chrome/browser/policy/policy_service_stub.h" | 97 #include "chrome/browser/policy/policy_service_stub.h" |
98 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 98 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
99 | 99 |
100 #if defined(OS_WIN) | 100 #if defined(OS_WIN) |
101 #include "chrome/installer/util/install_util.h" | 101 #include "chrome/installer/util/install_util.h" |
102 #endif | 102 #endif |
103 | 103 |
104 #if defined(OS_CHROMEOS) | 104 #if defined(OS_CHROMEOS) |
105 #include "chrome/browser/chromeos/enterprise_extension_observer.h" | 105 #include "chrome/browser/chromeos/enterprise_extension_observer.h" |
(...skipping 227 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_ = | |
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
587 if (top_sites_.get()) | 592 if (top_sites_.get()) |
588 top_sites_->Shutdown(); | 593 top_sites_->Shutdown(); |
589 | 594 |
590 if (pref_proxy_config_tracker_.get()) | 595 if (pref_proxy_config_tracker_.get()) |
591 pref_proxy_config_tracker_->DetachFromPrefService(); | 596 pref_proxy_config_tracker_->DetachFromPrefService(); |
592 | 597 |
593 if (host_content_settings_map_) | 598 if (host_content_settings_map_) |
594 host_content_settings_map_->ShutdownOnUIThread(); | 599 host_content_settings_map_->ShutdownOnUIThread(); |
595 | 600 |
596 #if defined(ENABLE_CONFIGURATION_POLICY) | 601 #if defined(ENABLE_CONFIGURATION_POLICY) |
597 if (cloud_policy_manager_) | |
598 cloud_policy_manager_->Shutdown(); | |
Joao da Silva
2012/11/23 10:08:12
This is still necessary.
Mattias Nissler (ping if slow)
2012/11/23 17:36:06
Actually not, UserCloudPolicyManagerFactory::Shutd
| |
599 if (managed_mode_policy_provider_) | 602 if (managed_mode_policy_provider_) |
600 managed_mode_policy_provider_->Shutdown(); | 603 managed_mode_policy_provider_->Shutdown(); |
601 #endif | 604 #endif |
602 | 605 |
603 // This causes the Preferences file to be written to disk. | 606 // This causes the Preferences file to be written to disk. |
604 if (prefs_loaded) | 607 if (prefs_loaded) |
605 SetExitType(EXIT_NORMAL); | 608 SetExitType(EXIT_NORMAL); |
606 } | 609 } |
607 | 610 |
608 std::string ProfileImpl::GetProfileName() { | 611 std::string ProfileImpl::GetProfileName() { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 } | 736 } |
734 } | 737 } |
735 | 738 |
736 Profile::ExitType ProfileImpl::GetLastSessionExitType() { | 739 Profile::ExitType ProfileImpl::GetLastSessionExitType() { |
737 // last_session_exited_cleanly_ is set when the preferences are loaded. Force | 740 // last_session_exited_cleanly_ is set when the preferences are loaded. Force |
738 // it to be set by asking for the prefs. | 741 // it to be set by asking for the prefs. |
739 GetPrefs(); | 742 GetPrefs(); |
740 return last_session_exit_type_; | 743 return last_session_exit_type_; |
741 } | 744 } |
742 | 745 |
743 policy::UserCloudPolicyManager* ProfileImpl::GetUserCloudPolicyManager() { | |
744 #if defined(ENABLE_CONFIGURATION_POLICY) | |
745 return cloud_policy_manager_.get(); | |
746 #else | |
747 return NULL; | |
748 #endif | |
749 } | |
750 | |
751 policy::ManagedModePolicyProvider* ProfileImpl::GetManagedModePolicyProvider() { | 746 policy::ManagedModePolicyProvider* ProfileImpl::GetManagedModePolicyProvider() { |
752 #if defined(ENABLE_CONFIGURATION_POLICY) | 747 #if defined(ENABLE_CONFIGURATION_POLICY) |
753 return managed_mode_policy_provider_.get(); | 748 return managed_mode_policy_provider_.get(); |
754 #else | 749 #else |
755 return NULL; | 750 return NULL; |
756 #endif | 751 #endif |
757 } | 752 } |
758 | 753 |
759 policy::PolicyService* ProfileImpl::GetPolicyService() { | 754 policy::PolicyService* ProfileImpl::GetPolicyService() { |
760 DCHECK(policy_service_.get()); // Should explicitly be initialized. | 755 DCHECK(policy_service_.get()); // Should explicitly be initialized. |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1151 if (!path.empty()) | 1146 if (!path.empty()) |
1152 *cache_path = path; | 1147 *cache_path = path; |
1153 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1148 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
1154 prefs_->GetInteger(prefs::kDiskCacheSize); | 1149 prefs_->GetInteger(prefs::kDiskCacheSize); |
1155 } | 1150 } |
1156 | 1151 |
1157 base::Callback<ChromeURLDataManagerBackend*(void)> | 1152 base::Callback<ChromeURLDataManagerBackend*(void)> |
1158 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { | 1153 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { |
1159 return io_data_.GetChromeURLDataManagerBackendGetter(); | 1154 return io_data_.GetChromeURLDataManagerBackendGetter(); |
1160 } | 1155 } |
OLD | NEW |