diff options
5 files changed, 35 insertions, 33 deletions
diff --git a/chrome/browser/ui/views/message_center/web_notification_tray_win.cc b/chrome/browser/ui/views/message_center/web_notification_tray_win.cc index 38a0238..1cdecab 100644 --- a/chrome/browser/ui/views/message_center/web_notification_tray_win.cc +++ b/chrome/browser/ui/views/message_center/web_notification_tray_win.cc @@ -25,7 +25,7 @@ #include "ui/message_center/message_center_tray_delegate.h" #include "ui/message_center/views/message_bubble_base.h" #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/views/widget/widget.h" namespace { @@ -120,17 +120,13 @@ message_center::MessageCenter* WebNotificationTrayWin::message_center() { } bool WebNotificationTrayWin::ShowPopups() { - scoped_ptr<message_center::MessagePopupBubble> bubble( - new message_center::MessagePopupBubble(message_center())); - popup_bubble_.reset(new internal::NotificationBubbleWrapperWin( - this, - bubble.Pass(), - internal::NotificationBubbleWrapperWin::BUBBLE_TYPE_POPUP)); + popup_collection_.reset( + new message_center::MessagePopupCollection(NULL, message_center())); return true; } void WebNotificationTrayWin::HidePopups() { - popup_bubble_.reset(); + popup_collection_.reset(); } bool WebNotificationTrayWin::ShowMessageCenter() { @@ -177,8 +173,8 @@ void WebNotificationTrayWin::UpdateMessageCenter() { } void WebNotificationTrayWin::UpdatePopups() { - if (popup_bubble_.get()) - popup_bubble_->bubble()->ScheduleUpdate(); + if (popup_collection_.get()) + popup_collection_->UpdatePopups(); }; void WebNotificationTrayWin::OnMessageCenterTrayChanged() { @@ -244,9 +240,6 @@ void WebNotificationTrayWin::HideBubbleWithView( if (message_center_bubble_.get() && bubble_view == message_center_bubble_->bubble_view()) { message_center_tray_->HideMessageCenterBubble(); - } else if (popup_bubble_.get() && - bubble_view == popup_bubble_->bubble_view()) { - message_center_tray_->HidePopupBubble(); } } @@ -263,12 +256,4 @@ WebNotificationTrayWin::GetMessageCenterBubbleForTest() { message_center_bubble_->bubble()); } -message_center::MessagePopupBubble* -WebNotificationTrayWin::GetPopupBubbleForTest() { - if (!popup_bubble_.get()) - return NULL; - return static_cast<message_center::MessagePopupBubble*>( - popup_bubble_->bubble()); -} - } // namespace message_center diff --git a/chrome/browser/ui/views/message_center/web_notification_tray_win.h b/chrome/browser/ui/views/message_center/web_notification_tray_win.h index 1fc397c..bb5b883 100644 --- a/chrome/browser/ui/views/message_center/web_notification_tray_win.h +++ b/chrome/browser/ui/views/message_center/web_notification_tray_win.h @@ -16,7 +16,7 @@ class StatusIcon; namespace message_center { class MessageCenter; class MessageCenterBubble; -class MessagePopupBubble; +class MessagePopupCollection; } namespace views { @@ -75,11 +75,10 @@ class WebNotificationTrayWin FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayWinTest, ManyPopupNotifications); void AddQuietModeMenu(StatusIcon* status_icon); - message_center::MessagePopupBubble* GetPopupBubbleForTest(); message_center::MessageCenterBubble* GetMessageCenterBubbleForTest(); - scoped_ptr<internal::NotificationBubbleWrapperWin> popup_bubble_; scoped_ptr<internal::NotificationBubbleWrapperWin> message_center_bubble_; + scoped_ptr<message_center::MessagePopupCollection> popup_collection_; StatusIcon* status_icon_; bool message_center_visible_; diff --git a/chrome/browser/ui/views/message_center/web_notification_tray_win_browsertest.cc b/chrome/browser/ui/views/message_center/web_notification_tray_win_browsertest.cc index efe5429..fb5b995 100644 --- a/chrome/browser/ui/views/message_center/web_notification_tray_win_browsertest.cc +++ b/chrome/browser/ui/views/message_center/web_notification_tray_win_browsertest.cc @@ -17,7 +17,7 @@ #include "ui/message_center/notification_list.h" #include "ui/message_center/notification_types.h" #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/views/controls/label.h" #include "ui/views/layout/fill_layout.h" #include "ui/views/view.h" @@ -103,8 +103,8 @@ typedef InProcessBrowserTest WebNotificationTrayWinTest; // TODO(dewittj): More exhaustive testing. IN_PROC_BROWSER_TEST_F(WebNotificationTrayWinTest, WebNotifications) { - scoped_ptr<WebNotificationTrayWin> tray(new WebNotificationTrayWin()); - message_center::MessageCenter* message_center = tray->message_center(); + message_center::MessageCenter* message_center = + message_center::MessageCenter::Get(); scoped_ptr<TestDelegate> delegate(new TestDelegate(message_center)); // Add a notification. @@ -187,6 +187,8 @@ IN_PROC_BROWSER_TEST_F(WebNotificationTrayWinTest, message_center->NotificationCount()); EXPECT_EQ(NotificationList::kMaxVisibleMessageCenterNotifications, tray->GetMessageCenterBubbleForTest()->NumMessageViewsForTest()); + message_center->notification_list()->RemoveAllNotifications(); + message_center->NotifyMessageCenterChanged(false); } IN_PROC_BROWSER_TEST_F(WebNotificationTrayWinTest, ManyPopupNotifications) { @@ -207,10 +209,11 @@ IN_PROC_BROWSER_TEST_F(WebNotificationTrayWinTest, ManyPopupNotifications) { EXPECT_TRUE(tray->message_center_tray_->popups_visible()); EXPECT_EQ(notifications_to_add, message_center->NotificationCount()); - EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, - tray->GetPopupBubbleForTest()->NumMessageViewsForTest()); - message_center->SetDelegate(NULL); + NotificationList::PopupNotifications popups = + message_center->notification_list()->GetPopupNotifications(); + EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, popups.size()); message_center->notification_list()->RemoveAllNotifications(); + message_center->NotifyMessageCenterChanged(false); } } // namespace message_center diff --git a/ui/message_center/message_center.h b/ui/message_center/message_center.h index 58575bd..1ddb29e 100644 --- a/ui/message_center/message_center.h +++ b/ui/message_center/message_center.h @@ -171,6 +171,9 @@ class MESSAGE_CENTER_EXPORT MessageCenter : public NotificationChangeObserver, virtual ~MessageCenter(); private: + FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayWinTest, + ManyMessageCenterNotifications); + FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayWinTest, ManyPopupNotifications); // Calls OnMessageCenterChanged on each observer. void NotifyMessageCenterChanged(bool new_notification); diff --git a/ui/message_center/views/message_popup_collection.cc b/ui/message_center/views/message_popup_collection.cc index c67bc3d..b6c3001 100644 --- a/ui/message_center/views/message_popup_collection.cc +++ b/ui/message_center/views/message_popup_collection.cc @@ -47,7 +47,10 @@ class ToastContentsView : public views::WidgetDelegateView { views::Widget::InitParams params( views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); params.keep_on_top = true; - params.context = context; + if (context) + params.context = context; + else + params.top_level = true; params.transparent = true; // The origin of the initial bounds are set to (0, 0). It'll then moved by // MessagePopupCollection. @@ -146,8 +149,17 @@ void MessagePopupCollection::UpdatePopups() { return; } - gfx::Screen* screen = gfx::Screen::GetScreenFor(context_); - gfx::Rect work_area = screen->GetDisplayNearestWindow(context_).work_area(); + gfx::Rect work_area; + if (!context_) { + // On Win+Aura, we don't have a context since the popups currently show up + // on the Windows desktop, not in the Aura/Ash desktop. This code will + // display the popups on the primary display. + gfx::Screen* screen = gfx::Screen::GetNativeScreen(); + work_area = screen->GetPrimaryDisplay().work_area(); + } else { + gfx::Screen* screen = gfx::Screen::GetScreenFor(context_); + work_area = screen->GetDisplayNearestWindow(context_).work_area(); + } std::set<std::string> old_toast_ids; for (ToastContainer::iterator iter = toasts_.begin(); iter != toasts_.end(); |