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

Side by Side Diff: components/signin/core/browser/profile_oauth2_token_service.cc

Issue 1143323005: Refactor AO2TS to make it easier to componentize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address roger's comments Created 5 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/signin/core/browser/profile_oauth2_token_service.h" 5 #include "components/signin/core/browser/profile_oauth2_token_service.h"
6 6
7 #include "base/bind.h" 7 void ProfileOAuth2TokenService::OnRefreshTokenAvailable(
8 #include "base/message_loop/message_loop.h" 8 const std::string& account_id) {
9 #include "base/stl_util.h" 9 CancelRequestsForAccount(account_id);
10 #include "base/time/time.h" 10 ClearCacheForAccount(account_id);
11 #include "components/signin/core/browser/signin_client.h" 11 }
12 #include "components/signin/core/browser/signin_error_controller.h"
13 #include "google_apis/gaia/gaia_auth_util.h"
14 #include "net/url_request/url_request_context_getter.h"
15 12
16 ProfileOAuth2TokenService::ProfileOAuth2TokenService() 13 ProfileOAuth2TokenService::ProfileOAuth2TokenService(
17 : client_(NULL), 14 OAuth2TokenServiceDelegate* delegate)
18 signin_error_controller_(NULL) {} 15 : OAuth2TokenService(delegate) {
16 AddObserver(this);
17 }
19 18
20 ProfileOAuth2TokenService::~ProfileOAuth2TokenService() {} 19 ProfileOAuth2TokenService::~ProfileOAuth2TokenService() {
21 20 RemoveObserver(this);
22 void ProfileOAuth2TokenService::Initialize(
23 SigninClient* client,
24 SigninErrorController* signin_error_controller) {
25 DCHECK(client);
26 DCHECK(!client_);
27 DCHECK(signin_error_controller);
28 DCHECK(!signin_error_controller_);
29 client_ = client;
30 signin_error_controller_ = signin_error_controller;
31 } 21 }
32 22
33 void ProfileOAuth2TokenService::Shutdown() { 23 void ProfileOAuth2TokenService::Shutdown() {
34 DCHECK(client_) << "Shutdown() called without matching call to Initialize()"; 24 CancelAllRequests();
35 } 25 GetDelegate()->Shutdown();
36
37 net::URLRequestContextGetter* ProfileOAuth2TokenService::GetRequestContext() {
38 return NULL;
39 }
40
41 void ProfileOAuth2TokenService::UpdateAuthError(
42 const std::string& account_id,
43 const GoogleServiceAuthError& error) {
44 NOTREACHED();
45 }
46
47 void ProfileOAuth2TokenService::ValidateAccountId(
48 const std::string& account_id) const {
49 DCHECK(!account_id.empty());
50
51 // If the account is given as an email, make sure its a canonical email.
52 // Note that some tests don't use email strings as account id, and after
53 // the gaia id migration it won't be an email. So only check for
54 // canonicalization if the account_id is suspected to be an email.
55 if (account_id.find('@') != std::string::npos)
56 DCHECK_EQ(gaia::CanonicalizeEmail(account_id), account_id);
57 }
58
59 std::vector<std::string> ProfileOAuth2TokenService::GetAccounts() {
60 NOTREACHED();
61 return std::vector<std::string>();
62 } 26 }
63 27
64 void ProfileOAuth2TokenService::LoadCredentials( 28 void ProfileOAuth2TokenService::LoadCredentials(
65 const std::string& primary_account_id) { 29 const std::string& primary_account_id) {
66 // Empty implementation by default. 30 GetDelegate()->LoadCredentials(primary_account_id);
67 } 31 }
68 32
69 void ProfileOAuth2TokenService::UpdateCredentials( 33 void ProfileOAuth2TokenService::UpdateCredentials(
70 const std::string& account_id, 34 const std::string& account_id,
71 const std::string& refresh_token) { 35 const std::string& refresh_token) {
72 NOTREACHED(); 36 GetDelegate()->UpdateCredentials(account_id, refresh_token);
73 } 37 }
74 38
75 void ProfileOAuth2TokenService::RevokeAllCredentials() { 39 void ProfileOAuth2TokenService::RevokeCredentials(
76 // Empty implementation by default. 40 const std::string& account_id) {
77 } 41 CancelRequestsForAccount(account_id);
42 ClearCacheForAccount(account_id);
gogerald1 2015/06/25 14:06:18 try to save one function lookup and call, but sinc
43 GetDelegate()->RevokeCredentials(account_id);
44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698