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 v1, using webkitRequestFullscreen. | 7 * Full-screen implementation for apps v1, using webkitRequestFullscreen. |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 if (fullscreen) { | 55 if (fullscreen) { |
56 document.body.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT); | 56 document.body.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT); |
57 } else { | 57 } else { |
58 document.webkitCancelFullScreen(); | 58 document.webkitCancelFullScreen(); |
59 } | 59 } |
60 }; | 60 }; |
61 | 61 |
| 62 /** @return {void} */ |
62 remoting.FullscreenAppsV1.prototype.toggle = function() { | 63 remoting.FullscreenAppsV1.prototype.toggle = function() { |
63 this.activate(!this.isActive()); | 64 this.activate(!this.isActive()); |
64 }; | 65 }; |
65 | 66 |
| 67 /** |
| 68 * @return {boolean} True if full-screen mode is active. |
| 69 */ |
66 remoting.FullscreenAppsV1.prototype.isActive = function() { | 70 remoting.FullscreenAppsV1.prototype.isActive = function() { |
67 return document.webkitIsFullScreen; | 71 return document.webkitIsFullScreen; |
68 }; | 72 }; |
69 | 73 |
| 74 /** |
| 75 * @param {function(boolean=):void} callback |
| 76 */ |
70 remoting.FullscreenAppsV1.prototype.addListener = function(callback) { | 77 remoting.FullscreenAppsV1.prototype.addListener = function(callback) { |
71 this.eventSource_.addEventListener(this.kEventName_, callback); | 78 this.eventSource_.addEventListener(this.kEventName_, callback); |
72 }; | 79 }; |
73 | 80 |
| 81 /** |
| 82 * @param {function(boolean=):void} callback |
| 83 */ |
74 remoting.FullscreenAppsV1.prototype.removeListener = function(callback) { | 84 remoting.FullscreenAppsV1.prototype.removeListener = function(callback) { |
75 this.eventSource_.removeEventListener(this.kEventName_, callback); | 85 this.eventSource_.removeEventListener(this.kEventName_, callback); |
76 }; | 86 }; |
77 | 87 |
78 /** | 88 /** |
79 * @private | 89 * @private |
80 */ | 90 */ |
81 remoting.FullscreenAppsV1.prototype.onFullscreenChanged_ = function() { | 91 remoting.FullscreenAppsV1.prototype.onFullscreenChanged_ = function() { |
| 92 /** @this {remoting.FullscreenAppsV1} */ |
| 93 var checkIsActive = function() { |
| 94 if (this.isActive()) { |
| 95 document.body.classList.add('fullscreen'); |
| 96 } else { |
| 97 document.body.classList.remove('fullscreen'); |
| 98 } |
| 99 this.eventSource_.raiseEvent(this.kEventName_, this.isActive()); |
| 100 }; |
| 101 |
82 // Querying full-screen immediately after the webkitfullscreenchange | 102 // Querying full-screen immediately after the webkitfullscreenchange |
83 // event fires sometimes gives the wrong answer on Mac, perhaps due to | 103 // event fires sometimes gives the wrong answer on Mac, perhaps due to |
84 // the time taken to animate presentation mode. Since I haven't been able | 104 // the time taken to animate presentation mode. Since I haven't been able |
85 // to isolate the exact repro steps, and we're not planning on using this | 105 // to isolate the exact repro steps, and we're not planning on using this |
86 // API for much longer, this hack will suffice for now. | 106 // API for much longer, this hack will suffice for now. |
87 window.setTimeout( | 107 window.setTimeout(checkIsActive.bind(this), 500); |
88 /** @this {remoting.FullscreenAppsV1} */ | |
89 function() { | |
90 if (this.isActive()) { | |
91 document.body.classList.add('fullscreen'); | |
92 } else { | |
93 document.body.classList.remove('fullscreen'); | |
94 } | |
95 this.eventSource_.raiseEvent(this.kEventName_, this.isActive()); | |
96 }.bind(this), | |
97 500); | |
98 }; | 108 }; |
OLD | NEW |