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

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

Issue 809313009: Make the SigninErrorController a PKS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Copyrighted: 2015 Created 5 years, 11 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 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_H_ 5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_H_
6 #define COMPONENTS_SIGNIN_CORE_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_H_ 6 #define COMPONENTS_SIGNIN_CORE_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
12 #include "components/keyed_service/core/keyed_service.h" 12 #include "components/keyed_service/core/keyed_service.h"
13 #include "components/signin/core/browser/signin_error_controller.h"
14 #include "google_apis/gaia/oauth2_token_service.h" 13 #include "google_apis/gaia/oauth2_token_service.h"
15 14
16 namespace net { 15 namespace net {
17 class URLRequestContextGetter; 16 class URLRequestContextGetter;
18 } 17 }
19 18
20 class GoogleServiceAuthError; 19 class GoogleServiceAuthError;
21 class SigninClient; 20 class SigninClient;
21 class SigninErrorController;
22 22
23 // ProfileOAuth2TokenService is a KeyedService that retrieves 23 // ProfileOAuth2TokenService is a KeyedService that retrieves
24 // OAuth2 access tokens for a given set of scopes using the OAuth2 login 24 // OAuth2 access tokens for a given set of scopes using the OAuth2 login
25 // refresh tokens. 25 // refresh tokens.
26 // 26 //
27 // See |OAuth2TokenService| for usage details. 27 // See |OAuth2TokenService| for usage details.
28 // 28 //
29 // Note: after StartRequest returns, in-flight requests will continue 29 // Note: after StartRequest returns, in-flight requests will continue
30 // even if the TokenService refresh token that was used to initiate 30 // even if the TokenService refresh token that was used to initiate
31 // the request changes or is cleared. When the request completes, 31 // the request changes or is cleared. When the request completes,
32 // Consumer::OnGetTokenSuccess will be invoked, but the access token 32 // Consumer::OnGetTokenSuccess will be invoked, but the access token
33 // won't be cached. 33 // won't be cached.
34 // 34 //
35 // Note: requests should be started from the UI thread. To start a 35 // Note: requests should be started from the UI thread. To start a
36 // request from other thread, please use OAuth2TokenServiceRequest. 36 // request from other thread, please use OAuth2TokenServiceRequest.
37 class ProfileOAuth2TokenService : public OAuth2TokenService, 37 class ProfileOAuth2TokenService : public OAuth2TokenService,
38 public KeyedService { 38 public KeyedService {
39 public: 39 public:
40 ~ProfileOAuth2TokenService() override; 40 ~ProfileOAuth2TokenService() override;
41 41
42 // Initializes this token service with the SigninClient. 42 // Initializes this token service with the SigninClient.
43 virtual void Initialize(SigninClient* client); 43 virtual void Initialize(SigninClient* client,
44 SigninErrorController* signin_error_controller);
Roger Tawa OOO till Jul 10th 2015/01/08 22:30:54 Instead of adding a signin_error_controller argume
Mike Lerman 2015/01/09 14:27:07 I disagree, for a few reasons. The SigninClient
44 45
45 // KeyedService implementation. 46 // KeyedService implementation.
46 void Shutdown() override; 47 void Shutdown() override;
47 48
48 // Lists account IDs of all accounts with a refresh token. 49 // Lists account IDs of all accounts with a refresh token.
49 std::vector<std::string> GetAccounts() override; 50 std::vector<std::string> GetAccounts() override;
50 51
51 // Loads credentials from a backing persistent store to make them available 52 // Loads credentials from a backing persistent store to make them available
52 // after service is used between profile restarts. 53 // after service is used between profile restarts.
53 // 54 //
54 // Only call this method if there is at least one account connected to the 55 // Only call this method if there is at least one account connected to the
55 // profile, otherwise startup will cause unneeded work on the IO thread. The 56 // profile, otherwise startup will cause unneeded work on the IO thread. The
56 // primary account is specified with the |primary_account_id| argument and 57 // primary account is specified with the |primary_account_id| argument and
57 // should not be empty. For a regular profile, the primary account id comes 58 // should not be empty. For a regular profile, the primary account id comes
58 // from SigninManager. For a supervised user, the id comes from 59 // from SigninManager. For a supervised user, the id comes from
59 // SupervisedUserService. 60 // SupervisedUserService.
60 virtual void LoadCredentials(const std::string& primary_account_id); 61 virtual void LoadCredentials(const std::string& primary_account_id);
61 62
62 // Updates a |refresh_token| for an |account_id|. Credentials are persisted, 63 // Updates a |refresh_token| for an |account_id|. Credentials are persisted,
63 // and available through |LoadCredentials| after service is restarted. 64 // and available through |LoadCredentials| after service is restarted.
64 virtual void UpdateCredentials(const std::string& account_id, 65 virtual void UpdateCredentials(const std::string& account_id,
65 const std::string& refresh_token); 66 const std::string& refresh_token);
66 67
67 // Revokes all credentials handled by the object. 68 // Revokes all credentials handled by the object.
68 virtual void RevokeAllCredentials(); 69 virtual void RevokeAllCredentials();
69 70
70 SigninErrorController* signin_error_controller() {
71 return signin_error_controller_.get();
72 }
73
74 const SigninErrorController* signin_error_controller() const {
75 return signin_error_controller_.get();
76 }
77
78 SigninClient* client() const { return client_; } 71 SigninClient* client() const { return client_; }
79 72
80 protected: 73 protected:
81 ProfileOAuth2TokenService(); 74 ProfileOAuth2TokenService();
82 75
83 // OAuth2TokenService overrides. 76 // OAuth2TokenService overrides.
84 // Note: These methods are overriden so that ProfileOAuth2TokenService is a 77 // Note: These methods are overriden so that ProfileOAuth2TokenService is a
85 // concrete class. 78 // concrete class.
86 79
87 // Simply returns NULL and should be overriden by subsclasses. 80 // Simply returns NULL and should be overriden by subsclasses.
88 net::URLRequestContextGetter* GetRequestContext() override; 81 net::URLRequestContextGetter* GetRequestContext() override;
89 82
90 // Updates the internal cache of the result from the most-recently-completed 83 // Updates the internal cache of the result from the most-recently-completed
91 // auth request (used for reporting errors to the user). 84 // auth request (used for reporting errors to the user).
92 void UpdateAuthError(const std::string& account_id, 85 void UpdateAuthError(const std::string& account_id,
93 const GoogleServiceAuthError& error) override; 86 const GoogleServiceAuthError& error) override;
94 87
95 // Validate that the account_id argument is valid. This method DCHECKs 88 // Validate that the account_id argument is valid. This method DCHECKs
96 // when invalid. 89 // when invalid.
97 void ValidateAccountId(const std::string& account_id) const; 90 void ValidateAccountId(const std::string& account_id) const;
98 91
92 SigninErrorController* signin_error_controller() {
93 return signin_error_controller_;
94 }
95
99 private: 96 private:
100 // The client with which this instance was initialized, or NULL. 97 // The client with which this instance was initialized, or NULL.
101 SigninClient* client_; 98 SigninClient* client_;
102 99
103 // Used to expose auth errors to the UI. 100 // The error controller with which this instance was initialized, or NULL.
104 scoped_ptr<SigninErrorController> signin_error_controller_; 101 SigninErrorController* signin_error_controller_;
105 102
106 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService); 103 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService);
107 }; 104 };
108 105
109 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_H_ 106 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698