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 * Full-screen implementation for apps v2, using chrome.AppWindow. | 7 * Full-screen implementation for apps v2, using chrome.AppWindow. |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 remoting.FullscreenAppsV2.prototype.addListener = function(callback) { | 87 remoting.FullscreenAppsV2.prototype.addListener = function(callback) { |
88 this.eventSource_.addEventListener(this.kEventName_, callback); | 88 this.eventSource_.addEventListener(this.kEventName_, callback); |
89 }; | 89 }; |
90 | 90 |
91 remoting.FullscreenAppsV2.prototype.removeListener = function(callback) { | 91 remoting.FullscreenAppsV2.prototype.removeListener = function(callback) { |
92 this.eventSource_.removeEventListener(this.kEventName_, callback); | 92 this.eventSource_.removeEventListener(this.kEventName_, callback); |
93 }; | 93 }; |
94 | 94 |
95 remoting.FullscreenAppsV2.prototype.syncWithMaximize = function(sync) { | 95 remoting.FullscreenAppsV2.prototype.syncWithMaximize = function(sync) { |
96 if (sync && chrome.app.window.current().isMaximized()) { | 96 if (sync && chrome.app.window.current().isMaximized()) { |
| 97 chrome.app.window.current().restore(); |
97 this.activate(true); | 98 this.activate(true); |
98 } | 99 } |
99 this.hookingWindowEvents_ = sync; | 100 this.hookingWindowEvents_ = sync; |
100 }; | 101 }; |
101 | 102 |
102 remoting.FullscreenAppsV2.prototype.onFullscreened_ = function() { | 103 remoting.FullscreenAppsV2.prototype.onFullscreened_ = function() { |
103 this.notifyCallbacksOnRestore_ = true; | 104 this.notifyCallbacksOnRestore_ = true; |
104 this.eventSource_.raiseEvent(this.kEventName_, true); | 105 this.eventSource_.raiseEvent(this.kEventName_, true); |
105 document.body.classList.add('fullscreen'); | 106 document.body.classList.add('fullscreen'); |
106 }; | 107 }; |
107 | 108 |
108 remoting.FullscreenAppsV2.prototype.onMaximized_ = function() { | 109 remoting.FullscreenAppsV2.prototype.onMaximized_ = function() { |
109 if (this.hookingWindowEvents_) { | 110 if (this.hookingWindowEvents_) { |
| 111 chrome.app.window.current().restore(); |
110 this.activate(true); | 112 this.activate(true); |
111 } | 113 } |
112 }; | 114 }; |
113 | 115 |
114 remoting.FullscreenAppsV2.prototype.onRestored_ = function() { | 116 remoting.FullscreenAppsV2.prototype.onRestored_ = function() { |
| 117 // TODO(jamiewalch): ChromeOS generates a spurious onRestore event if |
| 118 // fullscreen() is called from an onMaximized handler (crbug.com/394819), |
| 119 // so ignore the callback if the window is still full-screen. |
| 120 if (this.isActive()) { |
| 121 return; |
| 122 } |
| 123 |
115 document.body.classList.remove('fullscreen'); | 124 document.body.classList.remove('fullscreen'); |
116 if (this.hookingWindowEvents_) { | 125 if (this.hookingWindowEvents_) { |
117 this.activate(false); | 126 this.activate(false); |
118 } | 127 } |
119 if (this.notifyCallbacksOnRestore_) { | 128 if (this.notifyCallbacksOnRestore_) { |
120 this.notifyCallbacksOnRestore_ = false; | 129 this.notifyCallbacksOnRestore_ = false; |
121 this.eventSource_.raiseEvent(this.kEventName_, false); | 130 this.eventSource_.raiseEvent(this.kEventName_, false); |
122 } | 131 } |
123 }; | 132 }; |
OLD | NEW |