Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4986)

Unified Diff: chrome/browser/ui/browser.cc

Issue 7461059: Fullscreen JS API implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to comments Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/browser.cc
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 34c7cdd9e223c36e2173be01bb023ce2e25254ae..188728afd41dae515c7bc33fb357610556503261 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -250,7 +250,9 @@ Browser::Browser(Type type, Profile* profile)
ALLOW_THIS_IN_INITIALIZER_LIST(
tab_restore_service_delegate_(
new BrowserTabRestoreServiceDelegate(this))),
- bookmark_bar_state_(BookmarkBar::HIDDEN) {
+ bookmark_bar_state_(BookmarkBar::HIDDEN),
+ notify_tab_of_fullscreen_exit_(false),
+ tab_caused_fullscreen_(false) {
registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED,
NotificationService::AllSources());
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
@@ -1491,6 +1493,8 @@ void Browser::CloseWindow() {
void Browser::NewTab() {
UserMetrics::RecordAction(UserMetricsAction("NewTab"));
+ ExitTabbedFullscreenMode();
+
if (is_type_tabbed()) {
AddBlankTab(true);
GetSelectedTabContentsWrapper()->view()->RestoreFocus();
@@ -1509,15 +1513,18 @@ void Browser::CloseTab() {
UserMetrics::RecordAction(UserMetricsAction("CloseTab_Accelerator"));
if (CanCloseTab())
tab_handler_->GetTabStripModel()->CloseSelectedTabs();
+ ExitTabbedFullscreenMode();
}
void Browser::SelectNextTab() {
UserMetrics::RecordAction(UserMetricsAction("SelectNextTab"));
+ ExitTabbedFullscreenMode();
tab_handler_->GetTabStripModel()->SelectNextTab();
}
void Browser::SelectPreviousTab() {
UserMetrics::RecordAction(UserMetricsAction("SelectPrevTab"));
+ ExitTabbedFullscreenMode();
Ben Goodger (Google) 2011/08/15 22:37:12 For all of these... these aren't the only ways tha
koz (OOO until 15th September) 2011/08/16 07:06:55 Done.
tab_handler_->GetTabStripModel()->SelectPreviousTab();
}
@@ -1598,6 +1605,8 @@ void Browser::ConvertPopupToTabbedBrowser() {
}
void Browser::ToggleFullscreenMode() {
+ bool entering_fullscreen = !window_->IsFullscreen();
+
#if !defined(OS_MACOSX)
// In kiosk mode, we always want to be fullscreen. When the browser first
// starts we're not yet fullscreen, so let the initial toggle go through.
@@ -1607,7 +1616,7 @@ void Browser::ToggleFullscreenMode() {
#endif
UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen"));
- window_->SetFullscreen(!window_->IsFullscreen());
+ window_->SetFullscreen(entering_fullscreen);
// Once the window has become fullscreen it'll call back to
// WindowFullscreenStateChanged(). We don't do this immediately as
@@ -1619,6 +1628,19 @@ void Browser::ToggleFullscreenMode() {
#if defined(OS_MACOSX)
WindowFullscreenStateChanged();
#endif
+
+ if (!entering_fullscreen)
+ NotifyTabOfFullscreenExit();
+}
+
+void Browser::NotifyTabOfFullscreenExit() {
+ if (!notify_tab_of_fullscreen_exit_)
Ben Goodger (Google) 2011/08/15 22:37:12 Would be nice for the logic of this function to li
koz (OOO until 15th September) 2011/08/16 07:06:55 Done.
+ return;
+ TabContentsWrapper* tab_contents = GetSelectedTabContentsWrapper();
+ RenderViewHost* host = tab_contents->render_view_host();
+ host->Send(new ViewMsg_ExitFullscreen(host->routing_id()));
+ notify_tab_of_fullscreen_exit_ = false;
+ tab_caused_fullscreen_ = false;
}
#if defined(OS_CHROMEOS)
@@ -3123,8 +3145,15 @@ void Browser::AddNewContents(TabContents* source,
}
void Browser::ActivateContents(TabContents* contents) {
+ int activating_index =
+ tab_handler_->GetTabStripModel()->GetWrapperIndex(contents);
+ int active_index = tab_handler_->GetTabStripModel()->active_index();
+
+ if (activating_index != active_index) {
+ ExitTabbedFullscreenMode();
+ }
tab_handler_->GetTabStripModel()->ActivateTabAt(
- tab_handler_->GetTabStripModel()->GetWrapperIndex(contents), false);
+ activating_index, false);
window_->Activate();
}
@@ -3477,6 +3506,30 @@ content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() {
return GetJavaScriptDialogCreatorInstance();
}
+void Browser::ToggleFullscreenModeForRVH(TabContents* tab,
+ bool enter_fullscreen) {
+ if (tab != GetSelectedTabContents())
+ return;
+ if (enter_fullscreen) {
Ben Goodger (Google) 2011/08/15 22:37:12 These toggling functions make my brain hurt. Give
Peter Kasting 2011/08/15 22:42:54 BTW Ben, that's how things originally were, and I
Peter Kasting 2011/08/15 22:42:54 Nit: Shorter: notify_tab_of_fullscreen_exit_ =
koz (OOO until 15th September) 2011/08/16 07:06:55 This is shorter, but I feel it is less semantic. M
+ notify_tab_of_fullscreen_exit_ = true;
+ if (!window_->IsFullscreen()) {
+ tab_caused_fullscreen_ = true;
+ ToggleFullscreenMode();
+ }
+ } else {
+ notify_tab_of_fullscreen_exit_ = false;
+ if (tab_caused_fullscreen_)
+ ToggleFullscreenMode();
+ }
+}
+
+void Browser::ExitTabbedFullscreenMode() {
+ if (tab_caused_fullscreen_)
+ ToggleFullscreenMode();
+ else
+ NotifyTabOfFullscreenExit();
+}
+
///////////////////////////////////////////////////////////////////////////////
// Browser, TabContentsWrapperDelegate implementation:

Powered by Google App Engine
This is Rietveld 408576698