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
3 // found in the LICENSE file.
7 /** @suppress {duplicate} */
8 var remoting
= remoting
|| {};
10 remoting
.initElementEventHandlers = function() {
11 var goHome = function() {
12 remoting
.setMode(remoting
.AppMode
.HOME
);
14 var goFinishedIT2Me = function() {
15 if (remoting
.currentMode
== remoting
.AppMode
.CLIENT_CONNECT_FAILED_IT2ME
) {
16 remoting
.setMode(remoting
.AppMode
.CLIENT_UNCONNECTED
);
21 /** @type {Array<{event: string, id: string, fn: function(Event):void}>} */
23 { event
: 'click', id
: 'cancel-share-button', fn
: remoting
.cancelShare
},
24 { event
: 'click', id
: 'get-started-it2me',
25 fn
: remoting
.showIT2MeUiAndSave
},
26 { event
: 'click', id
: 'host-finished-button', fn
: goHome
},
27 { event
: 'click', id
: 'share-button', fn
: remoting
.tryShare
}
29 /** @type {Array<{event: string, id: string, fn: function(Event):void}>} */
31 { event
: 'click', id
: 'daemon-pin-cancel', fn
: goHome
},
32 { event
: 'click', id
: 'get-started-me2me',
33 fn
: remoting
.showMe2MeUiAndSave
}
35 /** @type {Array<{event: string, id: string, fn: function(Event):void}>} */
37 { event
: 'click', id
: 'close-paired-client-manager-dialog', fn
: goHome
},
38 { event
: 'click', id
: 'host-config-done-dismiss', fn
: goHome
},
39 { event
: 'click', id
: 'host-config-error-dismiss', fn
: goHome
},
40 { event
: 'click', id
: 'open-paired-client-manager-dialog',
41 fn
: remoting
.setMode
.bind(null,
42 remoting
.AppMode
.HOME_MANAGE_PAIRINGS
) },
43 { event
: 'click', id
: 'stop-sharing-button', fn
: remoting
.cancelShare
}
45 /** @type {Array<{event: string, id: string, fn: function(Event):void}>} */
47 { event
: 'click', id
: 'cancel-connect-button', fn
: goHome
},
48 { event
: 'click', id
: 'sign-out', fn
:remoting
.signOut
},
49 { event
: 'click', id
: 'token-refresh-error-ok', fn
: goHome
},
50 { event
: 'click', id
: 'token-refresh-error-sign-in',
51 fn
: remoting
.handleAuthFailureAndRelaunch
}
53 registerEventListeners(it2me_actions
);
54 registerEventListeners(me2me_actions
);
55 registerEventListeners(host_actions
);
56 registerEventListeners(auth_actions
);
60 * Sign the user out of Chromoting by clearing (and revoking, if possible) the
61 * OAuth refresh token.
63 * Also clear all local storage, to avoid leaking information.
65 remoting
.signOut = function() {
66 remoting
.oauth2
.removeCachedAuthToken().then(function(){
67 chrome
.storage
.local
.clear();
68 remoting
.setMode(remoting
.AppMode
.HOME
);
69 window
.location
.reload();