diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-07 09:12:30 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-07 09:12:30 +0000 |
commit | 7cc0c9656153dc680a182ae846e00fa83d10e513 (patch) | |
tree | da4d4f7f54337f0f6617c2731606f1edf80c6e80 /ash | |
parent | fe16e6518b235112d2803952c31e7cba5193f924 (diff) | |
download | chromium_src-7cc0c9656153dc680a182ae846e00fa83d10e513.zip chromium_src-7cc0c9656153dc680a182ae846e00fa83d10e513.tar.gz chromium_src-7cc0c9656153dc680a182ae846e00fa83d10e513.tar.bz2 |
Deprecates QuietModeBubble and uses context menu for quiet mode.
BUG=179437
Review URL: https://chromiumcodereview.appspot.com/12526006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186660 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/system/web_notification/web_notification_tray.cc | 62 | ||||
-rw-r--r-- | ash/system/web_notification/web_notification_tray.h | 22 |
2 files changed, 34 insertions, 50 deletions
diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc index cfc1e1c..98f3770 100644 --- a/ash/system/web_notification/web_notification_tray.cc +++ b/ash/system/web_notification/web_notification_tray.cc @@ -25,10 +25,10 @@ #include "ui/message_center/views/message_center_bubble.h" #include "ui/message_center/views/message_popup_bubble.h" #include "ui/message_center/views/message_popup_collection.h" -#include "ui/message_center/views/quiet_mode_bubble.h" #include "ui/views/bubble/tray_bubble_view.h" #include "ui/views/controls/button/image_button.h" -#include "ui/views/widget/widget_observer.h" +#include "ui/views/controls/menu/menu_model_adapter.h" +#include "ui/views/controls/menu/menu_runner.h" #if defined(OS_CHROMEOS) @@ -107,9 +107,6 @@ WebNotificationTray::~WebNotificationTray() { message_center_bubble_.reset(); popup_bubble_.reset(); popup_collection_.reset(); - if (quiet_mode_bubble() && quiet_mode_bubble()->GetBubbleWidget()) - quiet_mode_bubble()->GetBubbleWidget()->RemoveObserver(this); - quiet_mode_bubble_.reset(); } // Public methods. @@ -217,7 +214,24 @@ bool WebNotificationTray::ShouldShowMessageCenter() { status_area_widget()->ShouldShowWebNotifications(); } -bool WebNotificationTray::ShouldShowQuietModeBubble(const ui::Event& event) { +void WebNotificationTray::ShowQuietModeMenu() { + views::MenuModelAdapter menu_model_adapter( + message_center_tray_->CreateQuietModeMenu()); + quiet_mode_menu_runner_.reset( + new views::MenuRunner(menu_model_adapter.CreateMenu())); + gfx::Point point; + views::View::ConvertPointToScreen(this, &point); + ignore_result(quiet_mode_menu_runner_->RunMenuAt( + GetWidget(), + NULL, + gfx::Rect(point, bounds().size()), + views::MenuItemView::BUBBLE_ABOVE, + views::MenuRunner::HAS_MNEMONICS)); + quiet_mode_menu_runner_.reset(); + GetShelfLayoutManager()->UpdateAutoHideState(); +} + +bool WebNotificationTray::ShouldShowQuietModeMenu(const ui::Event& event) { // TODO(mukai): Add keyboard event handler. if (!event.IsMouseEvent()) return false; @@ -228,18 +242,6 @@ bool WebNotificationTray::ShouldShowQuietModeBubble(const ui::Event& event) { return mouse_event->IsRightMouseButton(); } -void WebNotificationTray::ShowQuietModeBubble() { - aura::Window* parent = Shell::GetContainer( - Shell::GetPrimaryRootWindow(), - internal::kShellWindowId_SettingBubbleContainer); - quiet_mode_bubble_.reset(new message_center::QuietModeBubble( - button_, - parent, - message_center_tray_->message_center()->notification_list())); - quiet_mode_bubble()->GetBubbleWidget()->StackAtTop(); - quiet_mode_bubble()->GetBubbleWidget()->AddObserver(this); -} - void WebNotificationTray::UpdateAfterLoginStatusChange( user::LoginStatus login_status) { if (message_center::IsRichNotificationEnabled()) { @@ -264,7 +266,8 @@ void WebNotificationTray::UpdateAfterLoginStatusChange( } bool WebNotificationTray::ShouldBlockLauncherAutoHide() const { - return IsMessageCenterBubbleVisible() || quiet_mode_bubble() != NULL; + return IsMessageCenterBubbleVisible() || + (quiet_mode_menu_runner_.get() && quiet_mode_menu_runner_->IsRunning()); } bool WebNotificationTray::IsMessageCenterBubbleVisible() const { @@ -306,9 +309,6 @@ void WebNotificationTray::AnchorUpdated() { message_center_bubble()->bubble_view()->UpdateBubble(); UpdateBubbleViewArrow(message_center_bubble()->bubble_view()); } - // Quiet mode settings bubble has to be on top. - if (quiet_mode_bubble() && quiet_mode_bubble()->GetBubbleWidget()) - quiet_mode_bubble()->GetBubbleWidget()->StackAtTop(); } string16 WebNotificationTray::GetAccessibleNameForTray() { @@ -328,11 +328,11 @@ void WebNotificationTray::HideBubbleWithView( } bool WebNotificationTray::PerformAction(const ui::Event& event) { - if (!quiet_mode_bubble() && ShouldShowQuietModeBubble(event)) { - ShowQuietModeBubble(); + if (ShouldShowQuietModeMenu(event)) { + ShowQuietModeMenu(); return true; } - quiet_mode_bubble_.reset(); + if (message_center_bubble()) message_center_tray_->HideMessageCenterBubble(); else @@ -378,13 +378,6 @@ void WebNotificationTray::ButtonPressed(views::Button* sender, PerformAction(event); } -void WebNotificationTray::OnWidgetDestroying(views::Widget* widget) { - if (quiet_mode_bubble() && quiet_mode_bubble()->GetBubbleWidget() == widget) { - widget->RemoveObserver(this); - } - quiet_mode_bubble_.reset(); -} - void WebNotificationTray::OnMessageCenterTrayChanged() { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); message_center::MessageCenter* message_center = @@ -424,10 +417,9 @@ void WebNotificationTray::OnMessageCenterTrayChanged() { } bool WebNotificationTray::ClickedOutsideBubble() { - // Only hide the message center and quiet mode bubble. - if (!message_center_bubble() && !quiet_mode_bubble()) + // Only hide the message center. + if (!message_center_bubble()) return false; - quiet_mode_bubble_.reset(); message_center_tray_->HideMessageCenterBubble(); return true; } diff --git a/ash/system/web_notification/web_notification_tray.h b/ash/system/web_notification/web_notification_tray.h index 923d2cf..ed3e45d 100644 --- a/ash/system/web_notification/web_notification_tray.h +++ b/ash/system/web_notification/web_notification_tray.h @@ -14,7 +14,6 @@ #include "ui/message_center/message_center_tray_delegate.h" #include "ui/views/bubble/tray_bubble_view.h" #include "ui/views/controls/button/button.h" -#include "ui/views/widget/widget_observer.h" // Status area tray for showing browser and app notifications. This hosts // a MessageCenter class which manages the notification list. This class @@ -26,6 +25,7 @@ namespace views { class ImageButton; +class MenuRunner; } namespace message_center { @@ -47,8 +47,7 @@ class ASH_EXPORT WebNotificationTray : public internal::TrayBackgroundView, public views::TrayBubbleView::Delegate, public message_center::MessageCenterTrayDelegate, - public views::ButtonListener, - public views::WidgetObserver { + public views::ButtonListener { public: explicit WebNotificationTray( internal::StatusAreaWidget* status_area_widget); @@ -97,9 +96,6 @@ class ASH_EXPORT WebNotificationTray virtual void ButtonPressed(views::Button* sender, const ui::Event& event) OVERRIDE; - // Overridden from WidgetObserver. - virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; - // Overridden from MessageCenterTrayDelegate. virtual void OnMessageCenterTrayChanged() OVERRIDE; virtual bool ShowMessageCenter() OVERRIDE; @@ -122,11 +118,11 @@ class ASH_EXPORT WebNotificationTray // the message center. bool ShouldShowMessageCenter(); - // Returns true if it should show the quiet mode bubble. - bool ShouldShowQuietModeBubble(const ui::Event& event); + // Returns true if it should show the quiet mode menu. + bool ShouldShowQuietModeMenu(const ui::Event& event); - // Shows the quiet mode bubble. - void ShowQuietModeBubble(); + // Shows the quiet mode menu. + void ShowQuietModeMenu(); internal::WebNotificationBubbleWrapper* message_center_bubble() const { return message_center_bubble_.get(); @@ -136,10 +132,6 @@ class ASH_EXPORT WebNotificationTray return popup_bubble_.get(); } - message_center::QuietModeBubble* quiet_mode_bubble() const { - return quiet_mode_bubble_.get(); - } - // Testing accessors. bool IsPopupVisible() const; message_center::MessageCenterBubble* GetMessageCenterBubbleForTest(); @@ -149,7 +141,7 @@ class ASH_EXPORT WebNotificationTray scoped_ptr<internal::WebNotificationBubbleWrapper> message_center_bubble_; scoped_ptr<internal::WebNotificationBubbleWrapper> popup_bubble_; scoped_ptr<message_center::MessagePopupCollection> popup_collection_; - scoped_ptr<message_center::QuietModeBubble> quiet_mode_bubble_; + scoped_ptr<views::MenuRunner> quiet_mode_menu_runner_; views::ImageButton* button_; bool show_message_center_on_unlock_; |