Chromium Code Reviews| 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 <vector> | |
| 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 // Special behavior for screen-captured tabs: When embedded fullscreen widgets | |
|
scheib
2014/02/12 01:41:16
Consider anchoring/naming this note with e.g.
"""
miu
2014/02/12 08:25:19
Done.
| |
| 41 // are enabled and the renderer toggles into fullscreen mode, the browser window | |
| 42 // will not expand to enter fullscreen. This allows the user to retain control | |
| 43 // of their desktop to work in other browser tabs or applications while the | |
| 44 // fullscreen view is displayed on a remote screen. FullscreenController will | |
| 45 // track which WebContentses have renderers in fullscreen mode, and use an | |
| 46 // alternate set of heuristics to manage them. | |
| 37 | 47 |
| 38 // This class implements fullscreen and mouselock behaviour. | 48 // This class implements fullscreen and mouselock behaviour. |
| 39 class FullscreenController : public content::NotificationObserver { | 49 class FullscreenController : public content::NotificationObserver { |
| 40 public: | 50 public: |
| 41 explicit FullscreenController(Browser* browser); | 51 explicit FullscreenController(Browser* browser); |
| 42 virtual ~FullscreenController(); | 52 virtual ~FullscreenController(); |
| 43 | 53 |
| 44 // Browser/User Fullscreen /////////////////////////////////////////////////// | 54 // Browser/User Fullscreen /////////////////////////////////////////////////// |
| 45 | 55 |
| 46 // Returns true if the window is currently fullscreen and was initially | 56 // Returns true if the window is currently fullscreen and was initially |
| 47 // transitioned to fullscreen by a browser (vs tab) mode transition. | 57 // transitioned to fullscreen by a browser (vs tab) mode transition. |
| 48 bool IsFullscreenForBrowser() const; | 58 bool IsFullscreenForBrowser() const; |
| 49 | 59 |
| 50 void ToggleFullscreenMode(); | 60 void ToggleFullscreenMode(); |
| 51 | 61 |
| 52 // Tab/HTML/Flash Fullscreen ///////////////////////////////////////////////// | 62 // Tab/HTML/Flash Fullscreen ///////////////////////////////////////////////// |
| 53 | 63 |
| 54 // Returns true if fullscreen has been caused by a tab. | 64 // Returns true if fullscreen has been caused by a tab. |
| 55 // The window may still be transitioning, and window_->IsFullscreen() | 65 // The window may still be transitioning, and window_->IsFullscreen() |
| 56 // may still return false. | 66 // may still return false. |
| 67 // | |
| 68 // NOTE: The zero-argument version returns true iff a fullscreen tab will | |
|
scheib
2014/02/12 01:41:16
For clarity (presuming I have it right): "iff a fu
miu
2014/02/12 08:25:19
Done.
| |
| 69 // result in the browser window expanding to fill the screen. On the other | |
| 70 // hand, the one-argument version will return true while the renderer is/will | |
| 71 // be in fullscreen mode, but not necessarily the browser window. The latter | |
| 72 // case accounts for the special behavior employed during screen capture of a | |
|
scheib
2014/02/12 01:41:16
And then reference "See 'EmbeddedFullscreen Note'"
miu
2014/02/12 08:25:19
Done.
| |
| 73 // WebContents where the fullscreen view remains within the browser tab. | |
| 57 bool IsFullscreenForTabOrPending() const; | 74 bool IsFullscreenForTabOrPending() const; |
|
scheib
2014/02/12 01:41:16
Consider renaming the method to differentiate the
miu
2014/02/12 08:25:19
Agreed. There are quite a few callers of it, so I
scheib
2014/02/12 18:01:36
Yes.
| |
| 58 bool IsFullscreenForTabOrPending( | 75 bool IsFullscreenForTabOrPending( |
| 59 const content::WebContents* web_contents) const; | 76 const content::WebContents* web_contents) const; |
| 60 // True if fullscreen was entered because of tab fullscreen (was not | 77 // True if fullscreen was entered because of tab fullscreen (was not |
| 61 // previously in browser fullscreen). | 78 // previously in browser fullscreen). |
| 62 bool IsFullscreenCausedByTab() const; | 79 bool IsFullscreenCausedByTab() const; |
| 63 | 80 |
| 64 void ToggleFullscreenModeForTab(content::WebContents* web_contents, | 81 void ToggleFullscreenModeForTab(content::WebContents* web_contents, |
| 65 bool enter_fullscreen); | 82 bool enter_fullscreen); |
| 66 | 83 |
| 67 // Extension API implementation uses this method to toggle fullscreen mode. | 84 // Extension API implementation uses this method to toggle fullscreen mode. |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 91 | 108 |
| 92 void RequestToLockMouse(content::WebContents* web_contents, | 109 void RequestToLockMouse(content::WebContents* web_contents, |
| 93 bool user_gesture, | 110 bool user_gesture, |
| 94 bool last_unlocked_by_target); | 111 bool last_unlocked_by_target); |
| 95 | 112 |
| 96 // Callbacks ///////////////////////////////////////////////////////////////// | 113 // Callbacks ///////////////////////////////////////////////////////////////// |
| 97 | 114 |
| 98 // Called by Browser::TabDeactivated. | 115 // Called by Browser::TabDeactivated. |
| 99 void OnTabDeactivated(content::WebContents* web_contents); | 116 void OnTabDeactivated(content::WebContents* web_contents); |
| 100 | 117 |
| 118 // Called by Browser::ActiveTabChanged. | |
| 119 void OnTabDetachedFromView(content::WebContents* web_contents); | |
| 120 | |
| 101 // Called by Browser::TabClosingAt. | 121 // Called by Browser::TabClosingAt. |
| 102 void OnTabClosing(content::WebContents* web_contents); | 122 void OnTabClosing(content::WebContents* web_contents); |
| 103 | 123 |
| 104 // Called by Browser::WindowFullscreenStateChanged. | 124 // Called by Browser::WindowFullscreenStateChanged. |
| 105 void WindowFullscreenStateChanged(); | 125 void WindowFullscreenStateChanged(); |
| 106 | 126 |
| 107 // Called by Browser::PreHandleKeyboardEvent. | 127 // Called by Browser::PreHandleKeyboardEvent. |
| 108 bool HandleUserPressedEscape(); | 128 bool HandleUserPressedEscape(); |
| 109 | 129 |
| 110 // Called by platform FullscreenExitBubble. | 130 // Called by platform FullscreenExitBubble. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 | 186 |
| 167 // Make the current tab exit fullscreen mode or mouse lock if it is in it. | 187 // Make the current tab exit fullscreen mode or mouse lock if it is in it. |
| 168 void ExitTabFullscreenOrMouseLockIfNecessary(); | 188 void ExitTabFullscreenOrMouseLockIfNecessary(); |
| 169 void UpdateFullscreenExitBubbleContent(); | 189 void UpdateFullscreenExitBubbleContent(); |
| 170 | 190 |
| 171 ContentSetting GetFullscreenSetting(const GURL& url) const; | 191 ContentSetting GetFullscreenSetting(const GURL& url) const; |
| 172 ContentSetting GetMouseLockSetting(const GURL& url) const; | 192 ContentSetting GetMouseLockSetting(const GURL& url) const; |
| 173 | 193 |
| 174 bool IsPrivilegedFullscreenForTab() const; | 194 bool IsPrivilegedFullscreenForTab() const; |
| 175 void SetPrivilegedFullscreenForTesting(bool is_privileged); | 195 void SetPrivilegedFullscreenForTesting(bool is_privileged); |
| 196 // Returns true if embedded fullscreen features have been enabled for the | |
| 197 // |browser_|. | |
|
scheib
2014/02/12 01:41:16
And then reference "See 'EmbeddedFullscreen Note'"
miu
2014/02/12 08:25:19
Done.
| |
| 198 bool IsEmbeddedFullscreenEnabled() const; | |
|
scheib
2014/02/12 01:41:16
Use a consistent terminology, always 'EmbeddedFull
miu
2014/02/12 08:25:19
I see your point, and agree the naming was confusi
scheib
2014/02/12 18:01:36
Thanks - I think it's clearer now - though still s
| |
| 199 // Returns true if |web_contents| is/was being screen-captured and was | |
| 200 // toggled into/out of fullscreen-within-tab mode. | |
| 201 bool MaybeToggleAsFullscreenWithinTab(content::WebContents* web_contents, | |
| 202 bool enter_fullscreen); | |
| 203 // Returns true if |web_contents| has its fullscreen view embedded within a | |
| 204 // browser tab and is being screen captured. | |
| 205 bool IsCapturedFullscreenTab(const content::WebContents* web_contents) const; | |
| 176 void UnlockMouse(); | 206 void UnlockMouse(); |
| 177 | 207 |
| 178 Browser* const browser_; | 208 Browser* const browser_; |
| 179 BrowserWindow* const window_; | 209 BrowserWindow* const window_; |
| 180 Profile* const profile_; | 210 Profile* const profile_; |
| 181 | 211 |
| 182 // If there is currently a tab in fullscreen mode (entered via | 212 // If there is currently a tab in fullscreen mode (entered via |
| 183 // webkitRequestFullScreen), this is its WebContents. | 213 // webkitRequestFullScreen), this is its WebContents. |
| 184 // Assign using SetFullscreenedTab(). | 214 // Assign using SetFullscreenedTab(). |
| 185 content::WebContents* fullscreened_tab_; | 215 content::WebContents* fullscreened_tab_; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 210 content::WebContents* mouse_lock_tab_; | 240 content::WebContents* mouse_lock_tab_; |
| 211 | 241 |
| 212 MouseLockState mouse_lock_state_; | 242 MouseLockState mouse_lock_state_; |
| 213 | 243 |
| 214 content::NotificationRegistrar registrar_; | 244 content::NotificationRegistrar registrar_; |
| 215 | 245 |
| 216 // Used to verify that calls we expect to reenter by calling | 246 // Used to verify that calls we expect to reenter by calling |
| 217 // WindowFullscreenStateChanged do so. | 247 // WindowFullscreenStateChanged do so. |
| 218 bool reentrant_window_state_change_call_check_; | 248 bool reentrant_window_state_change_call_check_; |
| 219 | 249 |
| 250 // A WebContents pointer is in this set if it entered fullscreen mode during | |
| 251 // screen capture. In other words, this tracks those WebContentses that are | |
| 252 // in fullscreen mode, but the browser window is not. Note: Behavior only | |
| 253 // applies when IsEmbeddedFullscreenEnabled() returns true. | |
| 254 std::vector<const content::WebContents*> captured_tabs_; | |
| 255 | |
| 220 // Used in testing to confirm proper behavior for specific, privileged | 256 // Used in testing to confirm proper behavior for specific, privileged |
| 221 // fullscreen cases. | 257 // fullscreen cases. |
| 222 bool is_privileged_fullscreen_for_testing_; | 258 bool is_privileged_fullscreen_for_testing_; |
| 223 | 259 |
| 224 base::WeakPtrFactory<FullscreenController> ptr_factory_; | 260 base::WeakPtrFactory<FullscreenController> ptr_factory_; |
| 225 | 261 |
| 226 DISALLOW_COPY_AND_ASSIGN(FullscreenController); | 262 DISALLOW_COPY_AND_ASSIGN(FullscreenController); |
| 227 }; | 263 }; |
| 228 | 264 |
| 229 #endif // CHROME_BROWSER_UI_FULLSCREEN_FULLSCREEN_CONTROLLER_H_ | 265 #endif // CHROME_BROWSER_UI_FULLSCREEN_FULLSCREEN_CONTROLLER_H_ |
| OLD | NEW |