Index: chrome/browser/ui/fullscreen_controller.cc |
diff --git a/chrome/browser/ui/fullscreen_controller.cc b/chrome/browser/ui/fullscreen_controller.cc |
index b87532864a24622f99ea67f8d293d9fec6f61530..dca0df2fd2e2bcd9bc90e7d49a65d51fdbb0c76e 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 { |
@@ -140,6 +159,7 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents, |
if (enter_fullscreen) { |
fullscreened_tab_ = TabContents::FromWebContents(web_contents); |
sky
2012/06/15 15:01:08
Do we know when we get here fullscreened_tab_ is a
koz (OOO until 15th September)
2012/06/18 02:28:10
I'm not sure. scheib, or yzshen would probably be
scheib
2012/06/18 03:58:09
As far as I can tell by inspection last Friday: I
|
if (!in_browser_or_tab_fullscreen_mode) { |
+ EnterCancelFullscreenOnNavigateMode(); |
tab_caused_fullscreen_ = true; |
#if defined(OS_MACOSX) |
TogglePresentationModeInternal(true); |
@@ -147,6 +167,7 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents, |
ToggleFullscreenModeInternal(true); |
#endif |
} else { |
+ ExitCancelFullscreenOnNavigateMode(); |
scheib
2012/06/15 16:12:31
Are you certain that we only want to be in CancelF
koz (OOO until 15th September)
2012/06/18 02:28:10
Ah yes, good point. Wouldn't I want to move the Ex
scheib
2012/06/18 03:58:09
Line 180 sounds right -- mis-reading of the } else
|
// We need to update the fullscreen exit bubble, e.g., going from browser |
// fullscreen to tab fullscreen will need to show different content. |
const GURL& url = web_contents->GetURL(); |
@@ -333,6 +354,7 @@ FullscreenController::~FullscreenController() {} |
void FullscreenController::NotifyTabOfExitIfNecessary() { |
if (fullscreened_tab_) { |
+ ExitCancelFullscreenOnNavigateMode(); |
RenderViewHost* rvh = |
fullscreened_tab_->web_contents()->GetRenderViewHost(); |
fullscreened_tab_ = NULL; |
@@ -357,6 +379,25 @@ 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_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
sky
2012/06/15 15:01:08
I think you should removeall here. Less error pron
koz (OOO until 15th September)
2012/06/18 02:28:10
Done.
|
+ content::Source<content::NavigationController>( |
+ &fullscreened_tab_->web_contents()->GetController())); |
+} |
+ |
+ |
void FullscreenController::ExitTabFullscreenOrMouseLockIfNecessary() { |
if (tab_caused_fullscreen_) |
ToggleFullscreenMode(); |