OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_EXTENSIONS_API_IDENTITY_GAIA_WEB_AUTH_FLOW_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_GAIA_WEB_AUTH_FLOW_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_GAIA_WEB_AUTH_FLOW_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_GAIA_WEB_AUTH_FLOW_H_ |
7 | 7 |
8 #include "chrome/browser/extensions/api/identity/web_auth_flow.h" | 8 #include "chrome/browser/extensions/api/identity/web_auth_flow.h" |
9 #include "chrome/browser/signin/ubertoken_fetcher.h" | 9 #include "chrome/browser/signin/ubertoken_fetcher.h" |
10 #include "chrome/browser/ui/host_desktop.h" | 10 #include "chrome/browser/ui/host_desktop.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 // includes the same URI in its title. The navigation to this URI gets | 35 // includes the same URI in its title. The navigation to this URI gets |
36 // filtered out because of its unusual protocol scheme, so | 36 // filtered out because of its unusual protocol scheme, so |
37 // GaiaWebAuthFlow pulls it out of the window title instead. | 37 // GaiaWebAuthFlow pulls it out of the window title instead. |
38 | 38 |
39 class GaiaWebAuthFlow : public UbertokenConsumer, public WebAuthFlow::Delegate { | 39 class GaiaWebAuthFlow : public UbertokenConsumer, public WebAuthFlow::Delegate { |
40 public: | 40 public: |
41 enum Failure { | 41 enum Failure { |
42 WINDOW_CLOSED, // Window closed by user. | 42 WINDOW_CLOSED, // Window closed by user. |
43 INVALID_REDIRECT, // Redirect parse error. | 43 INVALID_REDIRECT, // Redirect parse error. |
44 SERVICE_AUTH_ERROR, // Non-OAuth related authentication error | 44 SERVICE_AUTH_ERROR, // Non-OAuth related authentication error |
45 OAUTH_ERROR // Flow reached final redirect, which contained an error. | 45 OAUTH_ERROR, // Flow reached final redirect, which contained an error. |
| 46 LOAD_FAILED // An auth flow page failed to load. |
46 }; | 47 }; |
47 | 48 |
48 class Delegate { | 49 class Delegate { |
49 public: | 50 public: |
50 // Called when the flow fails prior to the final OAuth redirect, | 51 // Called when the flow fails prior to the final OAuth redirect, |
| 52 // TODO(courage): LOAD_FAILURE descriptions? |
51 virtual void OnGaiaFlowFailure(Failure failure, | 53 virtual void OnGaiaFlowFailure(Failure failure, |
52 GoogleServiceAuthError service_error, | 54 GoogleServiceAuthError service_error, |
53 const std::string& oauth_error) = 0; | 55 const std::string& oauth_error) = 0; |
54 // Called when the OAuth2 flow completes. | 56 // Called when the OAuth2 flow completes. |
55 virtual void OnGaiaFlowCompleted(const std::string& access_token, | 57 virtual void OnGaiaFlowCompleted(const std::string& access_token, |
56 const std::string& expiration) = 0; | 58 const std::string& expiration) = 0; |
57 }; | 59 }; |
58 | 60 |
59 GaiaWebAuthFlow(Delegate* delegate, | 61 GaiaWebAuthFlow(Delegate* delegate, |
60 Profile* profile, | 62 Profile* profile, |
61 chrome::HostDesktopType host_desktop_type, | |
62 const std::string& extension_id, | 63 const std::string& extension_id, |
63 const OAuth2Info& oauth2_info); | 64 const OAuth2Info& oauth2_info); |
64 virtual ~GaiaWebAuthFlow(); | 65 virtual ~GaiaWebAuthFlow(); |
65 | 66 |
66 // Starts the flow by fetching an ubertoken. Can override for testing. | 67 // Starts the flow by fetching an ubertoken. Can override for testing. |
67 virtual void Start(); | 68 virtual void Start(); |
68 | 69 |
69 // UbertokenConsumer implementation: | 70 // UbertokenConsumer implementation: |
70 virtual void OnUbertokenSuccess(const std::string& token) OVERRIDE; | 71 virtual void OnUbertokenSuccess(const std::string& token) OVERRIDE; |
71 virtual void OnUbertokenFailure(const GoogleServiceAuthError& error) OVERRIDE; | 72 virtual void OnUbertokenFailure(const GoogleServiceAuthError& error) OVERRIDE; |
(...skipping 16 matching lines...) Expand all Loading... |
88 GURL auth_url_; | 89 GURL auth_url_; |
89 scoped_ptr<UbertokenFetcher> ubertoken_fetcher_; | 90 scoped_ptr<UbertokenFetcher> ubertoken_fetcher_; |
90 scoped_ptr<WebAuthFlow> web_flow_; | 91 scoped_ptr<WebAuthFlow> web_flow_; |
91 | 92 |
92 DISALLOW_COPY_AND_ASSIGN(GaiaWebAuthFlow); | 93 DISALLOW_COPY_AND_ASSIGN(GaiaWebAuthFlow); |
93 }; | 94 }; |
94 | 95 |
95 } // extensions | 96 } // extensions |
96 | 97 |
97 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_GAIA_WEB_AUTH_FLOW_H_ | 98 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_GAIA_WEB_AUTH_FLOW_H_ |
OLD | NEW |