OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_FULLSCREEN_FULLSCREEN_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_FULLSCREEN_FULLSCREEN_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_FULLSCREEN_FULLSCREEN_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_FULLSCREEN_FULLSCREEN_CONTROLLER_H_ |
7 | 7 |
| 8 #include <set> |
| 9 |
8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
9 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
10 #include "chrome/browser/ui/fullscreen/fullscreen_exit_bubble_type.h" | 12 #include "chrome/browser/ui/fullscreen/fullscreen_exit_bubble_type.h" |
11 #include "chrome/common/content_settings.h" | 13 #include "chrome/common/content_settings.h" |
12 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
13 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
14 | 16 |
15 class Browser; | 17 class Browser; |
16 class BrowserWindow; | 18 class BrowserWindow; |
17 class GURL; | 19 class GURL; |
18 class Profile; | 20 class Profile; |
19 | 21 |
20 namespace content { | 22 namespace content { |
21 class WebContents; | 23 class WebContents; |
22 } | 24 } |
23 | 25 |
24 // There are two different kinds of fullscreen mode - "tab fullscreen" and | 26 // There are two different kinds of fullscreen mode - "tab fullscreen" and |
25 // "browser fullscreen". "Tab fullscreen" refers to a renderer-initiated | 27 // "browser fullscreen". "Tab fullscreen" refers to a renderer-initiated |
26 // fullscreen mode (eg: from a Flash plugin or via the JS fullscreen API), | 28 // fullscreen mode (eg: from a Flash plugin or via the JS fullscreen API), |
27 // whereas "browser fullscreen" refers to the user putting the browser itself | 29 // whereas "browser fullscreen" refers to the user putting the browser itself |
28 // into fullscreen mode from the UI. The difference is that tab fullscreen has | 30 // into fullscreen mode from the UI. The difference is that tab fullscreen has |
29 // implications for how the contents of the tab render (eg: a video element may | 31 // implications for how the contents of the tab render (eg: a video element may |
30 // grow to consume the whole tab), whereas browser fullscreen mode doesn't. | 32 // grow to consume the whole tab), whereas browser fullscreen mode doesn't. |
31 // Therefore if a user forces an exit from tab fullscreen, we need to notify the | 33 // Therefore if a user forces an exit from tab fullscreen, we need to notify the |
32 // tab so it can stop rendering in its fullscreen mode. | 34 // tab so it can stop rendering in its fullscreen mode. |
33 // | 35 // |
34 // For Flash, FullscreenController will auto-accept all permission requests for | 36 // For Flash, FullscreenController will auto-accept all permission requests for |
35 // fullscreen and/or mouse lock, since the assumption is that the plugin handles | 37 // fullscreen and/or mouse lock, since the assumption is that the plugin handles |
36 // this for us. | 38 // this for us. |
| 39 // |
| 40 // FullscreenWithinTab Note: |
| 41 // When the browser is configured as such, all fullscreen widgets are displayed |
| 42 // within the tab contents area, and FullscreenController will expand the |
| 43 // browser window so that the tab contents area fills the entire |
| 44 // screen. However, special behavior applies when a tab is being |
| 45 // screen-captured. First, the browser window will not be fullscreened. This |
| 46 // allows the user to retain control of their desktop to work in other browser |
| 47 // tabs or applications while the fullscreen view is displayed on a remote |
| 48 // screen. Second, FullscreenController will auto-resize fullscreen widgets to |
| 49 // that of the capture video resolution when they are hidden (e.g., when a user |
| 50 // has switched to another tab). This is both a performance and quality |
| 51 // improvement since scaling and letterboxing steps can be skipped in the |
| 52 // capture pipeline. |
37 | 53 |
38 // This class implements fullscreen and mouselock behaviour. | 54 // This class implements fullscreen and mouselock behaviour. |
39 class FullscreenController : public content::NotificationObserver { | 55 class FullscreenController : public content::NotificationObserver { |
40 public: | 56 public: |
41 explicit FullscreenController(Browser* browser); | 57 explicit FullscreenController(Browser* browser); |
42 virtual ~FullscreenController(); | 58 virtual ~FullscreenController(); |
43 | 59 |
44 // Browser/User Fullscreen /////////////////////////////////////////////////// | 60 // Browser/User Fullscreen /////////////////////////////////////////////////// |
45 | 61 |
46 // Returns true if the window is currently fullscreen and was initially | 62 // Returns true if the window is currently fullscreen and was initially |
47 // transitioned to fullscreen by a browser (vs tab) mode transition. | 63 // transitioned to fullscreen by a browser (vs tab) mode transition. |
48 bool IsFullscreenForBrowser() const; | 64 bool IsFullscreenForBrowser() const; |
49 | 65 |
50 void ToggleFullscreenMode(); | 66 void ToggleFullscreenMode(); |
51 | 67 |
52 // Tab/HTML/Flash Fullscreen ///////////////////////////////////////////////// | 68 // Tab/HTML/Flash Fullscreen ///////////////////////////////////////////////// |
53 | 69 |
54 // Returns true if fullscreen has been caused by a tab. | 70 // Returns true if fullscreen has been caused by a tab. |
55 // The window may still be transitioning, and window_->IsFullscreen() | 71 // The window may still be transitioning, and window_->IsFullscreen() |
56 // may still return false. | 72 // may still return false. |
| 73 // |
| 74 // NOTE: The zero-argument version returns true iff a fullscreen tab and its |
| 75 // browser window is/will be fullscreen. On the other hand, the one-argument |
| 76 // version will return true while the renderer is/will be in fullscreen mode, |
| 77 // but not necessarily the browser window. See 'FullscreenWithinTab Note'. |
57 bool IsFullscreenForTabOrPending() const; | 78 bool IsFullscreenForTabOrPending() const; |
58 bool IsFullscreenForTabOrPending( | 79 bool IsFullscreenForTabOrPending( |
59 const content::WebContents* web_contents) const; | 80 const content::WebContents* web_contents) const; |
60 // True if fullscreen was entered because of tab fullscreen (was not | 81 // True if fullscreen was entered because of tab fullscreen (was not |
61 // previously in browser fullscreen). | 82 // previously in browser fullscreen). |
62 bool IsFullscreenCausedByTab() const; | 83 bool IsFullscreenCausedByTab() const; |
63 | 84 |
64 void ToggleFullscreenModeForTab(content::WebContents* web_contents, | 85 void ToggleFullscreenModeForTab(content::WebContents* web_contents, |
65 bool enter_fullscreen); | 86 bool enter_fullscreen); |
66 | 87 |
(...skipping 24 matching lines...) Expand all Loading... |
91 | 112 |
92 void RequestToLockMouse(content::WebContents* web_contents, | 113 void RequestToLockMouse(content::WebContents* web_contents, |
93 bool user_gesture, | 114 bool user_gesture, |
94 bool last_unlocked_by_target); | 115 bool last_unlocked_by_target); |
95 | 116 |
96 // Callbacks ///////////////////////////////////////////////////////////////// | 117 // Callbacks ///////////////////////////////////////////////////////////////// |
97 | 118 |
98 // Called by Browser::TabDeactivated. | 119 // Called by Browser::TabDeactivated. |
99 void OnTabDeactivated(content::WebContents* web_contents); | 120 void OnTabDeactivated(content::WebContents* web_contents); |
100 | 121 |
| 122 // Called by Browser::ActiveTabChanged. |
| 123 void OnTabDetachedFromView(content::WebContents* web_contents); |
| 124 |
101 // Called by Browser::TabClosingAt. | 125 // Called by Browser::TabClosingAt. |
102 void OnTabClosing(content::WebContents* web_contents); | 126 void OnTabClosing(content::WebContents* web_contents); |
103 | 127 |
104 // Called by Browser::WindowFullscreenStateChanged. | 128 // Called by Browser::WindowFullscreenStateChanged. |
105 void WindowFullscreenStateChanged(); | 129 void WindowFullscreenStateChanged(); |
106 | 130 |
107 // Called by Browser::PreHandleKeyboardEvent. | 131 // Called by Browser::PreHandleKeyboardEvent. |
108 bool HandleUserPressedEscape(); | 132 bool HandleUserPressedEscape(); |
109 | 133 |
110 // Called by platform FullscreenExitBubble. | 134 // Called by platform FullscreenExitBubble. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 190 |
167 // Make the current tab exit fullscreen mode or mouse lock if it is in it. | 191 // Make the current tab exit fullscreen mode or mouse lock if it is in it. |
168 void ExitTabFullscreenOrMouseLockIfNecessary(); | 192 void ExitTabFullscreenOrMouseLockIfNecessary(); |
169 void UpdateFullscreenExitBubbleContent(); | 193 void UpdateFullscreenExitBubbleContent(); |
170 | 194 |
171 ContentSetting GetFullscreenSetting(const GURL& url) const; | 195 ContentSetting GetFullscreenSetting(const GURL& url) const; |
172 ContentSetting GetMouseLockSetting(const GURL& url) const; | 196 ContentSetting GetMouseLockSetting(const GURL& url) const; |
173 | 197 |
174 bool IsPrivilegedFullscreenForTab() const; | 198 bool IsPrivilegedFullscreenForTab() const; |
175 void SetPrivilegedFullscreenForTesting(bool is_privileged); | 199 void SetPrivilegedFullscreenForTesting(bool is_privileged); |
| 200 // Returns true if fullscreen-within-tab has been enabled for the |
| 201 // |browser_|. See 'FullscreenWithinTab Note'. |
| 202 bool IsFullscreenWithinTabPossible() const; |
| 203 // Returns true if |web_contents| was toggled into/out of fullscreen mode as a |
| 204 // screen-captured tab. See 'FullscreenWithinTab Note'. |
| 205 bool MaybeToggleFullscreenForCapturedTab(content::WebContents* web_contents, |
| 206 bool enter_fullscreen); |
| 207 // Returns true if |web_contents| is in fullscreen mode as a screen-captured |
| 208 // tab. See 'FullscreenWithinTab Note'. |
| 209 bool IsFullscreenForCapturedTab(const content::WebContents* web_contents) |
| 210 const; |
176 void UnlockMouse(); | 211 void UnlockMouse(); |
177 | 212 |
178 Browser* const browser_; | 213 Browser* const browser_; |
179 BrowserWindow* const window_; | 214 BrowserWindow* const window_; |
180 Profile* const profile_; | 215 Profile* const profile_; |
181 | 216 |
182 // If there is currently a tab in fullscreen mode (entered via | 217 // If there is currently a tab in fullscreen mode (entered via |
183 // webkitRequestFullScreen), this is its WebContents. | 218 // webkitRequestFullScreen), this is its WebContents. |
184 // Assign using SetFullscreenedTab(). | 219 // Assign using SetFullscreenedTab(). |
185 content::WebContents* fullscreened_tab_; | 220 content::WebContents* fullscreened_tab_; |
(...skipping 24 matching lines...) Expand all Loading... |
210 content::WebContents* mouse_lock_tab_; | 245 content::WebContents* mouse_lock_tab_; |
211 | 246 |
212 MouseLockState mouse_lock_state_; | 247 MouseLockState mouse_lock_state_; |
213 | 248 |
214 content::NotificationRegistrar registrar_; | 249 content::NotificationRegistrar registrar_; |
215 | 250 |
216 // Used to verify that calls we expect to reenter by calling | 251 // Used to verify that calls we expect to reenter by calling |
217 // WindowFullscreenStateChanged do so. | 252 // WindowFullscreenStateChanged do so. |
218 bool reentrant_window_state_change_call_check_; | 253 bool reentrant_window_state_change_call_check_; |
219 | 254 |
| 255 // A WebContents pointer is in this set if it entered fullscreen mode during |
| 256 // screen capture. In other words, this tracks those WebContentses that are in |
| 257 // fullscreen mode, but the browser window is not. See 'FullscreenWithinTab |
| 258 // Note'. |
| 259 std::set<const content::WebContents*> captured_tabs_; |
| 260 |
220 // Used in testing to confirm proper behavior for specific, privileged | 261 // Used in testing to confirm proper behavior for specific, privileged |
221 // fullscreen cases. | 262 // fullscreen cases. |
222 bool is_privileged_fullscreen_for_testing_; | 263 bool is_privileged_fullscreen_for_testing_; |
223 | 264 |
224 base::WeakPtrFactory<FullscreenController> ptr_factory_; | 265 base::WeakPtrFactory<FullscreenController> ptr_factory_; |
225 | 266 |
226 DISALLOW_COPY_AND_ASSIGN(FullscreenController); | 267 DISALLOW_COPY_AND_ASSIGN(FullscreenController); |
227 }; | 268 }; |
228 | 269 |
229 #endif // CHROME_BROWSER_UI_FULLSCREEN_FULLSCREEN_CONTROLLER_H_ | 270 #endif // CHROME_BROWSER_UI_FULLSCREEN_FULLSCREEN_CONTROLLER_H_ |
OLD | NEW |