diff options
author | dimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-06 07:01:48 +0000 |
---|---|---|
committer | dimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-06 07:01:48 +0000 |
commit | 07e77037384e1895ca6356ea495098889923a1b9 (patch) | |
tree | 77db4d3770292813e671e482a0cc6c0a189f1063 /ui/message_center | |
parent | e71ae09e5d39a3d7140fd93544a6c62e6c3e4d0b (diff) | |
download | chromium_src-07e77037384e1895ca6356ea495098889923a1b9.zip chromium_src-07e77037384e1895ca6356ea495098889923a1b9.tar.gz chromium_src-07e77037384e1895ca6356ea495098889923a1b9.tar.bz2 |
Notification refactor - step 1 - move message_center::Notification into its own file.
No code changes, simple move. See the bug for all steps of this refactor.
BUG=174164
Review URL: https://chromiumcodereview.appspot.com/12178031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180912 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/message_center')
-rw-r--r-- | ui/message_center/message_center.gyp | 2 | ||||
-rw-r--r-- | ui/message_center/message_popup_bubble.cc | 6 | ||||
-rw-r--r-- | ui/message_center/message_simple_view.cc | 4 | ||||
-rw-r--r-- | ui/message_center/message_simple_view.h | 4 | ||||
-rw-r--r-- | ui/message_center/message_view.cc | 6 | ||||
-rw-r--r-- | ui/message_center/message_view.h | 7 | ||||
-rw-r--r-- | ui/message_center/notification.cc | 22 | ||||
-rw-r--r-- | ui/message_center/notification.h | 56 | ||||
-rw-r--r-- | ui/message_center/notification_list.cc | 8 | ||||
-rw-r--r-- | ui/message_center/notification_list.h | 38 | ||||
-rw-r--r-- | ui/message_center/notification_view.cc | 9 | ||||
-rw-r--r-- | ui/message_center/notification_view.h | 4 |
12 files changed, 104 insertions, 62 deletions
diff --git a/ui/message_center/message_center.gyp b/ui/message_center/message_center.gyp index ba80c06..0f75450 100644 --- a/ui/message_center/message_center.gyp +++ b/ui/message_center/message_center.gyp @@ -47,6 +47,8 @@ 'message_simple_view.h', 'message_view.cc', 'message_view.h', + 'notification.cc', + 'notification.h', 'notification_list.cc', 'notification_list.h', 'notification_view.cc', diff --git a/ui/message_center/message_popup_bubble.cc b/ui/message_center/message_popup_bubble.cc index 0e998cf..3b27a4a 100644 --- a/ui/message_center/message_popup_bubble.cc +++ b/ui/message_center/message_popup_bubble.cc @@ -7,6 +7,7 @@ #include "base/bind.h" #include "base/stl_util.h" #include "ui/message_center/message_view.h" +#include "ui/message_center/notification.h" #include "ui/message_center/notification_view.h" #include "ui/notifications/notification_types.h" #include "ui/views/bubble/tray_bubble_view.h" @@ -78,8 +79,7 @@ void PopupBubbleContentsView::Update( // The timer to call OnAutoClose for |notification|. class MessagePopupBubble::AutocloseTimer { public: - AutocloseTimer(const NotificationList::Notification& notification, - MessagePopupBubble* bubble); + AutocloseTimer(const Notification& notification, MessagePopupBubble* bubble); void Start(); @@ -96,7 +96,7 @@ class MessagePopupBubble::AutocloseTimer { }; MessagePopupBubble::AutocloseTimer::AutocloseTimer( - const NotificationList::Notification& notification, + const Notification& notification, MessagePopupBubble* bubble) : id_(notification.id), bubble_(bubble) { diff --git a/ui/message_center/message_simple_view.cc b/ui/message_center/message_simple_view.cc index 80ff152..5c7c96f 100644 --- a/ui/message_center/message_simple_view.cc +++ b/ui/message_center/message_simple_view.cc @@ -6,6 +6,8 @@ #include "grit/ui_resources.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/message_center/notification.h" +#include "ui/message_center/notification_list.h" #include "ui/views/controls/button/image_button.h" #include "ui/views/controls/image_view.h" #include "ui/views/controls/label.h" @@ -19,7 +21,7 @@ const SkColor kNotificationReadColor = SkColorSetRGB(0xfa, 0xfa, 0xfa); MessageSimpleView::MessageSimpleView( NotificationList::Delegate* list_delegate, - const NotificationList::Notification& notification) + const Notification& notification) : MessageView(list_delegate, notification) { views::ImageButton* close = new views::ImageButton(this); close->SetImage( diff --git a/ui/message_center/message_simple_view.h b/ui/message_center/message_simple_view.h index 08ba052..bbd12f9 100644 --- a/ui/message_center/message_simple_view.h +++ b/ui/message_center/message_simple_view.h @@ -10,11 +10,13 @@ namespace message_center { +struct Notification; + // A simple view for a notification entry (icon + message + buttons). class MessageSimpleView : public MessageView { public: MessageSimpleView(NotificationList::Delegate* list_delegate, - const NotificationList::Notification& notification); + const Notification& notification); virtual ~MessageSimpleView(); // Overridden from MessageView: diff --git a/ui/message_center/message_view.cc b/ui/message_center/message_view.cc index 08837f9..27535b7 100644 --- a/ui/message_center/message_view.cc +++ b/ui/message_center/message_view.cc @@ -144,7 +144,7 @@ class WebNotificationMenuModel : public ui::SimpleMenuModel, public ui::SimpleMenuModel::Delegate { public: WebNotificationMenuModel(NotificationList::Delegate* list_delegate, - const NotificationList::Notification& notification) + const Notification& notification) : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), list_delegate_(list_delegate), notification_(notification) { @@ -215,14 +215,14 @@ class WebNotificationMenuModel : public ui::SimpleMenuModel, private: NotificationList::Delegate* list_delegate_; - NotificationList::Notification notification_; + Notification notification_; DISALLOW_COPY_AND_ASSIGN(WebNotificationMenuModel); }; MessageView::MessageView( NotificationList::Delegate* list_delegate, - const NotificationList::Notification& notification) + const Notification& notification) : list_delegate_(list_delegate), notification_(notification), scroller_(NULL) { diff --git a/ui/message_center/message_view.h b/ui/message_center/message_view.h index 5a782e5..be36eb4 100644 --- a/ui/message_center/message_view.h +++ b/ui/message_center/message_view.h @@ -5,6 +5,7 @@ #ifndef UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ #define UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ +#include "ui/message_center/notification.h" #include "ui/message_center/notification_list.h" #include "ui/views/controls/button/button.h" #include "ui/views/controls/slide_out_view.h" @@ -29,7 +30,7 @@ class MessageView : public views::SlideOutView, public views::ButtonListener { public: MessageView(NotificationList::Delegate* list_delegate, - const NotificationList::Notification& notification); + const Notification& notification); virtual ~MessageView(); @@ -59,13 +60,13 @@ class MessageView : public views::SlideOutView, virtual void OnSlideOut() OVERRIDE; NotificationList::Delegate* list_delegate() { return list_delegate_; } - NotificationList::Notification& notification() { return notification_; } + Notification& notification() { return notification_; } views::ImageButton* close_button() { return close_button_.get(); } views::ScrollView* scroller() { return scroller_; } private: NotificationList::Delegate* list_delegate_; - NotificationList::Notification notification_; + Notification notification_; scoped_ptr<views::ImageButton> close_button_; views::ScrollView* scroller_; diff --git a/ui/message_center/notification.cc b/ui/message_center/notification.cc new file mode 100644 index 0000000..c52cb95 --- /dev/null +++ b/ui/message_center/notification.cc @@ -0,0 +1,22 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/message_center/notification.h" + +namespace message_center { + +NotificationItem::NotificationItem(string16 title, string16 message) + : title(title), + message(message) { +} + +Notification::Notification() + : is_read(false), + shown_as_popup(false) { +} + +Notification::~Notification() { +} + +} // namespace message_center diff --git a/ui/message_center/notification.h b/ui/message_center/notification.h new file mode 100644 index 0000000..7c27d4d --- /dev/null +++ b/ui/message_center/notification.h @@ -0,0 +1,56 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_MESSAGE_CENTER_NOTIFICATION_H_ +#define UI_MESSAGE_CENTER_NOTIFICATION_H_ + +#include <vector> + +#include "base/string16.h" +#include "base/time.h" +#include "ui/gfx/image/image_skia.h" +#include "ui/message_center/message_center_export.h" +#include "ui/notifications/notification_types.h" + +namespace message_center { + +struct MESSAGE_CENTER_EXPORT NotificationItem { + string16 title; + string16 message; + + NotificationItem(string16 title, string16 message); +}; + +struct MESSAGE_CENTER_EXPORT Notification { + Notification(); + virtual ~Notification(); + + ui::notifications::NotificationType type; + std::string id; + string16 title; + string16 message; + string16 display_source; + std::string extension_id; + + // Begin unpacked values from optional_fields + int priority; + base::Time timestamp; + int unread_count; + std::vector<string16> button_titles; + string16 expanded_message; + std::vector<NotificationItem> items; + // End unpacked values + + // Images fetched asynchronously + gfx::ImageSkia primary_icon; + gfx::ImageSkia image; + std::vector<gfx::ImageSkia> button_icons; + + bool is_read; // True if this has been seen in the message center + bool shown_as_popup; // True if this has been shown as a popup notification +}; + +} // namespace message_center + +#endif // UI_MESSAGE_CENTER_NOTIFICATION_H_ diff --git a/ui/message_center/notification_list.cc b/ui/message_center/notification_list.cc index 2d8993f..322a9e8 100644 --- a/ui/message_center/notification_list.cc +++ b/ui/message_center/notification_list.cc @@ -8,19 +8,13 @@ #include "base/logging.h" #include "base/time.h" #include "base/values.h" +#include "ui/message_center/notification.h" namespace message_center { const size_t NotificationList::kMaxVisibleMessageCenterNotifications = 100; const size_t NotificationList::kMaxVisiblePopupNotifications = 2; -NotificationList::Notification::Notification() : is_read(false), - shown_as_popup(false) { -} - -NotificationList::Notification::~Notification() { -} - NotificationList::NotificationList(Delegate* delegate) : delegate_(delegate), message_center_visible_(false), diff --git a/ui/message_center/notification_list.h b/ui/message_center/notification_list.h index cb6b990..ec8b4db 100644 --- a/ui/message_center/notification_list.h +++ b/ui/message_center/notification_list.h @@ -15,6 +15,7 @@ #include "ui/gfx/image/image_skia.h" #include "ui/gfx/native_widget_types.h" #include "ui/message_center/message_center_export.h" +#include "ui/message_center/notification.h" #include "ui/notifications/notification_types.h" namespace base { @@ -26,43 +27,6 @@ namespace message_center { // A helper class to manage the list of notifications. class MESSAGE_CENTER_EXPORT NotificationList { public: - struct MESSAGE_CENTER_EXPORT NotificationItem { - string16 title; - string16 message; - NotificationItem(string16 title, string16 message) - : title(title), - message(message) {} - }; - - struct MESSAGE_CENTER_EXPORT Notification { - Notification(); - virtual ~Notification(); - - ui::notifications::NotificationType type; - std::string id; - string16 title; - string16 message; - string16 display_source; - std::string extension_id; - - // Begin unpacked values from optional_fields - int priority; - base::Time timestamp; - int unread_count; - std::vector<string16> button_titles; - string16 expanded_message; - std::vector<NotificationItem> items; - // End unpacked values - - // Images fetched asynchronously - gfx::ImageSkia primary_icon; - gfx::ImageSkia image; - std::vector<gfx::ImageSkia> button_icons; - - bool is_read; // True if this has been seen in the message center - bool shown_as_popup; // True if this has been shown as a popup notification - }; - typedef std::list<Notification> Notifications; class MESSAGE_CENTER_EXPORT Delegate { diff --git a/ui/message_center/notification_view.cc b/ui/message_center/notification_view.cc index 2342206..f38713e 100644 --- a/ui/message_center/notification_view.cc +++ b/ui/message_center/notification_view.cc @@ -61,15 +61,14 @@ views::Background* MakeBackground(SkColor color) { // message next to each other within a single column. class ItemView : public views::View { public: - ItemView(const message_center::NotificationList::NotificationItem& item); + ItemView(const message_center::NotificationItem& item); virtual ~ItemView(); private: DISALLOW_COPY_AND_ASSIGN(ItemView); }; -ItemView::ItemView( - const message_center::NotificationList::NotificationItem& item) { +ItemView::ItemView(const message_center::NotificationItem& item) { SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, kItemTitleToMessagePadding)); @@ -195,7 +194,7 @@ namespace message_center { // static MessageView* NotificationView::ViewForNotification( - const NotificationList::Notification& notification, + const Notification& notification, NotificationList::Delegate* list_delegate) { // For the time being, use MessageSimpleView for simple notifications unless // one of the use-the-new-style flags are set. This preserves the appearance @@ -231,7 +230,7 @@ MessageView* NotificationView::ViewForNotification( NotificationView::NotificationView( NotificationList::Delegate* list_delegate, - const NotificationList::Notification& notification) + const Notification& notification) : MessageView(list_delegate, notification) { } diff --git a/ui/message_center/notification_view.h b/ui/message_center/notification_view.h index b8041f9..1b9b630 100644 --- a/ui/message_center/notification_view.h +++ b/ui/message_center/notification_view.h @@ -20,11 +20,11 @@ class NotificationView : public MessageView { // always NotificationView instances but in the future may be instances of // other classes, with the class depending on the notification type. static MessageView* ViewForNotification( - const NotificationList::Notification& notification, + const Notification& notification, NotificationList::Delegate* list_delegate); NotificationView(NotificationList::Delegate* list_delegate, - const NotificationList::Notification& notification); + const Notification& notification); virtual ~NotificationView(); // Overridden from View. |