Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: chrome/browser/profiles/profile_impl.cc

Issue 11415094: Split UserCloudPolicyManager implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DeviceCloudPolicyManagerChromeOSTest.EnrolledDevice failure. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 #if !defined(OS_CHROMEOS)
95 #include "chrome/browser/policy/user_cloud_policy_manager.h" 96 #include "chrome/browser/policy/user_cloud_policy_manager.h"
97 #include "chrome/browser/policy/user_cloud_policy_manager_factory.h"
98 #endif
96 #else 99 #else
97 #include "chrome/browser/policy/policy_service_stub.h" 100 #include "chrome/browser/policy/policy_service_stub.h"
98 #endif // defined(ENABLE_CONFIGURATION_POLICY) 101 #endif // defined(ENABLE_CONFIGURATION_POLICY)
99 102
100 #if defined(OS_WIN) 103 #if defined(OS_WIN)
101 #include "chrome/installer/util/install_util.h" 104 #include "chrome/installer/util/install_util.h"
102 #endif 105 #endif
103 106
104 #if defined(OS_CHROMEOS) 107 #if defined(OS_CHROMEOS)
105 #include "chrome/browser/chromeos/enterprise_extension_observer.h" 108 #include "chrome/browser/chromeos/enterprise_extension_observer.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 #endif 336 #endif
334 337
335 // Determine if prefetch is enabled for this profile. 338 // Determine if prefetch is enabled for this profile.
336 // If not profile_manager is present, it means we are in a unittest. 339 // If not profile_manager is present, it means we are in a unittest.
337 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 340 const CommandLine* command_line = CommandLine::ForCurrentProcess();
338 predictor_ = chrome_browser_net::Predictor::CreatePredictor( 341 predictor_ = chrome_browser_net::Predictor::CreatePredictor(
339 !command_line->HasSwitch(switches::kDisablePreconnect), 342 !command_line->HasSwitch(switches::kDisablePreconnect),
340 g_browser_process->profile_manager() == NULL); 343 g_browser_process->profile_manager() == NULL);
341 344
342 #if defined(ENABLE_CONFIGURATION_POLICY) 345 #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 346 // If we are creating the profile synchronously, then we should load the
350 // policy data immediately. 347 // policy data immediately.
351 bool force_immediate_policy_load = (create_mode == CREATE_MODE_SYNCHRONOUS); 348 bool force_immediate_policy_load = (create_mode == CREATE_MODE_SYNCHRONOUS);
352 cloud_policy_manager_ = 349
353 connector->CreateCloudPolicyManager(this, force_immediate_policy_load); 350 // TODO(atwilson): Change |cloud_policy_manager_| and
354 if (cloud_policy_manager_) 351 // |managed_mode_policy_provider_| to proper ProfileKeyedServices once
352 // PrefService is a ProfileKeyedService (policy must be initialized before
353 // PrefService because PrefService depends on policy loading to get overridden
354 // pref values).
355 #if !defined(OS_CHROMEOS)
356 if (command_line->HasSwitch(switches::kLoadCloudPolicyOnSignin)) {
357 cloud_policy_manager_ =
358 policy::UserCloudPolicyManagerFactory::CreateForProfile(
359 this, force_immediate_policy_load);
355 cloud_policy_manager_->Init(); 360 cloud_policy_manager_->Init();
361 }
362 #endif
356 managed_mode_policy_provider_ = 363 managed_mode_policy_provider_ =
357 policy::ManagedModePolicyProvider::Create(this, 364 policy::ManagedModePolicyProvider::Create(this,
358 sequenced_task_runner, 365 sequenced_task_runner,
359 force_immediate_policy_load); 366 force_immediate_policy_load);
360 managed_mode_policy_provider_->Init(); 367 managed_mode_policy_provider_->Init();
361 policy_service_ = connector->CreatePolicyService(this); 368 policy_service_ =
369 g_browser_process->browser_policy_connector()->CreatePolicyService(this);
362 #else 370 #else
363 policy_service_.reset(new policy::PolicyServiceStub()); 371 policy_service_.reset(new policy::PolicyServiceStub());
364 #endif 372 #endif
365 373
366 if (create_mode == CREATE_MODE_ASYNCHRONOUS) { 374 if (create_mode == CREATE_MODE_ASYNCHRONOUS) {
367 prefs_.reset(PrefService::CreatePrefService( 375 prefs_.reset(PrefService::CreatePrefService(
368 GetPrefFilePath(), 376 GetPrefFilePath(),
369 sequenced_task_runner, 377 sequenced_task_runner,
370 policy_service_.get(), 378 policy_service_.get(),
371 new ExtensionPrefStore( 379 new ExtensionPrefStore(
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 if (top_sites_.get()) 607 if (top_sites_.get())
600 top_sites_->Shutdown(); 608 top_sites_->Shutdown();
601 609
602 if (pref_proxy_config_tracker_.get()) 610 if (pref_proxy_config_tracker_.get())
603 pref_proxy_config_tracker_->DetachFromPrefService(); 611 pref_proxy_config_tracker_->DetachFromPrefService();
604 612
605 if (host_content_settings_map_) 613 if (host_content_settings_map_)
606 host_content_settings_map_->ShutdownOnUIThread(); 614 host_content_settings_map_->ShutdownOnUIThread();
607 615
608 #if defined(ENABLE_CONFIGURATION_POLICY) 616 #if defined(ENABLE_CONFIGURATION_POLICY)
609 if (cloud_policy_manager_)
610 cloud_policy_manager_->Shutdown();
611 if (managed_mode_policy_provider_) 617 if (managed_mode_policy_provider_)
612 managed_mode_policy_provider_->Shutdown(); 618 managed_mode_policy_provider_->Shutdown();
613 #endif 619 #endif
614 620
615 // This causes the Preferences file to be written to disk. 621 // This causes the Preferences file to be written to disk.
616 if (prefs_loaded) 622 if (prefs_loaded)
617 SetExitType(EXIT_NORMAL); 623 SetExitType(EXIT_NORMAL);
618 } 624 }
619 625
620 std::string ProfileImpl::GetProfileName() { 626 std::string ProfileImpl::GetProfileName() {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 } 751 }
746 } 752 }
747 753
748 Profile::ExitType ProfileImpl::GetLastSessionExitType() { 754 Profile::ExitType ProfileImpl::GetLastSessionExitType() {
749 // last_session_exited_cleanly_ is set when the preferences are loaded. Force 755 // last_session_exited_cleanly_ is set when the preferences are loaded. Force
750 // it to be set by asking for the prefs. 756 // it to be set by asking for the prefs.
751 GetPrefs(); 757 GetPrefs();
752 return last_session_exit_type_; 758 return last_session_exit_type_;
753 } 759 }
754 760
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() { 761 policy::ManagedModePolicyProvider* ProfileImpl::GetManagedModePolicyProvider() {
764 #if defined(ENABLE_CONFIGURATION_POLICY) 762 #if defined(ENABLE_CONFIGURATION_POLICY)
765 return managed_mode_policy_provider_.get(); 763 return managed_mode_policy_provider_.get();
766 #else 764 #else
767 return NULL; 765 return NULL;
768 #endif 766 #endif
769 } 767 }
770 768
771 policy::PolicyService* ProfileImpl::GetPolicyService() { 769 policy::PolicyService* ProfileImpl::GetPolicyService() {
772 DCHECK(policy_service_.get()); // Should explicitly be initialized. 770 DCHECK(policy_service_.get()); // Should explicitly be initialized.
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 if (!path.empty()) 1151 if (!path.empty())
1154 *cache_path = path; 1152 *cache_path = path;
1155 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : 1153 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) :
1156 prefs_->GetInteger(prefs::kDiskCacheSize); 1154 prefs_->GetInteger(prefs::kDiskCacheSize);
1157 } 1155 }
1158 1156
1159 base::Callback<ChromeURLDataManagerBackend*(void)> 1157 base::Callback<ChromeURLDataManagerBackend*(void)>
1160 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { 1158 ProfileImpl::GetChromeURLDataManagerBackendGetter() const {
1161 return io_data_.GetChromeURLDataManagerBackendGetter(); 1159 return io_data_.GetChromeURLDataManagerBackendGetter();
1162 } 1160 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698