| 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/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/notifications/notification.h" | 17 #include "chrome/browser/notifications/notification.h" |
| 18 #include "chrome/browser/notifications/notification_operation_common.h" |
| 18 #include "chrome/browser/notifications/persistent_notification_delegate.h" | 19 #include "chrome/browser/notifications/persistent_notification_delegate.h" |
| 19 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 20 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 23 #include "components/pref_registry/pref_registry_syncable.h" | 24 #include "components/pref_registry/pref_registry_syncable.h" |
| 24 #include "content/public/common/persistent_notification_status.h" | 25 #include "content/public/common/persistent_notification_status.h" |
| 25 #include "content/public/common/platform_notification_data.h" | 26 #include "content/public/common/platform_notification_data.h" |
| 26 #include "jni/NotificationPlatformBridge_jni.h" | 27 #include "jni/NotificationPlatformBridge_jni.h" |
| 27 #include "third_party/skia/include/core/SkBitmap.h" | 28 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 std::string tag = ConvertJavaStringToUTF8(env, java_tag); | 99 std::string tag = ConvertJavaStringToUTF8(env, java_tag); |
| 99 std::string profile_id = ConvertJavaStringToUTF8(env, java_profile_id); | 100 std::string profile_id = ConvertJavaStringToUTF8(env, java_profile_id); |
| 100 std::string webapk_package = | 101 std::string webapk_package = |
| 101 ConvertJavaStringToUTF8(env, java_webapk_package); | 102 ConvertJavaStringToUTF8(env, java_webapk_package); |
| 102 | 103 |
| 103 regenerated_notification_infos_[persistent_notification_id] = | 104 regenerated_notification_infos_[persistent_notification_id] = |
| 104 RegeneratedNotificationInfo(origin.spec(), tag, webapk_package); | 105 RegeneratedNotificationInfo(origin.spec(), tag, webapk_package); |
| 105 | 106 |
| 106 PlatformNotificationServiceImpl::GetInstance() | 107 PlatformNotificationServiceImpl::GetInstance() |
| 107 ->ProcessPersistentNotificationOperation( | 108 ->ProcessPersistentNotificationOperation( |
| 108 PlatformNotificationServiceImpl::NOTIFICATION_CLICK, profile_id, | 109 notification_operation_common::NOTIFICATION_CLICK, profile_id, |
| 109 incognito, origin, persistent_notification_id, action_index); | 110 incognito, origin, persistent_notification_id, action_index); |
| 110 } | 111 } |
| 111 | 112 |
| 112 void NotificationPlatformBridgeAndroid::OnNotificationClosed( | 113 void NotificationPlatformBridgeAndroid::OnNotificationClosed( |
| 113 JNIEnv* env, | 114 JNIEnv* env, |
| 114 const JavaParamRef<jobject>& java_object, | 115 const JavaParamRef<jobject>& java_object, |
| 115 jlong persistent_notification_id, | 116 jlong persistent_notification_id, |
| 116 const JavaParamRef<jstring>& java_origin, | 117 const JavaParamRef<jstring>& java_origin, |
| 117 const JavaParamRef<jstring>& java_profile_id, | 118 const JavaParamRef<jstring>& java_profile_id, |
| 118 jboolean incognito, | 119 jboolean incognito, |
| 119 const JavaParamRef<jstring>& java_tag, | 120 const JavaParamRef<jstring>& java_tag, |
| 120 jboolean by_user) { | 121 jboolean by_user) { |
| 121 GURL origin(ConvertJavaStringToUTF8(env, java_origin)); | 122 GURL origin(ConvertJavaStringToUTF8(env, java_origin)); |
| 122 std::string profile_id = ConvertJavaStringToUTF8(env, java_profile_id); | 123 std::string profile_id = ConvertJavaStringToUTF8(env, java_profile_id); |
| 123 std::string tag = ConvertJavaStringToUTF8(env, java_tag); | 124 std::string tag = ConvertJavaStringToUTF8(env, java_tag); |
| 124 | 125 |
| 125 // The notification was closed by the platform, so clear all local state. | 126 // The notification was closed by the platform, so clear all local state. |
| 126 regenerated_notification_infos_.erase(persistent_notification_id); | 127 regenerated_notification_infos_.erase(persistent_notification_id); |
| 127 PlatformNotificationServiceImpl::GetInstance() | 128 PlatformNotificationServiceImpl::GetInstance() |
| 128 ->ProcessPersistentNotificationOperation( | 129 ->ProcessPersistentNotificationOperation( |
| 129 PlatformNotificationServiceImpl::NOTIFICATION_CLOSE, profile_id, | 130 notification_operation_common::NOTIFICATION_CLOSE, profile_id, |
| 130 incognito, origin, persistent_notification_id, -1); | 131 incognito, origin, persistent_notification_id, -1); |
| 131 } | 132 } |
| 132 | 133 |
| 133 void NotificationPlatformBridgeAndroid::Display( | 134 void NotificationPlatformBridgeAndroid::Display( |
| 134 const std::string& notification_id, | 135 const std::string& notification_id, |
| 135 const std::string& profile_id, | 136 const std::string& profile_id, |
| 136 bool incognito, | 137 bool incognito, |
| 137 const Notification& notification) { | 138 const Notification& notification) { |
| 138 JNIEnv* env = AttachCurrentThread(); | 139 JNIEnv* env = AttachCurrentThread(); |
| 139 | 140 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 RegeneratedNotificationInfo() {} | 276 RegeneratedNotificationInfo() {} |
| 276 | 277 |
| 277 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: | 278 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: |
| 278 RegeneratedNotificationInfo(const std::string& origin, | 279 RegeneratedNotificationInfo(const std::string& origin, |
| 279 const std::string& tag, | 280 const std::string& tag, |
| 280 const std::string& webapk_package) | 281 const std::string& webapk_package) |
| 281 : origin(origin), tag(tag), webapk_package(webapk_package) {} | 282 : origin(origin), tag(tag), webapk_package(webapk_package) {} |
| 282 | 283 |
| 283 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: | 284 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: |
| 284 ~RegeneratedNotificationInfo() {} | 285 ~RegeneratedNotificationInfo() {} |
| OLD | NEW |