| Index: remoting/webapp/crd/js/fullscreen_v2.js
|
| diff --git a/remoting/webapp/crd/js/fullscreen_v2.js b/remoting/webapp/crd/js/fullscreen_v2.js
|
| index ea20f9000f7185ce7554154ac9890fc1bbec28dc..b07931bfec792431e592c14ce2c9844bf04e4178 100644
|
| --- a/remoting/webapp/crd/js/fullscreen_v2.js
|
| +++ b/remoting/webapp/crd/js/fullscreen_v2.js
|
| @@ -18,16 +18,24 @@ var remoting = remoting || {};
|
| */
|
| remoting.FullscreenAppsV2 = function() {
|
| /**
|
| - * @type {boolean} True if the next onRestored event should cause callbacks
|
| - * to be notified of a full-screen changed event. onRestored fires when
|
| - * full-screen mode is exited and also when the window is restored from
|
| - * being minimized; callbacks should not be notified of the latter.
|
| + * @type {boolean} True if the window is minimized. onRestored fires when the
|
| + * the window transitions from minimized to any other state, but since we
|
| + * only want transitions from full-screen to windowed to cause a callback,
|
| + * we must keep track of the minimized state of the window.
|
| * @private
|
| */
|
| - this.notifyCallbacksOnRestore_ = this.isActive();
|
| + this.isMinimized_ = chrome.app.window.current().isMinimized();
|
|
|
| /**
|
| - * @type {string} Internal 'full-screen changed' event name
|
| + * @type {?boolean} The most recent full-screen state passed to the callback.
|
| + * This guards against redundant invocations, as as would otherwise occur
|
| + * in response to a full-screen -> maximized -> unmaximized transition,
|
| + * because this results in two onRestored callbacks.
|
| + */
|
| + this.previousCallbackState_ = null;
|
| +
|
| + /**
|
| + * @type {string} Internal 'full-screen changed' event name.
|
| * @private
|
| */
|
| this.kEventName_ = '_fullscreenchanged';
|
| @@ -43,8 +51,14 @@ remoting.FullscreenAppsV2 = function() {
|
| this.onFullscreened_.bind(this));
|
| chrome.app.window.current().onRestored.addListener(
|
| this.onRestored_.bind(this));
|
| + chrome.app.window.current().onMinimized.addListener(
|
| + this.onMinimized_.bind(this));
|
| };
|
|
|
| +/**
|
| + * @param {boolean} fullscreen True to enter full-screen mode; false to leave.
|
| + * @param {function():void=} opt_onDone Optional completion callback.
|
| + */
|
| remoting.FullscreenAppsV2.prototype.activate = function(
|
| fullscreen, opt_onDone) {
|
| if (opt_onDone) {
|
| @@ -72,6 +86,9 @@ remoting.FullscreenAppsV2.prototype.toggle = function() {
|
| this.activate(!this.isActive());
|
| };
|
|
|
| +/**
|
| + * @return {boolean}
|
| + */
|
| remoting.FullscreenAppsV2.prototype.isActive = function() {
|
| return chrome.app.window.current().isFullscreen();
|
| };
|
| @@ -90,16 +107,40 @@ remoting.FullscreenAppsV2.prototype.removeListener = function(callback) {
|
| this.eventSource_.removeEventListener(this.kEventName_, callback);
|
| };
|
|
|
| +/**
|
| + * @private
|
| + */
|
| remoting.FullscreenAppsV2.prototype.onFullscreened_ = function() {
|
| - this.notifyCallbacksOnRestore_ = true;
|
| - this.eventSource_.raiseEvent(this.kEventName_, true);
|
| + this.isMinimized_ = false;
|
| + this.raiseEvent_(true);
|
| document.body.classList.add('fullscreen');
|
| };
|
|
|
| +/**
|
| + * @private
|
| + */
|
| remoting.FullscreenAppsV2.prototype.onRestored_ = function() {
|
| - document.body.classList.remove('fullscreen');
|
| - if (this.notifyCallbacksOnRestore_) {
|
| - this.notifyCallbacksOnRestore_ = false;
|
| - this.eventSource_.raiseEvent(this.kEventName_, false);
|
| + if (!this.isMinimized_) {
|
| + document.body.classList.remove('fullscreen');
|
| + this.raiseEvent_(false);
|
| + }
|
| + this.isMinimized_ = false;
|
| +};
|
| +
|
| +/**
|
| + * @private
|
| + */
|
| +remoting.FullscreenAppsV2.prototype.onMinimized_ = function() {
|
| + this.isMinimized_ = true;
|
| +};
|
| +
|
| +/**
|
| + * @param {boolean} isFullscreen
|
| + * @private
|
| + */
|
| +remoting.FullscreenAppsV2.prototype.raiseEvent_ = function(isFullscreen) {
|
| + if (isFullscreen !== this.previousCallbackState_) {
|
| + this.previousCallbackState_ = isFullscreen;
|
| + this.eventSource_.raiseEvent(this.kEventName_, isFullscreen);
|
| }
|
| };
|
|
|