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

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

Issue 10693022: Add support for loading user cloud policy on desktop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaked some comments after self-review. Created 8 years, 4 months 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
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/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
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
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 if (command_line->HasSwitch(switches::kEnableCloudPolicyService)) {
289 g_browser_process->browser_policy_connector()->CreatePolicyService(this)); 290 bool wait_for_policy_fetch = false;
291 #if defined(OS_CHROMEOS)
292 // TODO(mnissler): Revisit once Chrome OS gains multi-profiles support.
293 // Don't wait for a policy fetch if there's no logged in user.
294 if (chromeos::UserManager::Get()->IsUserLoggedIn()) {
295 wait_for_policy_fetch =
296 g_browser_process->browser_policy_connector()->GetUserAffiliation(
297 chromeos::UserManager::Get()->GetLoggedInUser().email()) ==
298 policy::USER_AFFILIATION_MANAGED;
Mattias Nissler (ping if slow) 2012/08/03 12:19:08 Ah, I still feel bad for this hack. It would be ni
Andrew T Wilson (Slow) 2012/08/04 00:54:41 Well, ultimately PolicyService and UserCloudPolicy
299 }
290 #else 300 #else
291 policy_service_.reset(new policy::PolicyServiceStub()); 301 // On desktop, there's no way to figure out if a user is logged in yet
302 // because prefs are not yet initialized. So we do not block waiting for
303 // the policy fetch to happen (because that would inhibit startup for
304 // non-signed-in users) and instead rely on the fact that a signed-in
305 // profile will already have policy downloaded. If no policy is available
306 // (due to a previous fetch failing), the normal policy refresh mechanism
307 // will cause it to get downloaded eventually.
Mattias Nissler (ping if slow) 2012/08/03 12:19:08 Not sure this is going to fly long term. If we for
Andrew T Wilson (Slow) 2012/08/04 00:54:41 Yeah, what we do here is very dependent on what ki
Mattias Nissler (ping if slow) 2012/08/06 08:33:52 Reapplying policy when it changes is generally our
308 #endif
309 cloud_policy_manager_ = policy::UserCloudPolicyManager::Create(
310 this, wait_for_policy_fetch);
311 }
312 policy_service_ =
313 g_browser_process->browser_policy_connector()->CreatePolicyService(this);
314 #else
315 policy_service_.reset(new policy::PolicyServiceStub());
292 #endif 316 #endif
293 if (create_mode == CREATE_MODE_ASYNCHRONOUS) { 317 if (create_mode == CREATE_MODE_ASYNCHRONOUS) {
294 prefs_.reset(PrefService::CreatePrefService( 318 prefs_.reset(PrefService::CreatePrefService(
295 GetPrefFilePath(), 319 GetPrefFilePath(),
296 policy_service_.get(), 320 policy_service_.get(),
297 new ExtensionPrefStore( 321 new ExtensionPrefStore(
298 ExtensionPrefValueMapFactory::GetForProfile(this), false), 322 ExtensionPrefValueMapFactory::GetForProfile(this), false),
299 true)); 323 true));
300 // Wait for the notification that prefs has been loaded (successfully or 324 // Wait for the notification that prefs has been loaded (successfully or
301 // not). 325 // not).
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 ChromeVersionService::OnProfileLoaded(prefs_.get(), is_new_profile); 660 ChromeVersionService::OnProfileLoaded(prefs_.get(), is_new_profile);
637 DoFinalInit(is_new_profile); 661 DoFinalInit(is_new_profile);
638 } 662 }
639 663
640 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { 664 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) {
641 Version profile_version(ChromeVersionService::GetVersion(prefs_.get())); 665 Version profile_version(ChromeVersionService::GetVersion(prefs_.get()));
642 Version arg_version(version); 666 Version arg_version(version);
643 return (profile_version.CompareTo(arg_version) >= 0); 667 return (profile_version.CompareTo(arg_version) >= 0);
644 } 668 }
645 669
670 policy::UserCloudPolicyManager* ProfileImpl::GetUserCloudPolicyManager() {
671 return cloud_policy_manager_.get();
672 }
673
646 policy::PolicyService* ProfileImpl::GetPolicyService() { 674 policy::PolicyService* ProfileImpl::GetPolicyService() {
647 DCHECK(policy_service_.get()); // Should explicitly be initialized. 675 DCHECK(policy_service_.get()); // Should explicitly be initialized.
648 return policy_service_.get(); 676 return policy_service_.get();
649 } 677 }
650 678
651 PrefService* ProfileImpl::GetPrefs() { 679 PrefService* ProfileImpl::GetPrefs() {
652 DCHECK(prefs_.get()); // Should explicitly be initialized. 680 DCHECK(prefs_.get()); // Should explicitly be initialized.
653 return prefs_.get(); 681 return prefs_.get();
654 } 682 }
655 683
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 if (!path.empty()) 1113 if (!path.empty())
1086 *cache_path = path; 1114 *cache_path = path;
1087 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : 1115 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) :
1088 prefs_->GetInteger(prefs::kDiskCacheSize); 1116 prefs_->GetInteger(prefs::kDiskCacheSize);
1089 } 1117 }
1090 1118
1091 base::Callback<ChromeURLDataManagerBackend*(void)> 1119 base::Callback<ChromeURLDataManagerBackend*(void)>
1092 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { 1120 ProfileImpl::GetChromeURLDataManagerBackendGetter() const {
1093 return io_data_.GetChromeURLDataManagerBackendGetter(); 1121 return io_data_.GetChromeURLDataManagerBackendGetter();
1094 } 1122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698