1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * @fileoverview Inline login UI.
9 <include src="../gaia_auth_host/gaia_auth_host.js"></include>
11 cr.define('inline.login', function() {
15 * The auth extension host instance.
21 * Handler of auth host 'ready' event.
23 function onAuthReady() {
24 $('contents').classList.toggle('loading', false);
28 * Handler of auth host 'completed' event.
29 * @param {!Object} credentials Credentials of the completed authentication.
31 function onAuthCompleted(credentials) {
32 chrome.send('completeLogin', [credentials]);
33 $('contents').classList.toggle('loading', true);
39 function initialize() {
40 authExtHost = new cr.login.GaiaAuthHost('signin-frame');
41 authExtHost.addEventListener('ready', onAuthReady);
43 chrome.send('initialize');
47 * Loads auth extension.
48 * @param {Object} data Parameters for auth extension.
50 function loadAuthExtension(data) {
51 authExtHost.load(data.authMode, data, onAuthCompleted);
52 $('contents').classList.toggle('loading', true);
56 * Closes the inline login dialog.
58 function closeDialog() {
59 chrome.send('DialogClose', ['']);
63 * Invoked when failed to get oauth2 refresh token.
65 function handleOAuth2TokenFailure() {
66 // TODO(xiyuan): Show an error UI.
68 $('contents').classList.toggle('loading', true);
72 initialize: initialize,
73 loadAuthExtension: loadAuthExtension,
74 closeDialog: closeDialog,
75 handleOAuth2TokenFailure: handleOAuth2TokenFailure
79 document.addEventListener('DOMContentLoaded', inline.login.initialize);