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

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: rebase 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/browser_browsertest.cc » ('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 7a3b85ed2881565b506f4153b91d5e4f0a4281de..c54df51b8330a112ce12f56da55c0eb9cf420575 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -262,7 +262,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,
@@ -1282,6 +1284,16 @@ void Browser::ShowSingletonTabOverwritingNTP(
void Browser::WindowFullscreenStateChanged() {
UpdateCommandsForFullscreenMode(window_->IsFullscreen());
UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN);
+ MessageLoop::current()->PostTask(
+ FROM_HERE, method_factory_.NewRunnableMethod(
+ &Browser::NotifyFullscreenChange));
+}
+
+void Browser::NotifyFullscreenChange() {
+ NotificationService::current()->Notify(
+ chrome::NOTIFICATION_FULLSCREEN_CHANGED,
+ Source<Browser>(this),
+ NotificationService::NoDetails());
}
///////////////////////////////////////////////////////////////////////////////
@@ -1630,6 +1642,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.
@@ -1639,7 +1653,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
@@ -1651,6 +1665,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)
@@ -2996,6 +3020,8 @@ void Browser::TabDetachedAt(TabContentsWrapper* contents, int index) {
}
void Browser::TabDeactivated(TabContentsWrapper* contents) {
+ if (contents == fullscreened_tab_)
+ ExitTabbedFullscreenModeIfNecessary();
if (instant())
instant()->DestroyPreviewContents();
@@ -3599,6 +3625,25 @@ void Browser::EnumerateDirectory(TabContents* tab, int request_id,
Browser::EnumerateDirectoryHelper(tab, request_id, path);
}
+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:
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698