diff options
-rw-r--r-- | chrome/browser/extensions/api/notification/notification_api.cc | 60 | ||||
-rw-r--r-- | chrome/browser/extensions/api/notification/notification_apitest.cc | 42 | ||||
-rw-r--r-- | chrome/common/extensions/api/experimental_notification.idl | 49 | ||||
-rw-r--r-- | ui/message_center/base_format_view.cc | 156 | ||||
-rw-r--r-- | ui/message_center/base_format_view.h | 12 | ||||
-rw-r--r-- | ui/message_center/message_simple_view.cc | 15 | ||||
-rw-r--r-- | ui/message_center/message_view.cc | 11 | ||||
-rw-r--r-- | ui/message_center/message_view.h | 2 | ||||
-rw-r--r-- | ui/message_center/notification_list.cc | 48 | ||||
-rw-r--r-- | ui/message_center/notification_list.h | 14 | ||||
-rw-r--r-- | ui/notifications/notification_types.cc | 26 | ||||
-rw-r--r-- | ui/notifications/notification_types.h | 22 |
12 files changed, 103 insertions, 354 deletions
diff --git a/chrome/browser/extensions/api/notification/notification_api.cc b/chrome/browser/extensions/api/notification/notification_api.cc index 4d3e1d4..a96d5b0 100644 --- a/chrome/browser/extensions/api/notification/notification_api.cc +++ b/chrome/browser/extensions/api/notification/notification_api.cc @@ -93,50 +93,36 @@ bool NotificationShowFunction::RunImpl() { src_id_ = ExtractSrcId(options_dict.get()); event_notifier_ = CreateEventNotifier(src_id_); - ui::notifications::NotificationType type = - ui::notifications::StringToNotificationType(options->notification_type); GURL icon_url(UTF8ToUTF16(options->icon_url)); string16 title(UTF8ToUTF16(options->title)); string16 message(UTF8ToUTF16(options->message)); - scoped_ptr<DictionaryValue> optional_fields(new DictionaryValue()); - - if (options->message_intent.get()) - optional_fields->SetString(ui::notifications::kMessageIntentKey, - UTF8ToUTF16(*options->message_intent)); - if (options->priority.get()) - optional_fields->SetInteger(ui::notifications::kPriorityKey, - *options->priority); - if (options->timestamp.get()) - optional_fields->SetString(ui::notifications::kTimestampKey, - *options->timestamp); - if (options->second_icon_url.get()) - optional_fields->SetString(ui::notifications::kSecondIconUrlKey, - UTF8ToUTF16(*options->second_icon_url)); - if (options->unread_count.get()) - optional_fields->SetInteger(ui::notifications::kUnreadCountKey, - *options->unread_count); - if (options->button_one_title.get()) - optional_fields->SetString(ui::notifications::kButtonOneTitleKey, - UTF8ToUTF16(*options->button_one_title)); - if (options->button_one_intent.get()) - optional_fields->SetString(ui::notifications::kButtonOneIntentKey, - UTF8ToUTF16(*options->button_one_intent)); - if (options->button_two_title.get()) - optional_fields->SetString(ui::notifications::kButtonTwoTitleKey, - UTF8ToUTF16(*options->button_two_title)); - if (options->button_two_intent.get()) - optional_fields->SetString(ui::notifications::kButtonTwoIntentKey, - UTF8ToUTF16(*options->button_two_intent)); - if (options->expanded_message.get()) - optional_fields->SetString(ui::notifications::kExpandedMessageKey, - UTF8ToUTF16(*options->expanded_message)); - if (options->image_url.get()) - optional_fields->SetString(ui::notifications::kImageUrlKey, - UTF8ToUTF16(*options->image_url)); + // TEMP fields that are here to demonstrate usage of... fields. + // TODO(miket): replace with real fields from BaseFormatView. + string16 extra_field; + if (options->extra_field.get()) + extra_field = UTF8ToUTF16(*options->extra_field); + string16 second_extra_field; + if (options->second_extra_field.get()) + second_extra_field = UTF8ToUTF16(*options->second_extra_field); string16 replace_id(UTF8ToUTF16(options->replace_id)); + ui::notifications::NotificationType type; + scoped_ptr<DictionaryValue> optional_fields(new DictionaryValue()); + // TODO(miket): this is a lazy hacky way to distinguish the old and new + // notification types. Once we have something more than just "old" and "new," + // we'll probably want to pass the type all the way up from the JS, and then + // we won't need this hack at all. + if (extra_field.empty()) { + type = ui::notifications::NOTIFICATION_TYPE_SIMPLE; + } else { + type = ui::notifications::NOTIFICATION_TYPE_BASE_FORMAT; + optional_fields->SetString(ui::notifications::kExtraFieldKey, + extra_field); + optional_fields->SetString(ui::notifications::kSecondExtraFieldKey, + second_extra_field); + } Notification notification(type, icon_url, title, message, WebKit::WebTextDirectionDefault, string16(), replace_id, diff --git a/chrome/browser/extensions/api/notification/notification_apitest.cc b/chrome/browser/extensions/api/notification/notification_apitest.cc index b3ff3a2..d32f51c 100644 --- a/chrome/browser/extensions/api/notification/notification_apitest.cc +++ b/chrome/browser/extensions/api/notification/notification_apitest.cc @@ -23,7 +23,7 @@ class NotificationApiTest : public ExtensionApiTest { } // namespace -IN_PROC_BROWSER_TEST_F(NotificationApiTest, TestSimpleNotification) { +IN_PROC_BROWSER_TEST_F(NotificationApiTest, TestNormalNotification) { scoped_refptr<extensions::NotificationShowFunction> notification_show_function(new extensions::NotificationShowFunction()); scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); @@ -34,7 +34,6 @@ IN_PROC_BROWSER_TEST_F(NotificationApiTest, TestSimpleNotification) { scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( notification_show_function, "[{" - "\"notificationType\": \"simple\"," "\"iconUrl\": \"http://www.google.com/intl/en/chrome/assets/" "common/images/chrome_logo_2x.png\"," "\"title\": \"Attention!\"," @@ -44,43 +43,4 @@ IN_PROC_BROWSER_TEST_F(NotificationApiTest, TestSimpleNotification) { browser(), utils::NONE)); ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); - - // TODO(miket): confirm that the show succeeded. -} - -IN_PROC_BROWSER_TEST_F(NotificationApiTest, TestBaseFormatNotification) { - scoped_refptr<extensions::NotificationShowFunction> - notification_show_function(new extensions::NotificationShowFunction()); - scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); - - notification_show_function->set_extension(empty_extension.get()); - notification_show_function->set_has_callback(true); - - scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - notification_show_function, - "[{" - "\"notificationType\": \"base\"," - "\"iconUrl\": \"http://www.google.com/intl/en/chrome/assets/" - "common/images/chrome_logo_2x.png\"," - "\"title\": \"Attention!\"," - "\"message\": \"Check out Cirque du Soleil\"," - "\"messageIntent\": \"[pending]\"," - "\"priority\": 1," - "\"timestamp\": \"Tue, 15 Nov 1994 12:45:26 GMT\"," - "\"secondIconUrl\": \"http://www.google.com/logos/2012/" - "Day-Of-The-Dead-12-hp.jpg\"," - "\"unreadCount\": 42," - "\"buttonOneTitle\": \"Up\"," - "\"buttonOneIntent\": \"[pending]\"," - "\"buttonTwoTitle\": \"Down\"," - "\"buttonTwoIntent\": \"[pending]\"," - "\"expandedMessage\": \"This is a longer expanded message.\"," - "\"imageUrl\": \"http://www.google.com/logos/2012/election12-hp.jpg\"," - "\"replaceId\": \"12345678\"" - "}]", - browser(), utils::NONE)); - - ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); - - // TODO(miket): confirm that the show succeeded. } diff --git a/chrome/common/extensions/api/experimental_notification.idl b/chrome/common/extensions/api/experimental_notification.idl index 4184d8e..8164b91 100644 --- a/chrome/common/extensions/api/experimental_notification.idl +++ b/chrome/common/extensions/api/experimental_notification.idl @@ -4,56 +4,11 @@ [nodoc] namespace experimental.notification { dictionary ShowOptions { - // Which type of notification to display. - // - // simple: icon, title, message - // base: our MVP, with two buttons, expanded text, etc. TEMPORARY! - DOMString notificationType; - - // Sender's avatar, app icon, or a thumbnail for image notifications. DOMString iconUrl; - - // Title of the notification (e.g. sender name for email). DOMString title; - - // Main notification content. DOMString message; - - // What happens when the user clicks on the message. - // TODO(miket): this is imaginary. - DOMString? messageIntent; - - // Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero - // is default. - long? priority; - - // A timestamp associated with the notification. An example is - // "Tue, 15 Nov 1994 12:45:26 GMT". Note that RFC822 doesn't specify the - // timezone label "UTC." To specify UTC, use "GMT" instead. - DOMString? timestamp; - - // Smaller version of the icon. - DOMString? secondIconUrl; - - // A number, controlled entirely by the caller, that is intended to - // summarize the number of outstanding notifications. TODO(miket) what does - // that mean? - long? unreadCount; - - // Text and intent of the first button in the notification. - DOMString? buttonOneTitle; - DOMString? buttonOneIntent; - - // Text and intent of the second button in the notification. - DOMString? buttonTwoTitle; - DOMString? buttonTwoIntent; - - // Secondary notification content. - DOMString? expandedMessage; - - // Image thumbnail for image-type notifications - DOMString? imageUrl; - + DOMString? extraField; + DOMString? secondExtraField; DOMString replaceId; // Used for internal event routing. Do not set or rely on its value. diff --git a/ui/message_center/base_format_view.cc b/ui/message_center/base_format_view.cc index 6f1790e..f8cec95 100644 --- a/ui/message_center/base_format_view.cc +++ b/ui/message_center/base_format_view.cc @@ -4,11 +4,9 @@ #include "ui/message_center/base_format_view.h" -#include "base/i18n/time_formatting.h" #include "grit/ui_resources.h" #include "ui/base/resource/resource_bundle.h" #include "ui/views/controls/button/image_button.h" -#include "ui/views/controls/button/label_button.h" #include "ui/views/controls/image_view.h" #include "ui/views/controls/label.h" #include "ui/views/layout/grid_layout.h" @@ -18,13 +16,6 @@ namespace message_center { const SkColor kNotificationColor = SkColorSetRGB(0xfe, 0xfe, 0xfe); const SkColor kNotificationReadColor = SkColorSetRGB(0xfa, 0xfa, 0xfa); -const int kBaseFormatPrimaryIconWidth = 40; -const int kBaseFormatSecondaryIconWidth = 16; -const int kBaseFormatTimestampWidth = 60; -const int kBaseFormatButtonWidth = 60; -const int kBaseFormatPaddingBetweenItems = 10; -const int kBaseFormatOuterHorizontalPadding = 18; - BaseFormatView::BaseFormatView( NotificationList::Delegate* list_delegate, const NotificationList::Notification& notification) @@ -38,154 +29,91 @@ BaseFormatView::~BaseFormatView() { } void BaseFormatView::SetUpView() { - DCHECK(close_button_); - SkColor bg_color = notification_.is_read ? kNotificationReadColor : kNotificationColor; set_background(views::Background::CreateSolidBackground(bg_color)); - views::ImageView* icon = new views::ImageView; - icon->SetImageSize( - gfx::Size(kBaseFormatPrimaryIconWidth, kBaseFormatPrimaryIconWidth)); - icon->SetImage(notification_.image); - - views::ImageView* second_icon = new views::ImageView; - second_icon->SetImageSize( - gfx::Size(kBaseFormatSecondaryIconWidth, kBaseFormatSecondaryIconWidth)); - // TODO: set up second image - second_icon->SetImage(notification_.image); + icon_ = new views::ImageView; + icon_->SetImageSize( + gfx::Size(kWebNotificationIconSize, kWebNotificationIconSize)); + icon_->SetImage(notification_.image); views::Label* title = new views::Label(notification_.title); title->SetHorizontalAlignment(gfx::ALIGN_LEFT); title->SetFont(title->font().DeriveFont(0, gfx::Font::BOLD)); + views::Label* extra_field = new views::Label(notification_.extra_field); + extra_field->SetHorizontalAlignment(gfx::ALIGN_LEFT); + views::Label* second_extra_field = + new views::Label(notification_.second_extra_field); + second_extra_field->SetHorizontalAlignment(gfx::ALIGN_LEFT); + views::Label* message = new views::Label(notification_.message); message->SetHorizontalAlignment(gfx::ALIGN_LEFT); message->SetMultiLine(true); - message->SetElideBehavior(views::Label::ELIDE_AT_END); - - views::Label* timestamp = NULL; - if (notification_.timestamp != base::Time()) { - timestamp = new views::Label( - base::TimeFormatTimeOfDay(notification_.timestamp)); - timestamp->SetHorizontalAlignment(gfx::ALIGN_RIGHT); - } - - // TODO(miket): unreadCount - - views::LabelButton* button_one = NULL; - if (notification_.button_one_title.length() != 0) { - button_one = new views::LabelButton( - this, notification_.button_one_title); - button_one->SetHorizontalAlignment(gfx::ALIGN_CENTER); - button_one->SetNativeTheme(true); - } - views::LabelButton* button_two = NULL; - if (button_one && notification_.button_two_title.length() != 0) { - button_two = new views::LabelButton( - this, notification_.button_two_title); - button_two->SetHorizontalAlignment(gfx::ALIGN_CENTER); - button_two->SetNativeTheme(true); - } - - views::Label* expanded_message = new views::Label( - notification_.expanded_message); - expanded_message->SetHorizontalAlignment(gfx::ALIGN_LEFT); - expanded_message->SetMultiLine(true); - - // TODO(miket): Image thumbnail for image-type notifications (imageUrl) + + close_button_ = new views::ImageButton(this); + close_button_->SetImage( + views::CustomButton::BS_NORMAL, + ResourceBundle::GetSharedInstance().GetImageSkiaNamed( + IDR_MESSAGE_CLOSE)); + close_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, + views::ImageButton::ALIGN_MIDDLE); views::GridLayout* layout = new views::GridLayout(this); SetLayoutManager(layout); views::ColumnSet* columns = layout->AddColumnSet(0); - const int padding_width = kBaseFormatOuterHorizontalPadding / 2; + const int padding_width = kPaddingHorizontal / 2; columns->AddPaddingColumn(0, padding_width); - // Column 0: Notification Icon. + // Notification Icon. columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING, 0, /* resize percent */ views::GridLayout::FIXED, - kBaseFormatPrimaryIconWidth, kBaseFormatPrimaryIconWidth); - columns->AddPaddingColumn(0, kBaseFormatPaddingBetweenItems); + kWebNotificationIconSize, kWebNotificationIconSize); - // Column 1: Notification message text and first button. - columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, - 100, /* resize percent */ - views::GridLayout::USE_PREF, - kBaseFormatButtonWidth, kBaseFormatButtonWidth); - columns->AddPaddingColumn(0, kBaseFormatPaddingBetweenItems); + columns->AddPaddingColumn(0, padding_width); - // Column 2: Notification message text and second button. + // Notification message text. + const int message_width = kWebNotificationWidth - kWebNotificationIconSize - + kWebNotificationButtonWidth - (padding_width * 3); columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 100, /* resize percent */ - views::GridLayout::USE_PREF, - kBaseFormatButtonWidth, kBaseFormatButtonWidth); - columns->AddPaddingColumn(0, kBaseFormatPaddingBetweenItems); - - // Column 3: Notification message text and timestamp. - columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, - 0, /* resize percent */ views::GridLayout::FIXED, - kBaseFormatTimestampWidth, kBaseFormatTimestampWidth); - columns->AddPaddingColumn(0, kBaseFormatPaddingBetweenItems); + message_width, message_width); - // Column 4: Close button and secondary icon. - columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::BASELINE, + columns->AddPaddingColumn(0, padding_width); + + // Close button. + columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING, 0, /* resize percent */ views::GridLayout::FIXED, - kBaseFormatSecondaryIconWidth, - kBaseFormatSecondaryIconWidth); - columns->AddPaddingColumn(0, kBaseFormatPaddingBetweenItems); + kWebNotificationButtonWidth, + kWebNotificationButtonWidth); - // Lay out rows. - // Row 0: Just timestamp and close box. - layout->StartRow(0, 0); - layout->SkipColumns(5); - if (timestamp) - layout->AddView(timestamp, 1, 1); - else - layout->SkipColumns(2); - layout->AddView(close_button_, 1, 1); + // Layout rows + layout->AddPaddingRow(0, kPaddingBetweenItems); - // Row 1: Big icon, title. layout->StartRow(0, 0); - layout->AddView(icon, 1, 3); - layout->AddView(title, 6, 1); + layout->AddView(icon_, 1, 2); + layout->AddView(title, 1, 1); + layout->AddView(close_button_, 1, 1); - // Row 2: Continuation of big icon, message. layout->StartRow(0, 0); - layout->SkipColumns(1); - layout->AddView(message, 6, 1); - layout->AddPaddingRow(0, kBaseFormatPaddingBetweenItems); + layout->SkipColumns(2); + layout->AddView(message, 1, 1); - // Row 3: Continuation of big icon, two buttons, secondary icon. layout->StartRow(0,0); layout->SkipColumns(1); - if (button_one) { - layout->AddView(button_one, 1, 1); - layout->AddView(button_two, 1, 1); - } else { - layout->SkipColumns(3); // two buttons plus padding - } - layout->SkipColumns(1); - layout->AddView(second_icon, 1, 1); - layout->AddPaddingRow(0, kBaseFormatPaddingBetweenItems); + layout->AddView(extra_field, 1, 1); - // Row 4: Secondary message. layout->StartRow(0,0); layout->SkipColumns(1); - layout->AddView(expanded_message, 3, 1); - - // A final bit of padding to make it look nice. - layout->AddPaddingRow(0, kBaseFormatPaddingBetweenItems); -} + layout->AddView(second_extra_field, 1, 1); -void BaseFormatView::ButtonPressed(views::Button* sender, - const ui::Event& event) { - // TODO(miket): propagate to caller. - MessageView::ButtonPressed(sender, event); + layout->AddPaddingRow(0, kPaddingBetweenItems); } } // namespace message_center diff --git a/ui/message_center/base_format_view.h b/ui/message_center/base_format_view.h index 131521a..8f35df0 100644 --- a/ui/message_center/base_format_view.h +++ b/ui/message_center/base_format_view.h @@ -8,13 +8,12 @@ #include "ui/message_center/message_view.h" #include "ui/message_center/notification_list.h" -namespace views { -class ImageView; -} - namespace message_center { -// A comprehensive message view. +// An early version of a more comprehensive message view. +// +// TODO: add remaining fields from prototype specification, and bring cosmetics +// to an acceptable level of polish. class BaseFormatView : public MessageView { public: BaseFormatView(NotificationList::Delegate* list_delegate, @@ -24,9 +23,6 @@ class BaseFormatView : public MessageView { // MessageView virtual void SetUpView() OVERRIDE; - // views::ButtonListener - virtual void ButtonPressed(views::Button* sender, const ui::Event& event); - protected: BaseFormatView(); diff --git a/ui/message_center/message_simple_view.cc b/ui/message_center/message_simple_view.cc index bc4f6a3..5e127d4 100644 --- a/ui/message_center/message_simple_view.cc +++ b/ui/message_center/message_simple_view.cc @@ -31,10 +31,10 @@ void MessageSimpleView::SetUpView() { kNotificationReadColor : kNotificationColor; set_background(views::Background::CreateSolidBackground(bg_color)); - views::ImageView* icon = new views::ImageView; - icon->SetImageSize( + icon_ = new views::ImageView; + icon_->SetImageSize( gfx::Size(kWebNotificationIconSize, kWebNotificationIconSize)); - icon->SetImage(notification_.image); + icon_->SetImage(notification_.image); views::Label* title = new views::Label(notification_.title); title->SetHorizontalAlignment(gfx::ALIGN_LEFT); @@ -43,6 +43,13 @@ void MessageSimpleView::SetUpView() { message->SetHorizontalAlignment(gfx::ALIGN_LEFT); message->SetMultiLine(true); + close_button_ = new views::ImageButton(this); + close_button_->SetImage( + views::CustomButton::BS_NORMAL, + ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_MESSAGE_CLOSE)); + close_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, + views::ImageButton::ALIGN_MIDDLE); + views::GridLayout* layout = new views::GridLayout(this); SetLayoutManager(layout); @@ -81,7 +88,7 @@ void MessageSimpleView::SetUpView() { layout->AddPaddingRow(0, kPaddingBetweenItems); layout->StartRow(0, 0); - layout->AddView(icon, 1, 2); + layout->AddView(icon_, 1, 2); layout->AddView(title, 1, 1); layout->AddView(close_button_, 1, 1); diff --git a/ui/message_center/message_view.cc b/ui/message_center/message_view.cc index bf48a51..931fc27 100644 --- a/ui/message_center/message_view.cc +++ b/ui/message_center/message_view.cc @@ -8,8 +8,6 @@ #include "grit/ui_strings.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/simple_menu_model.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/views/controls/button/image_button.h" #include "ui/views/controls/menu/menu_model_adapter.h" #include "ui/views/controls/menu/menu_runner.h" @@ -109,14 +107,9 @@ MessageView::MessageView( const NotificationList::Notification& notification) : list_delegate_(list_delegate), notification_(notification), + icon_(NULL), close_button_(NULL), scroller_(NULL) { - close_button_ = new views::ImageButton(this); - close_button_->SetImage( - views::CustomButton::BS_NORMAL, - ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_MESSAGE_CLOSE)); - close_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, - views::ImageButton::ALIGN_MIDDLE); } MessageView::MessageView() { @@ -159,7 +152,7 @@ ui::EventResult MessageView::OnGestureEvent(ui::GestureEvent* event) { } void MessageView::ButtonPressed(views::Button* sender, - const ui::Event& event) { + const ui::Event& event) { if (sender == close_button_) list_delegate_->SendRemoveNotification(notification_.id); } diff --git a/ui/message_center/message_view.h b/ui/message_center/message_view.h index e59484d..c2a7555 100644 --- a/ui/message_center/message_view.h +++ b/ui/message_center/message_view.h @@ -12,6 +12,7 @@ namespace views { class ImageButton; +class ImageView; class ScrollView; } @@ -60,6 +61,7 @@ class MessageView : public views::SlideOutView, NotificationList::Delegate* list_delegate_; NotificationList::Notification notification_; + views::ImageView* icon_; views::ImageButton* close_button_; views::ScrollView* scroller_; diff --git a/ui/message_center/notification_list.cc b/ui/message_center/notification_list.cc index 3ed47b6..19747ba 100644 --- a/ui/message_center/notification_list.cc +++ b/ui/message_center/notification_list.cc @@ -4,7 +4,6 @@ #include "ui/message_center/notification_list.h" -#include "base/time.h" #include "base/values.h" namespace message_center { @@ -59,11 +58,6 @@ void NotificationList::AddNotification( notification.message = message; notification.display_source = display_source; notification.extension_id = extension_id; - - // Initialize primitive fields before unpacking optional fields. - // timestamp initializes to default NULL time. - notification.priority = 0; - UnpackOptionalFields(optional_fields, notification); PushNotification(notification); @@ -74,42 +68,12 @@ void NotificationList::UnpackOptionalFields( if (!optional_fields) return; - if (optional_fields->HasKey(ui::notifications::kMessageIntentKey)) - optional_fields->GetString(ui::notifications::kMessageIntentKey, - ¬ification.message_intent); - if (optional_fields->HasKey(ui::notifications::kPriorityKey)) - optional_fields->GetInteger(ui::notifications::kPriorityKey, - ¬ification.priority); - if (optional_fields->HasKey(ui::notifications::kTimestampKey)) { - std::string time_string; - optional_fields->GetString(ui::notifications::kTimestampKey, &time_string); - base::Time::FromString(time_string.c_str(), ¬ification.timestamp); - } - // TODO - // if (optional_fields->HasKey(ui::notifications::kSecondIconUrlKey)) - // optional_fields->GetString(ui::notifications::kSecondIconUrlKey, - // ¬ification.second_icon_url); - if (optional_fields->HasKey(ui::notifications::kUnreadCountKey)) - optional_fields->GetInteger(ui::notifications::kUnreadCountKey, - ¬ification.unread_count); - if (optional_fields->HasKey(ui::notifications::kButtonOneTitleKey)) - optional_fields->GetString(ui::notifications::kButtonOneTitleKey, - ¬ification.button_one_title); - if (optional_fields->HasKey(ui::notifications::kButtonOneIntentKey)) - optional_fields->GetString(ui::notifications::kButtonOneIntentKey, - ¬ification.button_one_intent); - if (optional_fields->HasKey(ui::notifications::kButtonTwoTitleKey)) - optional_fields->GetString(ui::notifications::kButtonTwoTitleKey, - ¬ification.button_two_title); - if (optional_fields->HasKey(ui::notifications::kButtonTwoIntentKey)) - optional_fields->GetString(ui::notifications::kButtonTwoIntentKey, - ¬ification.button_two_intent); - if (optional_fields->HasKey(ui::notifications::kExpandedMessageKey)) - optional_fields->GetString(ui::notifications::kExpandedMessageKey, - ¬ification.expanded_message); - if (optional_fields->HasKey(ui::notifications::kImageUrlKey)) - optional_fields->GetString(ui::notifications::kImageUrlKey, - ¬ification.image_url); + if (optional_fields->HasKey(ui::notifications::kExtraFieldKey)) + optional_fields->GetString(ui::notifications::kExtraFieldKey, + ¬ification.extra_field); + if (optional_fields->HasKey(ui::notifications::kSecondExtraFieldKey)) + optional_fields->GetString(ui::notifications::kSecondExtraFieldKey, + ¬ification.second_extra_field); } void NotificationList::UpdateNotificationMessage(const std::string& old_id, diff --git a/ui/message_center/notification_list.h b/ui/message_center/notification_list.h index 4a66660..f8ec418 100644 --- a/ui/message_center/notification_list.h +++ b/ui/message_center/notification_list.h @@ -9,7 +9,6 @@ #include <string> #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" @@ -35,17 +34,8 @@ class MESSAGE_CENTER_EXPORT NotificationList { std::string extension_id; // Begin unpacked values from optional_fields - string16 message_intent; - int priority; - base::Time timestamp; - gfx::ImageSkia second_image; - int unread_count; - string16 button_one_title; - string16 button_one_intent; - string16 button_two_title; - string16 button_two_intent; - string16 expanded_message; - string16 image_url; + string16 extra_field; + string16 second_extra_field; // End unpacked values gfx::ImageSkia image; diff --git a/ui/notifications/notification_types.cc b/ui/notifications/notification_types.cc index 9ec43c8..b4f0c83 100644 --- a/ui/notifications/notification_types.cc +++ b/ui/notifications/notification_types.cc @@ -8,30 +8,8 @@ namespace ui { namespace notifications { -const char kMessageIntentKey[] = "message_intent"; -const char kPriorityKey[] = "priority"; -const char kTimestampKey[] = "timestamp"; -const char kSecondIconUrlKey[] = "second_icon_url"; -const char kUnreadCountKey[] = "unread_count"; -const char kButtonOneTitleKey[] = "button_one_title"; -const char kButtonOneIntentKey[] = "button_one_intent"; -const char kButtonTwoTitleKey[] = "button_two_title"; -const char kButtonTwoIntentKey[] = "button_two_intent"; -const char kExpandedMessageKey[] = "expanded_message"; -const char kImageUrlKey[] = "image_url"; - -const char kSimpleType[] = "simple"; -const char kBaseFormatType[] = "base"; - -NotificationType StringToNotificationType(std::string& string_type) { - if (string_type == kSimpleType) - return NOTIFICATION_TYPE_SIMPLE; - if (string_type == kBaseFormatType) - return NOTIFICATION_TYPE_BASE_FORMAT; - - // In case of unrecognized string, fall back to most common type. - return NOTIFICATION_TYPE_SIMPLE; -} +const char kExtraFieldKey[] = "extra_field"; +const char kSecondExtraFieldKey[] = "second_extra_field"; } // namespace notifications diff --git a/ui/notifications/notification_types.h b/ui/notifications/notification_types.h index 049628f..d1c9725 100644 --- a/ui/notifications/notification_types.h +++ b/ui/notifications/notification_types.h @@ -5,34 +5,24 @@ #ifndef UI_NOTIFICATIONS_NOTIFICATION_TYPES_H_ #define UI_NOTIFICATIONS_NOTIFICATION_TYPES_H_ -#include <string> - #include "ui/base/ui_export.h" namespace ui { namespace notifications { -// Keys for optional fields in Notification. -UI_EXPORT extern const char kMessageIntentKey[]; -UI_EXPORT extern const char kPriorityKey[]; -UI_EXPORT extern const char kTimestampKey[]; -UI_EXPORT extern const char kSecondIconUrlKey[]; -UI_EXPORT extern const char kUnreadCountKey[]; -UI_EXPORT extern const char kButtonOneTitleKey[]; -UI_EXPORT extern const char kButtonOneIntentKey[]; -UI_EXPORT extern const char kButtonTwoTitleKey[]; -UI_EXPORT extern const char kButtonTwoIntentKey[]; -UI_EXPORT extern const char kExpandedMessageKey[]; -UI_EXPORT extern const char kImageUrlKey[]; +// TODO(miket): these are temporary field names that will be replaced very +// shortly with real names. See +// chrome/browser/extensions/api/notification/notification_api.cc for more +// context. +UI_EXPORT extern const char kExtraFieldKey[]; +UI_EXPORT extern const char kSecondExtraFieldKey[]; enum NotificationType { NOTIFICATION_TYPE_SIMPLE, NOTIFICATION_TYPE_BASE_FORMAT, }; -UI_EXPORT NotificationType StringToNotificationType(std::string& string_type); - } // namespace notifications } // namespace ui |