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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // Parse URL parameters. | 86 // Parse URL parameters. |
87 var urlParams = getUrlParameters_(); | 87 var urlParams = getUrlParameters_(); |
88 if ('mode' in urlParams) { | 88 if ('mode' in urlParams) { |
89 if (urlParams['mode'] == 'me2me') { | 89 if (urlParams['mode'] == 'me2me') { |
90 var hostId = urlParams['hostId']; | 90 var hostId = urlParams['hostId']; |
91 remoting.connectMe2Me(hostId); | 91 remoting.connectMe2Me(hostId); |
92 return; | 92 return; |
93 } | 93 } |
94 } | 94 } |
95 // No valid URL parameters, start up normally. | 95 // No valid URL parameters, start up normally. |
96 remoting.initDaemonUi(); | 96 remoting.initHomeScreenUi(); |
97 } | 97 } |
98 remoting.hostList.load(onLoad); | 98 remoting.hostList.load(onLoad); |
99 | 99 |
100 // Show the tab-type warnings if necessary. | 100 // Show the tab-type warnings if necessary. |
101 /** @param {boolean} isWindowed */ | 101 /** @param {boolean} isWindowed */ |
102 var onIsWindowed = function(isWindowed) { | 102 var onIsWindowed = function(isWindowed) { |
103 if (!isWindowed && | 103 if (!isWindowed && |
104 navigator.platform.indexOf('Mac') == -1) { | 104 navigator.platform.indexOf('Mac') == -1) { |
105 document.getElementById('startup-mode-box-me2me').hidden = false; | 105 document.getElementById('startup-mode-box-me2me').hidden = false; |
106 document.getElementById('startup-mode-box-it2me').hidden = false; | 106 document.getElementById('startup-mode-box-it2me').hidden = false; |
107 } | 107 } |
108 }; | 108 }; |
109 isWindowed_(onIsWindowed); | 109 isWindowed_(onIsWindowed); |
110 }; | 110 }; |
111 | 111 |
112 /** | 112 /** |
113 * Display the user's email address and allow access to the rest of the app, | 113 * Display the user's email address and allow access to the rest of the app, |
114 * including parsing URL parameters. | 114 * including parsing URL parameters. |
115 * | 115 * |
116 * @param {string} email The user's email address. | 116 * @param {string} email The user's email address. |
117 * @return {void} Nothing. | 117 * @return {void} Nothing. |
118 */ | 118 */ |
119 remoting.onEmail = function(email) { | 119 remoting.onEmail = function(email) { |
120 document.getElementById('current-email').innerText = email; | 120 document.getElementById('current-email').innerText = email; |
121 document.getElementById('get-started-it2me').disabled = false; | 121 document.getElementById('get-started-it2me').disabled = false; |
122 document.getElementById('get-started-me2me').disabled = false; | 122 document.getElementById('get-started-me2me').disabled = false; |
123 }; | 123 }; |
124 | 124 |
125 /** initDaemonUi is called if the app is not starting up in session mode, and | 125 /** |
126 * also if the user cancels pin entry or the connection in session mode. */ | 126 * initHomeScreenUi is called if the app is not starting up in session mode, |
127 remoting.initDaemonUi = function() { | 127 * and also if the user cancels pin entry or the connection in session mode. |
| 128 */ |
| 129 remoting.initHomeScreenUi = function() { |
128 remoting.hostController = new remoting.HostController(); | 130 remoting.hostController = new remoting.HostController(); |
129 document.getElementById('share-button').disabled = | 131 document.getElementById('share-button').disabled = |
130 !remoting.hostController.isPluginSupported(); | 132 !remoting.hostController.isPluginSupported(); |
131 remoting.setMode(remoting.AppMode.HOME); | 133 remoting.setMode(remoting.AppMode.HOME); |
132 if (!remoting.oauth2.isAuthenticated()) { | 134 if (!remoting.oauth2.isAuthenticated()) { |
133 document.getElementById('auth-dialog').hidden = false; | 135 document.getElementById('auth-dialog').hidden = false; |
134 } | 136 } |
135 remoting.hostSetupDialog = | 137 remoting.hostSetupDialog = |
136 new remoting.HostSetupDialog(remoting.hostController); | 138 new remoting.HostSetupDialog(remoting.hostController); |
137 // Display the cached host list, then asynchronously update and re-display it. | 139 // Display the cached host list, then asynchronously update and re-display it. |
138 remoting.updateLocalHostState(); | 140 remoting.updateLocalHostState(); |
139 remoting.hostList.refresh(remoting.updateLocalHostState); | 141 remoting.hostList.refresh(remoting.updateLocalHostState); |
| 142 remoting.initSurvey(); |
140 }; | 143 }; |
141 | 144 |
142 /** | 145 /** |
143 * Fetches local host state and updates host list accordingly. | 146 * Fetches local host state and updates host list accordingly. |
144 */ | 147 */ |
145 remoting.updateLocalHostState = function() { | 148 remoting.updateLocalHostState = function() { |
146 /** | 149 /** |
147 * @param {remoting.HostController.State} state Host state. | 150 * @param {remoting.HostController.State} state Host state. |
148 * @param {string?} localHostId | 151 * @param {string?} localHostId |
149 */ | 152 */ |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 } else { | 341 } else { |
339 chrome.windows.get(tab.windowId, null, windowCallback); | 342 chrome.windows.get(tab.windowId, null, windowCallback); |
340 } | 343 } |
341 }; | 344 }; |
342 if (chrome.tabs) { | 345 if (chrome.tabs) { |
343 chrome.tabs.getCurrent(tabCallback); | 346 chrome.tabs.getCurrent(tabCallback); |
344 } else { | 347 } else { |
345 console.error('chome.tabs is not available.'); | 348 console.error('chome.tabs is not available.'); |
346 } | 349 } |
347 } | 350 } |
OLD | NEW |