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_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 |
| 44 // content::NotificationObserver | |
|
sky
2012/06/15 15:01:08
nit: in general we try to put overriden methods at
koz (OOO until 15th September)
2012/06/18 02:28:10
Done.
| |
| 45 virtual void Observe(int type, | |
| 46 const content::NotificationSource& source, | |
| 47 const content::NotificationDetails& details) OVERRIDE; | |
| 48 | |
| 41 // Querying. | 49 // Querying. |
| 42 | 50 |
| 43 // Returns true if the window is currently fullscreen and was initially | 51 // Returns true if the window is currently fullscreen and was initially |
| 44 // transitioned to fullscreen by a browser (vs tab) mode transition. | 52 // transitioned to fullscreen by a browser (vs tab) mode transition. |
| 45 bool IsFullscreenForBrowser() const; | 53 bool IsFullscreenForBrowser() const; |
| 46 | 54 |
| 47 // Returns true if fullscreen has been caused by a tab. | 55 // Returns true if fullscreen has been caused by a tab. |
| 48 // The window may still be transitioning, and window_->IsFullscreen() | 56 // The window may still be transitioning, and window_->IsFullscreen() |
| 49 // may still return false. | 57 // may still return false. |
| 50 bool IsFullscreenForTabOrPending() const; | 58 bool IsFullscreenForTabOrPending() const; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |