Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Unified Diff: ui/message_center/views/message_popup_collection.h

Issue 369573004: Separate the logic of popup alignment and workarea handling as delegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/message_center/views/message_popup_collection.h
diff --git a/ui/message_center/views/message_popup_collection.h b/ui/message_center/views/message_popup_collection.h
index 955af32ddb5e2a25363f4de44b3829b2d7ce7592..8d6d644c68a262a800e538ba96a514024d044f79 100644
--- a/ui/message_center/views/message_popup_collection.h
+++ b/ui/message_center/views/message_popup_collection.h
@@ -12,8 +12,6 @@
#include "base/gtest_prod_util.h"
#include "base/memory/weak_ptr.h"
#include "base/timer/timer.h"
-#include "ui/gfx/display.h"
-#include "ui/gfx/display_observer.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/rect.h"
#include "ui/message_center/message_center_export.h"
@@ -30,12 +28,8 @@ namespace views {
class Widget;
}
-namespace ash {
-class WebNotificationTrayTest;
-FORWARD_DECLARE_TEST(WebNotificationTrayTest, ManyPopupNotifications);
-}
-
namespace gfx {
+class Display;
class Screen;
}
@@ -47,13 +41,7 @@ class MessagePopupCollectionTest;
class MessageCenter;
class MessageCenterTray;
class MessageViewContextMenuController;
-
-enum PopupAlignment {
- POPUP_ALIGNMENT_TOP = 1 << 0,
- POPUP_ALIGNMENT_LEFT = 1 << 1,
- POPUP_ALIGNMENT_BOTTOM = 1 << 2,
- POPUP_ALIGNMENT_RIGHT = 1 << 3,
-};
+class PopupAlignmentDelegate;
// Container for popup toasts. Because each toast is a frameless window rather
// than a view in a bubble, now the container just manages all of those toasts.
@@ -62,17 +50,15 @@ enum PopupAlignment {
// be slightly different.
class MESSAGE_CENTER_EXPORT MessagePopupCollection
: public MessageCenterController,
- public MessageCenterObserver,
- public gfx::DisplayObserver {
+ public MessageCenterObserver {
public:
// |parent| specifies the parent widget of the toast windows. The default
// parent will be used for NULL. Usually each icon is spacing against its
- // predecessor. If |first_item_has_no_margin| is set however the first item
- // does not space against the tray.
+ // predecessor.
MessagePopupCollection(gfx::NativeView parent,
MessageCenter* message_center,
MessageCenterTray* tray,
- bool first_item_has_no_margin);
+ PopupAlignmentDelegate* alignment_delegate);
virtual ~MessagePopupCollection();
// Overridden from MessageCenterController:
@@ -109,30 +95,14 @@ class MESSAGE_CENTER_EXPORT MessagePopupCollection
// toast is irrevocably closed (such as within RemoveToast).
void ForgetToast(ToastContentsView* toast);
- // Updates |work_area_| and re-calculates the alignment of notification toasts
- // rearranging them if necessary.
- // This is separated from methods from OnDisplayMetricsChanged(), since
- // sometimes the display info has to be specified directly. One example is
- // shelf's auto-hide change. When the shelf in ChromeOS is temporarily shown
- // from auto hide status, it doesn't change the display's work area but the
- // actual work area for toasts should be resized.
- void SetDisplayInfo(const gfx::Rect& work_area,
- const gfx::Rect& screen_bounds);
-
- // Overridden from gfx::DislayObserver:
- virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE;
- virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE;
- virtual void OnDisplayMetricsChanged(const gfx::Display& display,
- uint32_t metrics) OVERRIDE;
+ // Called when the display bounds has been changed. Used in Windows only.
+ void OnDisplayMetricsChanged(const gfx::Display& display);
// Used by ToastContentsView to locate itself.
gfx::NativeView parent() const { return parent_; }
private:
- FRIEND_TEST_ALL_PREFIXES(ash::WebNotificationTrayTest,
- ManyPopupNotifications);
friend class test::MessagePopupCollectionTest;
- friend class ash::WebNotificationTrayTest;
typedef std::list<ToastContentsView*> Toasts;
// Iterates toasts and starts closing them.
@@ -141,9 +111,6 @@ class MESSAGE_CENTER_EXPORT MessagePopupCollection
// Called by ToastContentsView when its window is closed.
void RemoveToast(ToastContentsView* toast, bool mark_as_shown);
- // Returns the x-origin for the given toast bounds in the current work area.
- int GetToastOriginX(const gfx::Rect& toast_bounds) const;
-
// Creates new widgets for new toast notifications, and updates |toasts_| and
// |widgets_| correctly.
void UpdateWidgets();
@@ -156,8 +123,6 @@ class MESSAGE_CENTER_EXPORT MessagePopupCollection
// See crbug.com/224089
void RepositionWidgetsWithTarget();
- void ComputePopupAlignment(gfx::Rect work_area, gfx::Rect screen_bounds);
-
// The base line is an (imaginary) line that would touch the bottom of the
// next created notification if bottom-aligned or its top if top-aligned.
int GetBaseLine(ToastContentsView* last_toast) const;
@@ -187,13 +152,8 @@ class MESSAGE_CENTER_EXPORT MessagePopupCollection
MessageCenter* message_center_;
MessageCenterTray* tray_;
Toasts toasts_;
- gfx::Rect work_area_;
- int64 display_id_;
- gfx::Screen* screen_;
- // Specifies which corner of the screen popups should show up. This should
- // ideally be the same corner the notification area (systray) is at.
- PopupAlignment alignment_;
+ PopupAlignmentDelegate* alignment_delegate_;
int defer_counter_;
@@ -215,9 +175,6 @@ class MESSAGE_CENTER_EXPORT MessagePopupCollection
// Weak, only exists temporarily in tests.
scoped_ptr<base::RunLoop> run_loop_for_test_;
- // True if the first item should not have spacing against the tray.
- bool first_item_has_no_margin_;
-
scoped_ptr<MessageViewContextMenuController> context_menu_controller_;
// Gives out weak pointers to toast contents views which have an unrelated
« no previous file with comments | « ui/message_center/views/desktop_popup_alignment_delegate.cc ('k') | ui/message_center/views/message_popup_collection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698