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

Unified Diff: content/child/notifications/notification_data_conversions.cc

Issue 1855443002: Implement receiving side of web notification inline replies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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: content/child/notifications/notification_data_conversions.cc
diff --git a/content/child/notifications/notification_data_conversions.cc b/content/child/notifications/notification_data_conversions.cc
index 23763043869f23539e54c69b70240892c2f5dc64..2a64d919f9bc9c29d2de649521b975efd68e20d0 100644
--- a/content/child/notifications/notification_data_conversions.cc
+++ b/content/child/notifications/notification_data_conversions.cc
@@ -18,6 +18,11 @@ using blink::WebNotificationData;
namespace content {
+namespace {
+static const char kButtonString[] = "button";
Michael van Ouwerkerk 2016/04/05 10:06:54 nit: rename to kTypeButton and kTypeText
Nina 2016/04/05 13:28:22 Done.
+static const char kTextString[] = "text";
+}
+
PlatformNotificationData ToPlatformNotificationData(
const WebNotificationData& web_data) {
PlatformNotificationData platform_data;
@@ -51,6 +56,15 @@ PlatformNotificationData ToPlatformNotificationData(
platform_data.data.assign(web_data.data.begin(), web_data.data.end());
platform_data.actions.resize(web_data.actions.size());
for (size_t i = 0; i < web_data.actions.size(); ++i) {
+ if (web_data.actions[i].type == kButtonString) {
+ platform_data.actions[i].type = PLATFORM_NOTIFICATION_ACTION_TYPE_BUTTON;
+ } else if (web_data.actions[i].type == kTextString) {
+ platform_data.actions[i].type = PLATFORM_NOTIFICATION_ACTION_TYPE_TEXT;
+ } else {
+ NOTREACHED() << "Unknown notification action type: "
+ << web_data.actions[i].type.utf8();
+ }
+ platform_data.actions[i].placeholder = web_data.actions[i].placeholder;
platform_data.actions[i].action =
base::UTF16ToUTF8(base::StringPiece16(web_data.actions[i].action));
Michael van Ouwerkerk 2016/04/05 10:06:54 Hmm, it seems no conversions are needed for placeh
Nina 2016/04/05 13:28:22 Unfortunately, action is std::string (as opposed t
platform_data.actions[i].title = web_data.actions[i].title;
@@ -93,6 +107,18 @@ WebNotificationData ToWebNotificationData(
platform_data.actions.size());
web_data.actions.swap(resized);
for (size_t i = 0; i < platform_data.actions.size(); ++i) {
+ switch (platform_data.actions[i].type) {
+ case PLATFORM_NOTIFICATION_ACTION_TYPE_BUTTON:
+ web_data.actions[i].type = kButtonString;
+ break;
+ case PLATFORM_NOTIFICATION_ACTION_TYPE_TEXT:
+ web_data.actions[i].type = kTextString;
+ break;
+ default:
+ NOTREACHED() << "Unknown platform data type: "
+ << platform_data.actions[i].type;
+ }
+ web_data.actions[i].placeholder = platform_data.actions[i].placeholder;
web_data.actions[i].action =
blink::WebString::fromUTF8(platform_data.actions[i].action);
Michael van Ouwerkerk 2016/04/05 10:06:54 Same thing here, can the conversion code be remove
Nina 2016/04/05 13:28:22 ^^
web_data.actions[i].title = platform_data.actions[i].title;

Powered by Google App Engine
This is Rietveld 408576698