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

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

Issue 10378061: Exit tabbed fullscreen mode on navigation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to comments, remove flaky reload test Created 8 years, 6 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/fullscreen_controller.h ('k') | chrome/browser/ui/fullscreen_controller_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/fullscreen_controller.cc
diff --git a/chrome/browser/ui/fullscreen_controller.cc b/chrome/browser/ui/fullscreen_controller.cc
index d75f4e615cc82cdd8eab7d75eb13b23b5ce9c3d1..d171bf016ef8802287abce5c16d4dfc91b98b273 100644
--- a/chrome/browser/ui/fullscreen_controller.cc
+++ b/chrome/browser/ui/fullscreen_controller.cc
@@ -16,6 +16,8 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
+#include "content/public/browser/navigation_details.h"
+#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
@@ -37,7 +39,24 @@ FullscreenController::FullscreenController(BrowserWindow* window,
tab_fullscreen_accepted_(false),
toggled_into_fullscreen_(false),
mouse_lock_tab_(NULL),
- mouse_lock_state_(MOUSELOCK_NOT_REQUESTED) {
+ mouse_lock_state_(MOUSELOCK_NOT_REQUESTED),
+ cancel_fullscreen_on_navigate_mode_(false) {
+}
+
+void FullscreenController::Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ switch (type) {
+ case content::NOTIFICATION_NAV_ENTRY_COMMITTED:
+ if (content::Details<content::LoadCommittedDetails>(details)->
+ is_navigation_to_different_page()) {
+ ExitTabFullscreenOrMouseLockIfNecessary();
+ }
+ break;
+
+ default:
+ NOTREACHED() << "Got a notification we didn't register for.";
+ }
}
bool FullscreenController::IsFullscreenForBrowser() const {
@@ -148,6 +167,7 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
if (enter_fullscreen) {
fullscreened_tab_ = TabContents::FromWebContents(web_contents);
+ EnterCancelFullscreenOnNavigateMode();
if (!in_browser_or_tab_fullscreen_mode) {
tab_caused_fullscreen_ = true;
#if defined(OS_MACOSX)
@@ -166,6 +186,7 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
UpdateFullscreenExitBubbleContent();
}
} else {
+ ExitCancelFullscreenOnNavigateMode();
if (in_browser_or_tab_fullscreen_mode) {
if (tab_caused_fullscreen_) {
#if defined(OS_MACOSX)
@@ -342,6 +363,7 @@ FullscreenController::~FullscreenController() {}
void FullscreenController::NotifyTabOfExitIfNecessary() {
if (fullscreened_tab_) {
+ ExitCancelFullscreenOnNavigateMode();
RenderViewHost* rvh =
fullscreened_tab_->web_contents()->GetRenderViewHost();
fullscreened_tab_ = NULL;
@@ -366,6 +388,23 @@ void FullscreenController::NotifyTabOfExitIfNecessary() {
UpdateFullscreenExitBubbleContent();
}
+void FullscreenController::EnterCancelFullscreenOnNavigateMode() {
+ if (cancel_fullscreen_on_navigate_mode_)
+ return;
+ cancel_fullscreen_on_navigate_mode_ = true;
+ registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
+ content::Source<content::NavigationController>(
+ &fullscreened_tab_->web_contents()->GetController()));
+}
+
+void FullscreenController::ExitCancelFullscreenOnNavigateMode() {
+ if (!cancel_fullscreen_on_navigate_mode_)
+ return;
+ cancel_fullscreen_on_navigate_mode_ = false;
+ registrar_.RemoveAll();
+}
+
+
void FullscreenController::ExitTabFullscreenOrMouseLockIfNecessary() {
if (tab_caused_fullscreen_)
ToggleFullscreenMode();
« no previous file with comments | « chrome/browser/ui/fullscreen_controller.h ('k') | chrome/browser/ui/fullscreen_controller_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698