cc: Drop skip_shared_out_of_order_tiles field from TilingSetEvictionQueue.
[chromium-blink-merge.git] / chrome / browser / notifications / notification_ui_manager_android.h
blob59b5adc640d150c7f03570e44c6065474a55b6c9
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_ANDROID_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_ANDROID_H_
8 #include <jni.h>
9 #include <map>
10 #include <string>
12 #include "base/android/scoped_java_ref.h"
13 #include "chrome/browser/notifications/notification_ui_manager.h"
15 // Implementation of the Notification UI Manager for Android, which defers to
16 // the Android framework for displaying notifications.
18 // Android does not support getting the notifications currently shown by an
19 // app without very intrusive permissions, which means that it's not possible
20 // to provide reliable implementations for methods which have to iterate over
21 // the existing notifications. Because of this, these have not been implemented.
23 // The UI manager implementation *is* reliable for adding and canceling single
24 // notifications based on their delegate id. Finally, events for persistent Web
25 // Notifications will be forwarded directly to the associated event handlers,
26 // as such notifications may outlive the browser process on Android.
27 class NotificationUIManagerAndroid : public NotificationUIManager {
28 public:
29 NotificationUIManagerAndroid();
30 ~NotificationUIManagerAndroid() override;
32 // Called by the Java implementation when the notification has been clicked.
33 bool OnNotificationClicked(JNIEnv* env,
34 jobject java_object,
35 jlong persistent_notification_id,
36 jstring java_origin,
37 jstring java_tag);
39 // Called by the Java implementation when the notification has been closed.
40 bool OnNotificationClosed(JNIEnv* env,
41 jobject java_object,
42 jlong persistent_notification_id,
43 jstring java_origin,
44 jstring java_tag);
46 // NotificationUIManager implementation.
47 void Add(const Notification& notification, Profile* profile) override;
48 bool Update(const Notification& notification,
49 Profile* profile) override;
50 const Notification* FindById(const std::string& delegate_id,
51 ProfileID profile_id) const override;
52 bool CancelById(const std::string& delegate_id,
53 ProfileID profile_id) override;
54 std::set<std::string> GetAllIdsByProfileAndSourceOrigin(Profile* profile,
55 const GURL& source)
56 override;
57 bool CancelAllBySourceOrigin(const GURL& source_origin) override;
58 bool CancelAllByProfile(ProfileID profile_id) override;
59 void CancelAll() override;
61 static bool RegisterNotificationUIManager(JNIEnv* env);
63 private:
64 // Pair containing the information necessary in order to enable closing
65 // notifications that were not created by this instance of the manager: the
66 // notification's origin and tag. This list may not contain the notifications
67 // that have not been interacted with since the last restart of Chrome.
68 using RegeneratedNotificationInfo = std::pair<std::string, std::string>;
70 // Mapping of a persistent notification id to renegerated notification info.
71 // TODO(peter): Remove this map once notification delegate ids for Web
72 // notifications are created by the content/ layer.
73 std::map<int64_t, RegeneratedNotificationInfo>
74 regenerated_notification_infos_;
76 base::android::ScopedJavaGlobalRef<jobject> java_object_;
78 DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerAndroid);
81 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_ANDROID_H_