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 #include "chrome/browser/extensions/api/identity/identity_api.h" | 5 #include "chrome/browser/extensions/api/identity/identity_api.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 8 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
9 #include "chrome/browser/signin/token_service.h" | 9 #include "chrome/browser/signin/token_service.h" |
10 #include "chrome/browser/signin/token_service_factory.h" | 10 #include "chrome/browser/signin/token_service_factory.h" |
11 #include "chrome/browser/tab_contents/tab_util.h" | |
Mihai Parparita -not on Chrome
2012/05/04 22:37:18
All of these #includes that got added seem to be u
| |
11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
13 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
15 #include "content/public/browser/web_contents.h" | |
16 #include "content/public/browser/web_contents_delegate.h" | |
14 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
18 #include "ui/views/controls/webview/webview.h" | |
19 #include "ui/views/widget/widget.h" | |
20 #include "ui/views/widget/widget_delegate.h" | |
21 | |
22 using content::WebContents; | |
23 using content::WebContentsDelegate; | |
15 | 24 |
16 namespace extensions { | 25 namespace extensions { |
17 | 26 |
18 namespace { | 27 namespace { |
19 | 28 |
20 const char kInvalidClientId[] = "Invalid OAuth2 Client ID."; | 29 const char kInvalidClientId[] = "Invalid OAuth2 Client ID."; |
21 const char kInvalidScopes[] = "Invalid OAuth2 scopes."; | 30 const char kInvalidScopes[] = "Invalid OAuth2 scopes."; |
31 const char kUrlFieldRequired[] = "Missing required field: url"; | |
32 const char kInvalidRedirect[] = "Did not redirect to the right URL."; | |
22 | 33 |
23 } // namespace | 34 } // namespace |
24 | 35 |
25 GetAuthTokenFunction::GetAuthTokenFunction() {} | 36 GetAuthTokenFunction::GetAuthTokenFunction() {} |
26 GetAuthTokenFunction::~GetAuthTokenFunction() {} | 37 GetAuthTokenFunction::~GetAuthTokenFunction() {} |
27 | 38 |
28 bool GetAuthTokenFunction::RunImpl() { | 39 bool GetAuthTokenFunction::RunImpl() { |
29 const Extension* extension = GetExtension(); | 40 const Extension* extension = GetExtension(); |
30 Extension::OAuth2Info oauth2_info = extension->oauth2_info(); | 41 Extension::OAuth2Info oauth2_info = extension->oauth2_info(); |
31 | 42 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 Release(); // Balanced in RunImpl. | 74 Release(); // Balanced in RunImpl. |
64 } | 75 } |
65 | 76 |
66 void GetAuthTokenFunction::OnMintTokenFailure( | 77 void GetAuthTokenFunction::OnMintTokenFailure( |
67 const GoogleServiceAuthError& error) { | 78 const GoogleServiceAuthError& error) { |
68 error_ = error.ToString(); | 79 error_ = error.ToString(); |
69 SendResponse(false); | 80 SendResponse(false); |
70 Release(); // Balanced in RunImpl. | 81 Release(); // Balanced in RunImpl. |
71 } | 82 } |
72 | 83 |
84 LaunchAuthFlowFunction::LaunchAuthFlowFunction() {} | |
85 LaunchAuthFlowFunction::~LaunchAuthFlowFunction() {} | |
86 | |
87 bool LaunchAuthFlowFunction::RunImpl() { | |
88 DictionaryValue* arg1 = NULL; | |
89 std::string url; | |
90 | |
91 if (!args_.get() || | |
92 !args_->GetDictionary(0, &arg1) || | |
93 !arg1->GetString("url", &url)) { | |
94 error_ = kUrlFieldRequired; | |
95 return false; | |
96 } | |
97 | |
98 GURL auth_url(url); | |
99 auth_flow_.reset(new ExtensionAuthFlow( | |
100 this, profile(), GetExtension()->id(), auth_url)); | |
101 auth_flow_->Start(); | |
102 AddRef(); | |
Mihai Parparita -not on Chrome
2012/05/04 22:37:18
Add comments about this being balanced in OnAuthFl
Munjal (Google)
2012/05/08 19:26:35
Done.
| |
103 return true; | |
104 } | |
105 | |
106 void LaunchAuthFlowFunction::OnAuthFlowCompleted( | |
Mihai Parparita -not on Chrome
2012/05/04 22:37:18
Nit: The token minting delegate uses the names On*
Munjal (Google)
2012/05/08 19:26:35
Done.
| |
107 const std::string& redirect_url) { | |
108 result_.reset(Value::CreateStringValue(redirect_url)); | |
109 SendResponse(true); | |
110 Release(); | |
111 } | |
112 | |
113 void LaunchAuthFlowFunction::OnAuthFlowFailed() { | |
114 error_ = kInvalidRedirect; | |
115 SendResponse(false); | |
116 Release(); | |
117 } | |
118 | |
73 } // namespace extensions | 119 } // namespace extensions |
OLD | NEW |