summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 13:07:11 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 13:07:11 +0000
commite77cfe45dc7dae8d35f9d1de9a4a27df547a368f (patch)
tree2ce650c3bb8b52c484e0903e0c33b02ced018382 /chrome
parent5288b8ea4bdac51d7bc4298af6cb7e1d27e924aa (diff)
downloadchromium_src-e77cfe45dc7dae8d35f9d1de9a4a27df547a368f.zip
chromium_src-e77cfe45dc7dae8d35f9d1de9a4a27df547a368f.tar.gz
chromium_src-e77cfe45dc7dae8d35f9d1de9a4a27df547a368f.tar.bz2
Revert 167589 - Continuing TODO items from a previous CL, remove the "extra_field" and "second_extra_field" keys from the API and replace with real keys from the Base Format View spec. Implement a rough layout that resembles the expanded mode of the view.
Breaks win_aura, I guess you need to add a dependency on base.gyp:base_i18n Outstanding items: - As stated above, the layout is still ugly. - We don't gracefully handle empty buttons. We don't crash, either, but it looks even uglier when the buttons are missing. - The buttons don't do anything when the user clicks on them. - The second icon is just a redraw of the first. - The timestamp is hardcoded to "10:43 AM" for layout purposes. I need to do more research on the appropriate date-formatting facilities available to us, and from that back out the timestamp field format in the API itself. Review URL: https://chromiumcodereview.appspot.com/11358144 TBR=miket@chromium.org Review URL: https://codereview.chromium.org/11377156 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167662 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/api/notification/notification_api.cc60
-rw-r--r--chrome/browser/extensions/api/notification/notification_apitest.cc42
-rw-r--r--chrome/common/extensions/api/experimental_notification.idl49
3 files changed, 26 insertions, 125 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.