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

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

Issue 11221002: Merge 162639 - Implement size and position support for launchWebAuthFlow. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1271/src/
Patch Set: 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
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/web_auth_flow.h" 5 #include "chrome/browser/extensions/api/identity/web_auth_flow.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 30 matching lines...) Expand all
41 41
42 } // namespace 42 } // namespace
43 43
44 namespace extensions { 44 namespace extensions {
45 45
46 WebAuthFlow::WebAuthFlow( 46 WebAuthFlow::WebAuthFlow(
47 Delegate* delegate, 47 Delegate* delegate,
48 Profile* profile, 48 Profile* profile,
49 const std::string& extension_id, 49 const std::string& extension_id,
50 const GURL& provider_url, 50 const GURL& provider_url,
51 Mode mode) 51 Mode mode,
52 const gfx::Rect& initial_bounds)
52 : delegate_(delegate), 53 : delegate_(delegate),
53 profile_(profile), 54 profile_(profile),
54 provider_url_(provider_url), 55 provider_url_(provider_url),
55 mode_(mode), 56 mode_(mode),
57 initial_bounds_(initial_bounds),
56 contents_(NULL), 58 contents_(NULL),
57 tab_contents_(NULL) { 59 tab_contents_(NULL) {
58 InitValidRedirectUrlPrefixes(extension_id); 60 InitValidRedirectUrlPrefixes(extension_id);
59 } 61 }
60 62
61 WebAuthFlow::~WebAuthFlow() { 63 WebAuthFlow::~WebAuthFlow() {
62 if (tab_contents_) { 64 if (tab_contents_) {
63 tab_contents_->web_contents()->Close(); 65 tab_contents_->web_contents()->Close();
64 } 66 }
65 if (contents_) { 67 if (contents_) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 105 }
104 106
105 WebContents* WebAuthFlow::CreateWebContents() { 107 WebContents* WebAuthFlow::CreateWebContents() {
106 return WebContents::Create(profile_, NULL, MSG_ROUTING_NONE, NULL); 108 return WebContents::Create(profile_, NULL, MSG_ROUTING_NONE, NULL);
107 } 109 }
108 110
109 void WebAuthFlow::ShowAuthFlowPopup() { 111 void WebAuthFlow::ShowAuthFlowPopup() {
110 // Pass ownership of WebContents to TabContents. 112 // Pass ownership of WebContents to TabContents.
111 tab_contents_ = TabContents::Factory::CreateTabContents(contents_); 113 tab_contents_ = TabContents::Factory::CreateTabContents(contents_);
112 contents_ = NULL; 114 contents_ = NULL;
113 Browser* browser = new Browser(Browser::CreateParams( 115 Browser::CreateParams browser_params(Browser::TYPE_POPUP, profile_);
114 Browser::TYPE_POPUP, profile_)); 116 browser_params.initial_bounds = initial_bounds_;
117 Browser* browser = new Browser(browser_params);
115 chrome::NavigateParams params(browser, tab_contents_); 118 chrome::NavigateParams params(browser, tab_contents_);
116 params.disposition = CURRENT_TAB; 119 params.disposition = CURRENT_TAB;
117 params.window_action = chrome::NavigateParams::SHOW_WINDOW; 120 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
118 chrome::Navigate(&params); 121 chrome::Navigate(&params);
119 // Observe method will be called before URLs are loaded. That is where 122 // Observe method will be called before URLs are loaded. That is where
120 // we check for redirect to the right URL. 123 // we check for redirect to the right URL.
121 } 124 }
122 125
123 bool WebAuthFlow::BeforeUrlLoaded(const GURL& url) { 126 bool WebAuthFlow::BeforeUrlLoaded(const GURL& url) {
124 if (IsValidRedirectUrl(url)) { 127 if (IsValidRedirectUrl(url)) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 break; 166 break;
164 case content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: { 167 case content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: {
165 ResourceRedirectDetails* redirect_details = 168 ResourceRedirectDetails* redirect_details =
166 content::Details<ResourceRedirectDetails>(details).ptr(); 169 content::Details<ResourceRedirectDetails>(details).ptr();
167 if (redirect_details != NULL) 170 if (redirect_details != NULL)
168 BeforeUrlLoaded(redirect_details->new_url); 171 BeforeUrlLoaded(redirect_details->new_url);
169 } 172 }
170 break; 173 break;
171 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: { 174 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: {
172 // User closed the auth flow window; report a failure. 175 // User closed the auth flow window; report a failure.
176 contents_ = NULL;
177 tab_contents_ = NULL;
173 ReportResult(GURL()); 178 ReportResult(GURL());
174 } 179 }
175 break; 180 break;
176 default: 181 default:
177 NOTREACHED() << "Got a notification that we did not register for: " 182 NOTREACHED() << "Got a notification that we did not register for: "
178 << type; 183 << type;
179 break; 184 break;
180 } 185 }
181 } 186 }
182 187
(...skipping 27 matching lines...) Expand all
210 215
211 void WebAuthFlow::InitValidRedirectUrlPrefixes( 216 void WebAuthFlow::InitValidRedirectUrlPrefixes(
212 const std::string& extension_id) { 217 const std::string& extension_id) {
213 valid_prefixes_.push_back(base::StringPrintf( 218 valid_prefixes_.push_back(base::StringPrintf(
214 kChromeExtensionSchemeUrlPattern, extension_id.c_str())); 219 kChromeExtensionSchemeUrlPattern, extension_id.c_str()));
215 valid_prefixes_.push_back(base::StringPrintf( 220 valid_prefixes_.push_back(base::StringPrintf(
216 kChromiumDomainRedirectUrlPattern, extension_id.c_str())); 221 kChromiumDomainRedirectUrlPattern, extension_id.c_str()));
217 } 222 }
218 223
219 } // namespace extensions 224 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698