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

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

Issue 11186036: Implement size and position support for launchWebAuthFlow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit tests Created 8 years, 2 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_apitest.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) 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/common/extensions/api/experimental_identity.h" 8 #include "chrome/common/extensions/api/experimental_identity.h"
9 #include "chrome/browser/extensions/extension_install_prompt.h" 9 #include "chrome/browser/extensions/extension_install_prompt.h"
10 #include "chrome/browser/extensions/extension_function_dispatcher.h" 10 #include "chrome/browser/extensions/extension_function_dispatcher.h"
(...skipping 20 matching lines...) Expand all
31 const char kAuthFailure[] = "OAuth2 request failed: "; 31 const char kAuthFailure[] = "OAuth2 request failed: ";
32 const char kNoGrant[] = "OAuth2 not granted or revoked."; 32 const char kNoGrant[] = "OAuth2 not granted or revoked.";
33 const char kUserRejected[] = "The user did not approve access."; 33 const char kUserRejected[] = "The user did not approve access.";
34 const char kUserNotSignedIn[] = "The user is not signed in."; 34 const char kUserNotSignedIn[] = "The user is not signed in.";
35 const char kInvalidRedirect[] = "Did not redirect to the right URL."; 35 const char kInvalidRedirect[] = "Did not redirect to the right URL.";
36 } 36 }
37 37
38 namespace GetAuthToken = extensions::api::experimental_identity::GetAuthToken; 38 namespace GetAuthToken = extensions::api::experimental_identity::GetAuthToken;
39 namespace LaunchWebAuthFlow = 39 namespace LaunchWebAuthFlow =
40 extensions::api::experimental_identity::LaunchWebAuthFlow; 40 extensions::api::experimental_identity::LaunchWebAuthFlow;
41 namespace identity = extensions::api::experimental_identity;
41 42
42 IdentityGetAuthTokenFunction::IdentityGetAuthTokenFunction() 43 IdentityGetAuthTokenFunction::IdentityGetAuthTokenFunction()
43 : interactive_(false) {} 44 : interactive_(false) {}
44 IdentityGetAuthTokenFunction::~IdentityGetAuthTokenFunction() {} 45 IdentityGetAuthTokenFunction::~IdentityGetAuthTokenFunction() {}
45 46
46 bool IdentityGetAuthTokenFunction::RunImpl() { 47 bool IdentityGetAuthTokenFunction::RunImpl() {
47 scoped_ptr<GetAuthToken::Params> params(GetAuthToken::Params::Create(*args_)); 48 scoped_ptr<GetAuthToken::Params> params(GetAuthToken::Params::Create(*args_));
48 EXTENSION_FUNCTION_VALIDATE(params.get()); 49 EXTENSION_FUNCTION_VALIDATE(params.get());
49 if (params->details.get() && params->details->interactive.get()) 50 if (params->details.get() && params->details->interactive.get())
50 interactive_ = *params->details->interactive; 51 interactive_ = *params->details->interactive;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 return token_service->HasOAuthLoginToken(); 219 return token_service->HasOAuthLoginToken();
219 } 220 }
220 221
221 IdentityLaunchWebAuthFlowFunction::IdentityLaunchWebAuthFlowFunction() {} 222 IdentityLaunchWebAuthFlowFunction::IdentityLaunchWebAuthFlowFunction() {}
222 IdentityLaunchWebAuthFlowFunction::~IdentityLaunchWebAuthFlowFunction() {} 223 IdentityLaunchWebAuthFlowFunction::~IdentityLaunchWebAuthFlowFunction() {}
223 224
224 bool IdentityLaunchWebAuthFlowFunction::RunImpl() { 225 bool IdentityLaunchWebAuthFlowFunction::RunImpl() {
225 scoped_ptr<LaunchWebAuthFlow::Params> params( 226 scoped_ptr<LaunchWebAuthFlow::Params> params(
226 LaunchWebAuthFlow::Params::Create(*args_)); 227 LaunchWebAuthFlow::Params::Create(*args_));
227 EXTENSION_FUNCTION_VALIDATE(params.get()); 228 EXTENSION_FUNCTION_VALIDATE(params.get());
229 const identity::WebAuthFlowDetails& details = params->details;
228 230
229 GURL auth_url(params->details.url); 231 GURL auth_url(details.url);
230 WebAuthFlow::Mode mode = 232 WebAuthFlow::Mode mode =
231 params->details.interactive.get() && *params->details.interactive ? 233 details.interactive && *details.interactive ?
232 WebAuthFlow::INTERACTIVE : WebAuthFlow::SILENT; 234 WebAuthFlow::INTERACTIVE : WebAuthFlow::SILENT;
233 235
236 // The bounds attributes are optional, but using 0 when they're not available
237 // does the right thing.
238 gfx::Rect initial_bounds;
239 if (details.width)
240 initial_bounds.set_width(*details.width);
241 if (details.height)
242 initial_bounds.set_height(*details.height);
243 if (details.left)
244 initial_bounds.set_x(*details.left);
245 if (details.top)
246 initial_bounds.set_y(*details.top);
247
234 AddRef(); // Balanced in OnAuthFlowSuccess/Failure. 248 AddRef(); // Balanced in OnAuthFlowSuccess/Failure.
235 auth_flow_.reset(new WebAuthFlow( 249 auth_flow_.reset(new WebAuthFlow(
236 this, profile(), GetExtension()->id(), auth_url, mode)); 250 this, profile(), GetExtension()->id(), auth_url, mode, initial_bounds));
237 auth_flow_->Start(); 251 auth_flow_->Start();
238 return true; 252 return true;
239 } 253 }
240 254
241 void IdentityLaunchWebAuthFlowFunction::OnAuthFlowSuccess( 255 void IdentityLaunchWebAuthFlowFunction::OnAuthFlowSuccess(
242 const std::string& redirect_url) { 256 const std::string& redirect_url) {
243 SetResult(Value::CreateStringValue(redirect_url)); 257 SetResult(Value::CreateStringValue(redirect_url));
244 SendResponse(true); 258 SendResponse(true);
245 Release(); // Balanced in RunImpl. 259 Release(); // Balanced in RunImpl.
246 } 260 }
247 261
248 void IdentityLaunchWebAuthFlowFunction::OnAuthFlowFailure() { 262 void IdentityLaunchWebAuthFlowFunction::OnAuthFlowFailure() {
249 error_ = identity_constants::kInvalidRedirect; 263 error_ = identity_constants::kInvalidRedirect;
250 SendResponse(false); 264 SendResponse(false);
251 Release(); // Balanced in RunImpl. 265 Release(); // Balanced in RunImpl.
252 } 266 }
253 267
254 } // namespace extensions 268 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/identity/identity_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698