Index: chrome/browser/ui/browser.cc |
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc |
index 34c7cdd9e223c36e2173be01bb023ce2e25254ae..be6c9d44e1cc2419475aec07cf3e8e261633254b 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), |
+ fullscreened_tab_(NULL), |
+ 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,16 @@ void Browser::ToggleFullscreenMode() { |
#if defined(OS_MACOSX) |
WindowFullscreenStateChanged(); |
#endif |
+ |
+ if (!entering_fullscreen) |
+ NotifyTabOfFullscreenExitIfNecessary(); |
+} |
+ |
+void Browser::NotifyTabOfFullscreenExitIfNecessary() { |
+ if (fullscreened_tab_) |
+ fullscreened_tab_->ExitFullscreenMode(); |
+ fullscreened_tab_ = NULL; |
+ tab_caused_fullscreen_ = false; |
} |
#if defined(OS_CHROMEOS) |
@@ -2912,6 +2926,7 @@ void Browser::ActiveTabChanged(TabContentsWrapper* old_contents, |
TabContentsWrapper* new_contents, |
int index, |
bool user_gesture) { |
+ ExitTabbedFullscreenModeIfNecessary(); |
Peter Kasting
2011/08/18 00:48:51
I wonder if it would be better to move this into T
|
// 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() == |
@@ -3477,6 +3492,25 @@ content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() { |
return GetJavaScriptDialogCreatorInstance(); |
} |
+void Browser::ToggleFullscreenModeForTab(TabContents* tab, |
+ bool enter_fullscreen) { |
+ if (tab != GetSelectedTabContents()) |
+ return; |
+ fullscreened_tab_ = enter_fullscreen ? |
+ TabContentsWrapper::GetCurrentWrapperForContents(tab) : NULL; |
+ if (enter_fullscreen && !window_->IsFullscreen()) |
+ tab_caused_fullscreen_ = true; |
+ if (tab_caused_fullscreen_) |
+ ToggleFullscreenMode(); |
+} |
+ |
+void Browser::ExitTabbedFullscreenModeIfNecessary() { |
+ if (tab_caused_fullscreen_) |
+ ToggleFullscreenMode(); |
+ else |
+ NotifyTabOfFullscreenExitIfNecessary(); |
+} |
+ |
/////////////////////////////////////////////////////////////////////////////// |
// Browser, TabContentsWrapperDelegate implementation: |