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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "chrome/browser/ui/fullscreen/fullscreen_exit_bubble_type.h" | 10 #include "chrome/browser/ui/fullscreen/fullscreen_exit_bubble_type.h" |
11 #include "chrome/common/content_settings.h" | 11 #include "chrome/common/content_settings.h" |
12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
14 | 14 |
15 class Browser; | 15 class Browser; |
16 class BrowserWindow; | 16 class BrowserWindow; |
17 class GURL; | 17 class GURL; |
18 class Profile; | 18 class Profile; |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 class WebContents; | 21 class WebContents; |
22 } | 22 } |
23 | 23 |
24 // There are two different kinds of fullscreen mode - "tab fullscreen" and | 24 // There are two different kinds of fullscreen mode - "tab fullscreen" and |
25 // "browser fullscreen". "Tab fullscreen" refers to when a tab enters | 25 // "browser fullscreen". "Tab fullscreen" refers to a renderer-initiated |
26 // fullscreen mode via the JS fullscreen API, and "browser fullscreen" refers | 26 // fullscreen mode (eg: from a Flash plugin or via the JS fullscreen API), |
27 // to the user putting the browser itself into fullscreen mode from the UI. The | 27 // whereas "browser fullscreen" refers to the user putting the browser itself |
28 // difference is that tab fullscreen has implications for how the contents of | 28 // into fullscreen mode from the UI. The difference is that tab fullscreen has |
29 // the tab render (eg: a video element may grow to consume the whole tab), | 29 // implications for how the contents of the tab render (eg: a video element may |
30 // whereas browser fullscreen mode doesn't. Therefore if a user forces an exit | 30 // grow to consume the whole tab), whereas browser fullscreen mode doesn't. |
31 // from tab fullscreen, we need to notify the tab so it can stop rendering in | 31 // Therefore if a user forces an exit from tab fullscreen, we need to notify the |
32 // its fullscreen mode. | 32 // tab so it can stop rendering in its fullscreen mode. |
| 33 // |
| 34 // For Flash, FullscreenController will auto-accept all permission requests for |
| 35 // fullscreen and/or mouse lock, since the assumption is that the plugin handles |
| 36 // this for us. |
33 | 37 |
34 // This class implements fullscreen and mouselock behaviour. | 38 // This class implements fullscreen and mouselock behaviour. |
35 class FullscreenController : public content::NotificationObserver { | 39 class FullscreenController : public content::NotificationObserver { |
36 public: | 40 public: |
37 explicit FullscreenController(Browser* browser); | 41 explicit FullscreenController(Browser* browser); |
38 virtual ~FullscreenController(); | 42 virtual ~FullscreenController(); |
39 | 43 |
40 // Browser/User Fullscreen /////////////////////////////////////////////////// | 44 // Browser/User Fullscreen /////////////////////////////////////////////////// |
41 | 45 |
42 // Returns true if the window is currently fullscreen and was initially | 46 // Returns true if the window is currently fullscreen and was initially |
43 // transitioned to fullscreen by a browser (vs tab) mode transition. | 47 // transitioned to fullscreen by a browser (vs tab) mode transition. |
44 bool IsFullscreenForBrowser() const; | 48 bool IsFullscreenForBrowser() const; |
45 | 49 |
46 void ToggleFullscreenMode(); | 50 void ToggleFullscreenMode(); |
47 | 51 |
48 // Tab/HTML Fullscreen /////////////////////////////////////////////////////// | 52 // Tab/HTML/Flash Fullscreen ///////////////////////////////////////////////// |
49 | 53 |
50 // Returns true if fullscreen has been caused by a tab. | 54 // Returns true if fullscreen has been caused by a tab. |
51 // The window may still be transitioning, and window_->IsFullscreen() | 55 // The window may still be transitioning, and window_->IsFullscreen() |
52 // may still return false. | 56 // may still return false. |
53 bool IsFullscreenForTabOrPending() const; | 57 bool IsFullscreenForTabOrPending() const; |
54 bool IsFullscreenForTabOrPending( | 58 bool IsFullscreenForTabOrPending( |
55 const content::WebContents* web_contents) const; | 59 const content::WebContents* web_contents) const; |
56 // True if fullscreen was entered because of tab fullscreen (was not | 60 // True if fullscreen was entered because of tab fullscreen (was not |
57 // previously in browser fullscreen). | 61 // previously in browser fullscreen). |
58 bool IsFullscreenCausedByTab() const; | 62 bool IsFullscreenCausedByTab() const; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 void SetFullscreenedTab(content::WebContents* tab); | 162 void SetFullscreenedTab(content::WebContents* tab); |
159 void SetMouseLockTab(content::WebContents* tab); | 163 void SetMouseLockTab(content::WebContents* tab); |
160 | 164 |
161 // Make the current tab exit fullscreen mode or mouse lock if it is in it. | 165 // Make the current tab exit fullscreen mode or mouse lock if it is in it. |
162 void ExitTabFullscreenOrMouseLockIfNecessary(); | 166 void ExitTabFullscreenOrMouseLockIfNecessary(); |
163 void UpdateFullscreenExitBubbleContent(); | 167 void UpdateFullscreenExitBubbleContent(); |
164 | 168 |
165 ContentSetting GetFullscreenSetting(const GURL& url) const; | 169 ContentSetting GetFullscreenSetting(const GURL& url) const; |
166 ContentSetting GetMouseLockSetting(const GURL& url) const; | 170 ContentSetting GetMouseLockSetting(const GURL& url) const; |
167 | 171 |
| 172 bool IsPrivilegedFullscreenForTab() const; |
| 173 void UnlockMouse(); |
| 174 |
168 base::WeakPtrFactory<FullscreenController> ptr_factory_; | 175 base::WeakPtrFactory<FullscreenController> ptr_factory_; |
169 | 176 |
170 Browser* browser_; | 177 Browser* const browser_; |
171 BrowserWindow* window_; | 178 BrowserWindow* const window_; |
172 Profile* profile_; | 179 Profile* const profile_; |
173 | 180 |
174 // If there is currently a tab in fullscreen mode (entered via | 181 // If there is currently a tab in fullscreen mode (entered via |
175 // webkitRequestFullScreen), this is its WebContents. | 182 // webkitRequestFullScreen), this is its WebContents. |
176 // Assign using SetFullscreenedTab(). | 183 // Assign using SetFullscreenedTab(). |
177 content::WebContents* fullscreened_tab_; | 184 content::WebContents* fullscreened_tab_; |
178 | 185 |
179 // The URL of the extension which trigerred "browser fullscreen" mode. | 186 // The URL of the extension which trigerred "browser fullscreen" mode. |
180 GURL extension_caused_fullscreen_; | 187 GURL extension_caused_fullscreen_; |
181 | 188 |
182 enum PriorFullscreenState { | 189 enum PriorFullscreenState { |
(...skipping 23 matching lines...) Expand all Loading... |
206 content::NotificationRegistrar registrar_; | 213 content::NotificationRegistrar registrar_; |
207 | 214 |
208 // Used to verify that calls we expect to reenter by calling | 215 // Used to verify that calls we expect to reenter by calling |
209 // WindowFullscreenStateChanged do so. | 216 // WindowFullscreenStateChanged do so. |
210 bool reentrant_window_state_change_call_check_; | 217 bool reentrant_window_state_change_call_check_; |
211 | 218 |
212 DISALLOW_COPY_AND_ASSIGN(FullscreenController); | 219 DISALLOW_COPY_AND_ASSIGN(FullscreenController); |
213 }; | 220 }; |
214 | 221 |
215 #endif // CHROME_BROWSER_UI_FULLSCREEN_FULLSCREEN_CONTROLLER_H_ | 222 #endif // CHROME_BROWSER_UI_FULLSCREEN_FULLSCREEN_CONTROLLER_H_ |
OLD | NEW |