| 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 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_ANDROID_H_ |
| 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_ANDROID_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 // Called by the Java implementation when the notification has been clicked. | 35 // Called by the Java implementation when the notification has been clicked. |
| 36 void OnNotificationClicked( | 36 void OnNotificationClicked( |
| 37 JNIEnv* env, | 37 JNIEnv* env, |
| 38 const base::android::JavaParamRef<jobject>& java_object, | 38 const base::android::JavaParamRef<jobject>& java_object, |
| 39 jlong persistent_notification_id, | 39 jlong persistent_notification_id, |
| 40 const base::android::JavaParamRef<jstring>& java_origin, | 40 const base::android::JavaParamRef<jstring>& java_origin, |
| 41 const base::android::JavaParamRef<jstring>& java_profile_id, | 41 const base::android::JavaParamRef<jstring>& java_profile_id, |
| 42 jboolean incognito, | 42 jboolean incognito, |
| 43 const base::android::JavaParamRef<jstring>& java_tag, | 43 const base::android::JavaParamRef<jstring>& java_tag, |
| 44 const base::android::JavaParamRef<jstring>& java_webapk_package, |
| 44 jint action_index); | 45 jint action_index); |
| 45 | 46 |
| 46 // Called by the Java implementation when the notification has been closed. | 47 // Called by the Java implementation when the notification has been closed. |
| 47 void OnNotificationClosed( | 48 void OnNotificationClosed( |
| 48 JNIEnv* env, | 49 JNIEnv* env, |
| 49 const base::android::JavaParamRef<jobject>& java_object, | 50 const base::android::JavaParamRef<jobject>& java_object, |
| 50 jlong persistent_notification_id, | 51 jlong persistent_notification_id, |
| 51 const base::android::JavaParamRef<jstring>& java_origin, | 52 const base::android::JavaParamRef<jstring>& java_origin, |
| 52 const base::android::JavaParamRef<jstring>& java_profile_id, | 53 const base::android::JavaParamRef<jstring>& java_profile_id, |
| 53 jboolean incognito, | 54 jboolean incognito, |
| 54 const base::android::JavaParamRef<jstring>& java_tag, | 55 const base::android::JavaParamRef<jstring>& java_tag, |
| 55 jboolean by_user); | 56 jboolean by_user); |
| 56 | 57 |
| 57 // NotificationPlatformBridge implementation. | 58 // NotificationPlatformBridge implementation. |
| 58 void Display(const std::string& notification_id, | 59 void Display(const std::string& notification_id, |
| 59 const std::string& profile_id, | 60 const std::string& profile_id, |
| 60 bool incognito, | 61 bool incognito, |
| 61 const Notification& notification) override; | 62 const Notification& notification) override; |
| 62 void Close(const std::string& profile_id, | 63 void Close(const std::string& profile_id, |
| 63 const std::string& notification_id) override; | 64 const std::string& notification_id) override; |
| 64 bool GetDisplayed(const std::string& profile_id, | 65 bool GetDisplayed(const std::string& profile_id, |
| 65 bool incognito, | 66 bool incognito, |
| 66 std::set<std::string>* notifications) const override; | 67 std::set<std::string>* notifications) const override; |
| 67 bool SupportsNotificationCenter() const override; | 68 bool SupportsNotificationCenter() const override; |
| 68 | 69 |
| 69 static bool RegisterNotificationPlatformBridge(JNIEnv* env); | 70 static bool RegisterNotificationPlatformBridge(JNIEnv* env); |
| 70 | 71 |
| 71 private: | 72 private: |
| 72 // Pair containing the information necessary in order to enable closing | 73 // Contains information necessary in order to enable closing notifications |
| 73 // notifications that were not created by this instance of the manager: the | 74 // that were not created by this instance of the manager. This list may not |
| 74 // notification's origin and tag. This list may not contain the notifications | 75 // contain the notifications that have not been interacted with since the last |
| 75 // that have not been interacted with since the last restart of Chrome. | 76 // restart of Chrome. |
| 76 using RegeneratedNotificationInfo = std::pair<std::string, std::string>; | 77 struct RegeneratedNotificationInfo { |
| 78 RegeneratedNotificationInfo(); |
| 79 RegeneratedNotificationInfo(const std::string& origin, |
| 80 const std::string& tag, |
| 81 const std::string& webapk_package); |
| 82 ~RegeneratedNotificationInfo(); |
| 83 |
| 84 std::string origin; |
| 85 std::string tag; |
| 86 std::string webapk_package; |
| 87 }; |
| 77 | 88 |
| 78 // Mapping of a persistent notification id to renegerated notification info. | 89 // Mapping of a persistent notification id to renegerated notification info. |
| 79 // TODO(peter): Remove this map once notification delegate ids for Web | 90 // TODO(peter): Remove this map once notification delegate ids for Web |
| 80 // notifications are created by the content/ layer. | 91 // notifications are created by the content/ layer. |
| 81 std::map<int64_t, RegeneratedNotificationInfo> | 92 std::map<int64_t, RegeneratedNotificationInfo> |
| 82 regenerated_notification_infos_; | 93 regenerated_notification_infos_; |
| 83 | 94 |
| 84 base::android::ScopedJavaGlobalRef<jobject> java_object_; | 95 base::android::ScopedJavaGlobalRef<jobject> java_object_; |
| 85 | 96 |
| 86 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeAndroid); | 97 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeAndroid); |
| 87 }; | 98 }; |
| 88 | 99 |
| 89 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_ANDROID_H_ | 100 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_ANDROID_H_ |
| OLD | NEW |