| OLD | NEW |
| 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/build_info.h" | |
| 11 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| 12 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
| 13 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 14 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 15 #include "base/logging.h" | 14 #include "base/logging.h" |
| 16 #include "base/strings/nullable_string16.h" | 15 #include "base/strings/nullable_string16.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 18 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/notifications/native_notification_display_service.h" | 18 #include "chrome/browser/notifications/native_notification_display_service.h" |
| 20 #include "chrome/browser/notifications/notification.h" | 19 #include "chrome/browser/notifications/notification.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 308 |
| 310 Java_NotificationPlatformBridge_closeNotification( | 309 Java_NotificationPlatformBridge_closeNotification( |
| 311 env, java_object_, j_profile_id, j_notification_id, origin, tag, | 310 env, java_object_, j_profile_id, j_notification_id, origin, tag, |
| 312 webapk_package); | 311 webapk_package); |
| 313 } | 312 } |
| 314 | 313 |
| 315 bool NotificationPlatformBridgeAndroid::GetDisplayed( | 314 bool NotificationPlatformBridgeAndroid::GetDisplayed( |
| 316 const std::string& profile_id, | 315 const std::string& profile_id, |
| 317 bool incognito, | 316 bool incognito, |
| 318 std::set<std::string>* notifications) const { | 317 std::set<std::string>* notifications) const { |
| 319 DCHECK(notifications); | 318 // TODO(miguelg): This can actually be implemented for M+ |
| 320 JNIEnv* env = AttachCurrentThread(); | 319 return false; |
| 321 | |
| 322 // Android only supports retrieving existing notifications from M+ | |
| 323 if (base::android::BuildInfo::GetInstance()->sdk_int() < | |
| 324 base::android::SDK_VERSION_MARSHMALLOW) { | |
| 325 return false; | |
| 326 } | |
| 327 | |
| 328 const ScopedJavaLocalRef<jstring> j_profile_id = | |
| 329 ConvertUTF8ToJavaString(env, profile_id); | |
| 330 | |
| 331 ScopedJavaLocalRef<jobjectArray> j_notification_ids = | |
| 332 Java_NotificationPlatformBridge_getNotificationsForProfile( | |
| 333 env, java_object_, j_profile_id); | |
| 334 if (j_notification_ids.obj()) { | |
| 335 std::vector<std::string> notification_ids; | |
| 336 base::android::AppendJavaStringArrayToStringVector( | |
| 337 env, j_notification_ids.obj(), ¬ification_ids); | |
| 338 for (const auto& id : notification_ids) { | |
| 339 notifications->insert(id); | |
| 340 } | |
| 341 } | |
| 342 return true; | |
| 343 } | 320 } |
| 344 | 321 |
| 345 // static | 322 // static |
| 346 bool NotificationPlatformBridgeAndroid::RegisterNotificationPlatformBridge( | 323 bool NotificationPlatformBridgeAndroid::RegisterNotificationPlatformBridge( |
| 347 JNIEnv* env) { | 324 JNIEnv* env) { |
| 348 return RegisterNativesImpl(env); | 325 return RegisterNativesImpl(env); |
| 349 } | 326 } |
| 350 | 327 |
| 351 // static | 328 // static |
| 352 void NotificationPlatformBridgeAndroid::RegisterProfilePrefs( | 329 void NotificationPlatformBridgeAndroid::RegisterProfilePrefs( |
| 353 user_prefs::PrefRegistrySyncable* registry) { | 330 user_prefs::PrefRegistrySyncable* registry) { |
| 354 registry->RegisterBooleanPref(prefs::kNotificationsVibrateEnabled, true); | 331 registry->RegisterBooleanPref(prefs::kNotificationsVibrateEnabled, true); |
| 355 } | 332 } |
| 356 | 333 |
| 357 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: | 334 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: |
| 358 RegeneratedNotificationInfo() {} | 335 RegeneratedNotificationInfo() {} |
| 359 | 336 |
| 360 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: | 337 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: |
| 361 RegeneratedNotificationInfo(const std::string& origin, | 338 RegeneratedNotificationInfo(const std::string& origin, |
| 362 const std::string& tag, | 339 const std::string& tag, |
| 363 const std::string& webapk_package) | 340 const std::string& webapk_package) |
| 364 : origin(origin), tag(tag), webapk_package(webapk_package) {} | 341 : origin(origin), tag(tag), webapk_package(webapk_package) {} |
| 365 | 342 |
| 366 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: | 343 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: |
| 367 ~RegeneratedNotificationInfo() {} | 344 ~RegeneratedNotificationInfo() {} |
| OLD | NEW |