| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * Entry point for app initialization. | 45 * Entry point for app initialization. |
| 46 */ | 46 */ |
| 47 remoting.init = function() { | 47 remoting.init = function() { |
| 48 // TODO(jamiewalch): Remove this when we migrate to apps v2 | 48 // TODO(jamiewalch): Remove this when we migrate to apps v2 |
| 49 // (http://crbug.com/ 134213). | 49 // (http://crbug.com/ 134213). |
| 50 remoting.initMockStorage(); | 50 remoting.initMockStorage(); |
| 51 | 51 |
| 52 remoting.logExtensionInfoAsync_(); | 52 remoting.logExtensionInfo_(); |
| 53 l10n.localize(); | 53 l10n.localize(); |
| 54 // Create global objects. | 54 // Create global objects. |
| 55 remoting.settings = new remoting.Settings(); | 55 remoting.settings = new remoting.Settings(); |
| 56 remoting.oauth2 = new remoting.OAuth2(); | 56 remoting.oauth2 = new remoting.OAuth2(); |
| 57 // TODO(jamiewalch): Reinstate this when we migrate to apps v2 | 57 // TODO(jamiewalch): Reinstate this when we migrate to apps v2 |
| 58 // (http://crbug.com/ 134213). | 58 // (http://crbug.com/ 134213). |
| 59 // remoting.identity = new remoting.Identity(consentRequired_); | 59 // remoting.identity = new remoting.Identity(consentRequired_); |
| 60 remoting.identity = remoting.oauth2; | 60 remoting.identity = remoting.oauth2; |
| 61 remoting.stats = new remoting.ConnectionStats( | 61 remoting.stats = new remoting.ConnectionStats( |
| 62 document.getElementById('statistics')); | 62 document.getElementById('statistics')); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 */ | 159 */ |
| 160 var onHostState = function(state, localHostId) { | 160 var onHostState = function(state, localHostId) { |
| 161 remoting.hostList.setLocalHostStateAndId(state, localHostId); | 161 remoting.hostList.setLocalHostStateAndId(state, localHostId); |
| 162 remoting.hostList.display(); | 162 remoting.hostList.display(); |
| 163 }; | 163 }; |
| 164 remoting.hostController.getLocalHostStateAndId(onHostState); | 164 remoting.hostController.getLocalHostStateAndId(onHostState); |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 /** | 167 /** |
| 168 * Log information about the current extension. | 168 * Log information about the current extension. |
| 169 * The extension manifest is loaded and parsed to extract this info. | 169 * The extension manifest is parsed to extract this info. |
| 170 */ | 170 */ |
| 171 remoting.logExtensionInfoAsync_ = function() { | 171 remoting.logExtensionInfo_ = function() { |
| 172 /** @type {XMLHttpRequest} */ | 172 var manifest = chrome.runtime.getManifest(); |
| 173 var xhr = new XMLHttpRequest(); | 173 if (manifest && manifest.version) { |
| 174 xhr.open('GET', 'manifest.json'); | 174 var name = chrome.i18n.getMessage('PRODUCT_NAME'); |
| 175 xhr.onload = function(e) { | 175 console.log(name + ' version: ' + manifest.version); |
| 176 var manifest = | 176 } else { |
| 177 /** @type {{name: string, version: string, default_locale: string}} */ | 177 console.error('Failed to get product version. Corrupt manifest?'); |
| 178 jsonParseSafe(xhr.responseText); | |
| 179 if (manifest) { | |
| 180 var name = chrome.i18n.getMessage('PRODUCT_NAME'); | |
| 181 console.log(name + ' version: ' + manifest.version); | |
| 182 } else { | |
| 183 console.error('Failed to get product version. Corrupt manifest?'); | |
| 184 } | |
| 185 } | 178 } |
| 186 xhr.send(null); | |
| 187 }; | 179 }; |
| 188 | 180 |
| 189 /** | 181 /** |
| 190 * If an IT2Me client or host is active then prompt the user before closing. | 182 * If an IT2Me client or host is active then prompt the user before closing. |
| 191 * If a Me2Me client is active then don't bother, since closing the window is | 183 * If a Me2Me client is active then don't bother, since closing the window is |
| 192 * the more intuitive way to end a Me2Me session, and re-connecting is easy. | 184 * the more intuitive way to end a Me2Me session, and re-connecting is easy. |
| 193 * | 185 * |
| 194 * @return {?string} The prompt string if a connection is active. | 186 * @return {?string} The prompt string if a connection is active. |
| 195 */ | 187 */ |
| 196 remoting.promptClose = function() { | 188 remoting.promptClose = function() { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 /** @param {chrome.Tab} tab The current tab. */ | 360 /** @param {chrome.Tab} tab The current tab. */ |
| 369 var tabCallback = function(tab) { | 361 var tabCallback = function(tab) { |
| 370 if (tab.pinned) { | 362 if (tab.pinned) { |
| 371 callback(remoting.TabType.PINNED); | 363 callback(remoting.TabType.PINNED); |
| 372 } else { | 364 } else { |
| 373 chrome.windows.get(tab.windowId, null, windowCallback); | 365 chrome.windows.get(tab.windowId, null, windowCallback); |
| 374 } | 366 } |
| 375 }; | 367 }; |
| 376 chrome.tabs.getCurrent(tabCallback); | 368 chrome.tabs.getCurrent(tabCallback); |
| 377 } | 369 } |
| OLD | NEW |