OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_BROWSER_H_ | 5 #ifndef CHROME_BROWSER_UI_BROWSER_H_ |
6 #define CHROME_BROWSER_UI_BROWSER_H_ | 6 #define CHROME_BROWSER_UI_BROWSER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 #include "content/public/common/page_transition_types.h" | 48 #include "content/public/common/page_transition_types.h" |
49 #include "content/public/common/page_zoom.h" | 49 #include "content/public/common/page_zoom.h" |
50 #include "ui/base/ui_base_types.h" | 50 #include "ui/base/ui_base_types.h" |
51 #include "ui/gfx/rect.h" | 51 #include "ui/gfx/rect.h" |
52 | 52 |
53 class BrowserSyncedWindowDelegate; | 53 class BrowserSyncedWindowDelegate; |
54 class BrowserTabRestoreServiceDelegate; | 54 class BrowserTabRestoreServiceDelegate; |
55 class BrowserWindow; | 55 class BrowserWindow; |
56 class Extension; | 56 class Extension; |
57 class FindBarController; | 57 class FindBarController; |
58 class FullscreenController; | |
58 class InstantController; | 59 class InstantController; |
59 class InstantUnloadHandler; | 60 class InstantUnloadHandler; |
60 class PrefService; | 61 class PrefService; |
61 class Profile; | 62 class Profile; |
62 class SessionStorageNamespace; | 63 class SessionStorageNamespace; |
63 class SkBitmap; | 64 class SkBitmap; |
64 class StatusBubble; | 65 class StatusBubble; |
65 class TabNavigation; | 66 class TabNavigation; |
66 class TabStripModel; | 67 class TabStripModel; |
67 struct WebApplicationInfo; | 68 struct WebApplicationInfo; |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
487 void ShowSingletonTabOverwritingNTP(const browser::NavigateParams& params); | 488 void ShowSingletonTabOverwritingNTP(const browser::NavigateParams& params); |
488 | 489 |
489 // Creates a NavigateParams struct for a singleton tab navigation. | 490 // Creates a NavigateParams struct for a singleton tab navigation. |
490 browser::NavigateParams GetSingletonTabNavigateParams(const GURL& url); | 491 browser::NavigateParams GetSingletonTabNavigateParams(const GURL& url); |
491 | 492 |
492 // Invoked when the fullscreen state of the window changes. | 493 // Invoked when the fullscreen state of the window changes. |
493 // BrowserWindow::EnterFullscreen invokes this after the window has become | 494 // BrowserWindow::EnterFullscreen invokes this after the window has become |
494 // fullscreen. | 495 // fullscreen. |
495 void WindowFullscreenStateChanged(); | 496 void WindowFullscreenStateChanged(); |
496 | 497 |
497 // Sends a notification that the fullscreen state has changed. | |
498 void NotifyFullscreenChange(); | |
499 | |
500 // Assorted browser commands //////////////////////////////////////////////// | 498 // Assorted browser commands //////////////////////////////////////////////// |
501 | 499 |
502 // NOTE: Within each of the following sections, the IDs are ordered roughly by | 500 // NOTE: Within each of the following sections, the IDs are ordered roughly by |
503 // how they appear in the GUI/menus (left to right, top to bottom, etc.). | 501 // how they appear in the GUI/menus (left to right, top to bottom, etc.). |
504 | 502 |
505 // Navigation commands | 503 // Navigation commands |
506 bool CanGoBack() const; | 504 bool CanGoBack() const; |
507 void GoBack(WindowOpenDisposition disposition); | 505 void GoBack(WindowOpenDisposition disposition); |
508 bool CanGoForward() const; | 506 bool CanGoForward() const; |
509 void GoForward(WindowOpenDisposition disposition); | 507 void GoForward(WindowOpenDisposition disposition); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
826 int from_index, | 824 int from_index, |
827 int to_index); | 825 int to_index); |
828 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | 826 virtual void TabReplacedAt(TabStripModel* tab_strip_model, |
829 TabContentsWrapper* old_contents, | 827 TabContentsWrapper* old_contents, |
830 TabContentsWrapper* new_contents, | 828 TabContentsWrapper* new_contents, |
831 int index); | 829 int index); |
832 virtual void TabPinnedStateChanged(TabContentsWrapper* contents, int index); | 830 virtual void TabPinnedStateChanged(TabContentsWrapper* contents, int index); |
833 virtual void TabStripEmpty(); | 831 virtual void TabStripEmpty(); |
834 | 832 |
835 // Fullscreen permission infobar callbacks. | 833 // Fullscreen permission infobar callbacks. |
836 void OnAcceptFullscreenPermission(const GURL& url, | 834 void OnAcceptFullscreenPermission(const GURL& url, |
yzshen1
2011/11/04 01:56:32
You could make fullscreen exit bubble directly not
koz (OOO until 15th September)
2011/11/06 23:30:20
Would you mind if I do that in a follow up change?
yzshen1
2011/11/08 00:55:41
Okay.
On 2011/11/06 23:30:20, koz wrote:
| |
837 FullscreenExitBubbleType bubble_type); | 835 FullscreenExitBubbleType bubble_type); |
838 void OnDenyFullscreenPermission(FullscreenExitBubbleType bubble_type); | 836 void OnDenyFullscreenPermission(FullscreenExitBubbleType bubble_type); |
839 ContentSetting GetFullscreenSetting(const GURL& url); | |
840 ContentSetting GetMouseLockSetting(const GURL& url); | |
841 | 837 |
842 // Figure out if there are tabs that have beforeunload handlers. | 838 // Figure out if there are tabs that have beforeunload handlers. |
843 bool TabsNeedBeforeUnloadFired(); | 839 bool TabsNeedBeforeUnloadFired(); |
844 | 840 |
845 bool is_type_tabbed() const { return type_ == TYPE_TABBED; } | 841 bool is_type_tabbed() const { return type_ == TYPE_TABBED; } |
846 bool is_type_popup() const { return type_ == TYPE_POPUP; } | 842 bool is_type_popup() const { return type_ == TYPE_POPUP; } |
847 bool is_type_panel() const { return type_ == TYPE_PANEL; } | 843 bool is_type_panel() const { return type_ == TYPE_PANEL; } |
848 | 844 |
849 bool is_app() const; | 845 bool is_app() const; |
850 bool is_devtools() const; | 846 bool is_devtools() const; |
851 | 847 |
852 // True when the current tab is in fullscreen mode, requested by | 848 // True when the current tab is in fullscreen mode, requested by |
853 // webkitRequestFullScreen. | 849 // webkitRequestFullScreen. |
854 bool is_fullscreen_for_tab() const { return fullscreened_tab_ != NULL; } | 850 bool IsFullscreenForTab() const; |
855 | 851 |
856 // Called each time the browser window is shown. | 852 // Called each time the browser window is shown. |
857 void OnWindowDidShow(); | 853 void OnWindowDidShow(); |
858 | 854 |
859 protected: | 855 protected: |
860 // Wrapper for the factory method in BrowserWindow. This allows subclasses to | 856 // Wrapper for the factory method in BrowserWindow. This allows subclasses to |
861 // set their own window. | 857 // set their own window. |
862 virtual BrowserWindow* CreateBrowserWindow(); | 858 virtual BrowserWindow* CreateBrowserWindow(); |
863 | 859 |
864 private: | 860 private: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
902 // Change is the result of the bookmark bar pref changing. | 898 // Change is the result of the bookmark bar pref changing. |
903 BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE, | 899 BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE, |
904 | 900 |
905 // Change is the result of a state change in the active tab. | 901 // Change is the result of a state change in the active tab. |
906 BOOKMARK_BAR_STATE_CHANGE_TAB_STATE, | 902 BOOKMARK_BAR_STATE_CHANGE_TAB_STATE, |
907 | 903 |
908 // Change is the result of window toggling in/out of fullscreen mode. | 904 // Change is the result of window toggling in/out of fullscreen mode. |
909 BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN, | 905 BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN, |
910 }; | 906 }; |
911 | 907 |
912 enum MouseLockState { | |
913 MOUSELOCK_NOT_REQUESTED, | |
914 // The page requests to lock the mouse and the user hasn't responded to the | |
915 // request. | |
916 MOUSELOCK_REQUESTED, | |
917 // Mouse lock has been allowed by the user. | |
918 MOUSELOCK_ACCEPTED | |
919 }; | |
920 | |
921 // Overridden from TabContentsDelegate: | 908 // Overridden from TabContentsDelegate: |
922 // Deprecated. Please use two-argument variant. | 909 // Deprecated. Please use two-argument variant. |
923 // TODO(adriansc): Remove this method once refactoring changed all call sites. | 910 // TODO(adriansc): Remove this method once refactoring changed all call sites. |
924 virtual TabContents* OpenURLFromTab( | 911 virtual TabContents* OpenURLFromTab( |
925 TabContents* source, | 912 TabContents* source, |
926 const GURL& url, | 913 const GURL& url, |
927 const GURL& referrer, | 914 const GURL& referrer, |
928 WindowOpenDisposition disposition, | 915 WindowOpenDisposition disposition, |
929 content::PageTransition transition) OVERRIDE; | 916 content::PageTransition transition) OVERRIDE; |
930 virtual TabContents* OpenURLFromTab(TabContents* source, | 917 virtual TabContents* OpenURLFromTab(TabContents* source, |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1153 // this to return NULL if called before the toolbar has initialized. | 1140 // this to return NULL if called before the toolbar has initialized. |
1154 // TODO(beng): remove this. | 1141 // TODO(beng): remove this. |
1155 StatusBubble* GetStatusBubble(); | 1142 StatusBubble* GetStatusBubble(); |
1156 | 1143 |
1157 // Session restore functions //////////////////////////////////////////////// | 1144 // Session restore functions //////////////////////////////////////////////// |
1158 | 1145 |
1159 // Notifies the history database of the index for all tabs whose index is | 1146 // Notifies the history database of the index for all tabs whose index is |
1160 // >= index. | 1147 // >= index. |
1161 void SyncHistoryWithTabs(int index); | 1148 void SyncHistoryWithTabs(int index); |
1162 | 1149 |
1163 // Tab fullscreen functions ///////////////////////////////////////////////// | |
1164 | |
1165 // There are two different kinds of fullscreen mode - "tab fullscreen" and | |
1166 // "browser fullscreen". "Tab fullscreen" refers to when a tab enters | |
1167 // fullscreen mode via the JS fullscreen API, and "browser fullscreen" | |
1168 // refers to the user putting the browser itself into fullscreen mode from | |
1169 // the UI. The difference is that tab fullscreen has implications for how | |
1170 // the contents of the tab render (eg: a video element may grow to consume | |
1171 // the whole tab), whereas browser fullscreen mode doesn't. Therefore if a | |
1172 // user forces an exit from fullscreen, we need to notify the tab so it can | |
1173 // stop rendering in its fullscreen mode. | |
1174 | |
1175 // Make the current tab exit fullscreen mode if it is in it. | |
1176 void ExitTabbedFullscreenModeIfNecessary(); | |
1177 | |
1178 // Notifies the tab that it has been forced out of fullscreen mode if | |
1179 // necessary. | |
1180 void NotifyTabOfFullscreenExitIfNecessary(); | |
1181 | |
1182 // OnBeforeUnload handling ////////////////////////////////////////////////// | 1150 // OnBeforeUnload handling ////////////////////////////////////////////////// |
1183 | 1151 |
1184 typedef std::set<TabContents*> UnloadListenerSet; | 1152 typedef std::set<TabContents*> UnloadListenerSet; |
1185 | 1153 |
1186 // Processes the next tab that needs it's beforeunload/unload event fired. | 1154 // Processes the next tab that needs it's beforeunload/unload event fired. |
1187 void ProcessPendingTabs(); | 1155 void ProcessPendingTabs(); |
1188 | 1156 |
1189 // Whether we've completed firing all the tabs' beforeunload/unload events. | 1157 // Whether we've completed firing all the tabs' beforeunload/unload events. |
1190 bool HasCompletedUnloadProcessing() const; | 1158 bool HasCompletedUnloadProcessing() const; |
1191 | 1159 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1291 void OpenBookmarkManagerWithHash(const std::string& action, int64 node_id); | 1259 void OpenBookmarkManagerWithHash(const std::string& action, int64 node_id); |
1292 | 1260 |
1293 // Make the current tab exit fullscreen mode. If the browser was fullscreen | 1261 // Make the current tab exit fullscreen mode. If the browser was fullscreen |
1294 // because of that (as opposed to the user clicking the fullscreen button) | 1262 // because of that (as opposed to the user clicking the fullscreen button) |
1295 // then take the browser out of fullscreen mode as well. | 1263 // then take the browser out of fullscreen mode as well. |
1296 void ExitTabbedFullscreenMode(); | 1264 void ExitTabbedFullscreenMode(); |
1297 | 1265 |
1298 // Notifies the tab that it has been forced out of fullscreen mode. | 1266 // Notifies the tab that it has been forced out of fullscreen mode. |
1299 void NotifyTabOfFullscreenExit(); | 1267 void NotifyTabOfFullscreenExit(); |
1300 | 1268 |
1301 // Determines what should be shown in the fullscreen exit bubble. | |
1302 FullscreenExitBubbleType GetFullscreenExitBubbleType() const; | |
1303 | |
1304 // Updates the content of the fullscreen exit bubble. | |
1305 void UpdateFullscreenExitBubbleContent(); | |
1306 | |
1307 // Data members ///////////////////////////////////////////////////////////// | 1269 // Data members ///////////////////////////////////////////////////////////// |
1308 | 1270 |
1309 content::NotificationRegistrar registrar_; | 1271 content::NotificationRegistrar registrar_; |
1310 | 1272 |
1311 PrefChangeRegistrar profile_pref_registrar_; | 1273 PrefChangeRegistrar profile_pref_registrar_; |
1312 | 1274 |
1313 PrefChangeRegistrar local_pref_registrar_; | 1275 PrefChangeRegistrar local_pref_registrar_; |
1314 | 1276 |
1315 // This Browser's type. | 1277 // This Browser's type. |
1316 const Type type_; | 1278 const Type type_; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1437 scoped_ptr<BrowserTabRestoreServiceDelegate> tab_restore_service_delegate_; | 1399 scoped_ptr<BrowserTabRestoreServiceDelegate> tab_restore_service_delegate_; |
1438 | 1400 |
1439 // Helper which implements the SyncedWindowDelegate interface. | 1401 // Helper which implements the SyncedWindowDelegate interface. |
1440 scoped_ptr<BrowserSyncedWindowDelegate> synced_window_delegate_; | 1402 scoped_ptr<BrowserSyncedWindowDelegate> synced_window_delegate_; |
1441 | 1403 |
1442 scoped_ptr<InstantController> instant_; | 1404 scoped_ptr<InstantController> instant_; |
1443 scoped_ptr<InstantUnloadHandler> instant_unload_handler_; | 1405 scoped_ptr<InstantUnloadHandler> instant_unload_handler_; |
1444 | 1406 |
1445 BookmarkBar::State bookmark_bar_state_; | 1407 BookmarkBar::State bookmark_bar_state_; |
1446 | 1408 |
1447 // If there is currently a tab in fullscreen mode (entered via | |
1448 // webkitRequestFullScreen), this is its wrapper. | |
1449 TabContentsWrapper* fullscreened_tab_; | |
1450 | |
1451 // True if the current tab entered fullscreen mode via webkitRequestFullScreen | |
1452 bool tab_caused_fullscreen_; | |
1453 // True if tab fullscreen has been allowed, either by settings or by user | |
1454 // clicking the allow button on the fullscreen infobar. | |
1455 bool tab_fullscreen_accepted_; | |
1456 | |
1457 MouseLockState mouse_lock_state_; | |
1458 | |
1459 // True if the browser window has been shown at least once. | 1409 // True if the browser window has been shown at least once. |
1460 bool window_has_shown_; | 1410 bool window_has_shown_; |
1461 | 1411 |
1412 FullscreenController* fullscreen_controller_; | |
Peter Kasting
2011/11/03 18:24:56
Nit: I'd put this above |window_has_shown_|
tfarina
2011/11/04 01:09:31
Aren't we leaking this? Could you use scoped_ptr?
koz (OOO until 15th September)
2011/11/06 23:30:20
Done.
koz (OOO until 15th September)
2011/11/06 23:30:20
Done.
| |
1413 | |
1462 DISALLOW_COPY_AND_ASSIGN(Browser); | 1414 DISALLOW_COPY_AND_ASSIGN(Browser); |
1463 }; | 1415 }; |
1464 | 1416 |
1465 #endif // CHROME_BROWSER_UI_BROWSER_H_ | 1417 #endif // CHROME_BROWSER_UI_BROWSER_H_ |
OLD | NEW |