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> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/android/scoped_java_ref.h" | 14 #include "base/android/scoped_java_ref.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "chrome/browser/notifications/notification_platform_bridge.h" | 16 #include "chrome/browser/notifications/notification_platform_bridge.h" |
17 | 17 |
| 18 namespace user_prefs { |
| 19 class PrefRegistrySyncable; |
| 20 } |
| 21 |
18 // Implementation of the NotificationPlatformBridge for Android, which defers to | 22 // Implementation of the NotificationPlatformBridge for Android, which defers to |
19 // the Android framework for displaying notifications. | 23 // the Android framework for displaying notifications. |
20 // | 24 // |
21 // Prior to Android Marshmellow, Android did not have the ability to retrieve | 25 // Prior to Android Marshmellow, Android did not have the ability to retrieve |
22 // the notifications currently showing for an app without a rather intrusive | 26 // the notifications currently showing for an app without a rather intrusive |
23 // permission. The GetDisplayed() method may return false because of this. | 27 // permission. The GetDisplayed() method may return false because of this. |
24 // | 28 // |
25 // The Android implementation *is* reliable for adding and canceling | 29 // The Android implementation *is* reliable for adding and canceling |
26 // single notifications based on their delegate id. Finally, events for | 30 // single notifications based on their delegate id. Finally, events for |
27 // persistent Web Notifications will be forwarded directly to the associated | 31 // persistent Web Notifications will be forwarded directly to the associated |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 const Notification& notification) override; | 66 const Notification& notification) override; |
63 void Close(const std::string& profile_id, | 67 void Close(const std::string& profile_id, |
64 const std::string& notification_id) override; | 68 const std::string& notification_id) override; |
65 bool GetDisplayed(const std::string& profile_id, | 69 bool GetDisplayed(const std::string& profile_id, |
66 bool incognito, | 70 bool incognito, |
67 std::set<std::string>* notifications) const override; | 71 std::set<std::string>* notifications) const override; |
68 bool SupportsNotificationCenter() const override; | 72 bool SupportsNotificationCenter() const override; |
69 | 73 |
70 static bool RegisterNotificationPlatformBridge(JNIEnv* env); | 74 static bool RegisterNotificationPlatformBridge(JNIEnv* env); |
71 | 75 |
| 76 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 77 |
72 private: | 78 private: |
73 // Contains information necessary in order to enable closing notifications | 79 // Contains information necessary in order to enable closing notifications |
74 // that were not created by this instance of the manager. This list may not | 80 // that were not created by this instance of the manager. This list may not |
75 // contain the notifications that have not been interacted with since the last | 81 // contain the notifications that have not been interacted with since the last |
76 // restart of Chrome. | 82 // restart of Chrome. |
77 struct RegeneratedNotificationInfo { | 83 struct RegeneratedNotificationInfo { |
78 RegeneratedNotificationInfo(); | 84 RegeneratedNotificationInfo(); |
79 RegeneratedNotificationInfo(const std::string& origin, | 85 RegeneratedNotificationInfo(const std::string& origin, |
80 const std::string& tag, | 86 const std::string& tag, |
81 const std::string& webapk_package); | 87 const std::string& webapk_package); |
82 ~RegeneratedNotificationInfo(); | 88 ~RegeneratedNotificationInfo(); |
83 | 89 |
84 std::string origin; | 90 std::string origin; |
85 std::string tag; | 91 std::string tag; |
86 std::string webapk_package; | 92 std::string webapk_package; |
87 }; | 93 }; |
88 | 94 |
89 // Mapping of a persistent notification id to renegerated notification info. | 95 // Mapping of a persistent notification id to renegerated notification info. |
90 // TODO(peter): Remove this map once notification delegate ids for Web | 96 // TODO(peter): Remove this map once notification delegate ids for Web |
91 // notifications are created by the content/ layer. | 97 // notifications are created by the content/ layer. |
92 std::map<int64_t, RegeneratedNotificationInfo> | 98 std::map<int64_t, RegeneratedNotificationInfo> |
93 regenerated_notification_infos_; | 99 regenerated_notification_infos_; |
94 | 100 |
95 base::android::ScopedJavaGlobalRef<jobject> java_object_; | 101 base::android::ScopedJavaGlobalRef<jobject> java_object_; |
96 | 102 |
97 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeAndroid); | 103 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeAndroid); |
98 }; | 104 }; |
99 | 105 |
100 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_ANDROID_H_ | 106 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_ANDROID_H_ |
OLD | NEW |