| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 Inline login UI. | 6 * @fileoverview Inline login UI. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 cr.define('inline.login', function() { | 9 cr.define('inline.login', function() { |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 function onResize(e) { | 23 function onResize(e) { |
| 24 chrome.send('switchToFullTab', [e.detail]); | 24 chrome.send('switchToFullTab', [e.detail]); |
| 25 } | 25 } |
| 26 | 26 |
| 27 function onAuthReady(e) { | 27 function onAuthReady(e) { |
| 28 $('contents').classList.toggle('loading', false); | 28 $('contents').classList.toggle('loading', false); |
| 29 authReadyFired = true; | 29 authReadyFired = true; |
| 30 } | 30 } |
| 31 | 31 |
| 32 function onDropLink(e) { |
| 33 // Navigate to the dropped link. |
| 34 window.location.href = e.detail; |
| 35 } |
| 36 |
| 32 function onNewWindow(e) { | 37 function onNewWindow(e) { |
| 33 window.open(e.detail.targetUrl, '_blank'); | 38 window.open(e.detail.targetUrl, '_blank'); |
| 34 e.detail.window.discard(); | 39 e.detail.window.discard(); |
| 35 } | 40 } |
| 36 | 41 |
| 37 function onAuthCompleted(e) { | 42 function onAuthCompleted(e) { |
| 38 completeLogin(e.detail); | 43 completeLogin(e.detail); |
| 39 } | 44 } |
| 40 | 45 |
| 41 function completeLogin(credentials) { | 46 function completeLogin(credentials) { |
| 42 chrome.send('completeLogin', [credentials]); | 47 chrome.send('completeLogin', [credentials]); |
| 43 $('contents').classList.toggle('loading', true); | 48 $('contents').classList.toggle('loading', true); |
| 44 } | 49 } |
| 45 | 50 |
| 46 /** | 51 /** |
| 47 * Initialize the UI. | 52 * Initialize the UI. |
| 48 */ | 53 */ |
| 49 function initialize() { | 54 function initialize() { |
| 50 authExtHost = new cr.login.GaiaAuthHost('signin-frame'); | 55 authExtHost = new cr.login.GaiaAuthHost('signin-frame'); |
| 56 authExtHost.addEventListener('dropLink', onDropLink); |
| 51 authExtHost.addEventListener('ready', onAuthReady); | 57 authExtHost.addEventListener('ready', onAuthReady); |
| 52 authExtHost.addEventListener('newWindow', onNewWindow); | 58 authExtHost.addEventListener('newWindow', onNewWindow); |
| 53 authExtHost.addEventListener('resize', onResize); | 59 authExtHost.addEventListener('resize', onResize); |
| 54 authExtHost.addEventListener('authCompleted', onAuthCompleted); | 60 authExtHost.addEventListener('authCompleted', onAuthCompleted); |
| 55 chrome.send('initialize'); | 61 chrome.send('initialize'); |
| 56 } | 62 } |
| 57 | 63 |
| 58 /** | 64 /** |
| 59 * Loads auth extension. | 65 * Loads auth extension. |
| 60 * @param {Object} data Parameters for auth extension. | 66 * @param {Object} data Parameters for auth extension. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 getAuthExtHost: getAuthExtHost, | 108 getAuthExtHost: getAuthExtHost, |
| 103 isAuthReady: isAuthReady, | 109 isAuthReady: isAuthReady, |
| 104 initialize: initialize, | 110 initialize: initialize, |
| 105 loadAuthExtension: loadAuthExtension, | 111 loadAuthExtension: loadAuthExtension, |
| 106 closeDialog: closeDialog, | 112 closeDialog: closeDialog, |
| 107 handleOAuth2TokenFailure: handleOAuth2TokenFailure | 113 handleOAuth2TokenFailure: handleOAuth2TokenFailure |
| 108 }; | 114 }; |
| 109 }); | 115 }); |
| 110 | 116 |
| 111 document.addEventListener('DOMContentLoaded', inline.login.initialize); | 117 document.addEventListener('DOMContentLoaded', inline.login.initialize); |
| OLD | NEW |