| Index: chrome/browser/ui/browser.cc
|
| diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
|
| index f54bcf50505712137a5a87b34461f1cbc9816a65..e41a5980bf7a395e72dfd26ae2601e0fe60867ce 100644
|
| --- a/chrome/browser/ui/browser.cc
|
| +++ b/chrome/browser/ui/browser.cc
|
| @@ -259,7 +259,9 @@ Browser::Browser(Type type, Profile* profile)
|
| ALLOW_THIS_IN_INITIALIZER_LIST(
|
| synced_window_delegate_(
|
| new BrowserSyncedWindowDelegate(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,
|
| @@ -1622,6 +1624,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.
|
| @@ -1631,7 +1635,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
|
| @@ -1643,6 +1647,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_MACOSX)
|
| @@ -2958,6 +2972,8 @@ void Browser::TabDetachedAt(TabContentsWrapper* contents, int index) {
|
| }
|
|
|
| void Browser::TabDeactivated(TabContentsWrapper* contents) {
|
| + if (contents == fullscreened_tab_)
|
| + ExitTabbedFullscreenModeIfNecessary();
|
| if (instant())
|
| instant()->DestroyPreviewContents();
|
|
|
| @@ -3552,6 +3568,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:
|
|
|
|
|