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

Unified Diff: chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc

Issue 14340007: Hide the tab indicators and the shelf when in immersive + tab fullscreen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed kImmersiveModeKey Created 7 years, 8 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
Index: chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc
diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc
index 40f4c01aa769dfda99049b72bd9bb2891b1bfb01..22fbdcf5f59791575d31539e37edc3f6a86e2b5f 100644
--- a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc
+++ b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc
@@ -8,10 +8,13 @@
#include "ash/shell.h"
#include "ash/wm/window_properties.h"
#include "base/command_line.h"
+#include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/top_container_view.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
+#include "chrome/common/chrome_notification_types.h"
+#include "content/public/browser/notification_service.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/capture_client.h"
@@ -312,12 +315,6 @@ class ImmersiveModeControllerAsh::WindowObserver : public aura::WindowObserver {
}
return;
}
- using ash::internal::kImmersiveModeKey;
- if (key == kImmersiveModeKey) {
- // Another component has toggled immersive mode.
- controller_->SetEnabled(window->GetProperty(kImmersiveModeKey));
- return;
- }
}
private:
@@ -333,7 +330,7 @@ ImmersiveModeControllerAsh::ImmersiveModeControllerAsh()
enabled_(false),
reveal_state_(CLOSED),
revealed_lock_count_(0),
- hide_tab_indicators_(false),
+ tab_indicator_visibility_(TAB_INDICATORS_HIDE),
native_window_(NULL),
weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
@@ -371,8 +368,10 @@ void ImmersiveModeControllerAsh::Init(BrowserView* browser_view) {
EnableWindowObservers(true);
// Optionally allow the tab indicators to be hidden.
- hide_tab_indicators_ = CommandLine::ForCurrentProcess()->
- HasSwitch(ash::switches::kAshImmersiveHideTabIndicators);
+ if (CommandLine::ForCurrentProcess()->
+ HasSwitch(ash::switches::kAshImmersiveHideTabIndicators)) {
+ tab_indicator_visibility_ = TAB_INDICATORS_FORCE_HIDE;
+ }
anchored_widget_manager_.reset(new AnchoredWidgetManager(this));
}
@@ -419,13 +418,7 @@ void ImmersiveModeControllerAsh::SetEnabled(bool enabled) {
// Don't need explicit layout because we're inside a fullscreen transition
// and it blocks layout calls.
- // This causes a no-op call to SetEnabled() since enabled_ is already set.
- native_window_->SetProperty(ash::internal::kImmersiveModeKey, enabled_);
- // Ash on Windows may not have a shell.
- if (ash::Shell::HasInstance()) {
- // Shelf auto-hides in immersive mode.
- ash::Shell::GetInstance()->UpdateShelfVisibility();
- }
+ UpdateUseMinimalChrome(LAYOUT_NO);
}
bool ImmersiveModeControllerAsh::IsEnabled() const {
@@ -433,7 +426,7 @@ bool ImmersiveModeControllerAsh::IsEnabled() const {
}
bool ImmersiveModeControllerAsh::ShouldHideTabIndicators() const {
- return hide_tab_indicators_;
+ return tab_indicator_visibility_ != TAB_INDICATORS_SHOW;
}
bool ImmersiveModeControllerAsh::ShouldHideTopViews() const {
@@ -475,6 +468,15 @@ void ImmersiveModeControllerAsh::OnTopContainerBoundsChanged() {
////////////////////////////////////////////////////////////////////////////////
// Observers:
+void ImmersiveModeControllerAsh::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type);
+ if (enabled_)
+ UpdateUseMinimalChrome(LAYOUT_YES);
+}
+
void ImmersiveModeControllerAsh::OnMouseEvent(ui::MouseEvent* event) {
if (!enabled_)
return;
@@ -558,8 +560,12 @@ void ImmersiveModeControllerAsh::OnImplicitAnimationsCompleted() {
////////////////////////////////////////////////////////////////////////////////
// Testing interface:
-void ImmersiveModeControllerAsh::SetHideTabIndicatorsForTest(bool hide) {
- hide_tab_indicators_ = hide;
+void ImmersiveModeControllerAsh::SetForceHideTabIndicatorsForTest(bool force) {
+ if (force)
+ tab_indicator_visibility_ = TAB_INDICATORS_FORCE_HIDE;
+ else if (tab_indicator_visibility_ == TAB_INDICATORS_FORCE_HIDE)
+ tab_indicator_visibility_ = TAB_INDICATORS_HIDE;
+ UpdateUseMinimalChrome(LAYOUT_YES);
}
void ImmersiveModeControllerAsh::StartRevealForTest(bool hovered) {
@@ -601,6 +607,20 @@ void ImmersiveModeControllerAsh::EnableWindowObservers(bool enable) {
// The window observer adds and removes itself from the native window.
window_observer_.reset(enable ? new WindowObserver(this) : NULL);
+ if (enable) {
+ registrar_.Add(
+ this,
+ chrome::NOTIFICATION_FULLSCREEN_CHANGED,
+ content::Source<FullscreenController>(
+ browser_view_->browser()->fullscreen_controller()));
+ } else {
+ registrar_.Remove(
+ this,
+ chrome::NOTIFICATION_FULLSCREEN_CHANGED,
+ content::Source<FullscreenController>(
+ browser_view_->browser()->fullscreen_controller()));
+ }
+
if (!enable)
StopObservingImplicitAnimations();
}
@@ -677,6 +697,35 @@ void ImmersiveModeControllerAsh::UpdateFocusRevealedLock() {
}
}
+void ImmersiveModeControllerAsh::UpdateUseMinimalChrome(Layout layout) {
+ bool in_tab_fullscreen = browser_view_->browser()->fullscreen_controller()->
+ IsFullscreenForTabOrPending();
+ bool use_minimal_chrome = !in_tab_fullscreen && enabled_;
+ native_window_->SetProperty(ash::internal::kFullscreenUsesMinimalChromeKey,
+ use_minimal_chrome);
+
+ TabIndicatorVisibility previous_tab_indicator_visibility =
+ tab_indicator_visibility_;
+ if (tab_indicator_visibility_ != TAB_INDICATORS_FORCE_HIDE) {
+ tab_indicator_visibility_ = use_minimal_chrome ?
+ TAB_INDICATORS_SHOW : TAB_INDICATORS_HIDE;
+ }
+
+ // Ash on Windows may not have a shell.
+ if (ash::Shell::HasInstance()) {
+ // When using minimal chrome, the shelf is auto-hidden. The auto-hidden
+ // shelf displays a 3px 'light bar' when it is closed.
+ ash::Shell::GetInstance()->UpdateShelfVisibility();
+ }
+
+ if (tab_indicator_visibility_ != previous_tab_indicator_visibility) {
+ // If the top-of-window views are revealed or animating, the change will
+ // take effect with the layout once the top-of-window views are closed.
+ if (layout == LAYOUT_YES && reveal_state_ == CLOSED)
+ LayoutBrowserView(true);
+ }
+}
+
int ImmersiveModeControllerAsh::GetAnimationDuration(Animate animate) const {
switch (animate) {
case ANIMATE_NO:

Powered by Google App Engine
This is Rietveld 408576698