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

Side by Side Diff: chrome/browser/policy/user_policy_signin_service.cc

Issue 11618024: [signin] Support for CrOS and OAuth2AccessTokenConsumer services. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Minor fixes 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
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/policy/user_policy_signin_service.h" 5 #include "chrome/browser/policy/user_policy_signin_service.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/policy/browser_policy_connector.h" 9 #include "chrome/browser/policy/browser_policy_connector.h"
10 #include "chrome/browser/policy/cloud_policy_service.h" 10 #include "chrome/browser/policy/cloud_policy_service.h"
11 #include "chrome/browser/policy/user_cloud_policy_manager.h" 11 #include "chrome/browser/policy/user_cloud_policy_manager.h"
12 #include "chrome/browser/policy/user_cloud_policy_manager_factory.h" 12 #include "chrome/browser/policy/user_cloud_policy_manager_factory.h"
13 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/signin/about_signin_internals.h"
16 #include "chrome/browser/signin/about_signin_internals_factory.h"
15 #include "chrome/browser/signin/signin_manager.h" 17 #include "chrome/browser/signin/signin_manager.h"
16 #include "chrome/browser/signin/signin_manager_factory.h" 18 #include "chrome/browser/signin/signin_manager_factory.h"
17 #include "chrome/browser/signin/token_service.h" 19 #include "chrome/browser/signin/token_service.h"
18 #include "chrome/browser/signin/token_service_factory.h" 20 #include "chrome/browser/signin/token_service_factory.h"
19 #include "chrome/common/chrome_notification_types.h" 21 #include "chrome/common/chrome_notification_types.h"
20 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
21 #include "content/public/browser/notification_details.h" 23 #include "content/public/browser/notification_details.h"
22 #include "content/public/browser/notification_source.h" 24 #include "content/public/browser/notification_source.h"
23 #include "google_apis/gaia/gaia_constants.h" 25 #include "google_apis/gaia/gaia_constants.h"
24 #include "google_apis/gaia/gaia_urls.h" 26 #include "google_apis/gaia/gaia_urls.h"
25 #include "google_apis/gaia/oauth2_access_token_fetcher.h" 27 #include "google_apis/gaia/oauth2_access_token_fetcher.h"
26 28
29 using content::BrowserThread;
30
27 namespace { 31 namespace {
28 // Various OAuth service scopes required to do CloudPolicyClient registration. 32 // Various OAuth service scopes required to do CloudPolicyClient registration.
29 const char kServiceScopeChromeOSDeviceManagement[] = 33 const char kServiceScopeChromeOSDeviceManagement[] =
30 "https://www.googleapis.com/auth/chromeosdevicemanagement"; 34 "https://www.googleapis.com/auth/chromeosdevicemanagement";
31 const char kServiceScopeGetUserInfo[] = 35 const char kServiceScopeGetUserInfo[] =
32 "https://www.googleapis.com/auth/userinfo.email"; 36 "https://www.googleapis.com/auth/userinfo.email";
33 37
34 // The key under which the hosted-domain value is stored in the UserInfo 38 // The key under which the hosted-domain value is stored in the UserInfo
35 // response. 39 // response.
36 const char kGetHostedDomainKey[] = "hd"; 40 const char kGetHostedDomainKey[] = "hd";
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 gaia_urls->oauth2_chrome_client_id(), 283 gaia_urls->oauth2_chrome_client_id(),
280 gaia_urls->oauth2_chrome_client_secret(), 284 gaia_urls->oauth2_chrome_client_secret(),
281 login_token, 285 login_token,
282 scopes); 286 scopes);
283 } 287 }
284 288
285 void UserPolicySigninService::OnGetTokenFailure( 289 void UserPolicySigninService::OnGetTokenFailure(
286 const GoogleServiceAuthError& error) { 290 const GoogleServiceAuthError& error) {
287 DLOG(WARNING) << "Could not fetch access token for " 291 DLOG(WARNING) << "Could not fetch access token for "
288 << kServiceScopeChromeOSDeviceManagement; 292 << kServiceScopeChromeOSDeviceManagement;
293
294 // Let AboutSigninInternals know about the failed token fetch.
295 DCHECK(profile_);
296 AboutSigninInternalsFactory::GetForProfile(profile_)->
297 NotifyTokenReceivedFailure(
298 signin_internals_util::kUserPolicySigninServiceToken,
299 error.ToString());
300
289 oauth2_access_token_fetcher_.reset(); 301 oauth2_access_token_fetcher_.reset();
290 // If there was a pending fetch request, let them know the fetch failed. 302 // If there was a pending fetch request, let them know the fetch failed.
291 NotifyPendingFetchCallback(false); 303 NotifyPendingFetchCallback(false);
292 } 304 }
293 305
294 void UserPolicySigninService::OnGetTokenSuccess( 306 void UserPolicySigninService::OnGetTokenSuccess(
295 const std::string& access_token, 307 const std::string& access_token,
296 const base::Time& expiration_time) { 308 const base::Time& expiration_time) {
297 oauth_access_token_ = access_token; 309 oauth_access_token_ = access_token;
298 DVLOG(1) << "Fetched new scoped OAuth token:" << oauth_access_token_; 310 DVLOG(1) << "Fetched new scoped OAuth token:" << access_token;
311
312 DCHECK(profile_);
313 AboutSigninInternalsFactory::GetForProfile(profile_)->
314 NotifyTokenReceivedSuccess(
315 signin_internals_util::kUserPolicySigninServiceToken,
316 access_token,
317 true);
318
299 oauth2_access_token_fetcher_.reset(); 319 oauth2_access_token_fetcher_.reset();
300 // Now we've gotten our access token - contact GAIA to see if this is a 320 // Now we've gotten our access token - contact GAIA to see if this is a
301 // hosted domain. 321 // hosted domain.
302 user_info_fetcher_.reset(new UserInfoFetcher(this, 322 user_info_fetcher_.reset(new UserInfoFetcher(this,
303 profile_->GetRequestContext())); 323 profile_->GetRequestContext()));
304 user_info_fetcher_->Start(oauth_access_token_); 324 user_info_fetcher_->Start(oauth_access_token_);
305 } 325 }
306 326
307 void UserPolicySigninService::OnGetUserInfoFailure( 327 void UserPolicySigninService::OnGetUserInfoFailure(
308 const GoogleServiceAuthError& error) { 328 const GoogleServiceAuthError& error) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 380
361 void UserPolicySigninService::Shutdown() { 381 void UserPolicySigninService::Shutdown() {
362 StopObserving(); 382 StopObserving();
363 } 383 }
364 384
365 UserCloudPolicyManager* UserPolicySigninService::GetManager() { 385 UserCloudPolicyManager* UserPolicySigninService::GetManager() {
366 return UserCloudPolicyManagerFactory::GetForProfile(profile_); 386 return UserCloudPolicyManagerFactory::GetForProfile(profile_);
367 } 387 }
368 388
369 } // namespace policy 389 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/auth_service.cc ('k') | chrome/browser/profiles/profile_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698