| OLD | NEW |
| 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
| 8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
| 9 | 9 |
| 10 function onLoad() { | 10 remoting.initEventHandlers = function() { |
| 11 var goHome = function() { | 11 var goHome = function() { |
| 12 remoting.setMode(remoting.AppMode.HOME); | 12 remoting.setMode(remoting.AppMode.HOME); |
| 13 }; | 13 }; |
| 14 var goEnterAccessCode = function() { | 14 var goEnterAccessCode = function() { |
| 15 // We don't need a token until we authenticate, but asking for one here | 15 // We don't need a token until we authenticate, but asking for one here |
| 16 // handles the token-expired case earlier, avoiding asking the user for | 16 // handles the token-expired case earlier, avoiding asking the user for |
| 17 // the access code both before and after re-authentication. | 17 // the access code both before and after re-authentication. |
| 18 remoting.identity.callWithToken( | 18 remoting.identity.callWithToken( |
| 19 /** @param {string} token */ | 19 /** @param {string} token */ |
| 20 function(token) { | 20 function(token) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 { event: 'click', id: 'auth-button', fn: doAuthRedirect }, | 108 { event: 'click', id: 'auth-button', fn: doAuthRedirect }, |
| 109 { event: 'click', id: 'cancel-connect-button', fn: goHome }, | 109 { event: 'click', id: 'cancel-connect-button', fn: goHome }, |
| 110 { event: 'click', id: 'sign-out', fn:remoting.signOut }, | 110 { event: 'click', id: 'sign-out', fn:remoting.signOut }, |
| 111 { event: 'click', id: 'token-refresh-error-ok', fn: goHome }, | 111 { event: 'click', id: 'token-refresh-error-ok', fn: goHome }, |
| 112 { event: 'click', id: 'token-refresh-error-sign-in', fn: fixAuthError } | 112 { event: 'click', id: 'token-refresh-error-sign-in', fn: fixAuthError } |
| 113 ]; | 113 ]; |
| 114 registerEventListeners(it2me_actions); | 114 registerEventListeners(it2me_actions); |
| 115 registerEventListeners(me2me_actions); | 115 registerEventListeners(me2me_actions); |
| 116 registerEventListeners(host_actions); | 116 registerEventListeners(host_actions); |
| 117 registerEventListeners(auth_actions); | 117 registerEventListeners(auth_actions); |
| 118 remoting.init(); | |
| 119 | 118 |
| 120 window.addEventListener('resize', remoting.onResize, false); | 119 window.addEventListener('resize', remoting.onResize, false); |
| 121 // When a window goes full-screen, a resize event is triggered, but the | 120 // When a window goes full-screen, a resize event is triggered, but the |
| 122 // Fullscreen.isActive call is not guaranteed to return true until the | 121 // Fullscreen.isActive call is not guaranteed to return true until the |
| 123 // full-screen event is triggered. In apps v2, the size of the window's | 122 // full-screen event is triggered. In apps v2, the size of the window's |
| 124 // client area is calculated differently in full-screen mode, so register | 123 // client area is calculated differently in full-screen mode, so register |
| 125 // for both events. | 124 // for both events. |
| 126 remoting.fullscreen.addListener(remoting.onResize); | 125 remoting.fullscreen.addListener(remoting.onResize); |
| 127 if (!base.isAppsV2()) { | 126 if (!base.isAppsV2()) { |
| 128 window.addEventListener('beforeunload', remoting.promptClose, false); | 127 window.addEventListener('beforeunload', remoting.promptClose, false); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 150 function registerEventListener(id, eventname, fn) { | 149 function registerEventListener(id, eventname, fn) { |
| 151 var element = document.getElementById(id); | 150 var element = document.getElementById(id); |
| 152 if (element) { | 151 if (element) { |
| 153 element.addEventListener(eventname, fn, false); | 152 element.addEventListener(eventname, fn, false); |
| 154 } else { | 153 } else { |
| 155 console.error('Could not set ' + eventname + | 154 console.error('Could not set ' + eventname + |
| 156 ' event handler on element ' + id + | 155 ' event handler on element ' + id + |
| 157 ': element not found.'); | 156 ': element not found.'); |
| 158 } | 157 } |
| 159 } | 158 } |
| 160 | |
| 161 window.addEventListener('load', onLoad, false); | |
| OLD | NEW |