diff options
Diffstat (limited to 'chrome/browser')
9 files changed, 84 insertions, 7 deletions
diff --git a/chrome/browser/notifications/message_center_notification_manager.cc b/chrome/browser/notifications/message_center_notification_manager.cc index 0ccc840..b249f49 100644 --- a/chrome/browser/notifications/message_center_notification_manager.cc +++ b/chrome/browser/notifications/message_center_notification_manager.cc @@ -7,6 +7,7 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/prefs/pref_service.h" +#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/extension_info_map.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/notifications/desktop_notification_service.h" @@ -19,6 +20,8 @@ #include "chrome/browser/ui/host_desktop.h" #include "chrome/common/extensions/extension_set.h" #include "chrome/common/pref_names.h" +#include "content/public/browser/notification_service.h" +#include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents.h" #include "content/public/common/url_constants.h" #include "ui/message_center/message_center_style.h" @@ -55,6 +58,9 @@ MessageCenterNotificationManager::MessageCenterNotificationManager( // views.Other platforms have global ownership and Create will return NULL. tray_.reset(message_center::CreateMessageCenterTray()); #endif + registrar_.Add(this, + chrome::NOTIFICATION_FULLSCREEN_CHANGED, + content::NotificationService::AllSources()); } MessageCenterNotificationManager::~MessageCenterNotificationManager() { @@ -328,6 +334,20 @@ void MessageCenterNotificationManager::SetMessageCenterTrayDelegateForTest( tray_.reset(delegate); } +void MessageCenterNotificationManager::Observe( + int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) { + if (type == chrome::NOTIFICATION_FULLSCREEN_CHANGED) { + const bool is_fullscreen = *content::Details<bool>(details).ptr(); + + if (is_fullscreen && tray_.get() && tray_->GetMessageCenterTray()) + tray_->GetMessageCenterTray()->HidePopupBubble(); + } else { + NotificationUIManagerImpl::Observe(type, source, details); + } +} + //////////////////////////////////////////////////////////////////////////////// // ImageDownloads diff --git a/chrome/browser/notifications/message_center_notification_manager.h b/chrome/browser/notifications/message_center_notification_manager.h index 89493a2..91701d2 100644 --- a/chrome/browser/notifications/message_center_notification_manager.h +++ b/chrome/browser/notifications/message_center_notification_manager.h @@ -16,6 +16,8 @@ #include "chrome/browser/notifications/notification.h" #include "chrome/browser/notifications/notification_ui_manager.h" #include "chrome/browser/notifications/notification_ui_manager_impl.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" #include "ui/message_center/message_center.h" #include "ui/message_center/message_center_observer.h" #include "ui/message_center/message_center_tray_delegate.h" @@ -81,6 +83,12 @@ class MessageCenterNotificationManager void SetMessageCenterTrayDelegateForTest( message_center::MessageCenterTrayDelegate* delegate); + protected: + // content::NotificationObserver override. + virtual void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) OVERRIDE; + private: class ImageDownloadsObserver { public: @@ -214,6 +222,9 @@ class MessageCenterNotificationManager scoped_ptr<MessageCenterSettingsController> settings_controller_; + // Registrar for the other kind of notifications (event signaling). + content::NotificationRegistrar registrar_; + DISALLOW_COPY_AND_ASSIGN(MessageCenterNotificationManager); }; diff --git a/chrome/browser/notifications/message_center_notifications_browsertest.cc b/chrome/browser/notifications/message_center_notifications_browsertest.cc index 28b4728..03f8012 100644 --- a/chrome/browser/notifications/message_center_notifications_browsertest.cc +++ b/chrome/browser/notifications/message_center_notifications_browsertest.cc @@ -10,6 +10,7 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/notifications/message_center_notification_manager.h" #include "chrome/browser/notifications/notification.h" #include "chrome/browser/notifications/notification_ui_manager.h" @@ -17,6 +18,9 @@ #include "chrome/browser/ui/browser.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/test_switches.h" +#include "content/public/browser/notification_details.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_source.h" #include "ui/message_center/message_center.h" #include "ui/message_center/message_center_switches.h" #include "ui/message_center/message_center_util.h" @@ -405,4 +409,29 @@ IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, delegate->Release(); } +#if !defined(OS_CHROMEOS) && defined(RUN_MESSAGE_CENTER_TESTS) +#define MAYBE_HideWhenFullscreenEnabled HideWhenFullscreenEnabled +#else +#define MAYBE_HideWhenFullscreenEnabled DISABLED_HideWhenFullscreenEnabled +#endif + +IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, + MAYBE_HideWhenFullscreenEnabled) { + EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); + + TestDelegate* delegate; + manager()->Add(CreateTestNotification("n", &delegate), profile()); + + EXPECT_EQ("Display_", delegate->log()); + EXPECT_TRUE(message_center()->HasPopupNotifications()); + bool is_fullscreen = true; + // Cast so that Observe() is public. + content::NotificationObserver* observer = + static_cast<content::NotificationObserver*>(manager()); + observer->Observe(chrome::NOTIFICATION_FULLSCREEN_CHANGED, + content::Source<Profile>(profile()), + content::Details<bool>(&is_fullscreen)); + EXPECT_FALSE(message_center()->HasPopupNotifications()); +} + #endif // !defined(OS_MACOSX) diff --git a/chrome/browser/notifications/message_center_notifications_unittest_win.cc b/chrome/browser/notifications/message_center_notifications_unittest_win.cc index 130fd9f..fd674e63 100644 --- a/chrome/browser/notifications/message_center_notifications_unittest_win.cc +++ b/chrome/browser/notifications/message_center_notifications_unittest_win.cc @@ -41,6 +41,9 @@ class FakeMessageCenterTrayDelegate : public MessageCenterTrayDelegate { virtual bool ShowMessageCenter() OVERRIDE { return true; } virtual bool ShowNotifierSettings() OVERRIDE { return true; } virtual void HideMessageCenter() OVERRIDE {} + virtual MessageCenterTray* GetMessageCenterTray() OVERRIDE { + return &tray_; + } bool displayed_first_run_balloon() const { return displayed_first_run_balloon_; diff --git a/chrome/browser/notifications/notification_ui_manager_impl.h b/chrome/browser/notifications/notification_ui_manager_impl.h index a56d439..23e0a78 100644 --- a/chrome/browser/notifications/notification_ui_manager_impl.h +++ b/chrome/browser/notifications/notification_ui_manager_impl.h @@ -58,23 +58,23 @@ class NotificationUIManagerImpl Profile* profile) = 0; // Replace an existing notification of the same id with this one if - // applicable; subclass returns 'true' if the replacement happened. + // applicable. Subclass returns 'true' if the replacement happened. virtual bool UpdateNotification(const Notification& notification, Profile* profile) = 0; - // Attempts to display notifications from the show_queue. Invoked by subclass - // if it previously returned 'false' from ShowNotifications, which may happen - // when there is no room to show another notification. When room appears, the - // subclass should call this method to cause an attempt to show more - // notifications from the waiting queue. + // Attempts to display notifications from the show_queue. Invoked by + // subclasses if they previously returned 'false' from ShowNotifications, + // which may happen when there is no room to show another notification. When + // room appears, the subclass should call this method to cause an attempt to + // show more notifications from the waiting queue. void CheckAndShowNotifications(); - private: // content::NotificationObserver override. virtual void Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) OVERRIDE; + private: // Attempts to display notifications from the show_queue. void ShowNotifications(); diff --git a/chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.h b/chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.h index 2b4daf1..a01164f 100644 --- a/chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.h +++ b/chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.h @@ -39,6 +39,7 @@ class MessageCenterTrayBridge : virtual bool ShowMessageCenter() OVERRIDE; virtual void HideMessageCenter() OVERRIDE; virtual bool ShowNotifierSettings() OVERRIDE; + virtual message_center::MessageCenterTray* GetMessageCenterTray() OVERRIDE; message_center::MessageCenter* message_center() { return message_center_; } diff --git a/chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.mm b/chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.mm index 2ece534..9185998 100644 --- a/chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.mm +++ b/chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.mm @@ -85,6 +85,11 @@ bool MessageCenterTrayBridge::ShowNotifierSettings() { return false; } +message_center::MessageCenterTray* +MessageCenterTrayBridge::GetMessageCenterTray() { + return tray_.get(); +} + void MessageCenterTrayBridge::UpdateStatusItem() { if (!status_item_view_) { status_item_view_.reset([[MCStatusItemView alloc] init]); diff --git a/chrome/browser/ui/views/message_center/web_notification_tray.cc b/chrome/browser/ui/views/message_center/web_notification_tray.cc index 2d2058a..b3faf1a 100644 --- a/chrome/browser/ui/views/message_center/web_notification_tray.cc +++ b/chrome/browser/ui/views/message_center/web_notification_tray.cc @@ -10,6 +10,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/status_icons/status_icon.h" #include "chrome/browser/status_icons/status_tray.h" +#include "content/public/browser/notification_service.h" #include "content/public/browser/user_metrics.h" #include "grit/chromium_strings.h" #include "grit/theme_resources.h" @@ -289,6 +290,10 @@ PositionInfo WebNotificationTray::GetPositionInfo() { return pos_info; } +MessageCenterTray* WebNotificationTray::GetMessageCenterTray() { + return message_center_tray_.get(); +} + void WebNotificationTray::CreateStatusIcon(const gfx::ImageSkia& image, const string16& tool_tip) { if (status_icon_) diff --git a/chrome/browser/ui/views/message_center/web_notification_tray.h b/chrome/browser/ui/views/message_center/web_notification_tray.h index 1bc6fa4..040f9a6 100644 --- a/chrome/browser/ui/views/message_center/web_notification_tray.h +++ b/chrome/browser/ui/views/message_center/web_notification_tray.h @@ -8,6 +8,8 @@ #include "base/memory/weak_ptr.h" #include "chrome/browser/status_icons/status_icon_observer.h" #include "chrome/browser/ui/views/message_center/message_center_widget_delegate.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" #include "ui/base/models/simple_menu_model.h" #include "ui/gfx/rect.h" #include "ui/message_center/message_center_tray.h" @@ -69,6 +71,7 @@ class WebNotificationTray : public message_center::MessageCenterTrayDelegate, // Gets the point where the status icon was clicked. gfx::Point mouse_click_point() { return mouse_click_point_; } + virtual MessageCenterTray* GetMessageCenterTray() OVERRIDE; private: FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); |