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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 * Initialize the application and register all event handlers. After this | 59 * Initialize the application and register all event handlers. After this |
60 * is called, the app is running and waiting for user events. | 60 * is called, the app is running and waiting for user events. |
61 * | 61 * |
62 * @return {void} Nothing. | 62 * @return {void} Nothing. |
63 */ | 63 */ |
64 remoting.DesktopRemoting.prototype.init = function() { | 64 remoting.DesktopRemoting.prototype.init = function() { |
65 remoting.initGlobalObjects(); | 65 remoting.initGlobalObjects(); |
66 remoting.initIdentity(remoting.onUserInfoAvailable); | 66 remoting.initIdentity(remoting.onUserInfoAvailable); |
67 | 67 |
68 remoting.initElementEventHandlers(); | 68 remoting.initElementEventHandlers(); |
69 remoting.initGlobalEventHandlers(); | |
70 | 69 |
71 if (base.isAppsV2()) { | 70 if (base.isAppsV2()) { |
72 remoting.fullscreen = new remoting.FullscreenAppsV2(); | |
73 remoting.windowFrame = new remoting.WindowFrame( | 71 remoting.windowFrame = new remoting.WindowFrame( |
74 document.getElementById('title-bar')); | 72 document.getElementById('title-bar')); |
75 remoting.optionsMenu = remoting.windowFrame.createOptionsMenu(); | 73 remoting.optionsMenu = remoting.windowFrame.createOptionsMenu(); |
| 74 |
| 75 var START_FULLSCREEN = 'start-fullscreen'; |
| 76 remoting.fullscreen = new remoting.FullscreenAppsV2(); |
| 77 remoting.fullscreen.addListener(function(isFullscreen) { |
| 78 chrome.storage.local.set({START_FULLSCREEN: isFullscreen}); |
| 79 }); |
| 80 // TODO(jamiewalch): This should be handled by the background page when the |
| 81 // window is created, but due to crbug.com/51587 it needs to be done here. |
| 82 // Remove this hack once that bug is fixed. |
| 83 chrome.storage.local.get( |
| 84 START_FULLSCREEN, |
| 85 /** @param {Object} values */ |
| 86 function(values) { |
| 87 if (values[START_FULLSCREEN]) { |
| 88 remoting.fullscreen.activate(true); |
| 89 } |
| 90 } |
| 91 ); |
| 92 |
76 } else { | 93 } else { |
77 remoting.fullscreen = new remoting.FullscreenAppsV1(); | 94 remoting.fullscreen = new remoting.FullscreenAppsV1(); |
78 remoting.toolbar = new remoting.Toolbar( | 95 remoting.toolbar = new remoting.Toolbar( |
79 document.getElementById('session-toolbar')); | 96 document.getElementById('session-toolbar')); |
80 remoting.optionsMenu = remoting.toolbar.createOptionsMenu(); | 97 remoting.optionsMenu = remoting.toolbar.createOptionsMenu(); |
| 98 |
| 99 window.addEventListener('beforeunload', remoting.promptClose, false); |
| 100 window.addEventListener('unload', remoting.disconnect, false); |
81 } | 101 } |
82 | 102 |
| 103 // When a window goes full-screen, a resize event is triggered, but the |
| 104 // Fullscreen.isActive call is not guaranteed to return true until the |
| 105 // full-screen event is triggered. In apps v2, the size of the window's |
| 106 // client area is calculated differently in full-screen mode, so register |
| 107 // for both events. |
| 108 window.addEventListener('resize', remoting.onResize, false); |
| 109 remoting.fullscreen.addListener(remoting.onResize); |
| 110 |
83 remoting.initHostlist_(); | 111 remoting.initHostlist_(); |
84 | 112 |
85 var homeFeedback = new remoting.MenuButton( | 113 var homeFeedback = new remoting.MenuButton( |
86 document.getElementById('help-feedback-main')); | 114 document.getElementById('help-feedback-main')); |
87 var toolbarFeedback = new remoting.MenuButton( | 115 var toolbarFeedback = new remoting.MenuButton( |
88 document.getElementById('help-feedback-toolbar')); | 116 document.getElementById('help-feedback-toolbar')); |
89 remoting.manageHelpAndFeedback( | 117 remoting.manageHelpAndFeedback( |
90 document.getElementById('title-bar')); | 118 document.getElementById('title-bar')); |
91 remoting.manageHelpAndFeedback( | 119 remoting.manageHelpAndFeedback( |
92 document.getElementById('help-feedback-toolbar')); | 120 document.getElementById('help-feedback-toolbar')); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 if (mode == remoting.ClientSession.Mode.IT2ME) { | 317 if (mode == remoting.ClientSession.Mode.IT2ME) { |
290 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME); | 318 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME); |
291 remoting.hangoutSessionEvents.raiseEvent( | 319 remoting.hangoutSessionEvents.raiseEvent( |
292 remoting.hangoutSessionEvents.sessionStateChanged, | 320 remoting.hangoutSessionEvents.sessionStateChanged, |
293 remoting.ClientSession.State.FAILED | 321 remoting.ClientSession.State.FAILED |
294 ); | 322 ); |
295 } else { | 323 } else { |
296 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); | 324 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); |
297 } | 325 } |
298 }; | 326 }; |
OLD | NEW |