OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_FULLSCREEN_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_FULLSCREEN_CONTROLLER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/basictypes.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/task.h" |
| 12 #include "chrome/browser/ui/fullscreen_exit_bubble_type.h" |
| 13 #include "chrome/common/content_settings.h" |
| 14 |
| 15 class Browser; |
| 16 class BrowserWindow; |
| 17 class GURL; |
| 18 class Profile; |
| 19 class TabContents; |
| 20 class TabContentsWrapper; |
| 21 |
| 22 // There are two different kinds of fullscreen mode - "tab fullscreen" and |
| 23 // "browser fullscreen". "Tab fullscreen" refers to when a tab enters |
| 24 // fullscreen mode via the JS fullscreen API, and "browser fullscreen" refers |
| 25 // to the user putting the browser itself into fullscreen mode from the UI. The |
| 26 // difference is that tab fullscreen has implications for how the contents of |
| 27 // the tab render (eg: a video element may grow to consume the whole tab), |
| 28 // whereas browser fullscreen mode doesn't. Therefore if a user forces an exit |
| 29 // from tab fullscreen, we need to notify the tab so it can stop rendering in |
| 30 // its fullscreen mode. |
| 31 |
| 32 // This class implements fullscreen and mouselock behaviour. |
| 33 class FullscreenController : public base::RefCounted<FullscreenController> { |
| 34 public: |
| 35 FullscreenController(BrowserWindow* window, |
| 36 Profile* profile, |
| 37 Browser* browser); |
| 38 virtual ~FullscreenController(); |
| 39 |
| 40 // Querying. |
| 41 bool IsFullscreenForTab() const; |
| 42 bool IsFullscreenForTab(const TabContents* tab) const; |
| 43 |
| 44 // Requests. |
| 45 void RequestToLockMouse(TabContents* tab); |
| 46 void ToggleFullscreenModeForTab(TabContents* tab, bool enter_fullscreen); |
| 47 #if defined(OS_MACOSX) |
| 48 void TogglePresentationMode(bool for_tab); |
| 49 #endif |
| 50 // TODO(koz): Change |for_tab| to an enum. |
| 51 void ToggleFullscreenMode(bool for_tab); |
| 52 |
| 53 // Notifications. |
| 54 void LostMouseLock(); |
| 55 void OnTabClosing(TabContents* tab_contents); |
| 56 void OnTabDeactivated(TabContentsWrapper* contents); |
| 57 void OnAcceptFullscreenPermission(const GURL& url, |
| 58 FullscreenExitBubbleType bubble_type); |
| 59 void OnDenyFullscreenPermission(FullscreenExitBubbleType bubble_type); |
| 60 void WindowFullscreenStateChanged(); |
| 61 bool HandleUserPressedEscape(); |
| 62 |
| 63 private: |
| 64 enum MouseLockState { |
| 65 MOUSELOCK_NOT_REQUESTED, |
| 66 // The page requests to lock the mouse and the user hasn't responded to the |
| 67 // request. |
| 68 MOUSELOCK_REQUESTED, |
| 69 // Mouse lock has been allowed by the user. |
| 70 MOUSELOCK_ACCEPTED |
| 71 }; |
| 72 |
| 73 // Notifies the tab that it has been forced out of fullscreen mode if |
| 74 // necessary. |
| 75 void NotifyTabOfFullscreenExitIfNecessary(); |
| 76 // Make the current tab exit fullscreen mode if it is in it. |
| 77 void ExitTabbedFullscreenModeIfNecessary(); |
| 78 void UpdateFullscreenExitBubbleContent(); |
| 79 void NotifyFullscreenChange(); |
| 80 FullscreenExitBubbleType GetFullscreenExitBubbleType() const; |
| 81 ContentSetting GetFullscreenSetting(const GURL& url) const; |
| 82 ContentSetting GetMouseLockSetting(const GURL& url) const; |
| 83 |
| 84 BrowserWindow* window_; |
| 85 Profile* profile_; |
| 86 Browser* browser_; |
| 87 |
| 88 // If there is currently a tab in fullscreen mode (entered via |
| 89 // webkitRequestFullScreen), this is its wrapper. |
| 90 TabContentsWrapper* fullscreened_tab_; |
| 91 |
| 92 // True if the current tab entered fullscreen mode via webkitRequestFullScreen |
| 93 bool tab_caused_fullscreen_; |
| 94 // True if tab fullscreen has been allowed, either by settings or by user |
| 95 // clicking the allow button on the fullscreen infobar. |
| 96 bool tab_fullscreen_accepted_; |
| 97 |
| 98 MouseLockState mouse_lock_state_; |
| 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(FullscreenController); |
| 101 }; |
| 102 |
| 103 #endif // CHROME_BROWSER_UI_FULLSCREEN_CONTROLLER_H_ |
OLD | NEW |