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/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/nullable_string16.h" | 15 #include "base/strings/nullable_string16.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/notifications/native_notification_display_service.h" | 18 #include "chrome/browser/notifications/native_notification_display_service.h" |
19 #include "chrome/browser/notifications/notification.h" | 19 #include "chrome/browser/notifications/notification.h" |
20 #include "chrome/browser/notifications/notification_common.h" | 20 #include "chrome/browser/notifications/notification_common.h" |
21 #include "chrome/browser/notifications/notification_display_service_factory.h" | 21 #include "chrome/browser/notifications/notification_display_service_factory.h" |
22 #include "chrome/browser/notifications/persistent_notification_delegate.h" | 22 #include "chrome/browser/notifications/persistent_notification_delegate.h" |
23 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 23 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
24 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
27 #include "components/pref_registry/pref_registry_syncable.h" | 27 #include "components/pref_registry/pref_registry_syncable.h" |
| 28 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/common/persistent_notification_status.h" | 29 #include "content/public/common/persistent_notification_status.h" |
29 #include "content/public/common/platform_notification_data.h" | 30 #include "content/public/common/platform_notification_data.h" |
30 #include "jni/ActionInfo_jni.h" | 31 #include "jni/ActionInfo_jni.h" |
31 #include "jni/NotificationPlatformBridge_jni.h" | 32 #include "jni/NotificationPlatformBridge_jni.h" |
32 #include "third_party/skia/include/core/SkBitmap.h" | 33 #include "third_party/skia/include/core/SkBitmap.h" |
33 #include "ui/gfx/android/java_bitmap.h" | 34 #include "ui/gfx/android/java_bitmap.h" |
34 #include "ui/gfx/image/image.h" | 35 #include "ui/gfx/image/image.h" |
35 | 36 |
36 using base::android::AttachCurrentThread; | 37 using base::android::AttachCurrentThread; |
37 using base::android::ConvertJavaStringToUTF8; | 38 using base::android::ConvertJavaStringToUTF8; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 ScopedJavaLocalRef<jstring> j_profile_id = | 305 ScopedJavaLocalRef<jstring> j_profile_id = |
305 ConvertUTF8ToJavaString(env, profile_id); | 306 ConvertUTF8ToJavaString(env, profile_id); |
306 | 307 |
307 regenerated_notification_infos_.erase(iterator); | 308 regenerated_notification_infos_.erase(iterator); |
308 | 309 |
309 Java_NotificationPlatformBridge_closeNotification( | 310 Java_NotificationPlatformBridge_closeNotification( |
310 env, java_object_, j_profile_id, j_notification_id, origin, tag, | 311 env, java_object_, j_profile_id, j_notification_id, origin, tag, |
311 webapk_package); | 312 webapk_package); |
312 } | 313 } |
313 | 314 |
314 bool NotificationPlatformBridgeAndroid::GetDisplayed( | 315 void NotificationPlatformBridgeAndroid::GetDisplayed( |
315 const std::string& profile_id, | 316 const std::string& profile_id, |
316 bool incognito, | 317 bool incognito, |
317 std::set<std::string>* notifications) const { | 318 const DisplayedNotificationsCallback& callback) const { |
318 // TODO(miguelg): This can actually be implemented for M+ | 319 auto displayed_notifications = base::MakeUnique<std::set<std::string>>(); |
319 return false; | 320 content::BrowserThread::PostTask( |
| 321 content::BrowserThread::UI, FROM_HERE, |
| 322 base::Bind(callback, base::Passed(&displayed_notifications), |
| 323 false /* supports_synchronization */)); |
320 } | 324 } |
321 | 325 |
322 // static | 326 // static |
323 bool NotificationPlatformBridgeAndroid::RegisterNotificationPlatformBridge( | 327 bool NotificationPlatformBridgeAndroid::RegisterNotificationPlatformBridge( |
324 JNIEnv* env) { | 328 JNIEnv* env) { |
325 return RegisterNativesImpl(env); | 329 return RegisterNativesImpl(env); |
326 } | 330 } |
327 | 331 |
328 // static | 332 // static |
329 void NotificationPlatformBridgeAndroid::RegisterProfilePrefs( | 333 void NotificationPlatformBridgeAndroid::RegisterProfilePrefs( |
330 user_prefs::PrefRegistrySyncable* registry) { | 334 user_prefs::PrefRegistrySyncable* registry) { |
331 registry->RegisterBooleanPref(prefs::kNotificationsVibrateEnabled, true); | 335 registry->RegisterBooleanPref(prefs::kNotificationsVibrateEnabled, true); |
332 } | 336 } |
333 | 337 |
334 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: | 338 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: |
335 RegeneratedNotificationInfo() {} | 339 RegeneratedNotificationInfo() {} |
336 | 340 |
337 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: | 341 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: |
338 RegeneratedNotificationInfo(const std::string& origin, | 342 RegeneratedNotificationInfo(const std::string& origin, |
339 const std::string& tag, | 343 const std::string& tag, |
340 const std::string& webapk_package) | 344 const std::string& webapk_package) |
341 : origin(origin), tag(tag), webapk_package(webapk_package) {} | 345 : origin(origin), tag(tag), webapk_package(webapk_package) {} |
342 | 346 |
343 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: | 347 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: |
344 ~RegeneratedNotificationInfo() {} | 348 ~RegeneratedNotificationInfo() {} |
OLD | NEW |