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

Unified Diff: chrome/browser/policy/user_cloud_policy_manager.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, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/user_cloud_policy_manager.cc
diff --git a/chrome/browser/policy/user_cloud_policy_manager.cc b/chrome/browser/policy/user_cloud_policy_manager.cc
index ccbc55dda31fbab82898fc60c9342ed7d4902193..5489d7d003a3588860329eef354686528c72d1f5 100644
--- a/chrome/browser/policy/user_cloud_policy_manager.cc
+++ b/chrome/browser/policy/user_cloud_policy_manager.cc
@@ -56,32 +56,20 @@ UserCloudPolicyManager::~UserCloudPolicyManager() {
store_->RemoveObserver(this);
}
-#if defined(OS_CHROMEOS)
// static
scoped_ptr<UserCloudPolicyManager> UserCloudPolicyManager::Create(
- bool wait_for_policy_fetch) {
- FilePath profile_dir;
- CHECK(PathService::Get(chrome::DIR_USER_DATA, &profile_dir));
- CommandLine* command_line = CommandLine::ForCurrentProcess();
- const FilePath policy_dir =
- profile_dir
- .Append(command_line->GetSwitchValuePath(switches::kLoginProfile))
- .Append(kPolicyDir);
- const FilePath policy_cache_file = policy_dir.Append(kPolicyCacheFile);
- const FilePath token_cache_file = policy_dir.Append(kTokenCacheFile);
-
- scoped_ptr<CloudPolicyStore> store(
- new UserCloudPolicyStoreChromeOS(
- chromeos::DBusThreadManager::Get()->GetSessionManagerClient(),
- token_cache_file, policy_cache_file));
+ Profile* profile, bool wait_for_policy_fetch) {
Mattias Nissler (ping if slow) 2012/08/03 12:19:08 parameters on separate lines.
Andrew T Wilson (Slow) 2012/08/04 00:54:41 Done.
+ scoped_ptr<CloudPolicyStore> store =
+ CloudPolicyStore::CreateUserPolicyStore(profile);
return scoped_ptr<UserCloudPolicyManager>(
new UserCloudPolicyManager(store.Pass(), wait_for_policy_fetch));
}
-#endif
void UserCloudPolicyManager::Initialize(PrefService* prefs,
DeviceManagementService* service,
UserAffiliation user_affiliation) {
+ DCHECK(service);
+ DCHECK(prefs);
DCHECK(!service_.get());
prefs_ = prefs;
scoped_ptr<CloudPolicyClient> client(
@@ -129,6 +117,18 @@ void UserCloudPolicyManager::CancelWaitForPolicyFetch() {
}
}
+bool UserCloudPolicyManager::IsClientRegistered() const {
+ if (!service_.get())
+ return false;
+ return service_->client()->is_registered();
+}
+
+void UserCloudPolicyManager::RegisterClient(const std::string& access_token) {
+ DCHECK(cloud_policy_service()) << "Callers must invoke Initialize() first";
+ if (!cloud_policy_service()->client()->is_registered())
+ cloud_policy_service()->client()->Register(access_token);
+}
+
bool UserCloudPolicyManager::IsInitializationComplete() const {
return store_->is_initialized() && !wait_for_policy_fetch_;
}

Powered by Google App Engine
This is Rietveld 408576698