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

Side by Side Diff: content/browser/notifications/notification_database_data_conversions.cc

Issue 1656243002: Implementation of renotify flag for Notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added TypeError for incorrect options and unit test Created 4 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/notifications/notification_database_data_conversions.h " 5 #include "content/browser/notifications/notification_database_data_conversions.h "
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 notification_data->icon = GURL(payload.icon()); 53 notification_data->icon = GURL(payload.icon());
54 54
55 if (payload.vibration_pattern().size() > 0) { 55 if (payload.vibration_pattern().size() > 0) {
56 notification_data->vibration_pattern.assign( 56 notification_data->vibration_pattern.assign(
57 payload.vibration_pattern().begin(), payload.vibration_pattern().end()); 57 payload.vibration_pattern().begin(), payload.vibration_pattern().end());
58 } 58 }
59 59
60 notification_data->timestamp = 60 notification_data->timestamp =
61 base::Time::FromInternalValue(payload.timestamp()); 61 base::Time::FromInternalValue(payload.timestamp());
62 notification_data->silent = payload.silent(); 62 notification_data->silent = payload.silent();
63 notification_data->renotify = payload.renotify();
63 notification_data->require_interaction = payload.require_interaction(); 64 notification_data->require_interaction = payload.require_interaction();
64 65
65 if (payload.data().length()) { 66 if (payload.data().length()) {
66 notification_data->data.assign(payload.data().begin(), 67 notification_data->data.assign(payload.data().begin(),
67 payload.data().end()); 68 payload.data().end());
68 } 69 }
69 70
70 for (const auto& payload_action : payload.actions()) { 71 for (const auto& payload_action : payload.actions()) {
71 PlatformNotificationAction action; 72 PlatformNotificationAction action;
72 action.action = payload_action.action(); 73 action.action = payload_action.action();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 payload->set_lang(notification_data.lang); 107 payload->set_lang(notification_data.lang);
107 payload->set_body(base::UTF16ToUTF8(notification_data.body)); 108 payload->set_body(base::UTF16ToUTF8(notification_data.body));
108 payload->set_tag(notification_data.tag); 109 payload->set_tag(notification_data.tag);
109 payload->set_icon(notification_data.icon.spec()); 110 payload->set_icon(notification_data.icon.spec());
110 111
111 for (size_t i = 0; i < notification_data.vibration_pattern.size(); ++i) 112 for (size_t i = 0; i < notification_data.vibration_pattern.size(); ++i)
112 payload->add_vibration_pattern(notification_data.vibration_pattern[i]); 113 payload->add_vibration_pattern(notification_data.vibration_pattern[i]);
113 114
114 payload->set_timestamp(notification_data.timestamp.ToInternalValue()); 115 payload->set_timestamp(notification_data.timestamp.ToInternalValue());
115 payload->set_silent(notification_data.silent); 116 payload->set_silent(notification_data.silent);
117 payload->set_renotify(notification_data.renotify);
116 payload->set_require_interaction(notification_data.require_interaction); 118 payload->set_require_interaction(notification_data.require_interaction);
117 119
118 if (notification_data.data.size()) { 120 if (notification_data.data.size()) {
119 payload->set_data(&notification_data.data.front(), 121 payload->set_data(&notification_data.data.front(),
120 notification_data.data.size()); 122 notification_data.data.size());
121 } 123 }
122 124
123 for (const PlatformNotificationAction& action : notification_data.actions) { 125 for (const PlatformNotificationAction& action : notification_data.actions) {
124 NotificationDatabaseDataProto::NotificationAction* payload_action = 126 NotificationDatabaseDataProto::NotificationAction* payload_action =
125 payload->add_actions(); 127 payload->add_actions();
126 payload_action->set_action(action.action); 128 payload_action->set_action(action.action);
127 payload_action->set_title(base::UTF16ToUTF8(action.title)); 129 payload_action->set_title(base::UTF16ToUTF8(action.title));
128 } 130 }
129 131
130 NotificationDatabaseDataProto message; 132 NotificationDatabaseDataProto message;
131 message.set_notification_id(input.notification_id); 133 message.set_notification_id(input.notification_id);
132 message.set_origin(input.origin.spec()); 134 message.set_origin(input.origin.spec());
133 message.set_service_worker_registration_id( 135 message.set_service_worker_registration_id(
134 input.service_worker_registration_id); 136 input.service_worker_registration_id);
135 message.set_allocated_notification_data(payload.release()); 137 message.set_allocated_notification_data(payload.release());
136 138
137 return message.SerializeToString(output); 139 return message.SerializeToString(output);
138 } 140 }
139 141
140 } // namespace content 142 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698