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

Side by Side Diff: chrome/browser/signin/profile_oauth2_token_service.cc

Issue 44083005: policy: Remove UserCloudPolicyManagerFactory's dependency on Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 1 month 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/signin/profile_oauth2_token_service.h" 5 #include "chrome/browser/signin/profile_oauth2_token_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 NOTREACHED() << "Invalid notification type=" << type; 206 NOTREACHED() << "Invalid notification type=" << type;
207 break; 207 break;
208 } 208 }
209 } 209 }
210 210
211 std::string ProfileOAuth2TokenService::GetPrimaryAccountId() { 211 std::string ProfileOAuth2TokenService::GetPrimaryAccountId() {
212 if (profile_->IsManaged()) 212 if (profile_->IsManaged())
213 return std::string("SupervisedUser"); 213 return std::string("SupervisedUser");
214 214
215 SigninManagerBase* signin_manager = 215 SigninManagerBase* signin_manager =
216 SigninManagerFactory::GetForProfileIfExists(profile_); 216 SigninManagerFactory::GetForBrowserContextIfExists(profile_);
217 // TODO(fgorski): DCHECK(signin_manager) here - it may require update to test 217 // TODO(fgorski): DCHECK(signin_manager) here - it may require update to test
218 // code and the line above (SigninManager might not exist yet). 218 // code and the line above (SigninManager might not exist yet).
219 return signin_manager ? signin_manager->GetAuthenticatedUsername() 219 return signin_manager ? signin_manager->GetAuthenticatedUsername()
220 : std::string(); 220 : std::string();
221 } 221 }
222 222
223 std::vector<std::string> ProfileOAuth2TokenService::GetAccounts() { 223 std::vector<std::string> ProfileOAuth2TokenService::GetAccounts() {
224 std::vector<std::string> account_ids; 224 std::vector<std::string> account_ids;
225 for (AccountInfoMap::const_iterator iter = refresh_tokens_.begin(); 225 for (AccountInfoMap::const_iterator iter = refresh_tokens_.begin();
226 iter != refresh_tokens_.end(); ++iter) { 226 iter != refresh_tokens_.end(); ++iter) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } 368 }
369 } 369 }
370 370
371 if (!old_login_token.empty() && 371 if (!old_login_token.empty() &&
372 refresh_tokens_.count(GetPrimaryAccountId()) == 0) { 372 refresh_tokens_.count(GetPrimaryAccountId()) == 0) {
373 UpdateCredentials(GetPrimaryAccountId(), old_login_token); 373 UpdateCredentials(GetPrimaryAccountId(), old_login_token);
374 } 374 }
375 375
376 FireRefreshTokensLoaded(); 376 FireRefreshTokensLoaded();
377 } 377 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698