OLD | NEW |
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 #ifndef CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
6 #define CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 6 #define CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 ~PendingRequest(); | 49 ~PendingRequest(); |
50 | 50 |
51 std::string account_id; | 51 std::string account_id; |
52 std::string client_id; | 52 std::string client_id; |
53 std::string client_secret; | 53 std::string client_secret; |
54 ScopeSet scopes; | 54 ScopeSet scopes; |
55 base::WeakPtr<RequestImpl> request; | 55 base::WeakPtr<RequestImpl> request; |
56 }; | 56 }; |
57 | 57 |
58 FakeProfileOAuth2TokenService(); | 58 FakeProfileOAuth2TokenService(); |
59 virtual ~FakeProfileOAuth2TokenService(); | 59 ~FakeProfileOAuth2TokenService() override; |
60 | 60 |
61 // Overriden to make sure it works on Android. | 61 // Overriden to make sure it works on Android. |
62 virtual bool RefreshTokenIsAvailable( | 62 bool RefreshTokenIsAvailable(const std::string& account_id) const override; |
63 const std::string& account_id) const override; | |
64 | 63 |
65 // Overriden to make sure it works on iOS. | 64 // Overriden to make sure it works on iOS. |
66 virtual void LoadCredentials(const std::string& primary_account_id) override; | 65 void LoadCredentials(const std::string& primary_account_id) override; |
67 | 66 |
68 virtual std::vector<std::string> GetAccounts() override; | 67 std::vector<std::string> GetAccounts() override; |
69 | 68 |
70 // Overriden to make sure it works on Android. Simply calls | 69 // Overriden to make sure it works on Android. Simply calls |
71 // IssueRefreshToken(). | 70 // IssueRefreshToken(). |
72 virtual void UpdateCredentials(const std::string& account_id, | 71 void UpdateCredentials(const std::string& account_id, |
73 const std::string& refresh_token) override; | 72 const std::string& refresh_token) override; |
74 | 73 |
75 // Sets the current refresh token. If |token| is non-empty, this will invoke | 74 // Sets the current refresh token. If |token| is non-empty, this will invoke |
76 // OnRefreshTokenAvailable() on all Observers, otherwise this will invoke | 75 // OnRefreshTokenAvailable() on all Observers, otherwise this will invoke |
77 // OnRefreshTokenRevoked(). | 76 // OnRefreshTokenRevoked(). |
78 void IssueRefreshToken(const std::string& token); | 77 void IssueRefreshToken(const std::string& token); |
79 | 78 |
80 // TODO(fgorski,rogerta): Merge with UpdateCredentials when this class fully | 79 // TODO(fgorski,rogerta): Merge with UpdateCredentials when this class fully |
81 // supports multiple accounts. | 80 // supports multiple accounts. |
82 void IssueRefreshTokenForUser(const std::string& account_id, | 81 void IssueRefreshTokenForUser(const std::string& account_id, |
83 const std::string& token); | 82 const std::string& token); |
(...skipping 25 matching lines...) Expand all Loading... |
109 const base::Time& expiration); | 108 const base::Time& expiration); |
110 | 109 |
111 void IssueErrorForAllPendingRequests(const GoogleServiceAuthError& error); | 110 void IssueErrorForAllPendingRequests(const GoogleServiceAuthError& error); |
112 | 111 |
113 void set_auto_post_fetch_response_on_message_loop(bool auto_post_response) { | 112 void set_auto_post_fetch_response_on_message_loop(bool auto_post_response) { |
114 auto_post_fetch_response_on_message_loop_ = auto_post_response; | 113 auto_post_fetch_response_on_message_loop_ = auto_post_response; |
115 } | 114 } |
116 | 115 |
117 protected: | 116 protected: |
118 // OAuth2TokenService overrides. | 117 // OAuth2TokenService overrides. |
119 virtual void FetchOAuth2Token(RequestImpl* request, | 118 void FetchOAuth2Token(RequestImpl* request, |
120 const std::string& account_id, | 119 const std::string& account_id, |
121 net::URLRequestContextGetter* getter, | 120 net::URLRequestContextGetter* getter, |
122 const std::string& client_id, | 121 const std::string& client_id, |
123 const std::string& client_secret, | 122 const std::string& client_secret, |
124 const ScopeSet& scopes) override; | 123 const ScopeSet& scopes) override; |
125 | 124 |
126 virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( | 125 OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( |
127 const std::string& account_id, | 126 const std::string& account_id, |
128 net::URLRequestContextGetter* getter, | 127 net::URLRequestContextGetter* getter, |
129 OAuth2AccessTokenConsumer* consumer) override; | 128 OAuth2AccessTokenConsumer* consumer) override; |
130 | 129 |
131 virtual void InvalidateOAuth2Token(const std::string& account_id, | 130 void InvalidateOAuth2Token(const std::string& account_id, |
132 const std::string& client_id, | 131 const std::string& client_id, |
133 const ScopeSet& scopes, | 132 const ScopeSet& scopes, |
134 const std::string& access_token) override; | 133 const std::string& access_token) override; |
135 | 134 |
136 virtual net::URLRequestContextGetter* GetRequestContext() override; | 135 net::URLRequestContextGetter* GetRequestContext() override; |
137 | 136 |
138 private: | 137 private: |
139 // Helper function to complete pending requests - if |all_scopes| is true, | 138 // Helper function to complete pending requests - if |all_scopes| is true, |
140 // then all pending requests are completed, otherwise, only those requests | 139 // then all pending requests are completed, otherwise, only those requests |
141 // matching |scopes| are completed. If |account_id| is empty, then pending | 140 // matching |scopes| are completed. If |account_id| is empty, then pending |
142 // requests for all accounts are completed, otherwise only requests for the | 141 // requests for all accounts are completed, otherwise only requests for the |
143 // given account. | 142 // given account. |
144 void CompleteRequests(const std::string& account_id, | 143 void CompleteRequests(const std::string& account_id, |
145 bool all_scopes, | 144 bool all_scopes, |
146 const ScopeSet& scopes, | 145 const ScopeSet& scopes, |
(...skipping 12 matching lines...) Expand all Loading... |
159 // |FetchOAuth2Token| on the current run loop. There is no need to call | 158 // |FetchOAuth2Token| on the current run loop. There is no need to call |
160 // |IssueTokenForScope| in this case. | 159 // |IssueTokenForScope| in this case. |
161 bool auto_post_fetch_response_on_message_loop_; | 160 bool auto_post_fetch_response_on_message_loop_; |
162 | 161 |
163 base::WeakPtrFactory<FakeProfileOAuth2TokenService> weak_ptr_factory_; | 162 base::WeakPtrFactory<FakeProfileOAuth2TokenService> weak_ptr_factory_; |
164 | 163 |
165 DISALLOW_COPY_AND_ASSIGN(FakeProfileOAuth2TokenService); | 164 DISALLOW_COPY_AND_ASSIGN(FakeProfileOAuth2TokenService); |
166 }; | 165 }; |
167 | 166 |
168 #endif // CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 167 #endif // CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
OLD | NEW |