Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 27 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 27 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| 28 #include "chrome/browser/sync/profile_sync_service_observer.h" | 28 #include "chrome/browser/sync/profile_sync_service_observer.h" |
| 29 #include "chrome/browser/tabs/tab_handler.h" | 29 #include "chrome/browser/tabs/tab_handler.h" |
| 30 #include "chrome/browser/tabs/tab_strip_model_delegate.h" // TODO(beng): remove | 30 #include "chrome/browser/tabs/tab_strip_model_delegate.h" // TODO(beng): remove |
| 31 #include "chrome/browser/tabs/tab_strip_model_observer.h" // TODO(beng): remove | 31 #include "chrome/browser/tabs/tab_strip_model_observer.h" // TODO(beng): remove |
| 32 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate. h" | 32 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate. h" |
| 33 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" | 33 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" |
| 34 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper_delegate.h" | 34 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper_delegate.h" |
| 35 #include "chrome/browser/ui/browser_navigator.h" | 35 #include "chrome/browser/ui/browser_navigator.h" |
| 36 #include "chrome/browser/ui/constrained_window_tab_helper_delegate.h" | 36 #include "chrome/browser/ui/constrained_window_tab_helper_delegate.h" |
| 37 #include "chrome/browser/ui/fullscreen_controller.h" | |
| 37 #include "chrome/browser/ui/fullscreen_exit_bubble_type.h" | 38 #include "chrome/browser/ui/fullscreen_exit_bubble_type.h" |
| 38 #include "chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h" | 39 #include "chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h" |
| 39 #include "chrome/browser/ui/select_file_dialog.h" | 40 #include "chrome/browser/ui/select_file_dialog.h" |
| 40 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" | 41 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" |
| 41 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 42 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
| 42 #include "chrome/common/content_settings.h" | 43 #include "chrome/common/content_settings.h" |
| 43 #include "chrome/common/content_settings_types.h" | 44 #include "chrome/common/content_settings_types.h" |
| 44 #include "chrome/common/extensions/extension_constants.h" | 45 #include "chrome/common/extensions/extension_constants.h" |
| 45 #include "content/browser/tab_contents/page_navigator.h" | 46 #include "content/browser/tab_contents/page_navigator.h" |
| 46 #include "content/browser/tab_contents/tab_contents_delegate.h" | 47 #include "content/browser/tab_contents/tab_contents_delegate.h" |
| 47 #include "content/public/browser/notification_registrar.h" | 48 #include "content/public/browser/notification_registrar.h" |
| 48 #include "content/public/common/page_transition_types.h" | 49 #include "content/public/common/page_transition_types.h" |
| 49 #include "content/public/common/page_zoom.h" | 50 #include "content/public/common/page_zoom.h" |
| 50 #include "ui/base/ui_base_types.h" | 51 #include "ui/base/ui_base_types.h" |
| 51 #include "ui/gfx/rect.h" | 52 #include "ui/gfx/rect.h" |
| 52 | 53 |
| 53 class BrowserSyncedWindowDelegate; | 54 class BrowserSyncedWindowDelegate; |
| 54 class BrowserTabRestoreServiceDelegate; | 55 class BrowserTabRestoreServiceDelegate; |
| 55 class BrowserWindow; | 56 class BrowserWindow; |
| 56 class Extension; | 57 class Extension; |
| 57 class FindBarController; | 58 class FindBarController; |
| 59 class FullscreenController; | |
| 58 class HtmlDialogUIDelegate; | 60 class HtmlDialogUIDelegate; |
| 59 class InstantController; | 61 class InstantController; |
| 60 class InstantUnloadHandler; | 62 class InstantUnloadHandler; |
| 61 class PrefService; | 63 class PrefService; |
| 62 class Profile; | 64 class Profile; |
| 63 class SessionStorageNamespace; | 65 class SessionStorageNamespace; |
| 64 class SkBitmap; | 66 class SkBitmap; |
| 65 class StatusBubble; | 67 class StatusBubble; |
| 66 class TabNavigation; | 68 class TabNavigation; |
| 67 class TabStripModel; | 69 class TabStripModel; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 // this Browser. | 217 // this Browser. |
| 216 InstantController* instant() const { return instant_.get(); } | 218 InstantController* instant() const { return instant_.get(); } |
| 217 | 219 |
| 218 #if defined(UNIT_TEST) | 220 #if defined(UNIT_TEST) |
| 219 // Sets the BrowserWindow. This is intended for testing and generally not | 221 // Sets the BrowserWindow. This is intended for testing and generally not |
| 220 // useful outside of testing. Use CreateBrowserWindow outside of testing, or | 222 // useful outside of testing. Use CreateBrowserWindow outside of testing, or |
| 221 // the static convenience methods that create a BrowserWindow for you. | 223 // the static convenience methods that create a BrowserWindow for you. |
| 222 void set_window(BrowserWindow* window) { | 224 void set_window(BrowserWindow* window) { |
| 223 DCHECK(!window_); | 225 DCHECK(!window_); |
| 224 window_ = window; | 226 window_ = window; |
| 227 fullscreen_controller_ = new FullscreenController(window_, profile_, this); | |
| 225 } | 228 } |
| 226 #endif | 229 #endif |
| 227 | 230 |
| 228 // |window()| will return NULL if called before |CreateBrowserWindow()| | 231 // |window()| will return NULL if called before |CreateBrowserWindow()| |
| 229 // is done. | 232 // is done. |
| 230 BrowserWindow* window() const { return window_; } | 233 BrowserWindow* window() const { return window_; } |
| 231 ToolbarModel* toolbar_model() { return &toolbar_model_; } | 234 ToolbarModel* toolbar_model() { return &toolbar_model_; } |
| 232 const SessionID& session_id() const { return session_id_; } | 235 const SessionID& session_id() const { return session_id_; } |
| 233 CommandUpdater* command_updater() { return &command_updater_; } | 236 CommandUpdater* command_updater() { return &command_updater_; } |
| 234 bool block_command_execution() const { return block_command_execution_; } | 237 bool block_command_execution() const { return block_command_execution_; } |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 void ShowSingletonTabOverwritingNTP(const browser::NavigateParams& params); | 495 void ShowSingletonTabOverwritingNTP(const browser::NavigateParams& params); |
| 493 | 496 |
| 494 // Creates a NavigateParams struct for a singleton tab navigation. | 497 // Creates a NavigateParams struct for a singleton tab navigation. |
| 495 browser::NavigateParams GetSingletonTabNavigateParams(const GURL& url); | 498 browser::NavigateParams GetSingletonTabNavigateParams(const GURL& url); |
| 496 | 499 |
| 497 // Invoked when the fullscreen state of the window changes. | 500 // Invoked when the fullscreen state of the window changes. |
| 498 // BrowserWindow::EnterFullscreen invokes this after the window has become | 501 // BrowserWindow::EnterFullscreen invokes this after the window has become |
| 499 // fullscreen. | 502 // fullscreen. |
| 500 void WindowFullscreenStateChanged(); | 503 void WindowFullscreenStateChanged(); |
| 501 | 504 |
| 502 // Sends a notification that the fullscreen state has changed. | |
| 503 void NotifyFullscreenChange(); | |
| 504 | |
| 505 // Assorted browser commands //////////////////////////////////////////////// | 505 // Assorted browser commands //////////////////////////////////////////////// |
| 506 | 506 |
| 507 // NOTE: Within each of the following sections, the IDs are ordered roughly by | 507 // NOTE: Within each of the following sections, the IDs are ordered roughly by |
| 508 // how they appear in the GUI/menus (left to right, top to bottom, etc.). | 508 // how they appear in the GUI/menus (left to right, top to bottom, etc.). |
| 509 | 509 |
| 510 // Navigation commands | 510 // Navigation commands |
| 511 bool CanGoBack() const; | 511 bool CanGoBack() const; |
| 512 void GoBack(WindowOpenDisposition disposition); | 512 void GoBack(WindowOpenDisposition disposition); |
| 513 bool CanGoForward() const; | 513 bool CanGoForward() const; |
| 514 void GoForward(WindowOpenDisposition disposition); | 514 void GoForward(WindowOpenDisposition disposition); |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 831 int from_index, | 831 int from_index, |
| 832 int to_index); | 832 int to_index); |
| 833 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | 833 virtual void TabReplacedAt(TabStripModel* tab_strip_model, |
| 834 TabContentsWrapper* old_contents, | 834 TabContentsWrapper* old_contents, |
| 835 TabContentsWrapper* new_contents, | 835 TabContentsWrapper* new_contents, |
| 836 int index); | 836 int index); |
| 837 virtual void TabPinnedStateChanged(TabContentsWrapper* contents, int index); | 837 virtual void TabPinnedStateChanged(TabContentsWrapper* contents, int index); |
| 838 virtual void TabStripEmpty(); | 838 virtual void TabStripEmpty(); |
| 839 | 839 |
| 840 // Fullscreen permission infobar callbacks. | 840 // Fullscreen permission infobar callbacks. |
| 841 // TODO(koz): Remove this and have callers call FullscreenController directly. | |
|
Peter Kasting
2011/11/21 19:17:46
This is probably also what we should do for Toggle
| |
| 841 void OnAcceptFullscreenPermission(const GURL& url, | 842 void OnAcceptFullscreenPermission(const GURL& url, |
| 842 FullscreenExitBubbleType bubble_type); | 843 FullscreenExitBubbleType bubble_type); |
| 843 void OnDenyFullscreenPermission(FullscreenExitBubbleType bubble_type); | 844 void OnDenyFullscreenPermission(FullscreenExitBubbleType bubble_type); |
| 844 ContentSetting GetFullscreenSetting(const GURL& url); | |
| 845 ContentSetting GetMouseLockSetting(const GURL& url); | |
| 846 | 845 |
| 847 // Figure out if there are tabs that have beforeunload handlers. | 846 // Figure out if there are tabs that have beforeunload handlers. |
| 848 bool TabsNeedBeforeUnloadFired(); | 847 bool TabsNeedBeforeUnloadFired(); |
| 849 | 848 |
| 850 bool is_type_tabbed() const { return type_ == TYPE_TABBED; } | 849 bool is_type_tabbed() const { return type_ == TYPE_TABBED; } |
| 851 bool is_type_popup() const { return type_ == TYPE_POPUP; } | 850 bool is_type_popup() const { return type_ == TYPE_POPUP; } |
| 852 bool is_type_panel() const { return type_ == TYPE_PANEL; } | 851 bool is_type_panel() const { return type_ == TYPE_PANEL; } |
| 853 | 852 |
| 854 bool is_app() const; | 853 bool is_app() const; |
| 855 bool is_devtools() const; | 854 bool is_devtools() const; |
| 856 | 855 |
| 857 // True when the current tab is in fullscreen mode, requested by | 856 // True when the current tab is in fullscreen mode, requested by |
| 858 // webkitRequestFullScreen. | 857 // webkitRequestFullScreen. |
| 859 bool is_fullscreen_for_tab() const { return fullscreened_tab_ != NULL; } | 858 bool IsFullscreenForTab() const; |
| 860 | 859 |
| 861 // Called each time the browser window is shown. | 860 // Called each time the browser window is shown. |
| 862 void OnWindowDidShow(); | 861 void OnWindowDidShow(); |
| 863 | 862 |
| 864 protected: | 863 protected: |
| 865 // Wrapper for the factory method in BrowserWindow. This allows subclasses to | 864 // Wrapper for the factory method in BrowserWindow. This allows subclasses to |
| 866 // set their own window. | 865 // set their own window. |
| 867 virtual BrowserWindow* CreateBrowserWindow(); | 866 virtual BrowserWindow* CreateBrowserWindow(); |
| 868 | 867 |
| 869 private: | 868 private: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 907 // Change is the result of the bookmark bar pref changing. | 906 // Change is the result of the bookmark bar pref changing. |
| 908 BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE, | 907 BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE, |
| 909 | 908 |
| 910 // Change is the result of a state change in the active tab. | 909 // Change is the result of a state change in the active tab. |
| 911 BOOKMARK_BAR_STATE_CHANGE_TAB_STATE, | 910 BOOKMARK_BAR_STATE_CHANGE_TAB_STATE, |
| 912 | 911 |
| 913 // Change is the result of window toggling in/out of fullscreen mode. | 912 // Change is the result of window toggling in/out of fullscreen mode. |
| 914 BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN, | 913 BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN, |
| 915 }; | 914 }; |
| 916 | 915 |
| 917 enum MouseLockState { | |
| 918 MOUSELOCK_NOT_REQUESTED, | |
| 919 // The page requests to lock the mouse and the user hasn't responded to the | |
| 920 // request. | |
| 921 MOUSELOCK_REQUESTED, | |
| 922 // Mouse lock has been allowed by the user. | |
| 923 MOUSELOCK_ACCEPTED | |
| 924 }; | |
| 925 | |
| 926 // Overridden from TabContentsDelegate: | 916 // Overridden from TabContentsDelegate: |
| 927 // Deprecated. Please use two-argument variant. | 917 // Deprecated. Please use two-argument variant. |
| 928 // TODO(adriansc): Remove this method once refactoring changed all call sites. | 918 // TODO(adriansc): Remove this method once refactoring changed all call sites. |
| 929 virtual TabContents* OpenURLFromTab( | 919 virtual TabContents* OpenURLFromTab( |
| 930 TabContents* source, | 920 TabContents* source, |
| 931 const GURL& url, | 921 const GURL& url, |
| 932 const GURL& referrer, | 922 const GURL& referrer, |
| 933 WindowOpenDisposition disposition, | 923 WindowOpenDisposition disposition, |
| 934 content::PageTransition transition) OVERRIDE; | 924 content::PageTransition transition) OVERRIDE; |
| 935 virtual TabContents* OpenURLFromTab(TabContents* source, | 925 virtual TabContents* OpenURLFromTab(TabContents* source, |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1167 // this to return NULL if called before the toolbar has initialized. | 1157 // this to return NULL if called before the toolbar has initialized. |
| 1168 // TODO(beng): remove this. | 1158 // TODO(beng): remove this. |
| 1169 StatusBubble* GetStatusBubble(); | 1159 StatusBubble* GetStatusBubble(); |
| 1170 | 1160 |
| 1171 // Session restore functions //////////////////////////////////////////////// | 1161 // Session restore functions //////////////////////////////////////////////// |
| 1172 | 1162 |
| 1173 // Notifies the history database of the index for all tabs whose index is | 1163 // Notifies the history database of the index for all tabs whose index is |
| 1174 // >= index. | 1164 // >= index. |
| 1175 void SyncHistoryWithTabs(int index); | 1165 void SyncHistoryWithTabs(int index); |
| 1176 | 1166 |
| 1177 // Tab fullscreen functions ///////////////////////////////////////////////// | |
| 1178 | |
| 1179 // There are two different kinds of fullscreen mode - "tab fullscreen" and | |
| 1180 // "browser fullscreen". "Tab fullscreen" refers to when a tab enters | |
| 1181 // fullscreen mode via the JS fullscreen API, and "browser fullscreen" | |
| 1182 // refers to the user putting the browser itself into fullscreen mode from | |
| 1183 // the UI. The difference is that tab fullscreen has implications for how | |
| 1184 // the contents of the tab render (eg: a video element may grow to consume | |
| 1185 // the whole tab), whereas browser fullscreen mode doesn't. Therefore if a | |
| 1186 // user forces an exit from fullscreen, we need to notify the tab so it can | |
| 1187 // stop rendering in its fullscreen mode. | |
| 1188 | |
| 1189 // Make the current tab exit fullscreen mode if it is in it. | |
| 1190 void ExitTabbedFullscreenModeIfNecessary(); | |
| 1191 | |
| 1192 // Notifies the tab that it has been forced out of fullscreen mode if | |
| 1193 // necessary. | |
| 1194 void NotifyTabOfFullscreenExitIfNecessary(); | |
| 1195 | |
| 1196 // OnBeforeUnload handling ////////////////////////////////////////////////// | 1167 // OnBeforeUnload handling ////////////////////////////////////////////////// |
| 1197 | 1168 |
| 1198 typedef std::set<TabContents*> UnloadListenerSet; | 1169 typedef std::set<TabContents*> UnloadListenerSet; |
| 1199 | 1170 |
| 1200 // Processes the next tab that needs it's beforeunload/unload event fired. | 1171 // Processes the next tab that needs it's beforeunload/unload event fired. |
| 1201 void ProcessPendingTabs(); | 1172 void ProcessPendingTabs(); |
| 1202 | 1173 |
| 1203 // Whether we've completed firing all the tabs' beforeunload/unload events. | 1174 // Whether we've completed firing all the tabs' beforeunload/unload events. |
| 1204 bool HasCompletedUnloadProcessing() const; | 1175 bool HasCompletedUnloadProcessing() const; |
| 1205 | 1176 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1305 void OpenBookmarkManagerWithHash(const std::string& action, int64 node_id); | 1276 void OpenBookmarkManagerWithHash(const std::string& action, int64 node_id); |
| 1306 | 1277 |
| 1307 // Make the current tab exit fullscreen mode. If the browser was fullscreen | 1278 // Make the current tab exit fullscreen mode. If the browser was fullscreen |
| 1308 // because of that (as opposed to the user clicking the fullscreen button) | 1279 // because of that (as opposed to the user clicking the fullscreen button) |
| 1309 // then take the browser out of fullscreen mode as well. | 1280 // then take the browser out of fullscreen mode as well. |
| 1310 void ExitTabbedFullscreenMode(); | 1281 void ExitTabbedFullscreenMode(); |
| 1311 | 1282 |
| 1312 // Notifies the tab that it has been forced out of fullscreen mode. | 1283 // Notifies the tab that it has been forced out of fullscreen mode. |
| 1313 void NotifyTabOfFullscreenExit(); | 1284 void NotifyTabOfFullscreenExit(); |
| 1314 | 1285 |
| 1315 // Determines what should be shown in the fullscreen exit bubble. | |
| 1316 FullscreenExitBubbleType GetFullscreenExitBubbleType() const; | |
| 1317 | |
| 1318 // Updates the content of the fullscreen exit bubble. | |
| 1319 void UpdateFullscreenExitBubbleContent(); | |
| 1320 | |
| 1321 // Data members ///////////////////////////////////////////////////////////// | 1286 // Data members ///////////////////////////////////////////////////////////// |
| 1322 | 1287 |
| 1323 content::NotificationRegistrar registrar_; | 1288 content::NotificationRegistrar registrar_; |
| 1324 | 1289 |
| 1325 PrefChangeRegistrar profile_pref_registrar_; | 1290 PrefChangeRegistrar profile_pref_registrar_; |
| 1326 | 1291 |
| 1327 PrefChangeRegistrar local_pref_registrar_; | 1292 PrefChangeRegistrar local_pref_registrar_; |
| 1328 | 1293 |
| 1329 // This Browser's type. | 1294 // This Browser's type. |
| 1330 const Type type_; | 1295 const Type type_; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1451 scoped_ptr<BrowserTabRestoreServiceDelegate> tab_restore_service_delegate_; | 1416 scoped_ptr<BrowserTabRestoreServiceDelegate> tab_restore_service_delegate_; |
| 1452 | 1417 |
| 1453 // Helper which implements the SyncedWindowDelegate interface. | 1418 // Helper which implements the SyncedWindowDelegate interface. |
| 1454 scoped_ptr<BrowserSyncedWindowDelegate> synced_window_delegate_; | 1419 scoped_ptr<BrowserSyncedWindowDelegate> synced_window_delegate_; |
| 1455 | 1420 |
| 1456 scoped_ptr<InstantController> instant_; | 1421 scoped_ptr<InstantController> instant_; |
| 1457 scoped_ptr<InstantUnloadHandler> instant_unload_handler_; | 1422 scoped_ptr<InstantUnloadHandler> instant_unload_handler_; |
| 1458 | 1423 |
| 1459 BookmarkBar::State bookmark_bar_state_; | 1424 BookmarkBar::State bookmark_bar_state_; |
| 1460 | 1425 |
| 1461 // If there is currently a tab in fullscreen mode (entered via | 1426 scoped_refptr<FullscreenController> fullscreen_controller_; |
|
Peter Kasting
2011/11/21 19:17:46
Why is this a refcounted object? It seems like a
| |
| 1462 // webkitRequestFullScreen), this is its wrapper. | |
| 1463 TabContentsWrapper* fullscreened_tab_; | |
| 1464 | |
| 1465 // True if the current tab entered fullscreen mode via webkitRequestFullScreen | |
| 1466 bool tab_caused_fullscreen_; | |
| 1467 // True if tab fullscreen has been allowed, either by settings or by user | |
| 1468 // clicking the allow button on the fullscreen infobar. | |
| 1469 bool tab_fullscreen_accepted_; | |
| 1470 | |
| 1471 MouseLockState mouse_lock_state_; | |
| 1472 | 1427 |
| 1473 // True if the browser window has been shown at least once. | 1428 // True if the browser window has been shown at least once. |
| 1474 bool window_has_shown_; | 1429 bool window_has_shown_; |
| 1475 | 1430 |
| 1476 DISALLOW_COPY_AND_ASSIGN(Browser); | 1431 DISALLOW_COPY_AND_ASSIGN(Browser); |
| 1477 }; | 1432 }; |
| 1478 | 1433 |
| 1479 #endif // CHROME_BROWSER_UI_BROWSER_H_ | 1434 #endif // CHROME_BROWSER_UI_BROWSER_H_ |
| OLD | NEW |