summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-18 17:00:54 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-18 17:00:54 +0000
commit7a3ea9054dbd3aa6914bd497fac2db52a0e226c1 (patch)
tree0551f7c65e917eb25d149e759d05787788fe3c4f
parent4f62d805c9db0281bde49a21e53a81d10470a776 (diff)
downloadchromium_src-7a3ea9054dbd3aa6914bd497fac2db52a0e226c1.zip
chromium_src-7a3ea9054dbd3aa6914bd497fac2db52a0e226c1.tar.gz
chromium_src-7a3ea9054dbd3aa6914bd497fac2db52a0e226c1.tar.bz2
aura: Update status area text style to match background.
We use a single view for the status area now. In compact mode, the window underneath it can vary (login screen, lock screen, regular or incognito browser window, etc.). This change makes us update the text style used for the status area accordingly. BUG=107389 TEST=manual testing in compact mode; also added a browser test Review URL: https://chromiumcodereview.appspot.com/9197018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118101 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/status/status_area_button.cc27
-rw-r--r--chrome/browser/chromeos/status/status_area_button.h7
-rw-r--r--chrome/browser/chromeos/status/status_area_view.cc10
-rw-r--r--chrome/browser/chromeos/status/status_area_view.h5
-rw-r--r--chrome/browser/ui/views/aura/chrome_shell_delegate.h4
-rw-r--r--chrome/browser/ui/views/aura/status_area_host_aura.cc74
-rw-r--r--chrome/browser/ui/views/aura/status_area_host_aura.h21
-rw-r--r--chrome/browser/ui/views/aura/status_area_host_aura_browsertest.cc73
-rw-r--r--chrome/chrome_tests.gypi3
9 files changed, 202 insertions, 22 deletions
diff --git a/chrome/browser/chromeos/status/status_area_button.cc b/chrome/browser/chromeos/status/status_area_button.cc
index 7d9ac0e..c524046 100644
--- a/chrome/browser/chromeos/status/status_area_button.cc
+++ b/chrome/browser/chromeos/status/status_area_button.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 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.
@@ -133,18 +133,6 @@ void StatusAreaButton::SetMenuActive(bool active) {
menu_active_ = active;
}
-int StatusAreaButton::icon_height() {
- return 24;
-}
-
-int StatusAreaButton::icon_width() {
- return 23;
-}
-
-int StatusAreaButton::horizontal_padding() {
- return 1;
-}
-
void StatusAreaButton::UpdateTextStyle() {
ClearEmbellishing();
switch (delegate_->GetStatusAreaTextStyle()) {
@@ -164,4 +152,17 @@ void StatusAreaButton::UpdateTextStyle() {
SetTextShadowOffset(0, 1);
break;
}
+ SchedulePaint();
+}
+
+int StatusAreaButton::icon_height() {
+ return 24;
+}
+
+int StatusAreaButton::icon_width() {
+ return 23;
+}
+
+int StatusAreaButton::horizontal_padding() {
+ return 1;
}
diff --git a/chrome/browser/chromeos/status/status_area_button.h b/chrome/browser/chromeos/status/status_area_button.h
index 67e4d40..f250bba 100644
--- a/chrome/browser/chromeos/status/status_area_button.h
+++ b/chrome/browser/chromeos/status/status_area_button.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 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.
@@ -78,6 +78,9 @@ class StatusAreaButton : public views::MenuButton {
// menus are activated.
virtual void SetMenuActive(bool active);
+ // Refresh the style used to paint this button's text. Schedules repaint.
+ void UpdateTextStyle();
+
bool menu_active() const { return menu_active_; }
protected:
@@ -101,8 +104,6 @@ class StatusAreaButton : public views::MenuButton {
bool menu_active_;
private:
- void UpdateTextStyle();
-
Delegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(StatusAreaButton);
diff --git a/chrome/browser/chromeos/status/status_area_view.cc b/chrome/browser/chromeos/status/status_area_view.cc
index 463ab79..fb04757 100644
--- a/chrome/browser/chromeos/status/status_area_view.cc
+++ b/chrome/browser/chromeos/status/status_area_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 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.
@@ -114,6 +114,14 @@ void StatusAreaView::UpdateButtonVisibility() {
PreferredSizeChanged();
}
+void StatusAreaView::UpdateButtonTextStyle() {
+ for (std::list<StatusAreaButton*>::const_iterator it = buttons_.begin();
+ it != buttons_.end(); ++it) {
+ StatusAreaButton* button = *it;
+ button->UpdateTextStyle();
+ }
+}
+
void StatusAreaView::TakeFocus(
bool reverse,
const ReturnFocusCallback& return_focus_cb) {
diff --git a/chrome/browser/chromeos/status/status_area_view.h b/chrome/browser/chromeos/status/status_area_view.h
index 9c53a72..62e1adc 100644
--- a/chrome/browser/chromeos/status/status_area_view.h
+++ b/chrome/browser/chromeos/status/status_area_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 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.
@@ -28,6 +28,9 @@ class StatusAreaView : public views::AccessiblePaneView,
void MakeButtonsActive(bool active);
void UpdateButtonVisibility();
+ // Refresh the style used to paint all buttons' text. Schedules repaint.
+ void UpdateButtonTextStyle();
+
// Takes focus and transfers it to the first (last if |reverse| is true).
// After focus has traversed through all elements, clears focus and calls
// |return_focus_cb(reverse)| from the message loop.
diff --git a/chrome/browser/ui/views/aura/chrome_shell_delegate.h b/chrome/browser/ui/views/aura/chrome_shell_delegate.h
index 96b4d3d..c8808bc 100644
--- a/chrome/browser/ui/views/aura/chrome_shell_delegate.h
+++ b/chrome/browser/ui/views/aura/chrome_shell_delegate.h
@@ -27,6 +27,10 @@ class ChromeShellDelegate : public ash::ShellDelegate {
static ChromeShellDelegate* instance() { return instance_; }
+ StatusAreaHostAura* status_area_host_for_test() {
+ return status_area_host_.get();
+ }
+
StatusAreaView* GetStatusArea();
// Returns whether a launcher item should be created for |browser|. If an item
diff --git a/chrome/browser/ui/views/aura/status_area_host_aura.cc b/chrome/browser/ui/views/aura/status_area_host_aura.cc
index c16aa32..ec0edcb 100644
--- a/chrome/browser/ui/views/aura/status_area_host_aura.cc
+++ b/chrome/browser/ui/views/aura/status_area_host_aura.cc
@@ -13,17 +13,23 @@
#include "chrome/browser/defaults.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/themes/theme_service.h"
+#include "chrome/browser/themes/theme_service_factory.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/aura/chrome_shell_delegate.h"
#include "chrome/browser/ui/views/aura/multiple_window_indicator_button.h"
+#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
+#include "content/public/browser/notification_service.h"
#include "ui/aura/window.h"
#include "ui/views/widget/widget.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/base_login_display_host.h"
#include "chrome/browser/chromeos/login/proxy_settings_dialog.h"
+#include "chrome/browser/chromeos/login/screen_locker.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/status/status_area_view_chromeos.h"
#include "chrome/browser/chromeos/status/timezone_clock_updater.h"
#include "ui/gfx/native_widget_types.h"
@@ -32,9 +38,19 @@
StatusAreaHostAura::StatusAreaHostAura()
: status_area_widget_(NULL),
status_area_view_(NULL) {
+ BrowserList::AddObserver(this);
+ registrar_.Add(this,
+ chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
+ content::NotificationService::AllSources());
+#if defined(OS_CHROMEOS)
+ registrar_.Add(this,
+ chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
+ content::NotificationService::AllSources());
+#endif
}
StatusAreaHostAura::~StatusAreaHostAura() {
+ BrowserList::RemoveObserver(this);
}
StatusAreaView* StatusAreaHostAura::GetStatusArea() {
@@ -156,10 +172,64 @@ gfx::Font StatusAreaHostAura::GetStatusAreaFont(const gfx::Font& font) const {
}
StatusAreaButton::TextStyle StatusAreaHostAura::GetStatusAreaTextStyle() const {
- return StatusAreaButton::WHITE_HALOED;
+#if defined(OS_CHROMEOS)
+ if (!chromeos::UserManager::Get()->user_is_logged_in())
+ return StatusAreaButton::GRAY_PLAIN;
+
+ const chromeos::ScreenLocker* locker =
+ chromeos::ScreenLocker::default_screen_locker();
+ if (locker && locker->locked())
+ return StatusAreaButton::GRAY_PLAIN;
+#endif
+
+ if (ash::Shell::GetInstance()->IsWindowModeCompact()) {
+ Browser* browser = BrowserList::GetLastActive();
+ if (!browser)
+ return StatusAreaButton::WHITE_HALOED;
+
+ ThemeService* theme_service =
+ ThemeServiceFactory::GetForProfile(browser->profile());
+ if (!theme_service->UsingDefaultTheme())
+ return StatusAreaButton::WHITE_HALOED;
+
+ return browser->profile()->IsOffTheRecord() ?
+ StatusAreaButton::WHITE_PLAIN :
+ StatusAreaButton::GRAY_EMBOSSED;
+ } else {
+ return StatusAreaButton::WHITE_HALOED;
+ }
}
void StatusAreaHostAura::ButtonVisibilityChanged(views::View* button_view) {
if (status_area_view_)
status_area_view_->UpdateButtonVisibility();
}
+
+void StatusAreaHostAura::OnBrowserAdded(const Browser* browser) {
+ status_area_view_->UpdateButtonTextStyle();
+}
+
+void StatusAreaHostAura::OnBrowserRemoved(const Browser* browser) {
+ status_area_view_->UpdateButtonTextStyle();
+}
+
+void StatusAreaHostAura::OnBrowserSetLastActive(const Browser* browser) {
+ status_area_view_->UpdateButtonTextStyle();
+}
+
+void StatusAreaHostAura::Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ switch (type) {
+ case chrome::NOTIFICATION_BROWSER_THEME_CHANGED:
+ status_area_view_->UpdateButtonTextStyle();
+ break;
+#if defined(OS_CHROMEOS)
+ case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED:
+ status_area_view_->UpdateButtonTextStyle();
+ break;
+#endif
+ default:
+ NOTREACHED() << "Unexpected notification " << type;
+ }
+}
diff --git a/chrome/browser/ui/views/aura/status_area_host_aura.h b/chrome/browser/ui/views/aura/status_area_host_aura.h
index 63905b0..f280b8b 100644
--- a/chrome/browser/ui/views/aura/status_area_host_aura.h
+++ b/chrome/browser/ui/views/aura/status_area_host_aura.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 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.
@@ -8,6 +8,9 @@
#include "base/compiler_specific.h"
#include "chrome/browser/chromeos/status/status_area_button.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
#if defined(OS_CHROMEOS)
#include "base/memory/scoped_ptr.h"
@@ -22,7 +25,9 @@ class Views;
class Widget;
}
-class StatusAreaHostAura : public StatusAreaButton::Delegate {
+class StatusAreaHostAura : public StatusAreaButton::Delegate,
+ public BrowserList::Observer,
+ public content::NotificationObserver {
public:
StatusAreaHostAura();
virtual ~StatusAreaHostAura();
@@ -44,6 +49,16 @@ class StatusAreaHostAura : public StatusAreaButton::Delegate {
virtual StatusAreaButton::TextStyle GetStatusAreaTextStyle() const OVERRIDE;
virtual void ButtonVisibilityChanged(views::View* button_view) OVERRIDE;
+ // BrowserList::Observer implementation.
+ virtual void OnBrowserAdded(const Browser* browser) OVERRIDE;
+ virtual void OnBrowserRemoved(const Browser* browser) OVERRIDE;
+ virtual void OnBrowserSetLastActive(const Browser* browser) OVERRIDE;
+
+ // content::NotificationObserver implementation.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
private:
// Owned by caller of CreateStatusArea().
views::Widget* status_area_widget_;
@@ -57,6 +72,8 @@ class StatusAreaHostAura : public StatusAreaButton::Delegate {
scoped_ptr<TimezoneClockUpdater> timezone_clock_updater_;
#endif
+ content::NotificationRegistrar registrar_;
+
DISALLOW_COPY_AND_ASSIGN(StatusAreaHostAura);
};
diff --git a/chrome/browser/ui/views/aura/status_area_host_aura_browsertest.cc b/chrome/browser/ui/views/aura/status_area_host_aura_browsertest.cc
new file mode 100644
index 0000000..e3a2c8e
--- /dev/null
+++ b/chrome/browser/ui/views/aura/status_area_host_aura_browsertest.cc
@@ -0,0 +1,73 @@
+// Copyright (c) 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 "ash/shell.h"
+#include "base/command_line.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/chromeos/status/status_area_button.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/views/aura/chrome_shell_delegate.h"
+#include "chrome/browser/ui/views/aura/status_area_host_aura.h"
+#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/notification_service.h"
+
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/login/screen_locker.h"
+#include "chrome/browser/chromeos/login/screen_locker_tester.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
+#endif
+
+typedef InProcessBrowserTest StatusAreaHostAuraTest;
+
+IN_PROC_BROWSER_TEST_F(StatusAreaHostAuraTest, TextStyle) {
+ ChromeShellDelegate* delegate = static_cast<ChromeShellDelegate*>(
+ ash::Shell::GetInstance()->delegate());
+ StatusAreaHostAura* host = delegate->status_area_host_for_test();
+
+#if defined(OS_CHROMEOS)
+ ASSERT_FALSE(chromeos::UserManager::Get()->user_is_logged_in());
+ EXPECT_EQ(StatusAreaButton::GRAY_PLAIN, host->GetStatusAreaTextStyle());
+
+ // ProfileManager expects a profile dir to be set on Chrome OS.
+ CommandLine::ForCurrentProcess()->AppendSwitchNative(
+ switches::kLoginProfile, "StatusAreaHostAuraTest");
+ chromeos::UserManager::Get()->UserLoggedIn("foo@example.com");
+ ASSERT_TRUE(chromeos::UserManager::Get()->user_is_logged_in());
+#endif
+
+ if (ash::Shell::GetInstance()->IsWindowModeCompact()) {
+ EXPECT_EQ(StatusAreaButton::GRAY_EMBOSSED, host->GetStatusAreaTextStyle());
+
+ Browser* incognito_browser = CreateIncognitoBrowser();
+ EXPECT_EQ(StatusAreaButton::WHITE_PLAIN, host->GetStatusAreaTextStyle());
+
+ incognito_browser->CloseWindow();
+ EXPECT_EQ(StatusAreaButton::GRAY_EMBOSSED, host->GetStatusAreaTextStyle());
+ } else {
+ EXPECT_EQ(StatusAreaButton::WHITE_HALOED, host->GetStatusAreaTextStyle());
+ }
+
+#if defined(OS_CHROMEOS)
+ // Lock the screen.
+ chromeos::ScreenLocker::Show();
+ scoped_ptr<chromeos::test::ScreenLockerTester> tester(
+ chromeos::ScreenLocker::GetTester());
+ tester->EmulateWindowManagerReady();
+ ui_test_utils::WindowedNotificationObserver lock_state_observer(
+ chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
+ content::NotificationService::AllSources());
+ if (!tester->IsLocked())
+ lock_state_observer.Wait();
+ ASSERT_TRUE(tester->IsLocked());
+ EXPECT_EQ(StatusAreaButton::GRAY_PLAIN, host->GetStatusAreaTextStyle());
+
+ chromeos::ScreenLocker::Hide();
+ ui_test_utils::RunAllPendingInMessageLoop();
+ ASSERT_FALSE(tester->IsLocked());
+#endif
+}
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 6250690..9c75f70 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -2523,6 +2523,8 @@
'browser/chromeos/login/mock_update_screen.cc',
'browser/chromeos/login/mock_update_screen.h',
'browser/chromeos/login/network_screen_browsertest.cc',
+ 'browser/chromeos/login/screen_locker_tester.cc',
+ 'browser/chromeos/login/screen_locker_tester.h',
'browser/chromeos/login/update_screen_browsertest.cc',
'browser/chromeos/login/wizard_controller_browsertest.cc',
'browser/chromeos/login/wizard_in_process_browser_test.cc',
@@ -2721,6 +2723,7 @@
'browser/ui/tab_modal_confirm_dialog_browsertest_mac.mm',
'browser/ui/tab_modal_confirm_dialog_browsertest.cc',
'browser/ui/tab_modal_confirm_dialog_browsertest.h',
+ 'browser/ui/views/aura/status_area_host_aura_browsertest.cc',
'browser/ui/views/browser_actions_container_browsertest.cc',
'browser/ui/views/dom_view_browsertest.cc',
'browser/ui/views/html_dialog_view_browsertest.cc',