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

Side by Side Diff: chrome/browser/extensions/api/identity/gaia_web_auth_flow.h

Issue 293063002: Multiple account support in chrome.identity.getAuthToken (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use full name of enable-new-profile-management Created 6 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 | Annotate | Revision Log
OLDNEW
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/ui/host_desktop.h" 9 #include "chrome/browser/ui/host_desktop.h"
10 #include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h" 10 #include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h"
11 #include "google_apis/gaia/ubertoken_fetcher.h" 11 #include "google_apis/gaia/ubertoken_fetcher.h"
12 12
13 namespace extensions { 13 namespace extensions {
14 14
15 // Implements a web-based OAuth2 scope approval dialog. This flow has 15 // Implements a web-based OAuth2 scope approval dialog. This flow has
16 // four parts: 16 // four parts:
17 // 1. Fetch an ubertoken for the signed-in user. 17 // 1. Fetch an ubertoken for a signed-in user.
18 // 2. Use the ubertoken to get session cookies using MergeSession. 18 // 2. Use the ubertoken to get session cookies using MergeSession.
19 // 3. Start the OAuth flow and wait for final redirect. 19 // 3. Start the OAuth flow and wait for final redirect.
20 // 4. Parse results from the fragment component of the final redirect URI. 20 // 4. Parse results from the fragment component of the final redirect URI.
21 // 21 //
22 // The OAuth flow is a special version of the OAuth2 out-of-band flow 22 // The OAuth flow is a special version of the OAuth2 out-of-band flow
23 // where the final response page's title contains the 23 // where the final response page's title contains the
24 // redirect_uri. The redirect URI has an unusual format to prevent its 24 // redirect_uri. The redirect URI has an unusual format to prevent its
25 // use in other contexts. The scheme of the URI is a reversed version 25 // use in other contexts. The scheme of the URI is a reversed version
26 // of the OAuth client ID, and the path starts with the Chrome 26 // of the OAuth client ID, and the path starts with the Chrome
27 // extension ID. For example, an app with the OAuth client ID 27 // extension ID. For example, an app with the OAuth client ID
(...skipping 25 matching lines...) Expand all
53 virtual void OnGaiaFlowFailure(Failure failure, 53 virtual void OnGaiaFlowFailure(Failure failure,
54 GoogleServiceAuthError service_error, 54 GoogleServiceAuthError service_error,
55 const std::string& oauth_error) = 0; 55 const std::string& oauth_error) = 0;
56 // Called when the OAuth2 flow completes. 56 // Called when the OAuth2 flow completes.
57 virtual void OnGaiaFlowCompleted(const std::string& access_token, 57 virtual void OnGaiaFlowCompleted(const std::string& access_token,
58 const std::string& expiration) = 0; 58 const std::string& expiration) = 0;
59 }; 59 };
60 60
61 GaiaWebAuthFlow(Delegate* delegate, 61 GaiaWebAuthFlow(Delegate* delegate,
62 Profile* profile, 62 Profile* profile,
63 const std::string& account_id,
63 const std::string& extension_id, 64 const std::string& extension_id,
64 const OAuth2Info& oauth2_info, 65 const OAuth2Info& oauth2_info,
65 const std::string& locale); 66 const std::string& locale);
66 virtual ~GaiaWebAuthFlow(); 67 virtual ~GaiaWebAuthFlow();
67 68
68 // Starts the flow by fetching an ubertoken. Can override for testing. 69 // Starts the flow by fetching an ubertoken. Can override for testing.
69 virtual void Start(); 70 virtual void Start();
70 71
71 // UbertokenConsumer implementation: 72 // UbertokenConsumer implementation:
72 virtual void OnUbertokenSuccess(const std::string& token) OVERRIDE; 73 virtual void OnUbertokenSuccess(const std::string& token) OVERRIDE;
73 virtual void OnUbertokenFailure(const GoogleServiceAuthError& error) OVERRIDE; 74 virtual void OnUbertokenFailure(const GoogleServiceAuthError& error) OVERRIDE;
74 75
75 // WebAuthFlow::Delegate implementation. 76 // WebAuthFlow::Delegate implementation.
76 virtual void OnAuthFlowFailure(WebAuthFlow::Failure failure) OVERRIDE; 77 virtual void OnAuthFlowFailure(WebAuthFlow::Failure failure) OVERRIDE;
77 virtual void OnAuthFlowURLChange(const GURL& redirect_url) OVERRIDE; 78 virtual void OnAuthFlowURLChange(const GURL& redirect_url) OVERRIDE;
78 virtual void OnAuthFlowTitleChange(const std::string& title) OVERRIDE; 79 virtual void OnAuthFlowTitleChange(const std::string& title) OVERRIDE;
79 80
80 private: 81 private:
81 // Creates a WebAuthFlow, which will navigate to |url|. Can override 82 // Creates a WebAuthFlow, which will navigate to |url|. Can override
82 // for testing. Used to kick off the MergeSession (step #2). 83 // for testing. Used to kick off the MergeSession (step #2).
83 virtual scoped_ptr<WebAuthFlow> CreateWebAuthFlow(GURL url); 84 virtual scoped_ptr<WebAuthFlow> CreateWebAuthFlow(GURL url);
84 85
85 Delegate* delegate_; 86 Delegate* delegate_;
86 Profile* profile_; 87 Profile* profile_;
88 std::string account_id_;
87 chrome::HostDesktopType host_desktop_type_; 89 chrome::HostDesktopType host_desktop_type_;
88 std::string redirect_scheme_; 90 std::string redirect_scheme_;
89 std::string redirect_path_prefix_; 91 std::string redirect_path_prefix_;
90 GURL auth_url_; 92 GURL auth_url_;
91 scoped_ptr<UbertokenFetcher> ubertoken_fetcher_; 93 scoped_ptr<UbertokenFetcher> ubertoken_fetcher_;
92 scoped_ptr<WebAuthFlow> web_flow_; 94 scoped_ptr<WebAuthFlow> web_flow_;
93 95
94 DISALLOW_COPY_AND_ASSIGN(GaiaWebAuthFlow); 96 DISALLOW_COPY_AND_ASSIGN(GaiaWebAuthFlow);
95 }; 97 };
96 98
97 } // extensions 99 } // namespace extensions
98 100
99 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_GAIA_WEB_AUTH_FLOW_H_ 101 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_GAIA_WEB_AUTH_FLOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698