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

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

Issue 1313363006: Plumb requireInteraction to PlatformNotificationData & database (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@constructor
Patch Set: Fix includes Created 5 years, 3 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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/browser/notifications/notification_database_data.pb.h" 9 #include "content/browser/notifications/notification_database_data.pb.h"
10 #include "content/public/browser/notification_database_data.h" 10 #include "content/public/browser/notification_database_data.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 notification_data->tag = payload.tag(); 49 notification_data->tag = payload.tag();
50 notification_data->icon = GURL(payload.icon()); 50 notification_data->icon = GURL(payload.icon());
51 51
52 if (payload.vibration_pattern().size() > 0) { 52 if (payload.vibration_pattern().size() > 0) {
53 notification_data->vibration_pattern.assign( 53 notification_data->vibration_pattern.assign(
54 payload.vibration_pattern().begin(), 54 payload.vibration_pattern().begin(),
55 payload.vibration_pattern().end()); 55 payload.vibration_pattern().end());
56 } 56 }
57 57
58 notification_data->silent = payload.silent(); 58 notification_data->silent = payload.silent();
59 notification_data->require_interaction = payload.require_interaction();
59 60
60 if (payload.data().length()) { 61 if (payload.data().length()) {
61 notification_data->data.assign(payload.data().begin(), 62 notification_data->data.assign(payload.data().begin(),
62 payload.data().end()); 63 payload.data().end());
63 } 64 }
64 65
65 for (const auto& payload_action : payload.actions()) { 66 for (const auto& payload_action : payload.actions()) {
66 PlatformNotificationAction action; 67 PlatformNotificationAction action;
67 action.action = payload_action.action(); 68 action.action = payload_action.action();
68 action.title = base::UTF8ToUTF16(payload_action.title()); 69 action.title = base::UTF8ToUTF16(payload_action.title());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 101
101 payload->set_lang(notification_data.lang); 102 payload->set_lang(notification_data.lang);
102 payload->set_body(base::UTF16ToUTF8(notification_data.body)); 103 payload->set_body(base::UTF16ToUTF8(notification_data.body));
103 payload->set_tag(notification_data.tag); 104 payload->set_tag(notification_data.tag);
104 payload->set_icon(notification_data.icon.spec()); 105 payload->set_icon(notification_data.icon.spec());
105 106
106 for (size_t i = 0; i < notification_data.vibration_pattern.size(); ++i) 107 for (size_t i = 0; i < notification_data.vibration_pattern.size(); ++i)
107 payload->add_vibration_pattern(notification_data.vibration_pattern[i]); 108 payload->add_vibration_pattern(notification_data.vibration_pattern[i]);
108 109
109 payload->set_silent(notification_data.silent); 110 payload->set_silent(notification_data.silent);
111 payload->set_require_interaction(notification_data.require_interaction);
110 112
111 if (notification_data.data.size()) { 113 if (notification_data.data.size()) {
112 payload->set_data(&notification_data.data.front(), 114 payload->set_data(&notification_data.data.front(),
113 notification_data.data.size()); 115 notification_data.data.size());
114 } 116 }
115 117
116 for (const PlatformNotificationAction& action : notification_data.actions) { 118 for (const PlatformNotificationAction& action : notification_data.actions) {
117 NotificationDatabaseDataProto::NotificationAction* payload_action = 119 NotificationDatabaseDataProto::NotificationAction* payload_action =
118 payload->add_actions(); 120 payload->add_actions();
119 payload_action->set_action(action.action); 121 payload_action->set_action(action.action);
120 payload_action->set_title(base::UTF16ToUTF8(action.title)); 122 payload_action->set_title(base::UTF16ToUTF8(action.title));
121 } 123 }
122 124
123 NotificationDatabaseDataProto message; 125 NotificationDatabaseDataProto message;
124 message.set_notification_id(input.notification_id); 126 message.set_notification_id(input.notification_id);
125 message.set_origin(input.origin.spec()); 127 message.set_origin(input.origin.spec());
126 message.set_service_worker_registration_id( 128 message.set_service_worker_registration_id(
127 input.service_worker_registration_id); 129 input.service_worker_registration_id);
128 message.set_allocated_notification_data(payload.release()); 130 message.set_allocated_notification_data(payload.release());
129 131
130 return message.SerializeToString(output); 132 return message.SerializeToString(output);
131 } 133 }
132 134
133 } // namespace content 135 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698