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

Side by Side Diff: chrome/browser/notifications/notification_platform_bridge_android.cc

Issue 2337963003: Plumb through notification action types and placeholders on Android (Closed)
Patch Set: Created 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/notifications/notification_platform_bridge_android.h" 5 #include "chrome/browser/notifications/notification_platform_bridge_android.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
11 #include "base/android/jni_string.h" 11 #include "base/android/jni_string.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/notifications/native_notification_display_service.h" 18 #include "chrome/browser/notifications/native_notification_display_service.h"
18 #include "chrome/browser/notifications/notification.h" 19 #include "chrome/browser/notifications/notification.h"
19 #include "chrome/browser/notifications/notification_common.h" 20 #include "chrome/browser/notifications/notification_common.h"
20 #include "chrome/browser/notifications/notification_display_service_factory.h" 21 #include "chrome/browser/notifications/notification_display_service_factory.h"
21 #include "chrome/browser/notifications/persistent_notification_delegate.h" 22 #include "chrome/browser/notifications/persistent_notification_delegate.h"
22 #include "chrome/browser/notifications/platform_notification_service_impl.h" 23 #include "chrome/browser/notifications/platform_notification_service_impl.h"
23 #include "chrome/browser/profiles/profile_manager.h" 24 #include "chrome/browser/profiles/profile_manager.h"
24 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 222
222 std::vector<base::string16> action_titles_vector; 223 std::vector<base::string16> action_titles_vector;
223 for (const message_center::ButtonInfo& button : notification.buttons()) 224 for (const message_center::ButtonInfo& button : notification.buttons())
224 action_titles_vector.push_back(button.title); 225 action_titles_vector.push_back(button.title);
225 ScopedJavaLocalRef<jobjectArray> action_titles = 226 ScopedJavaLocalRef<jobjectArray> action_titles =
226 base::android::ToJavaArrayOfStrings(env, action_titles_vector); 227 base::android::ToJavaArrayOfStrings(env, action_titles_vector);
227 228
228 ScopedJavaLocalRef<jobjectArray> action_icons = 229 ScopedJavaLocalRef<jobjectArray> action_icons =
229 ConvertToJavaBitmaps(notification.buttons()); 230 ConvertToJavaBitmaps(notification.buttons());
230 231
232 std::vector<base::string16> action_types_vector;
233 for (const message_center::ButtonInfo& button : notification.buttons()) {
234 if (button.type == message_center::NotificationActionType::TEXT) {
235 action_types_vector.push_back(base::ASCIIToUTF16("text"));
awdf 2016/09/13 14:14:55 I'm aware I probably want a vector of booleans or
Peter Beverloo 2016/09/14 16:27:12 I think you're looking at too small of a problem—
awdf 2016/09/22 14:17:11 Sure, it would definitely be nice to cut down the
awdf 2016/09/26 15:33:28 Is it reasonable for me to create a Chromium issue
Peter Beverloo 2016/09/26 16:04:34 Absolutely :) Bugs are free.
236 } else {
237 action_types_vector.push_back(base::ASCIIToUTF16("button"));
238 }
239 }
240 ScopedJavaLocalRef<jobjectArray> action_types =
241 base::android::ToJavaArrayOfStrings(env, action_types_vector);
242
243 std::vector<base::string16> action_placeholders_vector;
244 for (const message_center::ButtonInfo& button : notification.buttons()) {
245 if (!button.placeholder.is_null()) {
246 action_placeholders_vector.push_back(button.placeholder.string());
247 } else {
248 action_placeholders_vector.push_back(base::ASCIIToUTF16(""));
249 }
250 }
251 ScopedJavaLocalRef<jobjectArray> action_placeholders =
252 base::android::ToJavaArrayOfStrings(env, action_placeholders_vector);
253
231 ScopedJavaLocalRef<jintArray> vibration_pattern = 254 ScopedJavaLocalRef<jintArray> vibration_pattern =
232 base::android::ToJavaIntArray(env, notification.vibration_pattern()); 255 base::android::ToJavaIntArray(env, notification.vibration_pattern());
233 256
234 ScopedJavaLocalRef<jstring> j_profile_id = 257 ScopedJavaLocalRef<jstring> j_profile_id =
235 ConvertUTF8ToJavaString(env, profile_id); 258 ConvertUTF8ToJavaString(env, profile_id);
236 259
237 Java_NotificationPlatformBridge_displayNotification( 260 Java_NotificationPlatformBridge_displayNotification(
238 env, java_object_, j_notification_id, j_origin, j_profile_id, incognito, 261 env, java_object_, j_notification_id, j_origin, j_profile_id, incognito,
239 tag, webapk_package, title, body, image, notification_icon, badge, 262 tag, webapk_package, title, body, image, notification_icon, badge,
240 vibration_pattern, notification.timestamp().ToJavaTime(), 263 vibration_pattern, notification.timestamp().ToJavaTime(),
241 notification.renotify(), notification.silent(), action_titles, 264 notification.renotify(), notification.silent(), action_titles,
242 action_icons); 265 action_icons, action_types, action_placeholders);
243 266
244 regenerated_notification_infos_[notification_id] = 267 regenerated_notification_infos_[notification_id] =
245 RegeneratedNotificationInfo(origin_url.spec(), notification.tag(), 268 RegeneratedNotificationInfo(origin_url.spec(), notification.tag(),
246 ConvertJavaStringToUTF8(env, webapk_package)); 269 ConvertJavaStringToUTF8(env, webapk_package));
247 } 270 }
248 271
249 void NotificationPlatformBridgeAndroid::Close( 272 void NotificationPlatformBridgeAndroid::Close(
250 const std::string& profile_id, 273 const std::string& profile_id,
251 const std::string& notification_id) { 274 const std::string& notification_id) {
252 const auto iterator = regenerated_notification_infos_.find(notification_id); 275 const auto iterator = regenerated_notification_infos_.find(notification_id);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 RegeneratedNotificationInfo() {} 327 RegeneratedNotificationInfo() {}
305 328
306 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: 329 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo::
307 RegeneratedNotificationInfo(const std::string& origin, 330 RegeneratedNotificationInfo(const std::string& origin,
308 const std::string& tag, 331 const std::string& tag,
309 const std::string& webapk_package) 332 const std::string& webapk_package)
310 : origin(origin), tag(tag), webapk_package(webapk_package) {} 333 : origin(origin), tag(tag), webapk_package(webapk_package) {}
311 334
312 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: 335 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo::
313 ~RegeneratedNotificationInfo() {} 336 ~RegeneratedNotificationInfo() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698