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

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
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/tab_contents/tab_contents_wrapper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser.cc
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 34c7cdd9e223c36e2173be01bb023ce2e25254ae..71c5887b548835df97a3774308f5aebd19dfae72 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,
@@ -1598,6 +1600,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 +1611,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 +1623,17 @@ void Browser::ToggleFullscreenMode() {
#if defined(OS_MACOSX)
WindowFullscreenStateChanged();
#endif
+
+ if (!entering_fullscreen)
+ NotifyTabOfFullscreenExitIfNecessary();
+}
+
+void Browser::NotifyTabOfFullscreenExitIfNecessary() {
+ if (!notify_tab_of_fullscreen_exit_)
+ return;
+ GetSelectedTabContentsWrapper()->ExitFullscreenMode();
+ notify_tab_of_fullscreen_exit_ = false;
+ tab_caused_fullscreen_ = false;
}
#if defined(OS_CHROMEOS)
@@ -2886,6 +2901,8 @@ void Browser::TabInsertedAt(TabContentsWrapper* contents,
void Browser::TabClosingAt(TabStripModel* tab_strip_model,
TabContentsWrapper* contents,
int index) {
+ if (contents == GetSelectedTabContentsWrapper())
+ ExitTabbedFullscreenModeIfNecessary();
NotificationService::current()->Notify(
content::NOTIFICATION_TAB_CLOSING,
Source<NavigationController>(&contents->controller()),
@@ -2900,6 +2917,7 @@ void Browser::TabDetachedAt(TabContentsWrapper* contents, int index) {
}
void Browser::TabDeactivated(TabContentsWrapper* contents) {
+ ExitTabbedFullscreenModeIfNecessary();
if (instant())
instant()->DestroyPreviewContents();
@@ -2912,6 +2930,7 @@ void Browser::ActiveTabChanged(TabContentsWrapper* old_contents,
TabContentsWrapper* new_contents,
int index,
bool user_gesture) {
+ ExitTabbedFullscreenModeIfNecessary();
// On some platforms we want to automatically reload tabs that are
// killed when the user selects them.
if (user_gesture && new_contents->tab_contents()->crashed_status() ==
@@ -3123,8 +3142,12 @@ 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();
Peter Kasting 2011/08/16 18:04:43 Nit: This variable seems unused? In fact this who
koz (OOO until 15th September) 2011/08/17 03:47:05 Done.
+
tab_handler_->GetTabStripModel()->ActivateTabAt(
- tab_handler_->GetTabStripModel()->GetWrapperIndex(contents), false);
+ activating_index, false);
window_->Activate();
}
@@ -3477,6 +3500,37 @@ content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() {
return GetJavaScriptDialogCreatorInstance();
}
+void Browser::ToggleFullscreenModeForTab(TabContents* tab,
+ bool enter_fullscreen) {
+ if (tab != GetSelectedTabContents())
+ return;
+ if (enter_fullscreen)
+ EnterFullscreenModeForTab(tab);
Peter Kasting 2011/08/16 18:04:43 I don't think this is a win over your previous pat
koz (OOO until 15th September) 2011/08/17 03:47:05 I think this is clearer because each function is e
+ else
+ ExitFullscreenModeForTab(tab);
+}
+
+void Browser::EnterFullscreenModeForTab(TabContents* tab) {
+ notify_tab_of_fullscreen_exit_ = true;
+ if (!window_->IsFullscreen()) {
+ tab_caused_fullscreen_ = true;
+ ToggleFullscreenMode();
+ }
+}
+
+void Browser::ExitFullscreenModeForTab(TabContents* tab) {
+ notify_tab_of_fullscreen_exit_ = false;
+ if (tab_caused_fullscreen_)
+ ToggleFullscreenMode();
+}
+
+void Browser::ExitTabbedFullscreenModeIfNecessary() {
+ if (tab_caused_fullscreen_)
+ ToggleFullscreenMode();
+ else
+ NotifyTabOfFullscreenExitIfNecessary();
+}
+
///////////////////////////////////////////////////////////////////////////////
// Browser, TabContentsWrapperDelegate implementation:
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/tab_contents/tab_contents_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698