summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-21 07:38:09 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-21 07:38:09 +0000
commitd153e6ff6dafc24c3946184c1831538efe946532 (patch)
treea8a6226a5fc8f342154be32ba415ee1645e7678a
parentee0acee0c7aa78b3033fcea026bba34f1fc0b799 (diff)
downloadchromium_src-d153e6ff6dafc24c3946184c1831538efe946532.zip
chromium_src-d153e6ff6dafc24c3946184c1831538efe946532.tar.gz
chromium_src-d153e6ff6dafc24c3946184c1831538efe946532.tar.bz2
ash: Show immersive mode button by default in maximized window caption
* Added about:flags setting to show/hide the tab indicator bar at the top * Added a tooltip to the button * Added tests for layout BUG=167085 TEST=Added to browser_tests ImmersiveModeControllerTest Review URL: https://chromiumcodereview.appspot.com/11618052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174353 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/ash_switches.cc6
-rw-r--r--ash/ash_switches.h2
-rw-r--r--chrome/app/generated_resources.grd14
-rw-r--r--chrome/browser/about_flags.cc15
-rw-r--r--chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc23
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc3
-rw-r--r--chrome/browser/ui/views/frame/browser_view_layout.cc7
-rw-r--r--chrome/browser/ui/views/immersive_mode_controller.cc16
-rw-r--r--chrome/browser/ui/views/immersive_mode_controller.h13
-rw-r--r--chrome/browser/ui/views/immersive_mode_controller_browsertest.cc34
-rw-r--r--chrome/browser/ui/views/tabs/tab.cc4
-rw-r--r--chrome/browser/ui/views/tabs/tab_strip.h2
12 files changed, 107 insertions, 32 deletions
diff --git a/ash/ash_switches.cc b/ash/ash_switches.cc
index 2342b4c..706ce77 100644
--- a/ash/ash_switches.cc
+++ b/ash/ash_switches.cc
@@ -63,9 +63,9 @@ const char kAshEnableOak[] = "ash-enable-oak";
// Enables showing the tray bubble by dragging on the shelf.
const char kAshEnableTrayDragging[] = "ash-enable-tray-dragging";
-// Enables experimental "immersive" mode, a nearly-fullscreen view of the web
-// content without a tab strip or omnibox.
-const char kAshImmersive[] = "ash-immersive";
+// Hides the small tab indicators at the top of the screen.
+const char kAshImmersiveHideTabIndicators[] =
+ "ash-immersive-hide-tab-indicators";
// Enables creating a launcher per display.
const char kAshLauncherPerDisplay[] = "ash-launcher-per-display";
diff --git a/ash/ash_switches.h b/ash/ash_switches.h
index 3b756ec..ddb3d82 100644
--- a/ash/ash_switches.h
+++ b/ash/ash_switches.h
@@ -35,7 +35,7 @@ ASH_EXPORT extern const char kAshEnablePerAppLauncher[];
ASH_EXPORT extern const char kAshEnableOak[];
ASH_EXPORT extern const char kAshEnableTrayDragging[];
ASH_EXPORT extern const char kAshEnableWorkspaceScrubbing[];
-ASH_EXPORT extern const char kAshImmersive[];
+ASH_EXPORT extern const char kAshImmersiveHideTabIndicators[];
ASH_EXPORT extern const char kAshLauncherPerDisplay[];
ASH_EXPORT extern const char kAshSecondaryDisplayLayout[];
ASH_EXPORT extern const char kAshTouchHud[];
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index b02d4f1..a17c585 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6683,11 +6683,14 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_ENABLE_WORKSPACE_SCRUBBING_DESCRIPTION" desc="Description for the flag to enable workspace scrubbing.">
Enables workspace switching via 3 finger vertical scroll.
</message>
- <message name="IDS_FLAGS_ENABLE_IMMERSIVE_MODE_NAME" desc="Title for the flag to enable immersive mode.">
- Enable immersive windows
+ <message name="IDS_FLAGS_ASH_IMMERSIVE_MODE_NAME" desc="Title for the flag to set the immersive mode style.">
+ Immersive window style
</message>
- <message name="IDS_FLAGS_ENABLE_IMMERSIVE_MODE_DESCRIPTION" desc="Description for the flag to enable immersive mode.">
- Enables an "immersive mode" for browser windows that gives more spaces to web content. Active it by maximizing a window then clicking on the button in the top right corner.
+ <message name="IDS_FLAGS_ASH_IMMERSIVE_MODE_DESCRIPTION" desc="Description for the flag to enable immersive mode.">
+ Sets the style of an "immersive mode" for browser windows that gives more space to web content. Activate immersive mode by maximizing a window then clicking on the button in the top right corner.
+ </message>
+ <message name="IDS_FLAGS_ASH_IMMERSIVE_HIDE_TAB_INDICATORS" desc="Description a selection in the immersive mode popup menu.">
+ Hide tab indicators
</message>
<message name="IDS_FLAGS_ENABLE_MEMORY_MONITOR_NAME" desc="Title for the flag to enable advanced gestures.">
Enable memory monitor
@@ -7550,6 +7553,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_TOOLTIP_HOME" desc="The tooltip for the home button">
Open the home page
</message>
+ <message name="IDS_TOOLTIP_IMMERSIVE" desc="The tooltip for the immersive mode button">
+ Toggle immersive mode
+ </message>
<message name="IDS_TOOLTIP_RELOAD" desc="The tooltip for reload button">
Reload this page
</message>
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index b50f6e8..b49d6c9 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -214,6 +214,13 @@ const Experiment::Choice kChromeCaptivePortalDetectionChoices[] = {
};
#endif
+#if defined(USE_ASH)
+const Experiment::Choice kAshImmersiveModeChoices[] = {
+ { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", ""},
+ { IDS_FLAGS_ASH_IMMERSIVE_HIDE_TAB_INDICATORS,
+ ash::switches::kAshImmersiveHideTabIndicators, ""}
+};
+#endif
// RECORDING USER METRICS FOR FLAGS:
// -----------------------------------------------------------------------------
@@ -1040,11 +1047,11 @@ const Experiment kExperiments[] = {
kOsCrOS,
SINGLE_VALUE_TYPE(ash::switches::kAshEnableWorkspaceScrubbing),
},
- { "ash-enable-immersive-mode",
- IDS_FLAGS_ENABLE_IMMERSIVE_MODE_NAME,
- IDS_FLAGS_ENABLE_IMMERSIVE_MODE_DESCRIPTION,
+ { "ash-immersive-mode",
+ IDS_FLAGS_ASH_IMMERSIVE_MODE_NAME,
+ IDS_FLAGS_ASH_IMMERSIVE_MODE_DESCRIPTION,
kOsCrOS,
- SINGLE_VALUE_TYPE(ash::switches::kAshImmersive),
+ MULTI_VALUE_TYPE(kAshImmersiveModeChoices),
},
#if defined(OS_LINUX)
{ "ash-enable-memory-monitor",
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
index 41e9391..0c560c1 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
@@ -4,10 +4,8 @@
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h"
-#include "ash/ash_switches.h"
#include "ash/wm/frame_painter.h"
#include "ash/wm/workspace/frame_maximize_button.h"
-#include "base/command_line.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/views/avatar_menu_button.h"
@@ -119,17 +117,16 @@ void BrowserNonClientFrameViewAsh::Init() {
frame_painter_->Init(frame(), window_icon_, size_button_, close_button_,
size_button_behavior);
- // Button to enter immersive mode.
- if (CommandLine::ForCurrentProcess()->
- HasSwitch(ash::switches::kAshImmersive)) {
- immersive_button_ = new views::ToggleImageButton(this);
- immersive_button_->SetAccessibleName(
- l10n_util::GetStringUTF16(IDS_ACCNAME_IMMERSIVE));
- immersive_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
- views::ImageButton::ALIGN_BOTTOM);
- AddChildView(immersive_button_);
- frame_painter_->AddImmersiveButton(immersive_button_);
- }
+ // Button to toggle immersive mode.
+ immersive_button_ = new views::ToggleImageButton(this);
+ immersive_button_->SetAccessibleName(
+ l10n_util::GetStringUTF16(IDS_ACCNAME_IMMERSIVE));
+ immersive_button_->SetTooltipText(
+ l10n_util::GetStringUTF16(IDS_TOOLTIP_IMMERSIVE));
+ immersive_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
+ views::ImageButton::ALIGN_BOTTOM);
+ AddChildView(immersive_button_);
+ frame_painter_->AddImmersiveButton(immersive_button_);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 19bda98..d790098 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -639,6 +639,9 @@ gfx::Point BrowserView::OffsetPointForToolbarBackgroundImage(
}
bool BrowserView::IsTabStripVisible() const {
+ if (immersive_mode_controller_->ShouldHideTopViews() &&
+ immersive_mode_controller_->hide_tab_indicators())
+ return false;
return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP);
}
diff --git a/chrome/browser/ui/views/frame/browser_view_layout.cc b/chrome/browser/ui/views/frame/browser_view_layout.cc
index 90cd90d..8885190 100644
--- a/chrome/browser/ui/views/frame/browser_view_layout.cc
+++ b/chrome/browser/ui/views/frame/browser_view_layout.cc
@@ -272,8 +272,11 @@ void BrowserViewLayout::Layout(views::View* host) {
top = LayoutToolbar(top);
top = LayoutBookmarkAndInfoBars(top);
// During immersive mode reveal the content stays near the top of the view.
- if (browser_view_->immersive_mode_controller()->IsRevealed())
- top = browser_view_->tabstrip_->x() + TabStrip::GetImmersiveHeight();
+ if (browser_view_->immersive_mode_controller()->IsRevealed()) {
+ top = browser_view_->tabstrip_->y();
+ if (!browser_view_->immersive_mode_controller()->hide_tab_indicators())
+ top += TabStrip::GetImmersiveHeight();
+ }
int bottom = LayoutDownloadShelf(browser_view_->height());
int active_top_margin = GetTopMarginForActiveContent();
diff --git a/chrome/browser/ui/views/immersive_mode_controller.cc b/chrome/browser/ui/views/immersive_mode_controller.cc
index 8ef03db..93c0ff8 100644
--- a/chrome/browser/ui/views/immersive_mode_controller.cc
+++ b/chrome/browser/ui/views/immersive_mode_controller.cc
@@ -15,6 +15,11 @@
#include "ui/views/view.h"
#include "ui/views/window/non_client_view.h"
+#if defined(USE_ASH)
+#include "ash/ash_switches.h"
+#include "base/command_line.h"
+#endif
+
#if defined(USE_AURA)
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
@@ -257,6 +262,7 @@ ImmersiveModeController::ImmersiveModeController(BrowserView* browser_view)
: browser_view_(browser_view),
enabled_(false),
revealed_(false),
+ hide_tab_indicators_(false),
native_window_(NULL) {
}
@@ -272,6 +278,12 @@ void ImmersiveModeController::Init() {
// window pointer so |this| can stop observing during destruction.
native_window_ = browser_view_->GetNativeWindow();
DCHECK(native_window_);
+
+#if defined(USE_ASH)
+ // Optionally allow the tab indicators to be hidden.
+ hide_tab_indicators_ = CommandLine::ForCurrentProcess()->
+ HasSwitch(ash::switches::kAshImmersiveHideTabIndicators);
+#endif
}
void ImmersiveModeController::SetEnabled(bool enabled) {
@@ -342,6 +354,10 @@ void ImmersiveModeController::OnImplicitAnimationsCompleted() {
}
// Testing interface:
+void ImmersiveModeController::SetHideTabIndicatorsForTest(bool hide) {
+ hide_tab_indicators_ = hide;
+}
+
void ImmersiveModeController::StartRevealForTest() {
StartReveal();
}
diff --git a/chrome/browser/ui/views/immersive_mode_controller.h b/chrome/browser/ui/views/immersive_mode_controller.h
index 46b6804..53dcb9b 100644
--- a/chrome/browser/ui/views/immersive_mode_controller.h
+++ b/chrome/browser/ui/views/immersive_mode_controller.h
@@ -21,8 +21,9 @@ class View;
}
// Controller for an "immersive mode" similar to MacOS presentation mode where
-// the top-of-window views are hidden until the mouse hits the top of the screen
-// and the tab strip is painted in a rectangular "light-bar" style.
+// the top-of-window views are hidden until the mouse hits the top of the
+// screen. The tab strip is optionally painted with miniature "tab indicator"
+// rectangles.
class ImmersiveModeController : public ui::EventHandler,
public ui::ImplicitAnimationObserver {
public:
@@ -36,6 +37,9 @@ class ImmersiveModeController : public ui::EventHandler,
void SetEnabled(bool enabled);
bool enabled() const { return enabled_; }
+ // See member comment below.
+ bool hide_tab_indicators() const { return hide_tab_indicators_; }
+
// True when the controller is hiding the top views due to immersive mode.
bool ShouldHideTopViews() const { return enabled_ && !revealed_; }
@@ -65,6 +69,7 @@ class ImmersiveModeController : public ui::EventHandler,
virtual void OnImplicitAnimationsCompleted() OVERRIDE;
// Testing interface.
+ void SetHideTabIndicatorsForTest(bool hide);
void StartRevealForTest();
void OnRevealViewLostMouseForTest();
@@ -117,6 +122,10 @@ class ImmersiveModeController : public ui::EventHandler,
// false while the view is still animating out.
bool revealed_;
+ // 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_;
diff --git a/chrome/browser/ui/views/immersive_mode_controller_browsertest.cc b/chrome/browser/ui/views/immersive_mode_controller_browsertest.cc
index f43a751..7eede6c 100644
--- a/chrome/browser/ui/views/immersive_mode_controller_browsertest.cc
+++ b/chrome/browser/ui/views/immersive_mode_controller_browsertest.cc
@@ -5,9 +5,21 @@
#include "chrome/browser/ui/views/immersive_mode_controller.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
+#include "chrome/browser/ui/views/tabs/tab.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "ui/compositor/layer_animator.h"
+#include "ui/gfx/rect.h"
+#include "ui/views/view.h"
+
+namespace {
+
+// Returns the bounds of |view| in widget coordinates.
+gfx::Rect GetRectInWidget(views::View* view) {
+ return view->ConvertRectToWidget(view->GetLocalBounds());
+}
+
+} // namespace
typedef InProcessBrowserTest ImmersiveModeControllerTest;
@@ -24,6 +36,7 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, MAYBE_ImmersiveMode) {
BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
ImmersiveModeController* controller =
browser_view->immersive_mode_controller();
+ views::View* contents_view = browser_view->GetTabContentsContainerView();
browser_view->GetWidget()->Maximize();
// Immersive mode is not on by default.
@@ -43,6 +56,9 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, MAYBE_ImmersiveMode) {
EXPECT_TRUE(browser_view->tabstrip()->IsImmersiveStyle());
EXPECT_TRUE(browser_view->IsTabStripVisible());
EXPECT_FALSE(browser_view->IsToolbarVisible());
+ // Content area is immediately below the tab indicators.
+ EXPECT_EQ(GetRectInWidget(browser_view).y() + Tab::GetImmersiveHeight(),
+ GetRectInWidget(contents_view).y());
// Trigger a reveal keeps us in immersive mode, but top-of-window views
// become visible.
@@ -53,6 +69,9 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, MAYBE_ImmersiveMode) {
EXPECT_FALSE(browser_view->tabstrip()->IsImmersiveStyle());
EXPECT_TRUE(browser_view->IsTabStripVisible());
EXPECT_TRUE(browser_view->IsToolbarVisible());
+ // Content area is still immediately below the tab indicators.
+ EXPECT_EQ(GetRectInWidget(browser_view).y() + Tab::GetImmersiveHeight(),
+ GetRectInWidget(contents_view).y());
// Ending a reveal keeps us in immersive mode, but toolbar goes invisible.
controller->CancelReveal();
@@ -84,6 +103,21 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, MAYBE_ImmersiveMode) {
EXPECT_TRUE(browser_view->IsTabStripVisible());
EXPECT_TRUE(browser_view->IsToolbarVisible());
+ // When hiding the tab indicators, content is at the top of the browser view
+ // both before and during reveal.
+ controller->SetEnabled(false);
+ controller->SetHideTabIndicatorsForTest(true);
+ controller->SetEnabled(true);
+ EXPECT_FALSE(browser_view->IsTabStripVisible());
+ EXPECT_EQ(GetRectInWidget(browser_view).y(),
+ GetRectInWidget(contents_view).y());
+ controller->StartRevealForTest();
+ EXPECT_TRUE(browser_view->IsTabStripVisible());
+ EXPECT_EQ(GetRectInWidget(browser_view).y(),
+ GetRectInWidget(contents_view).y());
+ controller->SetEnabled(false);
+ controller->SetHideTabIndicatorsForTest(false);
+
// Reveal ends when the mouse moves out of the reveal view.
controller->SetEnabled(true);
controller->StartRevealForTest();
diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc
index 0e7395c..5aca46c 100644
--- a/chrome/browser/ui/views/tabs/tab.cc
+++ b/chrome/browser/ui/views/tabs/tab.cc
@@ -237,10 +237,10 @@ static const SkColor kMiniTitleChangeGradientColor2 =
// errors may lead to tabs in the same tabstrip having different sizes.
const size_t kMaxImageCacheSize = 4;
-// Height of the "light bar" tabs in the tab strip in immersive mode.
+// Height of the miniature tab strip in immersive mode.
const int kImmersiveTabHeight = 3;
-// Height of the colored bar representing the favicon in immersive mode.
+// Height of the small tab indicator rectangles in immersive mode.
const int kImmersiveBarHeight = 2;
// Color for active and inactive tabs in the immersive mode light strip. These
diff --git a/chrome/browser/ui/views/tabs/tab_strip.h b/chrome/browser/ui/views/tabs/tab_strip.h
index 4ba9526..d2ccd09 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.h
+++ b/chrome/browser/ui/views/tabs/tab_strip.h
@@ -162,7 +162,7 @@ class TabStrip : public views::View,
// Returns the new tab button. This is never NULL.
views::View* newtab_button();
- // Sets a painting style with a "light bar" at the top representing open tabs.
+ // Sets a painting style with miniature "tab indicator" rectangles at the top.
void SetImmersiveStyle(bool enable);
// TabController overrides: