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

Side by Side Diff: chrome/browser/resources/gaia_auth_host/authenticator.js

Issue 995753002: Load webview based GAIA in hidden state and pass focus when ready (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 /** 5 /**
6 * @fileoverview An UI component to authenciate to Chrome. The component hosts 6 * @fileoverview An UI component to authenciate to Chrome. The component hosts
7 * IdP web pages in a webview. A client who is interested in monitoring 7 * IdP web pages in a webview. A client who is interested in monitoring
8 * authentication events should pass a listener object of type 8 * authentication events should pass a listener object of type
9 * cr.login.GaiaAuthHost.Listener as defined in this file. After initialization, 9 * cr.login.GaiaAuthHost.Listener as defined in this file. After initialization,
10 * call {@code load} to start the authentication flow. 10 * call {@code load} to start the authentication flow.
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 /** 150 /**
151 * Reloads the authenticator component. 151 * Reloads the authenticator component.
152 */ 152 */
153 Authenticator.prototype.reload = function() { 153 Authenticator.prototype.reload = function() {
154 this.webview_.src = this.reloadUrl_; 154 this.webview_.src = this.reloadUrl_;
155 this.authFlow_ = AuthFlow.DEFAULT; 155 this.authFlow_ = AuthFlow.DEFAULT;
156 this.loaded_ = false; 156 this.loaded_ = false;
157 }; 157 };
158 158
159 /**
160 * Send message 'focusready' to Gaia so it sets focus on default input.
161 */
162 Authenticator.prototype.sendFocusReady = function() {
163 var currentUrl = this.webview_.src;
164 if (currentUrl.lastIndexOf(this.idpOrigin_) == 0) {
165 var msg = {
166 'method': 'focusready'
167 };
168 // TODO(rsorokin): Get rid of this check once issue crbug.com/456118 is
169 // fixed.
170 if (this.webview_.contentWindow) {
171 this.webview_.contentWindow.postMessage(msg, currentUrl);
172 }
173 }
174 };
175
176 Authenticator.prototype.constructInitialFrameUrl_ = function(data) { 159 Authenticator.prototype.constructInitialFrameUrl_ = function(data) {
177 var url = this.idpOrigin_ + (data.gaiaPath || IDP_PATH); 160 var url = this.idpOrigin_ + (data.gaiaPath || IDP_PATH);
178 161
179 if (this.isMinuteMaidChromeOS) { 162 if (this.isMinuteMaidChromeOS) {
180 if (data.chromeType) 163 if (data.chromeType)
181 url = appendParam(url, 'chrometype', data.chromeType); 164 url = appendParam(url, 'chrometype', data.chromeType);
182 if (data.clientId) 165 if (data.clientId)
183 url = appendParam(url, 'client_id', data.clientId); 166 url = appendParam(url, 'client_id', data.clientId);
184 if (data.enterpriseDomain) 167 if (data.enterpriseDomain)
185 url = appendParam(url, 'managedomain', data.enterpriseDomain); 168 url = appendParam(url, 'managedomain', data.enterpriseDomain);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 } 369 }
387 }; 370 };
388 371
389 /** 372 /**
390 * Invoked when the webview finishes loading a page. 373 * Invoked when the webview finishes loading a page.
391 * @private 374 * @private
392 */ 375 */
393 Authenticator.prototype.onLoadStop_ = function(e) { 376 Authenticator.prototype.onLoadStop_ = function(e) {
394 if (!this.loaded_) { 377 if (!this.loaded_) {
395 this.loaded_ = true; 378 this.loaded_ = true;
379 this.dispatchEvent(new Event('ready'));
380 // Focus webview after dispatching event when webview is already visible.
396 this.webview_.focus(); 381 this.webview_.focus();
397 this.dispatchEvent(new Event('ready'));
398 } 382 }
399 }; 383 };
400 384
401 /** 385 /**
402 * Invoked when the webview navigates withing the current document. 386 * Invoked when the webview navigates withing the current document.
403 * @private 387 * @private
404 */ 388 */
405 Authenticator.prototype.onLoadCommit_ = function(e) { 389 Authenticator.prototype.onLoadCommit_ = function(e) {
406 // TODO(rsorokin): Investigate whether this breaks SAML. 390 // TODO(rsorokin): Investigate whether this breaks SAML.
407 if (this.oauth_code_) { 391 if (this.oauth_code_) {
408 this.skipForNow_ = true; 392 this.skipForNow_ = true;
409 this.onAuthCompleted_(); 393 this.onAuthCompleted_();
410 } 394 }
411 }; 395 };
412 396
413 Authenticator.AuthFlow = AuthFlow; 397 Authenticator.AuthFlow = AuthFlow;
414 Authenticator.AuthMode = AuthMode; 398 Authenticator.AuthMode = AuthMode;
415 Authenticator.SUPPORTED_PARAMS = SUPPORTED_PARAMS; 399 Authenticator.SUPPORTED_PARAMS = SUPPORTED_PARAMS;
416 400
417 return { 401 return {
418 // TODO(guohui, xiyuan): Rename GaiaAuthHost to Authenticator once the old 402 // TODO(guohui, xiyuan): Rename GaiaAuthHost to Authenticator once the old
419 // iframe-based flow is deprecated. 403 // iframe-based flow is deprecated.
420 GaiaAuthHost: Authenticator 404 GaiaAuthHost: Authenticator
421 }; 405 };
422 }); 406 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698