diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-12 02:23:10 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-12 02:23:10 +0000 |
commit | 3ebd306836ea35009b04fa6f75e103b4929ebc80 (patch) | |
tree | 4b802d77aca954470302581f5841f1af964700e7 | |
parent | 44b8355d95c1e6f7d3021dcd69c4d1527e014e3f (diff) | |
download | chromium_src-3ebd306836ea35009b04fa6f75e103b4929ebc80.zip chromium_src-3ebd306836ea35009b04fa6f75e103b4929ebc80.tar.gz chromium_src-3ebd306836ea35009b04fa6f75e103b4929ebc80.tar.bz2 |
Add new TopContainerView to BrowserView for CrOS immersive fullscreen
This avoids reparenting the tabstrip and toolbar to a separate view
when sliding the top views in and out. It lays the ground work for
supporting the bookmark bar in the slide-out view.
BUG=180357,163646
TEST=added to browser_tests ImmersiveModeControllerTest, BrowserViewTest
Review URL: https://chromiumcodereview.appspot.com/12631010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187458 0039d316-1c4b-4281-b951-d872f2087c98
12 files changed, 269 insertions, 398 deletions
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc index 12d8934..4a92b2e 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc @@ -83,6 +83,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNonClientFrameViewAshTest, ImmersiveMode) { BrowserNonClientFrameViewAsh* frame_view = static_cast<BrowserNonClientFrameViewAsh*>( widget->non_client_view()->frame_view()); + ASSERT_FALSE(widget->IsFullscreen()); // Immersive mode starts disabled. EXPECT_FALSE(browser_view->immersive_mode_controller()->enabled()); @@ -94,17 +95,9 @@ IN_PROC_BROWSER_TEST_F(BrowserNonClientFrameViewAshTest, ImmersiveMode) { browser_view->EnterFullscreen(GURL(), FEB_TYPE_NONE); EXPECT_TRUE(browser_view->immersive_mode_controller()->enabled()); - // During the slide-out animation the buttons are visible. - EXPECT_TRUE(frame_view->size_button_->visible()); - EXPECT_TRUE(frame_view->close_button_->visible()); - EXPECT_TRUE(frame_view->ShouldPaint()); - - // Short-circuit the initial slide-out animation. In the steady state the - // frame and caption buttons are hidden. - browser_view->immersive_mode_controller()->CancelReveal(); - EXPECT_FALSE(frame_view->size_button_->visible()); - EXPECT_FALSE(frame_view->close_button_->visible()); - EXPECT_FALSE(frame_view->ShouldPaint()); + // TODO(jamescook): When adding back the slide-out animation for immersive + // mode, this is a good place to test the button visibility. CancelReveal() + // can short-circuit the animation if it has to wait on painting. // Frame abuts top of window. EXPECT_EQ(0, frame_view->NonClientTopBorderHeight(false)); diff --git a/chrome/browser/ui/views/frame/browser_root_view.cc b/chrome/browser/ui/views/frame/browser_root_view.cc index 4a35e52..7610d0e 100644 --- a/chrome/browser/ui/views/frame/browser_root_view.cc +++ b/chrome/browser/ui/views/frame/browser_root_view.cc @@ -13,6 +13,7 @@ #include "chrome/browser/ui/omnibox/location_bar.h" #include "chrome/browser/ui/views/frame/browser_frame.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/immersive_mode_controller.h" #include "chrome/browser/ui/views/tabs/tab_strip.h" #include "chrome/common/chrome_notification_types.h" @@ -130,15 +131,11 @@ void BrowserRootView::SchedulePaintInRect(const gfx::Rect& rect) { if (scheduling_immersive_reveal_painting_) return; + // Paint the frame caption area and window controls during immersive reveal. if (browser_view_ && - browser_view_->immersive_mode_controller() && browser_view_->immersive_mode_controller()->IsRevealed()) { - views::View* reveal = - browser_view_->immersive_mode_controller()->reveal_view(); - if (reveal) { - base::AutoReset<bool> reset(&scheduling_immersive_reveal_painting_, true); - reveal->SchedulePaintInRect(rect); - } + base::AutoReset<bool> reset(&scheduling_immersive_reveal_painting_, true); + browser_view_->top_container()->SchedulePaintInRect(rect); } } diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 2a9b01e..ac30bcb 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -63,6 +63,7 @@ #include "chrome/browser/ui/views/frame/browser_view_layout.h" #include "chrome/browser/ui/views/frame/contents_container.h" #include "chrome/browser/ui/views/frame/instant_overlay_controller_views.h" +#include "chrome/browser/ui/views/frame/top_container_view.h" #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" #include "chrome/browser/ui/views/immersive_mode_controller.h" #include "chrome/browser/ui/views/infobars/infobar_container_view.h" @@ -214,10 +215,6 @@ void PaintAttachedBookmarkBar(gfx::Canvas* canvas, // Returned from BrowserView::GetClassName. const char BrowserView::kViewClassName[] = "browser/ui/views/BrowserView"; -// static -const int BrowserView::kTabstripIndex = 0; -const int BrowserView::kInfoBarIndex = 1; -const int BrowserView::kToolbarIndex = 2; namespace { @@ -424,6 +421,7 @@ BrowserView::BrowserView(Browser* browser) views::ViewStorage::GetInstance()->CreateStorageID()), frame_(NULL), browser_(browser), + top_container_(NULL), active_bookmark_bar_(NULL), tabstrip_(NULL), toolbar_(NULL), @@ -972,8 +970,7 @@ void BrowserView::ToolbarSizeChanged(bool is_animating) { } void BrowserView::MaybeStackImmersiveRevealAtTop() { - if (immersive_mode_controller_) - immersive_mode_controller_->MaybeStackViewAtTop(); + immersive_mode_controller_->MaybeStackViewAtTop(); } LocationBar* BrowserView::GetLocationBar() const { @@ -2027,26 +2024,14 @@ void BrowserView::Init() { LoadAccelerators(); - // TabStrip takes ownership of the controller. - BrowserTabStripController* tabstrip_controller = - new BrowserTabStripController(browser_.get(), - browser_->tab_strip_model()); - tabstrip_ = new TabStrip(tabstrip_controller); - AddChildViewAt(tabstrip_, kTabstripIndex); - tabstrip_controller->InitFromModel(tabstrip_); - infobar_container_ = new InfoBarContainerView(this, browser()->search_model()); - AddChildViewAt(infobar_container_, kInfoBarIndex); + AddChildView(infobar_container_); contents_container_ = new views::WebView(browser_->profile()); contents_container_->set_id(VIEW_ID_TAB_CONTAINER); contents_ = new ContentsContainer(contents_container_); - toolbar_ = new ToolbarView(browser_.get()); - AddChildViewAt(toolbar_, kToolbarIndex); - toolbar_->Init(); - overlay_controller_.reset( new InstantOverlayControllerViews(browser(), contents_)); @@ -2074,6 +2059,23 @@ void BrowserView::Init() { status_bubble_.reset(new StatusBubbleViews(contents_)); + // Top container holds tab strip and toolbar and lives at the front of the + // view hierarchy. + top_container_ = new TopContainerView(this); + AddChildView(top_container_); + + // TabStrip takes ownership of the controller. + BrowserTabStripController* tabstrip_controller = + new BrowserTabStripController(browser_.get(), + browser_->tab_strip_model()); + tabstrip_ = new TabStrip(tabstrip_controller); + top_container_->AddChildView(tabstrip_); + tabstrip_controller->InitFromModel(tabstrip_); + + toolbar_ = new ToolbarView(browser_.get()); + top_container_->AddChildView(toolbar_); + toolbar_->Init(); + #if defined(OS_WIN) && !defined(USE_AURA) // Create a custom JumpList and add it to an observer of TabRestoreService // so we can update the custom JumpList when a tab is added or removed. diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index ee8fbce..9a8b789 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h @@ -54,6 +54,7 @@ class SearchViewController; class TabStrip; class TabStripModel; class ToolbarView; +class TopContainerView; #if defined(OS_WIN) class JumpList; @@ -101,10 +102,6 @@ class BrowserView : public BrowserWindow, public: // The browser view's class name. static const char kViewClassName[]; - // Initial child indices for well-known views. - static const int kTabstripIndex; - static const int kInfoBarIndex; - static const int kToolbarIndex; explicit BrowserView(Browser* browser); virtual ~BrowserView(); @@ -153,6 +150,9 @@ class BrowserView : public BrowserWindow, gfx::Point OffsetPointForToolbarBackgroundImage( const gfx::Point& point) const; + // Container for the tabstrip, toolbar, etc. + TopContainerView* top_container() { return top_container_; } + // Accessor for the TabStrip. TabStrip* tabstrip() { return tabstrip_; } @@ -604,41 +604,46 @@ class BrowserView : public BrowserWindow, // BrowserView layout (LTR one is pictured here). // // -------------------------------------------------------------------- - // | Tabs (tabstrip_) [1] | - // |------------------------------------------------------------------| - // | Navigation buttons, menus and the address bar (toolbar_) [1] | + // | TopContainerView (top_container_) | + // | -------------------------------------------------------------- | + // | | Tabs (tabstrip_) | | + // | |------------------------------------------------------------| | + // | | Navigation buttons, address bar, menu (toolbar_) | | + // | -------------------------------------------------------------- | // |------------------------------------------------------------------| - // | All infobars (infobar_container_) [2] | + // | All infobars (infobar_container_) [1] | // |------------------------------------------------------------------| - // | Bookmarks (bookmark_bar_view_) [2] | + // | Bookmarks (bookmark_bar_view_) [1] | // |------------------------------------------------------------------| // | Debugger splitter (contents_split_) | - // | +------------------------------------------------------------+ | + // | -------------------------------------------------------------- | // | | Page content (contents_) | | - // | | +------------------------------------------------------+ | | + // | | -------------------------------------------------------- | | // | | | contents_container_ and/or | | | // | | | overlay_controller_->overlay_container_ | | | // | | | | | | // | | | | | | - // | | +------------------------------------------------------+ | | - // | +------------------------------------------------------------+ | - // | +------------------------------------------------------------+ | + // | | -------------------------------------------------------- | | + // | -------------------------------------------------------------- | + // | -------------------------------------------------------------- | // | | Debugger (devtools_container_) | | // | | | | - // | +------------------------------------------------------------+ | + // | -------------------------------------------------------------- | // |------------------------------------------------------------------| // | Active downloads (download_shelf_) | // -------------------------------------------------------------------- // - // [1] During an immersive mode reveal the tab strip and toolbar may be - // reparented to a temporary view and may not be direct children of - // this view. - // [2] The bookmark bar and info bar are swapped when on the new tab page. + // [1] The bookmark bar and info bar are swapped when on the new tab page. // Additionally contents_ is positioned on top of the bookmark bar when // the bookmark bar is detached. This is done to allow the // overlay_controller_->overlay_container_ to appear over the bookmark // bar. + // The view that manages the tab strip, toolbar, and sometimes the bookmark + // bar. Stacked in the top of the view hiearachy so it can be used to + // slide out the top views in immersive fullscreen. + TopContainerView* top_container_; + // Tool/Info bars that we are currently showing. Used for layout. // active_bookmark_bar_ is either NULL, if the bookmark bar isn't showing, // or is bookmark_bar_view_ if the bookmark bar is showing. diff --git a/chrome/browser/ui/views/frame/browser_view_browsertest.cc b/chrome/browser/ui/views/frame/browser_view_browsertest.cc index 1119216..40f8b95 100644 --- a/chrome/browser/ui/views/frame/browser_view_browsertest.cc +++ b/chrome/browser/ui/views/frame/browser_view_browsertest.cc @@ -5,7 +5,12 @@ #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/browser_commands.h" +#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" +#include "chrome/browser/ui/views/frame/top_container_view.h" +#include "chrome/browser/ui/views/infobars/infobar_container_view.h" #include "chrome/browser/ui/views/location_bar/location_bar_view.h" +#include "chrome/browser/ui/views/tabs/tab_strip.h" +#include "chrome/browser/ui/views/toolbar_view.h" #include "chrome/test/base/in_process_browser_test.h" #include "ui/views/focus/focus_manager.h" @@ -13,6 +18,31 @@ using views::FocusManager; typedef InProcessBrowserTest BrowserViewTest; +IN_PROC_BROWSER_TEST_F(BrowserViewTest, Basics) { + BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); + views::View* top_container = browser_view->top_container(); + + // Verify the view hierarchy. + EXPECT_EQ(top_container, browser_view->tabstrip()->parent()); + EXPECT_EQ(top_container, browser_view->toolbar()->parent()); + EXPECT_EQ(browser_view, browser_view->infobar_container()->parent()); + + // Bookmark bar is at the front of the view hierarchy. + // TODO(jamescook): When top container supports the bookmark bar, the top + // container will be frontmost. + EXPECT_EQ(browser_view->child_count() - 1, + browser_view->GetIndexOf(browser_view->bookmark_bar())); + + // Top container is stacked under bookmark bar. + EXPECT_EQ(browser_view->child_count() - 2, + browser_view->GetIndexOf(top_container)); + + // Verify basic layout. + EXPECT_EQ(0, top_container->x()); + EXPECT_EQ(0, top_container->y()); + EXPECT_EQ(browser_view->width(), top_container->width()); +} + // Active window and focus testing is not reliable on Windows crbug.com/79493 // TODO(linux_aura) http://crbug.com/163931 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)) diff --git a/chrome/browser/ui/views/frame/browser_view_layout.cc b/chrome/browser/ui/views/frame/browser_view_layout.cc index 668096d..c3501e2 100644 --- a/chrome/browser/ui/views/frame/browser_view_layout.cc +++ b/chrome/browser/ui/views/frame/browser_view_layout.cc @@ -15,6 +15,7 @@ #include "chrome/browser/ui/views/frame/browser_frame.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/contents_container.h" +#include "chrome/browser/ui/views/frame/top_container_view.h" #include "chrome/browser/ui/views/immersive_mode_controller.h" #include "chrome/browser/ui/views/infobars/infobar_container_view.h" #include "chrome/browser/ui/views/tabs/tab_strip.h" @@ -288,6 +289,9 @@ void BrowserViewLayout::Layout(views::View* host) { browser_view_->frame()->GetTabStripInsets(false).top)); } top = LayoutToolbar(top); + // TODO(jamescook): When immersive mode supports the bookmark bar this should + // move below. + browser_view_->top_container()->SetBounds(0, 0, browser_view_->width(), top); top = LayoutBookmarkAndInfoBars(top); // During immersive mode reveal the content stays near the top of the view. if (browser_view_->immersive_mode_controller()->IsRevealed()) { diff --git a/chrome/browser/ui/views/frame/top_container_view.cc b/chrome/browser/ui/views/frame/top_container_view.cc new file mode 100644 index 0000000..4844525 --- /dev/null +++ b/chrome/browser/ui/views/frame/top_container_view.cc @@ -0,0 +1,49 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/views/frame/top_container_view.h" + +#include "chrome/browser/ui/views/frame/browser_frame.h" +#include "chrome/browser/ui/views/frame/browser_view.h" +#include "chrome/browser/ui/views/immersive_mode_controller.h" + +TopContainerView::TopContainerView(BrowserView* browser_view) + : browser_view_(browser_view), + focus_manager_(browser_view->GetFocusManager()) { + focus_manager_->AddFocusChangeListener(this); +} + +TopContainerView::~TopContainerView() { + focus_manager_->RemoveFocusChangeListener(this); +} + +std::string TopContainerView::GetClassName() const { + return "TopContainerView"; +} + +void TopContainerView::PaintChildren(gfx::Canvas* canvas) { + if (browser_view_->immersive_mode_controller()->IsRevealed()) { + // Top-views depend on parts of the frame (themes, window buttons) being + // painted underneath them. Clip rect has already been set to the bounds + // of this view, so just paint the frame. + views::View* frame = browser_view_->frame()->GetFrameView(); + frame->Paint(canvas); + } + + views::View::PaintChildren(canvas); +} + +void TopContainerView::OnWillChangeFocus(View* focused_before, + View* focused_now) { +} + +void TopContainerView::OnDidChangeFocus(View* focused_before, + View* focused_now) { + // If one of this view's children had focus before, but doesn't have focus + // now, we may want to slide out the top views in immersive fullscreen. + if (browser_view_->immersive_mode_controller()->enabled() && + Contains(focused_before) && + !Contains(focused_now)) + browser_view_->immersive_mode_controller()->OnRevealViewLostFocus(); +} diff --git a/chrome/browser/ui/views/frame/top_container_view.h b/chrome/browser/ui/views/frame/top_container_view.h new file mode 100644 index 0000000..6f607b1 --- /dev/null +++ b/chrome/browser/ui/views/frame/top_container_view.h @@ -0,0 +1,45 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_TOP_CONTAINER_VIEW_H_ +#define CHROME_BROWSER_UI_VIEWS_FRAME_TOP_CONTAINER_VIEW_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "ui/views/focus/focus_manager.h" +#include "ui/views/view.h" + +class BrowserView; + +// Container for the BrowserView's tab strip, toolbar, and sometimes bookmark +// bar. In Chrome OS immersive fullscreen it stacks on top of other views in +// order to slide in and out over the web contents. It informs the immersive +// mode controller when its children lose focus to trigger a slide out. +class TopContainerView : public views::View, + public views::FocusChangeListener { + public: + explicit TopContainerView(BrowserView* browser_view); + virtual ~TopContainerView(); + + // views::View overrides: + virtual std::string GetClassName() const OVERRIDE; + virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; + + // views::FocusChangeListener overrides: + virtual void OnWillChangeFocus(View* focused_before, + View* focused_now) OVERRIDE; + virtual void OnDidChangeFocus(View* focused_before, + View* focused_now) OVERRIDE; + + private: + // The parent of this view. Not owned. + BrowserView* browser_view_; + // The focus manager of |browser_view_|, cached to allow listener cleanup + // during |browser_view_| destruction. + views::FocusManager* focus_manager_; + + DISALLOW_COPY_AND_ASSIGN(TopContainerView); +}; + +#endif // CHROME_BROWSER_UI_VIEWS_FRAME_TOP_CONTAINER_VIEW_H_ diff --git a/chrome/browser/ui/views/immersive_mode_controller.cc b/chrome/browser/ui/views/immersive_mode_controller.cc index 0e35fdf..e548c51 100644 --- a/chrome/browser/ui/views/immersive_mode_controller.cc +++ b/chrome/browser/ui/views/immersive_mode_controller.cc @@ -1,20 +1,17 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ui/views/immersive_mode_controller.h" -#include "chrome/browser/ui/views/frame/browser_frame.h" #include "chrome/browser/ui/views/frame/browser_view.h" -#include "chrome/browser/ui/views/frame/contents_container.h" +#include "chrome/browser/ui/views/frame/top_container_view.h" #include "chrome/browser/ui/views/tabs/tab_strip.h" -#include "chrome/browser/ui/views/toolbar_view.h" #include "chrome/common/chrome_switches.h" -#include "ui/compositor/compositor_observer.h" #include "ui/compositor/scoped_layer_animation_settings.h" -#include "ui/gfx/screen.h" #include "ui/gfx/transform.h" #include "ui/views/view.h" +#include "ui/views/widget/widget.h" #include "ui/views/window/non_client_view.h" #if defined(USE_ASH) @@ -30,7 +27,6 @@ #include "ui/aura/window_observer.h" #endif -using ui::Compositor; using views::View; namespace { @@ -49,244 +45,6 @@ const int kRevealFastAnimationDurationMs = 200; //////////////////////////////////////////////////////////////////////////////// -// View to hold the tab strip, toolbar, and sometimes the bookmark bar during -// an immersive mode reveal. Paints on top of other layers in order to appear -// over the web contents. Immersive mode uses this view to avoid changing the -// BrowserView's view structure in the steady state. Informs the controller -// when the mouse leaves its bounds and when its children lose focus. -// TODO(jamescook): If immersive mode becomes non-experimental, use a permanent -// top-of-window container view in BrowserView instead of RevealView to avoid -// reparenting. -// TODO(jamescook): Bookmark bar does not yet work. -class ImmersiveModeController::RevealView : public views::View, - public views::FocusChangeListener, - public ui::CompositorObserver { - public: - RevealView(ImmersiveModeController* controller, BrowserView* browser_view); - virtual ~RevealView(); - - // Returns true if the mouse is in the bounds of this view. - bool hovered() const { return hovered_; } - - // Trigger a paint, composite and then an EndReveal animation. Used for the - // initial slide-out animation when enabling immersive mode. - void EndRevealAfterPaint(); - - // Returns true when this or any child view has focus. - bool ContainsFocusedView() const; - - // Reparents the |browser_view_| tab strip, toolbar, and bookmark bar to - // this view. - void AcquireTopViews(); - - // Reparents tab strip, toolbar, and bookmark bar back to |browser_view_|. - void ReleaseTopViews(); - - // views::View overrides: - virtual std::string GetClassName() const OVERRIDE; - virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; - virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; - virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; - - // views::FocusChangeListener overrides: - virtual void OnWillChangeFocus(View* focused_before, - View* focused_now) OVERRIDE {} - virtual void OnDidChangeFocus(View* focused_before, - View* focused_now) OVERRIDE; - - // ui::CompositorObserver overrides: - virtual void OnCompositingDidCommit(Compositor* compositor) OVERRIDE {} - virtual void OnCompositingStarted(Compositor* compositor, - base::TimeTicks start_time) OVERRIDE {} - virtual void OnCompositingEnded(Compositor* compositor) OVERRIDE; - virtual void OnCompositingAborted(Compositor* compositor) OVERRIDE {} - virtual void OnCompositingLockStateChanged(Compositor* compositor) OVERRIDE {} - virtual void OnUpdateVSyncParameters(Compositor* compositor, - base::TimeTicks timebase, - base::TimeDelta interval) OVERRIDE {} - - // Called when painting is complete. Public for tests. - void OnPainted(); - - private: - // Don't end the reveal until we have both painted and composited the layer. - enum EndRevealState { - END_REVEAL_NONE, - END_REVEAL_NEEDS_PAINT, - END_REVEAL_NEEDS_COMPOSITE, - }; - - // Returns true if the mouse cursor is inside this view. - bool ContainsCursor() const; - - // The controller owns this view. - ImmersiveModeController* controller_; - - // None of these views are owned. - BrowserView* browser_view_; - TabStrip* tabstrip_; - ToolbarView* toolbar_view_; - - // True until the mouse leaves the view. - bool hovered_; - - // State machine for PaintAndEndReveal(). - EndRevealState end_reveal_state_; - - // During widget destruction the views are disconnected from the widget and - // GetFocusManager() and GetWidget() return NULL. Cache a pointer to the - // focus manager so we can remove our listener. - views::FocusManager* focus_manager_; - - DISALLOW_COPY_AND_ASSIGN(RevealView); -}; - -ImmersiveModeController::RevealView::RevealView( - ImmersiveModeController* controller, - BrowserView* browser_view) - : controller_(controller), - browser_view_(browser_view), - tabstrip_(NULL), - toolbar_view_(NULL), - hovered_(false), - end_reveal_state_(END_REVEAL_NONE), - focus_manager_(browser_view->GetFocusManager()) { - set_notify_enter_exit_on_child(true); - SetPaintToLayer(true); - SetFillsBoundsOpaquely(true); - focus_manager_->AddFocusChangeListener(this); -} - -ImmersiveModeController::RevealView::~RevealView() { - // |this| could be deleted while waiting for a composite. - if (layer()->GetCompositor()) - layer()->GetCompositor()->RemoveObserver(this); - focus_manager_->RemoveFocusChangeListener(this); -} - -void ImmersiveModeController::RevealView::EndRevealAfterPaint() { - end_reveal_state_ = END_REVEAL_NEEDS_PAINT; -} - -bool ImmersiveModeController::RevealView::ContainsFocusedView() const { - // Views are considered to contain themselves and their children. - return Contains(focus_manager_->GetFocusedView()); -} - -void ImmersiveModeController::RevealView::AcquireTopViews() { - // Reparenting causes hit tests that require a parent for |this|. - DCHECK(parent()); - - tabstrip_ = browser_view_->tabstrip(); - toolbar_view_ = browser_view_->GetToolbarView(); - - // Ensure the indices are what we expect before we start moving the views. - DCHECK_EQ(browser_view_->GetIndexOf(tabstrip_), BrowserView::kTabstripIndex); - DCHECK_EQ(browser_view_->GetIndexOf(toolbar_view_), - BrowserView::kToolbarIndex); - - AddChildView(tabstrip_); - AddChildView(toolbar_view_); - - // Set our initial bounds, which triggers a Layout() and SchedulePaint(). - int width = parent()->width(); - int height = toolbar_view_->bounds().bottom(); - SetBounds(0, 0, width, height); -} - -void ImmersiveModeController::RevealView::ReleaseTopViews() { - // Reparenting causes hit tests that require a parent for |this|. - DCHECK(parent()); - // Check that the top views have not already been released. - DCHECK(tabstrip_); - DCHECK(toolbar_view_); - - browser_view_->AddChildViewAt(tabstrip_, BrowserView::kTabstripIndex); - browser_view_->AddChildViewAt(toolbar_view_, BrowserView::kToolbarIndex); - - // Ensure the newly restored views get painted. - tabstrip_->SchedulePaint(); - toolbar_view_->SchedulePaint(); - - tabstrip_ = NULL; - toolbar_view_ = NULL; -} - -std::string ImmersiveModeController::RevealView::GetClassName() const { - return "RevealView"; -} - -void ImmersiveModeController::RevealView::OnMouseEntered( - const ui::MouseEvent& event) { - // Entering this view or a child view always means we are hovered. - hovered_ = true; -} - -void ImmersiveModeController::RevealView::OnMouseExited( - const ui::MouseEvent& event) { - // TODO(jamescook): Currently Ash does not differentiate between disabling - // and hiding the mouse. When the mouse is "hidden" by typing, it actually - // moves to -10000, -10000 and generates mouse moved events. For now, ignore - // mouse exit events caused by a move to that location. Remove this code - // when crbug.com/153703 is fixed. - if (event.location().x() == -10000 && event.location().y() == -10000) - return; - - // This view may still be hovered if the mouse exit was on a child view. - bool was_hovered = hovered_; - hovered_ = ContainsCursor(); - - if (was_hovered && !hovered_) - controller_->OnRevealViewLostMouse(); -} - -void ImmersiveModeController::RevealView::PaintChildren(gfx::Canvas* canvas) { - // Top-views depend on parts of the frame (themes, window buttons) being - // painted underneath them. Clip rect has already been set to the bounds - // of this view, so just paint the frame. - views::View* frame = browser_view_->frame()->GetFrameView(); - frame->Paint(canvas); - - views::View::PaintChildren(canvas); - - OnPainted(); -} - -void ImmersiveModeController::RevealView::OnDidChangeFocus(View* focused_before, - View* focused_now) { - // If one of this view's children had focus before, but doesn't have focus - // now, inform the controller. - if (Contains(focused_before) && !Contains(focused_now)) - controller_->OnRevealViewLostFocus(); - // |this| may be deleted. -} - -void ImmersiveModeController::RevealView::OnCompositingEnded( - Compositor* compositor) { - if (end_reveal_state_ == END_REVEAL_NEEDS_COMPOSITE) { - // Pixels should be on the screen, so slide out the layer. - end_reveal_state_ = END_REVEAL_NONE; - layer()->GetCompositor()->RemoveObserver(this); - controller_->EndReveal(ANIMATE_SLOW, LAYOUT_YES); - } -} - -void ImmersiveModeController::RevealView::OnPainted() { - if (end_reveal_state_ == END_REVEAL_NEEDS_PAINT) { - end_reveal_state_ = END_REVEAL_NEEDS_COMPOSITE; - layer()->GetCompositor()->AddObserver(this); - } -} - -bool ImmersiveModeController::RevealView::ContainsCursor() const { - gfx::Point cursor_point(gfx::Screen::GetScreenFor( - GetWidget()->GetNativeView())->GetCursorScreenPoint()); - ConvertPointToTarget(NULL, this, &cursor_point); - return GetLocalBounds().Contains(cursor_point); -} - -//////////////////////////////////////////////////////////////////////////////// - #if defined(USE_AURA) // Observer to watch for window restore. views::Widget does not provide a hook // to observe for window restore, so do this at the Aura level. @@ -336,12 +94,14 @@ ImmersiveModeController::ImmersiveModeController(BrowserView* browser_view) enabled_(false), revealed_(false), reveal_locked_(false), + layout_after_hide_animation_(LAYOUT_NO), hide_tab_indicators_(false), + reveal_hovered_(false), native_window_(NULL) { } ImmersiveModeController::~ImmersiveModeController() { - // Ensure views are reparented if we are deleted while revealing. + // Reset our changes to the top_container. EndReveal(ANIMATE_NO, LAYOUT_NO); // Clean up our window observers. EnableWindowObservers(false); @@ -377,20 +137,21 @@ void ImmersiveModeController::SetEnabled(bool enabled) { return; enabled_ = enabled; - if (enabled_) { - // When UI is enabled slide-out the reveal views by slamming it to open then - // triggering an end-reveal animation. - StartReveal(ANIMATE_NO); - reveal_view_->EndRevealAfterPaint(); - } else { - // Layout occurs below because EndReveal() only performs layout if the view - // is already revealed. + // TODO(jamescook): Slide out the reveal view on enable by slamming it to + // open then triggering an end-reveal animation. This may require waiting for + // the view to paint before animating. + if (!enabled_) { EndReveal(ANIMATE_NO, LAYOUT_NO); - LayoutBrowserView(false); // Stop cursor-at-top tracking. top_timer_.Stop(); } + browser_view_->GetWidget()->non_client_view()->frame_view()-> + ResetWindowControls(); + browser_view_->tabstrip()->SetImmersiveStyle(enabled_); + // Don't need explicit layout because we're inside a fullscreen transition + // and it blocks layout calls. + #if defined(USE_ASH) // This causes a no-op call to SetEnabled() since enabled_ is already set. native_window_->SetProperty(ash::internal::kImmersiveModeKey, enabled_); @@ -402,15 +163,12 @@ void ImmersiveModeController::SetEnabled(bool enabled) { #endif } -views::View* ImmersiveModeController::reveal_view() { - return reveal_view_.get(); -} - void ImmersiveModeController::MaybeStackViewAtTop() { #if defined(USE_AURA) - if (enabled_ && revealed_ && reveal_view_.get()) { - ui::Layer* reveal_layer = reveal_view_->layer(); - reveal_layer->parent()->StackAtTop(reveal_layer); + if (enabled_ && revealed_) { + ui::Layer* reveal_layer = browser_view_->top_container()->layer(); + if (reveal_layer) + reveal_layer->parent()->StackAtTop(reveal_layer); } #endif } @@ -454,6 +212,18 @@ void ImmersiveModeController::OnMouseEvent(ui::MouseEvent* event) { // Cursor left the top edge. top_timer_.Stop(); } + + if (revealed_) { + // Look for the mouse leaving the bottom edge of the revealed view. + int bottom_edge = browser_view_->top_container()->bounds().bottom(); + if (event->location().y() > bottom_edge) { + reveal_hovered_ = false; + OnRevealViewLostMouse(); + } else { + reveal_hovered_ = true; + } + } + // Pass along event for further handling. } @@ -469,16 +239,6 @@ void ImmersiveModeController::SetHideTabIndicatorsForTest(bool hide) { hide_tab_indicators_ = hide; } -void ImmersiveModeController::SetEnabledForTest(bool enabled) { - bool was_enabled = enabled_; - SetEnabled(enabled); - if (enabled && !was_enabled) { - // Simulate the reveal view being painted and composited. - reveal_view_->OnPainted(); - reveal_view_->OnCompositingEnded(NULL); - } -} - void ImmersiveModeController::StartRevealForTest() { StartReveal(ANIMATE_NO); } @@ -518,47 +278,46 @@ void ImmersiveModeController::StartReveal(Animate animate) { return; revealed_ = true; + // Turn on layer painting so we can smoothly animate. + TopContainerView* top_container = browser_view_->top_container(); + top_container->SetPaintToLayer(true); + top_container->SetFillsBoundsOpaquely(true); + // Ensure window caption buttons are updated and the view bounds are computed // at normal (non-immersive-style) size. LayoutBrowserView(false); - // Place tabstrip, toolbar, and bookmarks bar in a new view at the end of - // the BrowserView hierarchy so it paints over the web contents. - reveal_view_.reset(new RevealView(this, browser_view_)); - browser_view_->AddChildView(reveal_view_.get()); - reveal_view_->AcquireTopViews(); - // Slide in the reveal view. if (animate != ANIMATE_NO) AnimateShowRevealView(); // Show is always fast. } void ImmersiveModeController::AnimateShowRevealView() { - DCHECK(reveal_view_.get()); + views::View* reveal_view = browser_view_->top_container(); + DCHECK(reveal_view->layer()); gfx::Transform transform; - transform.Translate(0, -reveal_view_->height()); - reveal_view_->SetTransform(transform); + transform.Translate(0, -reveal_view->height()); + reveal_view->SetTransform(transform); ui::ScopedLayerAnimationSettings settings( - reveal_view_->layer()->GetAnimator()); + reveal_view->layer()->GetAnimator()); settings.SetTweenType(ui::Tween::EASE_OUT); settings.SetTransitionDuration( base::TimeDelta::FromMilliseconds(kRevealFastAnimationDurationMs)); - reveal_view_->SetTransform(gfx::Transform()); + reveal_view->SetTransform(gfx::Transform()); } void ImmersiveModeController::OnRevealViewLostMouse() { - // Stop the reveal if the view's children don't have focus. - // TODO(jamescook): Consider stopping the reveal after a delay. This code - // isn't using a MouseWatcher because it needs to know if the mouse re-enters - // the RevealView before focus is lost. - if (!reveal_view_->ContainsFocusedView() && !reveal_locked_) + // Stop the reveal if the top view's children don't have focus. + views::View* focused = browser_view_->GetFocusManager()->GetFocusedView(); + if (!reveal_locked_ && + !browser_view_->top_container()->Contains(focused)) EndReveal(ANIMATE_FAST, LAYOUT_YES); } void ImmersiveModeController::OnRevealViewLostFocus() { // Stop the reveal if the mouse is outside the reveal view. - if (!reveal_view_->hovered() && !reveal_locked_) + if (!reveal_locked_ && !reveal_hovered_) EndReveal(ANIMATE_FAST, LAYOUT_YES); } @@ -566,36 +325,27 @@ void ImmersiveModeController::EndReveal(Animate animate, Layout layout) { if (!revealed_) return; revealed_ = false; + layout_after_hide_animation_ = layout; - if (reveal_view_.get()) { - // Always reparent the views when triggering a hide, otherwise tooltip - // position lookup during the slide-out will get confused about view - // parenting and crash. - reveal_view_->ReleaseTopViews(); - // Animations reset the reveal view when complete, which also removes - // it from its parent BrowserView. - if (animate == ANIMATE_FAST) - AnimateHideRevealView(kRevealFastAnimationDurationMs); - else if (animate == ANIMATE_SLOW) - AnimateHideRevealView(kRevealSlowAnimationDurationMs); - else - reveal_view_.reset(); - } - - if (layout == LAYOUT_YES) - LayoutBrowserView(enabled_); + // Animations restack the top container view when complete. + if (animate == ANIMATE_FAST) + AnimateHideRevealView(kRevealFastAnimationDurationMs); + else if (animate == ANIMATE_SLOW) + AnimateHideRevealView(kRevealSlowAnimationDurationMs); + else + OnHideAnimationCompleted(); } void ImmersiveModeController::LayoutBrowserView(bool immersive_style) { // Update the window caption buttons. - browser_view_->frame()->non_client_view()->frame_view()-> + browser_view_->GetWidget()->non_client_view()->frame_view()-> ResetWindowControls(); browser_view_->tabstrip()->SetImmersiveStyle(immersive_style); browser_view_->Layout(); } void ImmersiveModeController::AnimateHideRevealView(int duration_ms) { - ui::Layer* layer = reveal_view_->layer(); + ui::Layer* layer = browser_view_->top_container()->layer(); // Stop any show animation in progress, but don't skip to the end. This // avoids a visual "pop" when starting a hide in the middle of a show. layer->GetAnimator()->AbortAllAnimations(); @@ -614,5 +364,12 @@ void ImmersiveModeController::AnimateHideRevealView(int duration_ms) { } void ImmersiveModeController::OnHideAnimationCompleted() { - reveal_view_.reset(); // Also removes from parent. + if (layout_after_hide_animation_ == LAYOUT_YES) { + LayoutBrowserView(true); + layout_after_hide_animation_ = LAYOUT_NO; + } + + TopContainerView* top_container = browser_view_->top_container(); + top_container->SetFillsBoundsOpaquely(false); + top_container->SetPaintToLayer(false); } diff --git a/chrome/browser/ui/views/immersive_mode_controller.h b/chrome/browser/ui/views/immersive_mode_controller.h index ef184c6..93785e1 100644 --- a/chrome/browser/ui/views/immersive_mode_controller.h +++ b/chrome/browser/ui/views/immersive_mode_controller.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -50,11 +50,6 @@ class ImmersiveModeController : public ui::EventHandler, // True when the controller is temporarily showing the top views. bool IsRevealed() const { return enabled_ && revealed_; } - // Returns the view that contains the top UI components (tabstrip, toolbar - // etc.) during an immersive mode reveal. Can return NULL when not in a - // revealing state. - views::View* reveal_view(); - // If the controller is temporarily revealing the top views ensures that // the reveal view's layer is on top and hence visible over web contents. void MaybeStackViewAtTop(); @@ -70,6 +65,9 @@ class ImmersiveModeController : public ui::EventHandler, // with |reveal| false. Immersive mode must be enabled. void RevealAndLock(bool reveal); + // Called when the reveal view's children lose focus, may end the reveal. + void OnRevealViewLostFocus(); + // ui::EventHandler overrides: virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; @@ -78,13 +76,10 @@ class ImmersiveModeController : public ui::EventHandler, // Testing interface. void SetHideTabIndicatorsForTest(bool hide); - void SetEnabledForTest(bool enabled); void StartRevealForTest(); void OnRevealViewLostMouseForTest(); private: - class RevealView; - enum Animate { ANIMATE_NO, ANIMATE_SLOW, @@ -109,9 +104,6 @@ class ImmersiveModeController : public ui::EventHandler, // Called when the mouse exits the reveal view area, may end the reveal. void OnRevealViewLostMouse(); - // Called when the reveal view's children lose focus, may end the reveal. - void OnRevealViewLostFocus(); - // Hides the top-of-window views. Optionally animates. Optionally updates // the |browser_view_| layout when the reveal finishes. void EndReveal(Animate animate, Layout layout); @@ -141,17 +133,19 @@ class ImmersiveModeController : public ui::EventHandler, // top view. bool reveal_locked_; + // True if browser view needs Layout() after the hide animation completes. + Layout layout_after_hide_animation_; + // True if the miniature "tab indicators" should be hidden in the main browser // view when immersive mode is enabled. bool hide_tab_indicators_; - // View holding the tabstrip and toolbar during a reveal. Exists for a short - // time after |revealed_| is set false to allow layer animation to finish. - scoped_ptr<RevealView> reveal_view_; - // Timer to track cursor being held at the top. base::OneShotTimer<ImmersiveModeController> top_timer_; + // Mouse is hovering over the revealed view. + bool reveal_hovered_; + // Native window for the browser, needed to clean up observers. gfx::NativeWindow native_window_; diff --git a/chrome/browser/ui/views/immersive_mode_controller_browsertest.cc b/chrome/browser/ui/views/immersive_mode_controller_browsertest.cc index 39fe1f6..808b646e 100644 --- a/chrome/browser/ui/views/immersive_mode_controller_browsertest.cc +++ b/chrome/browser/ui/views/immersive_mode_controller_browsertest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -38,6 +38,7 @@ typedef InProcessBrowserTest ImmersiveModeControllerTest; #if defined(OS_CHROMEOS) IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, ImmersiveMode) { ui::LayerAnimator::set_disable_animations_for_test(true); + ASSERT_TRUE(ImmersiveModeController::UseImmersiveFullscreen()); BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); ImmersiveModeController* controller = @@ -59,7 +60,6 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, ImmersiveMode) { // Turning immersive mode on sets the toolbar to immersive style and hides // the top-of-window views while leaving the tab strip visible. - controller->SetEnabledForTest(true); chrome::ToggleFullscreenMode(browser()); ASSERT_TRUE(browser_view->IsFullscreen()); EXPECT_TRUE(controller->enabled()); @@ -103,7 +103,6 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, ImmersiveMode) { EXPECT_FALSE(browser_view->IsToolbarVisible()); // Disabling immersive mode puts us back to the beginning. - controller->SetEnabledForTest(false); chrome::ToggleFullscreenMode(browser()); ASSERT_FALSE(browser_view->IsFullscreen()); EXPECT_FALSE(controller->enabled()); @@ -115,11 +114,11 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, ImmersiveMode) { // Disabling immersive mode while we are revealed should take us back to // the beginning. - controller->SetEnabledForTest(true); chrome::ToggleFullscreenMode(browser()); ASSERT_TRUE(browser_view->IsFullscreen()); + EXPECT_TRUE(controller->enabled()); controller->StartRevealForTest(); - controller->SetEnabledForTest(false); + chrome::ToggleFullscreenMode(browser()); ASSERT_FALSE(browser_view->IsFullscreen()); EXPECT_FALSE(controller->enabled()); @@ -132,7 +131,6 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, ImmersiveMode) { // When hiding the tab indicators, content is at the top of the browser view // both before and during reveal. controller->SetHideTabIndicatorsForTest(true); - controller->SetEnabledForTest(true); chrome::ToggleFullscreenMode(browser()); ASSERT_TRUE(browser_view->IsFullscreen()); EXPECT_FALSE(browser_view->IsTabStripVisible()); @@ -145,15 +143,14 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, ImmersiveMode) { browser_view->parent()->Layout(); EXPECT_EQ(GetRectInWidget(browser_view).y(), GetRectInWidget(contents_view).y()); - controller->SetEnabledForTest(false); chrome::ToggleFullscreenMode(browser()); ASSERT_FALSE(browser_view->IsFullscreen()); controller->SetHideTabIndicatorsForTest(false); // Reveal ends when the mouse moves out of the reveal view. - controller->SetEnabledForTest(true); chrome::ToggleFullscreenMode(browser()); ASSERT_TRUE(browser_view->IsFullscreen()); + EXPECT_TRUE(controller->enabled()); controller->StartRevealForTest(); controller->OnRevealViewLostMouseForTest(); EXPECT_FALSE(controller->IsRevealed()); @@ -162,7 +159,6 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, ImmersiveMode) { #if !defined(OS_WIN) // Giving focus to the location bar prevents the reveal from ending when // the mouse exits. - controller->SetEnabledForTest(true); controller->StartRevealForTest(); browser_view->SetFocusToLocationBar(false); controller->OnRevealViewLostMouseForTest(); @@ -173,7 +169,6 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, ImmersiveMode) { EXPECT_FALSE(controller->IsRevealed()); // Placing focus in the location bar automatically causes a reveal. - controller->SetEnabledForTest(true); browser_view->SetFocusToLocationBar(false); EXPECT_TRUE(controller->IsRevealed()); @@ -186,7 +181,6 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, ImmersiveMode) { // Also, Windows Aura does not trigger maximize/restore notifications. #if defined(USE_AURA) && !defined(OS_WIN) // Restoring the window exits immersive mode. - controller->SetEnabledForTest(true); browser_view->GetWidget()->Restore(); ASSERT_FALSE(browser_view->IsFullscreen()); EXPECT_FALSE(controller->enabled()); @@ -198,10 +192,10 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, ImmersiveMode) { #endif // defined(USE_AURA) && !defined(OS_WIN) // Don't crash if we exit the test during a reveal. - controller->SetEnabledForTest(true); if (!browser_view->IsFullscreen()) chrome::ToggleFullscreenMode(browser()); ASSERT_TRUE(browser_view->IsFullscreen()); + ASSERT_TRUE(controller->enabled()); controller->StartRevealForTest(); } @@ -219,15 +213,15 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, ImmersiveShelf) { ASSERT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state()); // Turning immersive mode on sets the shelf to auto-hide. - immersive_controller->SetEnabledForTest(true); chrome::ToggleFullscreenMode(browser()); ASSERT_TRUE(browser_view->IsFullscreen()); + ASSERT_TRUE(immersive_controller->enabled()); EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); // Disabling immersive mode puts it back. - immersive_controller->SetEnabledForTest(false); chrome::ToggleFullscreenMode(browser()); ASSERT_FALSE(browser_view->IsFullscreen()); + ASSERT_FALSE(immersive_controller->enabled()); EXPECT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state()); // The user could toggle the launcher behavior. @@ -235,19 +229,18 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, ImmersiveShelf) { EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); // Enabling immersive mode keeps auto-hide. - immersive_controller->SetEnabledForTest(true); chrome::ToggleFullscreenMode(browser()); ASSERT_TRUE(browser_view->IsFullscreen()); + ASSERT_TRUE(immersive_controller->enabled()); EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); // Disabling immersive mode maintains the user's auto-hide selection. - immersive_controller->SetEnabledForTest(false); chrome::ToggleFullscreenMode(browser()); ASSERT_FALSE(browser_view->IsFullscreen()); + ASSERT_FALSE(immersive_controller->enabled()); EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); // Setting the window property directly toggles immersive mode. - // TODO(jamescook): Is this functionality still needed? aura::Window* window = browser_view->GetWidget()->GetNativeWindow(); window->SetProperty(ash::internal::kImmersiveModeKey, true); EXPECT_TRUE(immersive_controller->enabled()); diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 1235986..500ddc3 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -1581,6 +1581,8 @@ 'browser/ui/views/frame/taskbar_decorator.cc', 'browser/ui/views/frame/taskbar_decorator.h', 'browser/ui/views/frame/taskbar_decorator_win.cc', + 'browser/ui/views/frame/top_container_view.cc', + 'browser/ui/views/frame/top_container_view.h', 'browser/ui/views/fullscreen_exit_bubble_views.cc', 'browser/ui/views/fullscreen_exit_bubble_views.h', 'browser/ui/views/global_error_bubble_view.cc', |