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 | |
Peter Kasting
2011/11/21 19:17:46
Nit: This comment seems sort of randomly placed he
| |
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 FullscreenExitBubbleType GetFullscreenExitBubbleType() const; | |
64 | |
65 private: | |
66 enum MouseLockState { | |
67 MOUSELOCK_NOT_REQUESTED, | |
68 // The page requests to lock the mouse and the user hasn't responded to the | |
69 // request. | |
70 MOUSELOCK_REQUESTED, | |
71 // Mouse lock has been allowed by the user. | |
72 MOUSELOCK_ACCEPTED | |
73 }; | |
74 | |
75 // Notifies the tab that it has been forced out of fullscreen mode if | |
76 // necessary. | |
77 void NotifyTabOfFullscreenExitIfNecessary(); | |
78 // Make the current tab exit fullscreen mode if it is in it. | |
79 void ExitTabbedFullscreenModeIfNecessary(); | |
80 void UpdateFullscreenExitBubbleContent(); | |
81 void NotifyFullscreenChange(); | |
82 ContentSetting GetFullscreenSetting(const GURL& url) const; | |
83 ContentSetting GetMouseLockSetting(const GURL& url) const; | |
84 | |
85 BrowserWindow* window_; | |
86 Profile* profile_; | |
87 Browser* browser_; | |
88 | |
89 // If there is currently a tab in fullscreen mode (entered via | |
90 // webkitRequestFullScreen), this is its wrapper. | |
91 TabContentsWrapper* fullscreened_tab_; | |
92 | |
93 // True if the current tab entered fullscreen mode via webkitRequestFullScreen | |
94 bool tab_caused_fullscreen_; | |
95 // True if tab fullscreen has been allowed, either by settings or by user | |
96 // clicking the allow button on the fullscreen infobar. | |
97 bool tab_fullscreen_accepted_; | |
98 | |
99 MouseLockState mouse_lock_state_; | |
100 | |
101 DISALLOW_COPY_AND_ASSIGN(FullscreenController); | |
102 }; | |
103 | |
104 #endif // CHROME_BROWSER_UI_FULLSCREEN_CONTROLLER_H_ | |
OLD | NEW |