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_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_FULLSCREEN_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_FULLSCREEN_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_FULLSCREEN_CONTROLLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "chrome/browser/ui/fullscreen_exit_bubble_type.h" | 11 #include "chrome/browser/ui/fullscreen_exit_bubble_type.h" |
12 #include "chrome/common/content_settings.h" | 12 #include "chrome/common/content_settings.h" |
| 13 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" |
13 | 15 |
14 class Browser; | 16 class Browser; |
15 class BrowserWindow; | 17 class BrowserWindow; |
16 class GURL; | 18 class GURL; |
17 class Profile; | 19 class Profile; |
18 class TabContents; | 20 class TabContents; |
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 when a tab enters | 27 // "browser fullscreen". "Tab fullscreen" refers to when a tab enters |
26 // fullscreen mode via the JS fullscreen API, and "browser fullscreen" refers | 28 // fullscreen mode via the JS fullscreen API, and "browser fullscreen" refers |
27 // to the user putting the browser itself into fullscreen mode from the UI. The | 29 // to the user putting the browser itself into fullscreen mode from the UI. The |
28 // difference is that tab fullscreen has implications for how the contents of | 30 // difference is that tab fullscreen has implications for how the contents of |
29 // the tab render (eg: a video element may grow to consume the whole tab), | 31 // the tab render (eg: a video element may grow to consume the whole tab), |
30 // whereas browser fullscreen mode doesn't. Therefore if a user forces an exit | 32 // whereas browser fullscreen mode doesn't. Therefore if a user forces an exit |
31 // from tab fullscreen, we need to notify the tab so it can stop rendering in | 33 // from tab fullscreen, we need to notify the tab so it can stop rendering in |
32 // its fullscreen mode. | 34 // its fullscreen mode. |
33 | 35 |
34 // This class implements fullscreen and mouselock behaviour. | 36 // This class implements fullscreen and mouselock behaviour. |
35 class FullscreenController : public base::RefCounted<FullscreenController> { | 37 class FullscreenController : public base::RefCounted<FullscreenController>, |
| 38 public content::NotificationObserver { |
36 public: | 39 public: |
37 FullscreenController(BrowserWindow* window, | 40 FullscreenController(BrowserWindow* window, |
38 Profile* profile, | 41 Profile* profile, |
39 Browser* browser); | 42 Browser* browser); |
40 | 43 |
41 // Querying. | 44 // Querying. |
42 | 45 |
43 // Returns true if the window is currently fullscreen and was initially | 46 // Returns true if the window is currently fullscreen and was initially |
44 // transitioned to fullscreen by a browser (vs tab) mode transition. | 47 // transitioned to fullscreen by a browser (vs tab) mode transition. |
45 bool IsFullscreenForBrowser() const; | 48 bool IsFullscreenForBrowser() const; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 void OnTabClosing(content::WebContents* web_contents); | 87 void OnTabClosing(content::WebContents* web_contents); |
85 void OnTabDeactivated(TabContents* contents); | 88 void OnTabDeactivated(TabContents* contents); |
86 void OnAcceptFullscreenPermission(const GURL& url, | 89 void OnAcceptFullscreenPermission(const GURL& url, |
87 FullscreenExitBubbleType bubble_type); | 90 FullscreenExitBubbleType bubble_type); |
88 void OnDenyFullscreenPermission(FullscreenExitBubbleType bubble_type); | 91 void OnDenyFullscreenPermission(FullscreenExitBubbleType bubble_type); |
89 void WindowFullscreenStateChanged(); | 92 void WindowFullscreenStateChanged(); |
90 bool HandleUserPressedEscape(); | 93 bool HandleUserPressedEscape(); |
91 | 94 |
92 FullscreenExitBubbleType GetFullscreenExitBubbleType() const; | 95 FullscreenExitBubbleType GetFullscreenExitBubbleType() const; |
93 | 96 |
| 97 // content::NotificationObserver |
| 98 virtual void Observe(int type, |
| 99 const content::NotificationSource& source, |
| 100 const content::NotificationDetails& details) OVERRIDE; |
| 101 |
94 private: | 102 private: |
95 friend class base::RefCounted<FullscreenController>; | 103 friend class base::RefCounted<FullscreenController>; |
96 | 104 |
97 enum MouseLockState { | 105 enum MouseLockState { |
98 MOUSELOCK_NOT_REQUESTED, | 106 MOUSELOCK_NOT_REQUESTED, |
99 // The page requests to lock the mouse and the user hasn't responded to the | 107 // The page requests to lock the mouse and the user hasn't responded to the |
100 // request. | 108 // request. |
101 MOUSELOCK_REQUESTED, | 109 MOUSELOCK_REQUESTED, |
102 // Mouse lock has been allowed by the user. | 110 // Mouse lock has been allowed by the user. |
103 MOUSELOCK_ACCEPTED, | 111 MOUSELOCK_ACCEPTED, |
104 // Mouse lock has been silently accepted, no notification to user. | 112 // Mouse lock has been silently accepted, no notification to user. |
105 MOUSELOCK_ACCEPTED_SILENTLY | 113 MOUSELOCK_ACCEPTED_SILENTLY |
106 }; | 114 }; |
107 | 115 |
108 virtual ~FullscreenController(); | 116 virtual ~FullscreenController(); |
109 | 117 |
110 // Notifies the tab that it has been forced out of fullscreen and mouse lock | 118 // Notifies the tab that it has been forced out of fullscreen and mouse lock |
111 // mode if necessary. | 119 // mode if necessary. |
112 void NotifyTabOfExitIfNecessary(); | 120 void NotifyTabOfExitIfNecessary(); |
113 | 121 |
| 122 // Makes the browser exit fullscreen mode when a navigation occurs. |
| 123 void EnterCancelFullscreenOnNavigateMode(); |
| 124 |
| 125 // Makes the browser no longer exit fullscreen mode when a navigation occurs. |
| 126 void ExitCancelFullscreenOnNavigateMode(); |
| 127 |
114 // Make the current tab exit fullscreen mode or mouse lock if it is in it. | 128 // Make the current tab exit fullscreen mode or mouse lock if it is in it. |
115 void ExitTabFullscreenOrMouseLockIfNecessary(); | 129 void ExitTabFullscreenOrMouseLockIfNecessary(); |
116 void UpdateFullscreenExitBubbleContent(); | 130 void UpdateFullscreenExitBubbleContent(); |
117 void NotifyFullscreenChange(bool is_fullscreen); | 131 void NotifyFullscreenChange(bool is_fullscreen); |
118 void NotifyMouseLockChange(); | 132 void NotifyMouseLockChange(); |
119 ContentSetting GetFullscreenSetting(const GURL& url) const; | 133 ContentSetting GetFullscreenSetting(const GURL& url) const; |
120 ContentSetting GetMouseLockSetting(const GURL& url) const; | 134 ContentSetting GetMouseLockSetting(const GURL& url) const; |
121 | 135 |
122 #if defined(OS_MACOSX) | 136 #if defined(OS_MACOSX) |
123 void TogglePresentationModeInternal(bool for_tab); | 137 void TogglePresentationModeInternal(bool for_tab); |
(...skipping 19 matching lines...) Expand all Loading... |
143 bool tab_fullscreen_accepted_; | 157 bool tab_fullscreen_accepted_; |
144 | 158 |
145 // True if this controller has toggled into tab OR browser fullscreen. | 159 // True if this controller has toggled into tab OR browser fullscreen. |
146 bool toggled_into_fullscreen_; | 160 bool toggled_into_fullscreen_; |
147 | 161 |
148 // TabContents for current tab requesting or currently in mouse lock. | 162 // TabContents for current tab requesting or currently in mouse lock. |
149 TabContents* mouse_lock_tab_; | 163 TabContents* mouse_lock_tab_; |
150 | 164 |
151 MouseLockState mouse_lock_state_; | 165 MouseLockState mouse_lock_state_; |
152 | 166 |
| 167 content::NotificationRegistrar registrar_; |
| 168 |
| 169 // If this is true then we are listening for navigation events and will |
| 170 // cancel fullscreen when one occurs. |
| 171 bool cancel_fullscreen_on_navigate_mode_; |
| 172 |
153 DISALLOW_COPY_AND_ASSIGN(FullscreenController); | 173 DISALLOW_COPY_AND_ASSIGN(FullscreenController); |
154 }; | 174 }; |
155 | 175 |
156 #endif // CHROME_BROWSER_UI_FULLSCREEN_CONTROLLER_H_ | 176 #endif // CHROME_BROWSER_UI_FULLSCREEN_CONTROLLER_H_ |
OLD | NEW |