Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / resources / inline_login / inline_login.js
blob44dc44bd0327bdbb4f415f410167a197e363596f
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.
5 /**
6 * @fileoverview Inline login UI.
7 */
9 <include src="../gaia_auth_host/gaia_auth_host.js"></include>
11 cr.define('inline.login', function() {
12 'use strict';
14 /**
15 * The auth extension host instance.
16 * @type {Object}
18 var authExtHost;
20 /**
21 * Whether the auth ready event has been fired, for testing purpose.
23 var authReadyFired;
25 /**
26 * Handler of auth host 'ready' event.
28 function onAuthReady() {
29 $('contents').classList.toggle('loading', false);
30 authReadyFired = true;
33 /**
34 * Handler of auth host 'completed' event.
35 * @param {!Object} credentials Credentials of the completed authentication.
37 function onAuthCompleted(credentials) {
38 chrome.send('completeLogin', [credentials]);
39 $('contents').classList.toggle('loading', true);
42 /**
43 * Initialize the UI.
45 function initialize() {
46 authExtHost = new cr.login.GaiaAuthHost('signin-frame');
47 authExtHost.addEventListener('ready', onAuthReady);
49 chrome.send('initialize');
52 /**
53 * Loads auth extension.
54 * @param {Object} data Parameters for auth extension.
56 function loadAuthExtension(data) {
57 authExtHost.load(data.authMode, data, onAuthCompleted);
58 $('contents').classList.toggle('loading',
59 data.authMode != cr.login.GaiaAuthHost.AuthMode.DESKTOP);
62 /**
63 * Closes the inline login dialog.
65 function closeDialog() {
66 chrome.send('dialogClose', ['']);
69 /**
70 * Invoked when failed to get oauth2 refresh token.
72 function handleOAuth2TokenFailure() {
73 // TODO(xiyuan): Show an error UI.
74 authExtHost.reload();
75 $('contents').classList.toggle('loading', true);
78 /**
79 * Returns the auth host instance, for testing purpose.
81 function getAuthExtHost() {
82 return authExtHost;
85 /**
86 * Returns whether the auth UI is ready, for testing purpose.
88 function isAuthReady() {
89 return authReadyFired;
92 return {
93 getAuthExtHost: getAuthExtHost,
94 isAuthReady: isAuthReady,
95 initialize: initialize,
96 loadAuthExtension: loadAuthExtension,
97 closeDialog: closeDialog,
98 handleOAuth2TokenFailure: handleOAuth2TokenFailure
102 document.addEventListener('DOMContentLoaded', inline.login.initialize);