OLD | NEW |
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 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 void EraseAllCachedTokens(); | 106 void EraseAllCachedTokens(); |
107 const IdentityTokenCacheValue& GetCachedToken(const ExtensionTokenKey& key); | 107 const IdentityTokenCacheValue& GetCachedToken(const ExtensionTokenKey& key); |
108 | 108 |
109 const CachedTokens& GetAllCachedTokens(); | 109 const CachedTokens& GetAllCachedTokens(); |
110 | 110 |
111 // Account queries. | 111 // Account queries. |
112 std::vector<std::string> GetAccounts() const; | 112 std::vector<std::string> GetAccounts() const; |
113 std::string FindAccountKeyByGaiaId(const std::string& gaia_id); | 113 std::string FindAccountKeyByGaiaId(const std::string& gaia_id); |
114 | 114 |
115 // BrowserContextKeyedAPI implementation. | 115 // BrowserContextKeyedAPI implementation. |
116 virtual void Shutdown() OVERRIDE; | 116 virtual void Shutdown() override; |
117 static BrowserContextKeyedAPIFactory<IdentityAPI>* GetFactoryInstance(); | 117 static BrowserContextKeyedAPIFactory<IdentityAPI>* GetFactoryInstance(); |
118 | 118 |
119 // gaia::AccountTracker::Observer implementation: | 119 // gaia::AccountTracker::Observer implementation: |
120 virtual void OnAccountAdded(const gaia::AccountIds& ids) OVERRIDE; | 120 virtual void OnAccountAdded(const gaia::AccountIds& ids) override; |
121 virtual void OnAccountRemoved(const gaia::AccountIds& ids) OVERRIDE; | 121 virtual void OnAccountRemoved(const gaia::AccountIds& ids) override; |
122 virtual void OnAccountSignInChanged(const gaia::AccountIds& ids, | 122 virtual void OnAccountSignInChanged(const gaia::AccountIds& ids, |
123 bool is_signed_in) OVERRIDE; | 123 bool is_signed_in) override; |
124 | 124 |
125 void AddShutdownObserver(ShutdownObserver* observer); | 125 void AddShutdownObserver(ShutdownObserver* observer); |
126 void RemoveShutdownObserver(ShutdownObserver* observer); | 126 void RemoveShutdownObserver(ShutdownObserver* observer); |
127 | 127 |
128 void SetAccountStateForTest(gaia::AccountIds ids, bool is_signed_in); | 128 void SetAccountStateForTest(gaia::AccountIds ids, bool is_signed_in); |
129 | 129 |
130 private: | 130 private: |
131 friend class BrowserContextKeyedAPIFactory<IdentityAPI>; | 131 friend class BrowserContextKeyedAPIFactory<IdentityAPI>; |
132 | 132 |
133 // BrowserContextKeyedAPI implementation. | 133 // BrowserContextKeyedAPI implementation. |
(...skipping 15 matching lines...) Expand all Loading... |
149 public: | 149 public: |
150 DECLARE_EXTENSION_FUNCTION("identity.getAccounts", | 150 DECLARE_EXTENSION_FUNCTION("identity.getAccounts", |
151 IDENTITY_GETACCOUNTS); | 151 IDENTITY_GETACCOUNTS); |
152 | 152 |
153 IdentityGetAccountsFunction(); | 153 IdentityGetAccountsFunction(); |
154 | 154 |
155 private: | 155 private: |
156 virtual ~IdentityGetAccountsFunction(); | 156 virtual ~IdentityGetAccountsFunction(); |
157 | 157 |
158 // UIThreadExtensionFunction implementation. | 158 // UIThreadExtensionFunction implementation. |
159 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; | 159 virtual ExtensionFunction::ResponseAction Run() override; |
160 }; | 160 }; |
161 | 161 |
162 // identity.getAuthToken fetches an OAuth 2 function for the | 162 // identity.getAuthToken fetches an OAuth 2 function for the |
163 // caller. The request has three sub-flows: non-interactive, | 163 // caller. The request has three sub-flows: non-interactive, |
164 // interactive, and sign-in. | 164 // interactive, and sign-in. |
165 // | 165 // |
166 // In the non-interactive flow, getAuthToken requests a token from | 166 // In the non-interactive flow, getAuthToken requests a token from |
167 // GAIA. GAIA may respond with a token, an error, or "consent | 167 // GAIA. GAIA may respond with a token, an error, or "consent |
168 // required". In the consent required cases, getAuthToken proceeds to | 168 // required". In the consent required cases, getAuthToken proceeds to |
169 // the second, interactive phase. | 169 // the second, interactive phase. |
(...skipping 20 matching lines...) Expand all Loading... |
190 IdentityGetAuthTokenFunction(); | 190 IdentityGetAuthTokenFunction(); |
191 | 191 |
192 const ExtensionTokenKey* GetExtensionTokenKeyForTest() { | 192 const ExtensionTokenKey* GetExtensionTokenKeyForTest() { |
193 return token_key_.get(); | 193 return token_key_.get(); |
194 } | 194 } |
195 | 195 |
196 protected: | 196 protected: |
197 virtual ~IdentityGetAuthTokenFunction(); | 197 virtual ~IdentityGetAuthTokenFunction(); |
198 | 198 |
199 // IdentitySigninFlow::Delegate implementation: | 199 // IdentitySigninFlow::Delegate implementation: |
200 virtual void SigninSuccess() OVERRIDE; | 200 virtual void SigninSuccess() override; |
201 virtual void SigninFailed() OVERRIDE; | 201 virtual void SigninFailed() override; |
202 | 202 |
203 // GaiaWebAuthFlow::Delegate implementation: | 203 // GaiaWebAuthFlow::Delegate implementation: |
204 virtual void OnGaiaFlowFailure(GaiaWebAuthFlow::Failure failure, | 204 virtual void OnGaiaFlowFailure(GaiaWebAuthFlow::Failure failure, |
205 GoogleServiceAuthError service_error, | 205 GoogleServiceAuthError service_error, |
206 const std::string& oauth_error) OVERRIDE; | 206 const std::string& oauth_error) override; |
207 virtual void OnGaiaFlowCompleted(const std::string& access_token, | 207 virtual void OnGaiaFlowCompleted(const std::string& access_token, |
208 const std::string& expiration) OVERRIDE; | 208 const std::string& expiration) override; |
209 | 209 |
210 // Starts a login access token request. | 210 // Starts a login access token request. |
211 virtual void StartLoginAccessTokenRequest(); | 211 virtual void StartLoginAccessTokenRequest(); |
212 | 212 |
213 // OAuth2TokenService::Consumer implementation: | 213 // OAuth2TokenService::Consumer implementation: |
214 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 214 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
215 const std::string& access_token, | 215 const std::string& access_token, |
216 const base::Time& expiration_time) OVERRIDE; | 216 const base::Time& expiration_time) override; |
217 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 217 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
218 const GoogleServiceAuthError& error) OVERRIDE; | 218 const GoogleServiceAuthError& error) override; |
219 | 219 |
220 scoped_ptr<OAuth2TokenService::Request> login_token_request_; | 220 scoped_ptr<OAuth2TokenService::Request> login_token_request_; |
221 | 221 |
222 private: | 222 private: |
223 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, | 223 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, |
224 ComponentWithChromeClientId); | 224 ComponentWithChromeClientId); |
225 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, | 225 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, |
226 ComponentWithNormalClientId); | 226 ComponentWithNormalClientId); |
227 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, InteractiveQueueShutdown); | 227 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, InteractiveQueueShutdown); |
228 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, NoninteractiveShutdown); | 228 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, NoninteractiveShutdown); |
229 | 229 |
230 // ExtensionFunction: | 230 // ExtensionFunction: |
231 virtual bool RunAsync() OVERRIDE; | 231 virtual bool RunAsync() override; |
232 | 232 |
233 // Helpers to report async function results to the caller. | 233 // Helpers to report async function results to the caller. |
234 void StartAsyncRun(); | 234 void StartAsyncRun(); |
235 void CompleteAsyncRun(bool success); | 235 void CompleteAsyncRun(bool success); |
236 void CompleteFunctionWithResult(const std::string& access_token); | 236 void CompleteFunctionWithResult(const std::string& access_token); |
237 void CompleteFunctionWithError(const std::string& error); | 237 void CompleteFunctionWithError(const std::string& error); |
238 | 238 |
239 // Initiate/complete the sub-flows. | 239 // Initiate/complete the sub-flows. |
240 void StartSigninFlow(); | 240 void StartSigninFlow(); |
241 void StartMintTokenFlow(IdentityMintRequestQueue::MintType type); | 241 void StartMintTokenFlow(IdentityMintRequestQueue::MintType type); |
242 void CompleteMintTokenFlow(); | 242 void CompleteMintTokenFlow(); |
243 | 243 |
244 // IdentityMintRequestQueue::Request implementation: | 244 // IdentityMintRequestQueue::Request implementation: |
245 virtual void StartMintToken(IdentityMintRequestQueue::MintType type) OVERRIDE; | 245 virtual void StartMintToken(IdentityMintRequestQueue::MintType type) override; |
246 | 246 |
247 // OAuth2MintTokenFlow::Delegate implementation: | 247 // OAuth2MintTokenFlow::Delegate implementation: |
248 virtual void OnMintTokenSuccess(const std::string& access_token, | 248 virtual void OnMintTokenSuccess(const std::string& access_token, |
249 int time_to_live) OVERRIDE; | 249 int time_to_live) override; |
250 virtual void OnMintTokenFailure( | 250 virtual void OnMintTokenFailure( |
251 const GoogleServiceAuthError& error) OVERRIDE; | 251 const GoogleServiceAuthError& error) override; |
252 virtual void OnIssueAdviceSuccess( | 252 virtual void OnIssueAdviceSuccess( |
253 const IssueAdviceInfo& issue_advice) OVERRIDE; | 253 const IssueAdviceInfo& issue_advice) override; |
254 | 254 |
255 // IdentityAPI::ShutdownObserver implementation: | 255 // IdentityAPI::ShutdownObserver implementation: |
256 virtual void OnShutdown() OVERRIDE; | 256 virtual void OnShutdown() override; |
257 | 257 |
258 #if defined(OS_CHROMEOS) | 258 #if defined(OS_CHROMEOS) |
259 // Starts a login access token request for device robot account. This method | 259 // Starts a login access token request for device robot account. This method |
260 // will be called only in enterprise kiosk mode in ChromeOS. | 260 // will be called only in enterprise kiosk mode in ChromeOS. |
261 virtual void StartDeviceLoginAccessTokenRequest(); | 261 virtual void StartDeviceLoginAccessTokenRequest(); |
262 #endif | 262 #endif |
263 | 263 |
264 // Starts a mint token request to GAIA. | 264 // Starts a mint token request to GAIA. |
265 void StartGaiaRequest(const std::string& login_access_token); | 265 void StartGaiaRequest(const std::string& login_access_token); |
266 | 266 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 public: | 300 public: |
301 DECLARE_EXTENSION_FUNCTION("identity.getProfileUserInfo", | 301 DECLARE_EXTENSION_FUNCTION("identity.getProfileUserInfo", |
302 IDENTITY_GETPROFILEUSERINFO); | 302 IDENTITY_GETPROFILEUSERINFO); |
303 | 303 |
304 IdentityGetProfileUserInfoFunction(); | 304 IdentityGetProfileUserInfoFunction(); |
305 | 305 |
306 private: | 306 private: |
307 virtual ~IdentityGetProfileUserInfoFunction(); | 307 virtual ~IdentityGetProfileUserInfoFunction(); |
308 | 308 |
309 // UIThreadExtensionFunction implementation. | 309 // UIThreadExtensionFunction implementation. |
310 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; | 310 virtual ExtensionFunction::ResponseAction Run() override; |
311 }; | 311 }; |
312 | 312 |
313 class IdentityRemoveCachedAuthTokenFunction | 313 class IdentityRemoveCachedAuthTokenFunction |
314 : public ChromeSyncExtensionFunction { | 314 : public ChromeSyncExtensionFunction { |
315 public: | 315 public: |
316 DECLARE_EXTENSION_FUNCTION("identity.removeCachedAuthToken", | 316 DECLARE_EXTENSION_FUNCTION("identity.removeCachedAuthToken", |
317 EXPERIMENTAL_IDENTITY_REMOVECACHEDAUTHTOKEN) | 317 EXPERIMENTAL_IDENTITY_REMOVECACHEDAUTHTOKEN) |
318 IdentityRemoveCachedAuthTokenFunction(); | 318 IdentityRemoveCachedAuthTokenFunction(); |
319 | 319 |
320 protected: | 320 protected: |
321 virtual ~IdentityRemoveCachedAuthTokenFunction(); | 321 virtual ~IdentityRemoveCachedAuthTokenFunction(); |
322 | 322 |
323 // SyncExtensionFunction implementation: | 323 // SyncExtensionFunction implementation: |
324 virtual bool RunSync() OVERRIDE; | 324 virtual bool RunSync() override; |
325 }; | 325 }; |
326 | 326 |
327 class IdentityLaunchWebAuthFlowFunction : public ChromeAsyncExtensionFunction, | 327 class IdentityLaunchWebAuthFlowFunction : public ChromeAsyncExtensionFunction, |
328 public WebAuthFlow::Delegate { | 328 public WebAuthFlow::Delegate { |
329 public: | 329 public: |
330 DECLARE_EXTENSION_FUNCTION("identity.launchWebAuthFlow", | 330 DECLARE_EXTENSION_FUNCTION("identity.launchWebAuthFlow", |
331 EXPERIMENTAL_IDENTITY_LAUNCHWEBAUTHFLOW); | 331 EXPERIMENTAL_IDENTITY_LAUNCHWEBAUTHFLOW); |
332 | 332 |
333 IdentityLaunchWebAuthFlowFunction(); | 333 IdentityLaunchWebAuthFlowFunction(); |
334 | 334 |
335 // Tests may override extension_id. | 335 // Tests may override extension_id. |
336 void InitFinalRedirectURLPrefixForTest(const std::string& extension_id); | 336 void InitFinalRedirectURLPrefixForTest(const std::string& extension_id); |
337 | 337 |
338 private: | 338 private: |
339 virtual ~IdentityLaunchWebAuthFlowFunction(); | 339 virtual ~IdentityLaunchWebAuthFlowFunction(); |
340 virtual bool RunAsync() OVERRIDE; | 340 virtual bool RunAsync() override; |
341 | 341 |
342 // WebAuthFlow::Delegate implementation. | 342 // WebAuthFlow::Delegate implementation. |
343 virtual void OnAuthFlowFailure(WebAuthFlow::Failure failure) OVERRIDE; | 343 virtual void OnAuthFlowFailure(WebAuthFlow::Failure failure) override; |
344 virtual void OnAuthFlowURLChange(const GURL& redirect_url) OVERRIDE; | 344 virtual void OnAuthFlowURLChange(const GURL& redirect_url) override; |
345 virtual void OnAuthFlowTitleChange(const std::string& title) OVERRIDE {} | 345 virtual void OnAuthFlowTitleChange(const std::string& title) override {} |
346 | 346 |
347 // Helper to initialize final URL prefix. | 347 // Helper to initialize final URL prefix. |
348 void InitFinalRedirectURLPrefix(const std::string& extension_id); | 348 void InitFinalRedirectURLPrefix(const std::string& extension_id); |
349 | 349 |
350 scoped_ptr<WebAuthFlow> auth_flow_; | 350 scoped_ptr<WebAuthFlow> auth_flow_; |
351 GURL final_url_prefix_; | 351 GURL final_url_prefix_; |
352 }; | 352 }; |
353 | 353 |
354 } // namespace extensions | 354 } // namespace extensions |
355 | 355 |
356 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ | 356 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ |
OLD | NEW |