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

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: Plumb through the notification action types and placeholder text for inline replies 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"
Peter Beverloo 2016/09/22 18:07:56 nit: merge conflict? I removed this in a previous
awdf 2016/09/23 15:24:56 Done.
16 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/notifications/native_notification_display_service.h" 18 #include "chrome/browser/notifications/native_notification_display_service.h"
17 #include "chrome/browser/notifications/notification.h" 19 #include "chrome/browser/notifications/notification.h"
18 #include "chrome/browser/notifications/notification_common.h" 20 #include "chrome/browser/notifications/notification_common.h"
19 #include "chrome/browser/notifications/notification_display_service_factory.h" 21 #include "chrome/browser/notifications/notification_display_service_factory.h"
20 #include "chrome/browser/notifications/persistent_notification_delegate.h" 22 #include "chrome/browser/notifications/persistent_notification_delegate.h"
21 #include "chrome/browser/notifications/platform_notification_service_impl.h" 23 #include "chrome/browser/notifications/platform_notification_service_impl.h"
22 #include "chrome/browser/profiles/profile_manager.h" 24 #include "chrome/browser/profiles/profile_manager.h"
23 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
24 #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
220 222
221 std::vector<base::string16> action_titles_vector; 223 std::vector<base::string16> action_titles_vector;
222 for (const message_center::ButtonInfo& button : notification.buttons()) 224 for (const message_center::ButtonInfo& button : notification.buttons())
223 action_titles_vector.push_back(button.title); 225 action_titles_vector.push_back(button.title);
224 ScopedJavaLocalRef<jobjectArray> action_titles = 226 ScopedJavaLocalRef<jobjectArray> action_titles =
225 base::android::ToJavaArrayOfStrings(env, action_titles_vector); 227 base::android::ToJavaArrayOfStrings(env, action_titles_vector);
226 228
227 ScopedJavaLocalRef<jobjectArray> action_icons = 229 ScopedJavaLocalRef<jobjectArray> action_icons =
228 ConvertToJavaBitmaps(notification.buttons()); 230 ConvertToJavaBitmaps(notification.buttons());
229 231
232 std::vector<base::string16> action_types_vector;
233 for (const message_center::ButtonInfo& button : notification.buttons()) {
234 if (button.type == message_center::ButtonType::TEXT) {
235 action_types_vector.push_back(base::ASCIIToUTF16("text"));
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()) {
Peter Beverloo 2016/09/22 18:07:56 nit: why not unify the for loops into a single one
awdf 2016/09/23 15:24:56 Done.
246 action_placeholders_vector.push_back(button.placeholder.string());
247 } else {
248 action_placeholders_vector.push_back(base::ASCIIToUTF16(""));
awdf 2016/09/23 15:24:56 here I should shouldn't be replacing NULL with an
Peter Beverloo 2016/09/23 16:01:22 I agree - adding it in PlatformNotificationService
awdf 2016/09/26 15:33:28 Done.
249 }
250 }
251 ScopedJavaLocalRef<jobjectArray> action_placeholders =
252 base::android::ToJavaArrayOfStrings(env, action_placeholders_vector);
253
230 ScopedJavaLocalRef<jintArray> vibration_pattern = 254 ScopedJavaLocalRef<jintArray> vibration_pattern =
231 base::android::ToJavaIntArray(env, notification.vibration_pattern()); 255 base::android::ToJavaIntArray(env, notification.vibration_pattern());
232 256
233 ScopedJavaLocalRef<jstring> j_profile_id = 257 ScopedJavaLocalRef<jstring> j_profile_id =
234 ConvertUTF8ToJavaString(env, profile_id); 258 ConvertUTF8ToJavaString(env, profile_id);
235 259
236 Java_NotificationPlatformBridge_displayNotification( 260 Java_NotificationPlatformBridge_displayNotification(
237 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,
238 tag, webapk_package, title, body, image, notification_icon, badge, 262 tag, webapk_package, title, body, image, notification_icon, badge,
239 vibration_pattern, notification.timestamp().ToJavaTime(), 263 vibration_pattern, notification.timestamp().ToJavaTime(),
240 notification.renotify(), notification.silent(), action_titles, 264 notification.renotify(), notification.silent(), action_titles,
241 action_icons); 265 action_icons, action_types, action_placeholders);
242 266
243 regenerated_notification_infos_[notification_id] = 267 regenerated_notification_infos_[notification_id] =
244 RegeneratedNotificationInfo(origin_url.spec(), notification.tag(), 268 RegeneratedNotificationInfo(origin_url.spec(), notification.tag(),
245 ConvertJavaStringToUTF8(env, webapk_package)); 269 ConvertJavaStringToUTF8(env, webapk_package));
246 } 270 }
247 271
248 void NotificationPlatformBridgeAndroid::Close( 272 void NotificationPlatformBridgeAndroid::Close(
249 const std::string& profile_id, 273 const std::string& profile_id,
250 const std::string& notification_id) { 274 const std::string& notification_id) {
251 const auto iterator = regenerated_notification_infos_.find(notification_id); 275 const auto iterator = regenerated_notification_infos_.find(notification_id);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 RegeneratedNotificationInfo() {} 323 RegeneratedNotificationInfo() {}
300 324
301 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: 325 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo::
302 RegeneratedNotificationInfo(const std::string& origin, 326 RegeneratedNotificationInfo(const std::string& origin,
303 const std::string& tag, 327 const std::string& tag,
304 const std::string& webapk_package) 328 const std::string& webapk_package)
305 : origin(origin), tag(tag), webapk_package(webapk_package) {} 329 : origin(origin), tag(tag), webapk_package(webapk_package) {}
306 330
307 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: 331 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo::
308 ~RegeneratedNotificationInfo() {} 332 ~RegeneratedNotificationInfo() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698