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 /** @type {Array<{event: string, id: string, fn: function(Event):void}>} */
16 { event: 'click', id: 'cancel-share-button', fn: remoting.cancelShare },
17 { event: 'click', id: 'get-started-it2me',
18 fn: remoting.showIT2MeUiAndSave },
19 { event: 'click', id: 'host-finished-button', fn: goHome },
20 { event: 'click', id: 'share-button', fn: remoting.tryShare }
22 /** @type {Array<{event: string, id: string, fn: function(Event):void}>} */
24 { event: 'click', id: 'daemon-pin-cancel', fn: goHome },
25 { event: 'click', id: 'get-started-me2me',
26 fn: remoting.showMe2MeUiAndSave }
28 /** @type {Array<{event: string, id: string, fn: function(Event):void}>} */
30 { event: 'click', id: 'close-paired-client-manager-dialog', fn: goHome },
31 { event: 'click', id: 'host-config-done-dismiss', fn: goHome },
32 { event: 'click', id: 'host-config-error-dismiss', fn: goHome },
33 { event: 'click', id: 'open-paired-client-manager-dialog',
34 fn: remoting.setMode.bind(null,
35 remoting.AppMode.HOME_MANAGE_PAIRINGS) },
36 { event: 'click', id: 'stop-sharing-button', fn: remoting.cancelShare }
38 /** @type {Array<{event: string, id: string, fn: function(Event):void}>} */
40 { event: 'click', id: 'sign-out', fn:remoting.signOut },
41 { event: 'click', id: 'token-refresh-error-ok', fn: goHome },
42 { event: 'click', id: 'token-refresh-error-sign-in',
43 fn: remoting.handleAuthFailureAndRelaunch }
45 registerEventListeners(it2me_actions);
46 registerEventListeners(me2me_actions);
47 registerEventListeners(host_actions);
48 registerEventListeners(auth_actions);
52 * Sign the user out of Chromoting by clearing (and revoking, if possible) the
53 * OAuth refresh token.
55 * Also clear all local storage, to avoid leaking information.
57 remoting.signOut = function() {
58 remoting.oauth2.removeCachedAuthToken().then(function(){
59 chrome.storage.local.clear();
60 remoting.setMode(remoting.AppMode.HOME);
61 window.location.reload();