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

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

Issue 1267673003: Plumb Blink notification actions to button UI on desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix size_t Created 5 years, 4 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 payload.vibration_pattern().end()); 45 payload.vibration_pattern().end());
46 } 46 }
47 47
48 notification_data->silent = payload.silent(); 48 notification_data->silent = payload.silent();
49 49
50 if (payload.data().length()) { 50 if (payload.data().length()) {
51 notification_data->data.assign(payload.data().begin(), 51 notification_data->data.assign(payload.data().begin(),
52 payload.data().end()); 52 payload.data().end());
53 } 53 }
54 54
55 for (const auto& payload_action : payload.actions()) {
56 PlatformNotificationAction action;
57 action.action = payload_action.action();
58 action.title = base::UTF8ToUTF16(payload_action.title());
59 notification_data->actions.push_back(action);
60 }
61
55 return true; 62 return true;
56 } 63 }
57 64
58 bool SerializeNotificationDatabaseData(const NotificationDatabaseData& input, 65 bool SerializeNotificationDatabaseData(const NotificationDatabaseData& input,
59 std::string* output) { 66 std::string* output) {
60 DCHECK(output); 67 DCHECK(output);
61 68
62 scoped_ptr<NotificationDatabaseDataProto::NotificationData> payload( 69 scoped_ptr<NotificationDatabaseDataProto::NotificationData> payload(
63 new NotificationDatabaseDataProto::NotificationData()); 70 new NotificationDatabaseDataProto::NotificationData());
64 71
(...skipping 13 matching lines...) Expand all
78 for (size_t i = 0; i < notification_data.vibration_pattern.size(); ++i) 85 for (size_t i = 0; i < notification_data.vibration_pattern.size(); ++i)
79 payload->add_vibration_pattern(notification_data.vibration_pattern[i]); 86 payload->add_vibration_pattern(notification_data.vibration_pattern[i]);
80 87
81 payload->set_silent(notification_data.silent); 88 payload->set_silent(notification_data.silent);
82 89
83 if (notification_data.data.size()) { 90 if (notification_data.data.size()) {
84 payload->set_data(&notification_data.data.front(), 91 payload->set_data(&notification_data.data.front(),
85 notification_data.data.size()); 92 notification_data.data.size());
86 } 93 }
87 94
95 for (const PlatformNotificationAction& action : notification_data.actions) {
96 NotificationDatabaseDataProto::NotificationAction* payload_action =
97 payload->add_actions();
98 payload_action->set_action(action.action);
99 payload_action->set_title(base::UTF16ToUTF8(action.title));
100 }
101
88 NotificationDatabaseDataProto message; 102 NotificationDatabaseDataProto message;
89 message.set_notification_id(input.notification_id); 103 message.set_notification_id(input.notification_id);
90 message.set_origin(input.origin.spec()); 104 message.set_origin(input.origin.spec());
91 message.set_service_worker_registration_id( 105 message.set_service_worker_registration_id(
92 input.service_worker_registration_id); 106 input.service_worker_registration_id);
93 message.set_allocated_notification_data(payload.release()); 107 message.set_allocated_notification_data(payload.release());
94 108
95 return message.SerializeToString(output); 109 return message.SerializeToString(output);
96 } 110 }
97 111
98 } // namespace content 112 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698