diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-24 23:34:53 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-24 23:34:53 +0000 |
commit | 3a3ed7fbff49436e42617a9b05179f341ceab725 (patch) | |
tree | b64b6b9132bb81b024ffe9f0930e73913043be8e /ash | |
parent | 5d8d98d28ddcb0ee30b35950fafcf62304da19b0 (diff) | |
download | chromium_src-3a3ed7fbff49436e42617a9b05179f341ceab725.zip chromium_src-3a3ed7fbff49436e42617a9b05179f341ceab725.tar.gz chromium_src-3a3ed7fbff49436e42617a9b05179f341ceab725.tar.bz2 |
Do not show the notification of display configuration when unnecessary.
It should not be notified if the configuration change happens from
the settings UI. To achieve this casually, this CL simply blocks
the display notifications when chrome://settings/display is active.
This is not perfect but good enough I guess.
BUG=250650, 246271
R=oshima@chromium.org, jamescook@chromium.org, stevenjb@chromium.org
Review URL: https://chromiumcodereview.appspot.com/16818028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208299 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/system/chromeos/tray_display.cc | 11 | ||||
-rw-r--r-- | ash/system/chromeos/tray_display.h | 5 | ||||
-rw-r--r-- | ash/system/chromeos/tray_display_unittest.cc | 7 | ||||
-rw-r--r-- | ash/system/tray/system_tray_delegate.h | 4 | ||||
-rw-r--r-- | ash/system/tray/test_system_tray_delegate.cc | 5 | ||||
-rw-r--r-- | ash/system/tray/test_system_tray_delegate.h | 6 | ||||
-rw-r--r-- | ash/test/ash_test_base.cc | 8 |
7 files changed, 24 insertions, 22 deletions
diff --git a/ash/system/chromeos/tray_display.cc b/ash/system/chromeos/tray_display.cc index 484e0d2..0a8d61a 100644 --- a/ash/system/chromeos/tray_display.cc +++ b/ash/system/chromeos/tray_display.cc @@ -26,8 +26,6 @@ namespace ash { namespace internal { namespace { -bool display_notifications_disabled = false; - DisplayManager* GetDisplayManager() { return Shell::GetInstance()->display_manager(); } @@ -309,8 +307,10 @@ bool TrayDisplay::ShouldShowLauncher() const { } void TrayDisplay::OnDisplayConfigurationChanged() { - if (display_notifications_disabled) + if (!Shell::GetInstance()->system_tray_delegate()-> + ShouldShowDisplayNotification()) { return; + } // TODO(mukai): do not show the notification when the configuration changed // due to the user operation on display settings page. @@ -321,11 +321,6 @@ void TrayDisplay::OnDisplayConfigurationChanged() { ShowNotificationView(); } -// static -void TrayDisplay::SetDisplayNotificationsDisabledForTest(bool disabled) { - display_notifications_disabled = disabled; -} - base::string16 TrayDisplay::GetDefaultViewMessage() { if (!default_ || !default_->visible()) return base::string16(); diff --git a/ash/system/chromeos/tray_display.h b/ash/system/chromeos/tray_display.h index 4c2faa73..9c823bb 100644 --- a/ash/system/chromeos/tray_display.h +++ b/ash/system/chromeos/tray_display.h @@ -30,7 +30,6 @@ class ASH_EXPORT TrayDisplay : public SystemTrayItem, virtual ~TrayDisplay(); private: - friend class test::AshTestBase; friend class TrayDisplayTest; typedef std::map<int64, DisplayInfo> DisplayInfoMap; @@ -50,10 +49,6 @@ class ASH_EXPORT TrayDisplay : public SystemTrayItem, // Overridden from DisplayControllerObserver: virtual void OnDisplayConfigurationChanged() OVERRIDE; - // Call this with |diabled| = false when the test case wants to see the - // display notification. - static void SetDisplayNotificationsDisabledForTest(bool disabled); - // Test accessors. base::string16 GetDefaultViewMessage(); views::View* default_view() { return default_; } diff --git a/ash/system/chromeos/tray_display_unittest.cc b/ash/system/chromeos/tray_display_unittest.cc index 8c2ec5b..841214a 100644 --- a/ash/system/chromeos/tray_display_unittest.cc +++ b/ash/system/chromeos/tray_display_unittest.cc @@ -9,6 +9,7 @@ #include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/system/tray/system_tray.h" +#include "ash/system/tray/test_system_tray_delegate.h" #include "ash/test/ash_test_base.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" @@ -88,7 +89,6 @@ void TrayDisplayTest::SetUp() { tray_ = Shell::GetPrimaryRootWindowController()->GetSystemTray(); tray_display_ = new TrayDisplay(tray_); tray_->AddTrayItem(tray_display_); - TrayDisplay::SetDisplayNotificationsDisabledForTest(false); } void TrayDisplayTest::CloseNotification() { @@ -247,6 +247,11 @@ TEST_F(TrayDisplayTest, ExternalDisplayResized) { } TEST_F(TrayDisplayTest, DisplayNotifications) { + test::TestSystemTrayDelegate* tray_delegate = + static_cast<test::TestSystemTrayDelegate*>( + Shell::GetInstance()->system_tray_delegate()); + tray_delegate->set_should_show_display_notification(true); + UpdateDisplay("400x400"); DisplayManager* display_manager = Shell::GetInstance()->display_manager(); gfx::Display::SetInternalDisplayId(display_manager->first_display_id()); diff --git a/ash/system/tray/system_tray_delegate.h b/ash/system/tray/system_tray_delegate.h index 191d481..ee60831 100644 --- a/ash/system/tray/system_tray_delegate.h +++ b/ash/system/tray/system_tray_delegate.h @@ -167,6 +167,10 @@ class SystemTrayDelegate { // Shows settings related to multiple displays. virtual void ShowDisplaySettings() = 0; + // Returns true if the notification for the display configuration change + // should appear. + virtual bool ShouldShowDisplayNotification() = 0; + // Shows settings related to Google Drive. virtual void ShowDriveSettings() = 0; diff --git a/ash/system/tray/test_system_tray_delegate.cc b/ash/system/tray/test_system_tray_delegate.cc index 3092287..18ec7f8 100644 --- a/ash/system/tray/test_system_tray_delegate.cc +++ b/ash/system/tray/test_system_tray_delegate.cc @@ -53,6 +53,7 @@ class TestVolumeControlDelegate : public VolumeControlDelegate { TestSystemTrayDelegate::TestSystemTrayDelegate() : bluetooth_enabled_(true), caps_lock_enabled_(false), + should_show_display_notification_(false), volume_control_delegate_(new TestVolumeControlDelegate) { } @@ -138,6 +139,10 @@ void TestSystemTrayDelegate::ShowBluetoothSettings() { void TestSystemTrayDelegate::ShowDisplaySettings() { } +bool TestSystemTrayDelegate::ShouldShowDisplayNotification() { + return should_show_display_notification_; +} + void TestSystemTrayDelegate::ShowDriveSettings() { } diff --git a/ash/system/tray/test_system_tray_delegate.h b/ash/system/tray/test_system_tray_delegate.h index fa6b53c..56cb078 100644 --- a/ash/system/tray/test_system_tray_delegate.h +++ b/ash/system/tray/test_system_tray_delegate.h @@ -42,6 +42,7 @@ class TestSystemTrayDelegate : public SystemTrayDelegate { virtual void ShowNetworkSettings(const std::string& service_path) OVERRIDE; virtual void ShowBluetoothSettings() OVERRIDE; virtual void ShowDisplaySettings() OVERRIDE; + virtual bool ShouldShowDisplayNotification() OVERRIDE; virtual void ShowDriveSettings() OVERRIDE; virtual void ShowIMESettings() OVERRIDE; virtual void ShowHelp() OVERRIDE; @@ -95,9 +96,14 @@ class TestSystemTrayDelegate : public SystemTrayDelegate { const base::TimeDelta& delta) const OVERRIDE; virtual void MaybeSpeak(const std::string& utterance) const OVERRIDE; + void set_should_show_display_notification(bool should_show) { + should_show_display_notification_ = should_show; + } + private: bool bluetooth_enabled_; bool caps_lock_enabled_; + bool should_show_display_notification_; scoped_ptr<VolumeControlDelegate> volume_control_delegate_; DISALLOW_COPY_AND_ASSIGN(TestSystemTrayDelegate); diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc index 079f135..dca886b 100644 --- a/ash/test/ash_test_base.cc +++ b/ash/test/ash_test_base.cc @@ -118,14 +118,6 @@ void AshTestBase::SetUp() { Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000)); ash::Shell::GetInstance()->cursor_manager()->EnableMouseEvents(); -#if defined(OS_CHROMEOS) - // We do not want to see the notification for display configuration change, - // since it may trap mouse events unexpectedly. - // TODO(mukai): remove this code when the display notification code is moved - // to the message center. - internal::TrayDisplay::SetDisplayNotificationsDisabledForTest(true); -#endif - #if defined(OS_WIN) if (base::win::GetVersion() >= base::win::VERSION_WIN8 && !CommandLine::ForCurrentProcess()->HasSwitch( |