| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 /** | 5 /** | 
| 6  * @fileoverview | 6  * @fileoverview | 
| 7  * This class implements the functionality that is specific to desktop | 7  * This class implements the functionality that is specific to desktop | 
| 8  * remoting ("Chromoting" or CRD). | 8  * remoting ("Chromoting" or CRD). | 
| 9  */ | 9  */ | 
| 10 | 10 | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 74           } | 74           } | 
| 75         } | 75         } | 
| 76     ); | 76     ); | 
| 77 | 77 | 
| 78   } else { | 78   } else { | 
| 79     remoting.fullscreen = new remoting.FullscreenAppsV1(); | 79     remoting.fullscreen = new remoting.FullscreenAppsV1(); | 
| 80     remoting.toolbar = new remoting.Toolbar( | 80     remoting.toolbar = new remoting.Toolbar( | 
| 81         document.getElementById('session-toolbar')); | 81         document.getElementById('session-toolbar')); | 
| 82     remoting.optionsMenu = remoting.toolbar.createOptionsMenu(); | 82     remoting.optionsMenu = remoting.toolbar.createOptionsMenu(); | 
| 83 | 83 | 
| 84     window.addEventListener('beforeunload', remoting.promptClose, false); | 84     window.addEventListener('beforeunload', | 
|  | 85                             this.promptClose_.bind(this), false); | 
| 85     window.addEventListener('unload', | 86     window.addEventListener('unload', | 
| 86                             remoting.app.disconnect.bind(remoting.app), false); | 87                             remoting.app.disconnect.bind(remoting.app), false); | 
| 87   } | 88   } | 
| 88 | 89 | 
| 89   remoting.initHostlist_(); | 90   remoting.initHostlist_(); | 
| 90 | 91 | 
| 91   var homeFeedback = new remoting.MenuButton( | 92   var homeFeedback = new remoting.MenuButton( | 
| 92       document.getElementById('help-feedback-main')); | 93       document.getElementById('help-feedback-main')); | 
| 93   var toolbarFeedback = new remoting.MenuButton( | 94   var toolbarFeedback = new remoting.MenuButton( | 
| 94       document.getElementById('help-feedback-toolbar')); | 95       document.getElementById('help-feedback-toolbar')); | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 107   // For Apps v1, check the tab type to warn the user if they are not getting | 108   // For Apps v1, check the tab type to warn the user if they are not getting | 
| 108   // the best keyboard experience. | 109   // the best keyboard experience. | 
| 109   if (!base.isAppsV2() && !remoting.platformIsMac()) { | 110   if (!base.isAppsV2() && !remoting.platformIsMac()) { | 
| 110     /** @param {boolean} isWindowed */ | 111     /** @param {boolean} isWindowed */ | 
| 111     var onIsWindowed = function(isWindowed) { | 112     var onIsWindowed = function(isWindowed) { | 
| 112       if (!isWindowed) { | 113       if (!isWindowed) { | 
| 113         document.getElementById('startup-mode-box-me2me').hidden = false; | 114         document.getElementById('startup-mode-box-me2me').hidden = false; | 
| 114         document.getElementById('startup-mode-box-it2me').hidden = false; | 115         document.getElementById('startup-mode-box-it2me').hidden = false; | 
| 115       } | 116       } | 
| 116     }; | 117     }; | 
| 117     isWindowed_(onIsWindowed); | 118     this.isWindowed_(onIsWindowed); | 
| 118   } | 119   } | 
| 119 | 120 | 
| 120   remoting.ClientPlugin.factory.preloadPlugin(); | 121   remoting.ClientPlugin.factory.preloadPlugin(); | 
| 121 }; | 122 }; | 
| 122 | 123 | 
| 123 /** | 124 /** | 
| 124  * Start the application. Once start() is called, the delegate can assume that | 125  * Start the application. Once start() is called, the delegate can assume that | 
| 125  * the user has consented to all permissions specified in the manifest. | 126  * the user has consented to all permissions specified in the manifest. | 
| 126  * | 127  * | 
| 127  * @param {remoting.SessionConnector} connector | 128  * @param {remoting.SessionConnector} connector | 
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 326     remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); | 327     remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); | 
| 327   } | 328   } | 
| 328 }; | 329 }; | 
| 329 | 330 | 
| 330 /** | 331 /** | 
| 331  * No cleanup required for desktop remoting. | 332  * No cleanup required for desktop remoting. | 
| 332  */ | 333  */ | 
| 333 remoting.DesktopRemoting.prototype.handleExit = function() { | 334 remoting.DesktopRemoting.prototype.handleExit = function() { | 
| 334 }; | 335 }; | 
| 335 | 336 | 
|  | 337 /** | 
|  | 338  * Determine whether or not the app is running in a window. | 
|  | 339  * @param {function(boolean):void} callback Callback to receive whether or not | 
|  | 340  *     the current tab is running in windowed mode. | 
|  | 341  * @private | 
|  | 342  */ | 
|  | 343 remoting.DesktopRemoting.prototype.isWindowed_ = function(callback) { | 
|  | 344   /** @param {chrome.Window} win The current window. */ | 
|  | 345   var windowCallback = function(win) { | 
|  | 346     callback(win.type == 'popup'); | 
|  | 347   }; | 
|  | 348   /** @param {chrome.Tab} tab The current tab. */ | 
|  | 349   var tabCallback = function(tab) { | 
|  | 350     if (tab.pinned) { | 
|  | 351       callback(false); | 
|  | 352     } else { | 
|  | 353       chrome.windows.get(tab.windowId, null, windowCallback); | 
|  | 354     } | 
|  | 355   }; | 
|  | 356   if (chrome.tabs) { | 
|  | 357     chrome.tabs.getCurrent(tabCallback); | 
|  | 358   } else { | 
|  | 359     console.error('chome.tabs is not available.'); | 
|  | 360   } | 
|  | 361 } | 
|  | 362 | 
|  | 363 /** | 
|  | 364  * If an IT2Me client or host is active then prompt the user before closing. | 
|  | 365  * If a Me2Me client is active then don't bother, since closing the window is | 
|  | 366  * the more intuitive way to end a Me2Me session, and re-connecting is easy. | 
|  | 367  * @private | 
|  | 368  */ | 
|  | 369 remoting.DesktopRemoting.prototype.promptClose_ = function() { | 
|  | 370   var sessionConnector = remoting.app.getSessionConnector(); | 
|  | 371   if (sessionConnector && | 
|  | 372       sessionConnector.getConnectionMode() == | 
|  | 373           remoting.DesktopConnectedView.Mode.IT2ME) { | 
|  | 374     switch (remoting.currentMode) { | 
|  | 375       case remoting.AppMode.CLIENT_CONNECTING: | 
|  | 376       case remoting.AppMode.HOST_WAITING_FOR_CODE: | 
|  | 377       case remoting.AppMode.HOST_WAITING_FOR_CONNECTION: | 
|  | 378       case remoting.AppMode.HOST_SHARED: | 
|  | 379       case remoting.AppMode.IN_SESSION: | 
|  | 380         return chrome.i18n.getMessage(/*i18n-content*/'CLOSE_PROMPT'); | 
|  | 381       default: | 
|  | 382         return null; | 
|  | 383     } | 
|  | 384   } | 
|  | 385 }; | 
|  | 386 | 
| 336 /** @returns {remoting.DesktopConnectedView} */ | 387 /** @returns {remoting.DesktopConnectedView} */ | 
| 337 remoting.DesktopRemoting.prototype.getConnectedViewForTesting = function() { | 388 remoting.DesktopRemoting.prototype.getConnectedViewForTesting = function() { | 
| 338   return this.connectedView_; | 389   return this.connectedView_; | 
| 339 }; | 390 }; | 
| 340 | 391 | 
| 341 /** | 392 /** | 
| 342  * Global instance of remoting.DesktopRemoting used for testing. | 393  * Global instance of remoting.DesktopRemoting used for testing. | 
| 343  * @type {remoting.DesktopRemoting} | 394  * @type {remoting.DesktopRemoting} | 
| 344  */ | 395  */ | 
| 345 remoting.desktopDelegateForTesting = null; | 396 remoting.desktopDelegateForTesting = null; | 
| OLD | NEW | 
|---|