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

Side by Side Diff: chrome/browser/policy/cloud/user_policy_signin_service_base.cc

Issue 23068005: Convert UserPolicySigninService to use OAuth2TokenService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Android fixes. Created 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/policy/cloud/user_policy_signin_service_base.h" 5 #include "chrome/browser/policy/cloud/user_policy_signin_service_base.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/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 base::Bind( 126 base::Bind(
127 &UserPolicySigninServiceBase::ShutdownUserCloudPolicyManager, 127 &UserPolicySigninServiceBase::ShutdownUserCloudPolicyManager,
128 weak_factory_.GetWeakPtr())); 128 weak_factory_.GetWeakPtr()));
129 } else { 129 } else {
130 DVLOG(1) << "Error fetching policy: " << client->status(); 130 DVLOG(1) << "Error fetching policy: " << client->status();
131 } 131 }
132 } 132 }
133 } 133 }
134 134
135 void UserPolicySigninServiceBase::Shutdown() { 135 void UserPolicySigninServiceBase::Shutdown() {
136 PrepareForUserCloudPolicyManagerShutdown();
137 }
138
139 void UserPolicySigninServiceBase::PrepareForUserCloudPolicyManagerShutdown() {
136 UserCloudPolicyManager* manager = GetManager(); 140 UserCloudPolicyManager* manager = GetManager();
137 if (manager && manager->core()->client()) 141 if (manager && manager->core()->client())
138 manager->core()->client()->RemoveObserver(this); 142 manager->core()->client()->RemoveObserver(this);
139 if (manager && manager->core()->service()) 143 if (manager && manager->core()->service())
140 manager->core()->service()->RemoveObserver(this); 144 manager->core()->service()->RemoveObserver(this);
141 } 145 }
142 146
143 // static 147 // static
144 bool UserPolicySigninServiceBase::ShouldForceLoadPolicy() { 148 bool UserPolicySigninServiceBase::ShouldForceLoadPolicy() {
145 return CommandLine::ForCurrentProcess()->HasSwitch( 149 return CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 manager->Connect(local_state_, client.Pass()); 227 manager->Connect(local_state_, client.Pass());
224 DCHECK(manager->core()->service()); 228 DCHECK(manager->core()->service());
225 229
226 // Observe the client to detect errors fetching policy. 230 // Observe the client to detect errors fetching policy.
227 manager->core()->client()->AddObserver(this); 231 manager->core()->client()->AddObserver(this);
228 // Observe the service to determine when it's initialized. 232 // Observe the service to determine when it's initialized.
229 manager->core()->service()->AddObserver(this); 233 manager->core()->service()->AddObserver(this);
230 } 234 }
231 235
232 void UserPolicySigninServiceBase::ShutdownUserCloudPolicyManager() { 236 void UserPolicySigninServiceBase::ShutdownUserCloudPolicyManager() {
233 Shutdown(); 237 PrepareForUserCloudPolicyManagerShutdown();
234 UserCloudPolicyManager* manager = GetManager(); 238 UserCloudPolicyManager* manager = GetManager();
235 if (manager) 239 if (manager)
236 manager->DisconnectAndRemovePolicy(); 240 manager->DisconnectAndRemovePolicy();
237 } 241 }
238 242
239 UserCloudPolicyManager* UserPolicySigninServiceBase::GetManager() { 243 UserCloudPolicyManager* UserPolicySigninServiceBase::GetManager() {
240 return UserCloudPolicyManagerFactory::GetForProfile(profile_); 244 return UserCloudPolicyManagerFactory::GetForProfile(profile_);
241 } 245 }
242 246
243 } // namespace policy 247 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698