| OLD | NEW |
| 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
| 8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
| 9 | 9 |
| 10 remoting.initElementEventHandlers = function() { | 10 remoting.initElementEventHandlers = function() { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 }; | 31 }; |
| 32 /** @param {Event} event The event. */ | 32 /** @param {Event} event The event. */ |
| 33 var sendAccessCode = function(event) { | 33 var sendAccessCode = function(event) { |
| 34 remoting.connectIT2Me(); | 34 remoting.connectIT2Me(); |
| 35 event.preventDefault(); | 35 event.preventDefault(); |
| 36 }; | 36 }; |
| 37 var reconnect = function() { | 37 var reconnect = function() { |
| 38 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); | 38 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); |
| 39 remoting.app.getSessionConnector().reconnect(); | 39 remoting.app.getSessionConnector().reconnect(); |
| 40 }; | 40 }; |
| 41 var doAuthRedirect = function() { | |
| 42 if (!base.isAppsV2()) { | |
| 43 remoting.oauth2.doAuthRedirect(function() { | |
| 44 window.location.reload(); | |
| 45 }); | |
| 46 } | |
| 47 }; | |
| 48 var fixAuthError = function() { | |
| 49 if (base.isAppsV2()) { | |
| 50 var onRefresh = function() { | |
| 51 remoting.hostList.display(); | |
| 52 }; | |
| 53 var refreshHostList = function() { | |
| 54 goHome(); | |
| 55 remoting.hostList.refresh(onRefresh); | |
| 56 }; | |
| 57 remoting.identity.removeCachedAuthToken(refreshHostList); | |
| 58 } else { | |
| 59 doAuthRedirect(); | |
| 60 } | |
| 61 }; | |
| 62 /** @param {Event} event The event. */ | 41 /** @param {Event} event The event. */ |
| 63 var stopDaemon = function(event) { | 42 var stopDaemon = function(event) { |
| 64 remoting.hostSetupDialog.showForStop(); | 43 remoting.hostSetupDialog.showForStop(); |
| 65 event.stopPropagation(); | 44 event.stopPropagation(); |
| 66 }; | 45 }; |
| 67 var cancelAccessCode = function() { | 46 var cancelAccessCode = function() { |
| 68 remoting.setMode(remoting.AppMode.HOME); | 47 remoting.setMode(remoting.AppMode.HOME); |
| 69 document.getElementById('access-code-entry').value = ''; | 48 document.getElementById('access-code-entry').value = ''; |
| 70 }; | 49 }; |
| 71 /** @type {Array.<{event: string, id: string, fn: function(Event):void}>} */ | 50 /** @type {Array.<{event: string, id: string, fn: function(Event):void}>} */ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 98 { event: 'click', id: 'close-paired-client-manager-dialog', fn: goHome }, | 77 { event: 'click', id: 'close-paired-client-manager-dialog', fn: goHome }, |
| 99 { event: 'click', id: 'host-config-done-dismiss', fn: goHome }, | 78 { event: 'click', id: 'host-config-done-dismiss', fn: goHome }, |
| 100 { event: 'click', id: 'host-config-error-dismiss', fn: goHome }, | 79 { event: 'click', id: 'host-config-error-dismiss', fn: goHome }, |
| 101 { event: 'click', id: 'open-paired-client-manager-dialog', | 80 { event: 'click', id: 'open-paired-client-manager-dialog', |
| 102 fn: remoting.setMode.bind(null, | 81 fn: remoting.setMode.bind(null, |
| 103 remoting.AppMode.HOME_MANAGE_PAIRINGS) }, | 82 remoting.AppMode.HOME_MANAGE_PAIRINGS) }, |
| 104 { event: 'click', id: 'stop-sharing-button', fn: remoting.cancelShare } | 83 { event: 'click', id: 'stop-sharing-button', fn: remoting.cancelShare } |
| 105 ]; | 84 ]; |
| 106 /** @type {Array.<{event: string, id: string, fn: function(Event):void}>} */ | 85 /** @type {Array.<{event: string, id: string, fn: function(Event):void}>} */ |
| 107 var auth_actions = [ | 86 var auth_actions = [ |
| 108 { event: 'click', id: 'auth-button', fn: doAuthRedirect }, | |
| 109 { event: 'click', id: 'cancel-connect-button', fn: goHome }, | 87 { event: 'click', id: 'cancel-connect-button', fn: goHome }, |
| 110 { event: 'click', id: 'sign-out', fn:remoting.signOut }, | 88 { event: 'click', id: 'sign-out', fn:remoting.signOut }, |
| 111 { event: 'click', id: 'token-refresh-error-ok', fn: goHome }, | 89 { event: 'click', id: 'token-refresh-error-ok', fn: goHome }, |
| 112 { event: 'click', id: 'token-refresh-error-sign-in', fn: fixAuthError } | 90 { event: 'click', id: 'token-refresh-error-sign-in', |
| 91 fn: remoting.handleAuthFailureAndRelaunch } |
| 113 ]; | 92 ]; |
| 114 registerEventListeners(it2me_actions); | 93 registerEventListeners(it2me_actions); |
| 115 registerEventListeners(me2me_actions); | 94 registerEventListeners(me2me_actions); |
| 116 registerEventListeners(host_actions); | 95 registerEventListeners(host_actions); |
| 117 registerEventListeners(auth_actions); | 96 registerEventListeners(auth_actions); |
| 118 } | 97 } |
| OLD | NEW |