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 /** @type {remoting.HostSession} */ remoting.hostSession = null; | 10 /** @type {remoting.HostSession} */ remoting.hostSession = null; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 document.getElementById('session-toolbar')); | 46 document.getElementById('session-toolbar')); |
47 | 47 |
48 refreshEmail_(); | 48 refreshEmail_(); |
49 var email = remoting.oauth2.getCachedEmail(); | 49 var email = remoting.oauth2.getCachedEmail(); |
50 if (email) { | 50 if (email) { |
51 document.getElementById('current-email').innerText = email; | 51 document.getElementById('current-email').innerText = email; |
52 } | 52 } |
53 | 53 |
54 window.addEventListener('blur', pluginLostFocus_, false); | 54 window.addEventListener('blur', pluginLostFocus_, false); |
55 | 55 |
| 56 if (isHostModeSupported_()) { |
| 57 var noShare = document.getElementById('chrome-os-no-share'); |
| 58 noShare.parentNode.removeChild(noShare); |
| 59 } else { |
| 60 var button = document.getElementById('share-button'); |
| 61 button.disabled = true; |
| 62 } |
| 63 |
56 // Parse URL parameters. | 64 // Parse URL parameters. |
57 var urlParams = getUrlParameters_(); | 65 var urlParams = getUrlParameters_(); |
58 if ('mode' in urlParams) { | 66 if ('mode' in urlParams) { |
59 if (urlParams['mode'] == 'me2me') { | 67 if (urlParams['mode'] == 'me2me') { |
60 var hostId = urlParams['hostId']; | 68 var hostId = urlParams['hostId']; |
61 remoting.connectMe2Me(hostId, true); | 69 remoting.connectMe2Me(hostId, true); |
62 return; | 70 return; |
63 } | 71 } |
64 } | 72 } |
65 | 73 |
66 // No valid URL parameters, start up normally. | 74 // No valid URL parameters, start up normally. |
| 75 remoting.initDaemonUi(); |
| 76 }; |
| 77 |
| 78 // initDaemonUi is called if the app is not starting up in session mode, and |
| 79 // also if the user cancels the connection in session mode. |
| 80 remoting.initDaemonUi = function () { |
67 remoting.daemonPlugin = new remoting.DaemonPlugin(); | 81 remoting.daemonPlugin = new remoting.DaemonPlugin(); |
68 remoting.daemonPlugin.updateDom(); | 82 remoting.daemonPlugin.updateDom(); |
69 remoting.setMode(getAppStartupMode_()); | 83 remoting.setMode(getAppStartupMode_()); |
70 remoting.askPinDialog = new remoting.AskPinDialog(remoting.daemonPlugin); | 84 remoting.askPinDialog = new remoting.AskPinDialog(remoting.daemonPlugin); |
71 if (isHostModeSupported_()) { | |
72 var noShare = document.getElementById('chrome-os-no-share'); | |
73 noShare.parentNode.removeChild(noShare); | |
74 } else { | |
75 var button = document.getElementById('share-button'); | |
76 button.disabled = true; | |
77 } | |
78 }; | 85 }; |
79 | 86 |
80 /** | 87 /** |
81 * Log information about the current extension. | 88 * Log information about the current extension. |
82 * The extension manifest is loaded and parsed to extract this info. | 89 * The extension manifest is loaded and parsed to extract this info. |
83 */ | 90 */ |
84 remoting.logExtensionInfoAsync_ = function() { | 91 remoting.logExtensionInfoAsync_ = function() { |
85 /** @type {XMLHttpRequest} */ | 92 /** @type {XMLHttpRequest} */ |
86 var xhr = new XMLHttpRequest(); | 93 var xhr = new XMLHttpRequest(); |
87 xhr.open('GET', 'manifest.json'); | 94 xhr.open('GET', 'manifest.json'); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 */ | 207 */ |
201 function getUrlParameters_() { | 208 function getUrlParameters_() { |
202 var result = {}; | 209 var result = {}; |
203 var parts = window.location.search.substring(1).split('&'); | 210 var parts = window.location.search.substring(1).split('&'); |
204 for (var i = 0; i < parts.length; i++) { | 211 for (var i = 0; i < parts.length; i++) { |
205 var pair = parts[i].split('='); | 212 var pair = parts[i].split('='); |
206 result[pair[0]] = decodeURIComponent(pair[1]); | 213 result[pair[0]] = decodeURIComponent(pair[1]); |
207 } | 214 } |
208 return result; | 215 return result; |
209 } | 216 } |
OLD | NEW |