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

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

Issue 11882025: Move "oauth2" manifest key parsing out of Extension class. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/identity/identity_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
sail 2013/01/18 16:17:01 don't update the copyright year on files you modif
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 <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/extensions/api/identity/web_auth_flow.h" 12 #include "chrome/browser/extensions/api/identity/web_auth_flow.h"
13 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
13 #include "chrome/browser/extensions/app_notify_channel_setup.h" 14 #include "chrome/browser/extensions/app_notify_channel_setup.h"
14 #include "chrome/browser/extensions/extension_function.h" 15 #include "chrome/browser/extensions/extension_function.h"
15 #include "chrome/browser/extensions/extension_install_prompt.h" 16 #include "chrome/browser/extensions/extension_install_prompt.h"
16 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 17 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
17 #include "google_apis/gaia/oauth2_mint_token_flow.h" 18 #include "google_apis/gaia/oauth2_mint_token_flow.h"
18 19
19 class GetAuthTokenFunctionTest; 20 class GetAuthTokenFunctionTest;
20 class MockGetAuthTokenFunction; 21 class MockGetAuthTokenFunction;
21 class GoogleServiceAuthError; 22 class GoogleServiceAuthError;
23 class Profile;
22 24
23 namespace extensions { 25 namespace extensions {
24 26
25 namespace identity_constants { 27 namespace identity_constants {
26 extern const char kInvalidClientId[]; 28 extern const char kInvalidClientId[];
27 extern const char kInvalidScopes[]; 29 extern const char kInvalidScopes[];
28 extern const char kAuthFailure[]; 30 extern const char kAuthFailure[];
29 extern const char kNoGrant[]; 31 extern const char kNoGrant[];
30 extern const char kUserRejected[]; 32 extern const char kUserRejected[];
31 extern const char kUserNotSignedIn[]; 33 extern const char kUserNotSignedIn[];
32 extern const char kInvalidRedirect[]; 34 extern const char kInvalidRedirect[];
33 } 35 } // namespace identity_constants
34 36
35 class IdentityGetAuthTokenFunction : public AsyncExtensionFunction, 37 class IdentityGetAuthTokenFunction : public AsyncExtensionFunction,
36 public OAuth2MintTokenFlow::Delegate, 38 public OAuth2MintTokenFlow::Delegate,
37 public ExtensionInstallPrompt::Delegate, 39 public ExtensionInstallPrompt::Delegate,
38 public LoginUIService::Observer { 40 public LoginUIService::Observer {
39 public: 41 public:
40 DECLARE_EXTENSION_FUNCTION_NAME("experimental.identity.getAuthToken"); 42 DECLARE_EXTENSION_FUNCTION_NAME("experimental.identity.getAuthToken");
41 43
42 IdentityGetAuthTokenFunction(); 44 IdentityGetAuthTokenFunction();
43 45
44 protected: 46 protected:
45 virtual ~IdentityGetAuthTokenFunction(); 47 virtual ~IdentityGetAuthTokenFunction();
46 48
47 private: 49 private:
48 friend class ::GetAuthTokenFunctionTest; 50 friend class GetAuthTokenFunctionTest;
49 friend class ::MockGetAuthTokenFunction; 51 friend class MockGetAuthTokenFunction;
50 52
51 // ExtensionFunction: 53 // ExtensionFunction:
52 virtual bool RunImpl() OVERRIDE; 54 virtual bool RunImpl() OVERRIDE;
53 55
54 // OAuth2MintTokenFlow::Delegate implementation: 56 // OAuth2MintTokenFlow::Delegate implementation:
55 virtual void OnMintTokenSuccess(const std::string& access_token) OVERRIDE; 57 virtual void OnMintTokenSuccess(const std::string& access_token) OVERRIDE;
56 virtual void OnMintTokenFailure( 58 virtual void OnMintTokenFailure(
57 const GoogleServiceAuthError& error) OVERRIDE; 59 const GoogleServiceAuthError& error) OVERRIDE;
58 virtual void OnIssueAdviceSuccess( 60 virtual void OnIssueAdviceSuccess(
59 const IssueAdviceInfo& issue_advice) OVERRIDE; 61 const IssueAdviceInfo& issue_advice) OVERRIDE;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 virtual ~IdentityLaunchWebAuthFlowFunction(); 105 virtual ~IdentityLaunchWebAuthFlowFunction();
104 virtual bool RunImpl() OVERRIDE; 106 virtual bool RunImpl() OVERRIDE;
105 107
106 // WebAuthFlow::Delegate implementation. 108 // WebAuthFlow::Delegate implementation.
107 virtual void OnAuthFlowSuccess(const std::string& redirect_url) OVERRIDE; 109 virtual void OnAuthFlowSuccess(const std::string& redirect_url) OVERRIDE;
108 virtual void OnAuthFlowFailure() OVERRIDE; 110 virtual void OnAuthFlowFailure() OVERRIDE;
109 111
110 scoped_ptr<WebAuthFlow> auth_flow_; 112 scoped_ptr<WebAuthFlow> auth_flow_;
111 }; 113 };
112 114
115 class IdentityAPI : public ProfileKeyedAPI {
116 public:
117 explicit IdentityAPI(Profile* profile);
118 virtual ~IdentityAPI();
119
120 // ProfileKeyedAPI implementation.
121 static ProfileKeyedAPIFactory<IdentityAPI>* GetFactoryInstance();
122
123 private:
124 friend class ProfileKeyedAPIFactory<IdentityAPI>;
125
126 // ProfileKeyedAPI implementation.
127 static const char* service_name() {
128 return "IdentityAPI";
129 }
130 static const bool kServiceIsNULLWhileTesting = true;
131 };
132
113 } // namespace extensions 133 } // namespace extensions
114 134
115 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ 135 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/identity/identity_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698