Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: chrome/browser/notifications/notification_ui_manager_android.h

Issue 826883003: Android Notifications should be closable without a delegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a-serialize-pickle
Patch Set: rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_UI_MANAGER_ANDROID_H_ 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_ANDROID_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_ANDROID_H_ 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_ANDROID_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 12
13 #include "base/android/scoped_java_ref.h" 13 #include "base/android/scoped_java_ref.h"
14 #include "chrome/browser/notifications/notification_ui_manager.h" 14 #include "chrome/browser/notifications/notification_ui_manager.h"
15 15
16 class ProfileNotification; 16 class ProfileNotification;
17 17
18 // Implementation of the Notification UI Manager for Android, which defers to 18 // Implementation of the Notification UI Manager for Android, which defers to
19 // the Android framework for displaying notifications. 19 // the Android framework for displaying notifications.
20 class NotificationUIManagerAndroid : public NotificationUIManager { 20 class NotificationUIManagerAndroid : public NotificationUIManager {
21 public: 21 public:
22 NotificationUIManagerAndroid(); 22 NotificationUIManagerAndroid();
23 ~NotificationUIManagerAndroid() override; 23 ~NotificationUIManagerAndroid() override;
24 24
25 // Called by the Java implementation when a notification has been clicked on. 25 // Called by the Java implementation when a notification has been clicked on.
26 bool OnNotificationClicked(JNIEnv* env, 26 bool OnNotificationClicked(JNIEnv* env,
27 jobject java_object, 27 jobject java_object,
28 jstring notification_id, 28 jstring notification_id,
29 jint platform_id,
29 jbyteArray serialized_notification_data); 30 jbyteArray serialized_notification_data);
30 31
31 // Called by the Java implementation when a notification has been closed. 32 // Called by the Java implementation when a notification has been closed.
32 bool OnNotificationClosed(JNIEnv* env, 33 bool OnNotificationClosed(JNIEnv* env,
33 jobject java_object, 34 jobject java_object,
34 jstring notification_id); 35 jstring notification_id);
35 36
36 // NotificationUIManager implementation; 37 // NotificationUIManager implementation;
37 void Add(const Notification& notification, Profile* profile) override; 38 void Add(const Notification& notification, Profile* profile) override;
38 bool Update(const Notification& notification, 39 bool Update(const Notification& notification,
39 Profile* profile) override; 40 Profile* profile) override;
40 const Notification* FindById(const std::string& delegate_id, 41 const Notification* FindById(const std::string& delegate_id,
41 ProfileID profile_id) const override; 42 ProfileID profile_id) const override;
42 bool CancelById(const std::string& delegate_id, 43 bool CancelById(const std::string& delegate_id,
43 ProfileID profile_id) override; 44 ProfileID profile_id) override;
44 std::set<std::string> GetAllIdsByProfileAndSourceOrigin(Profile* profile, 45 std::set<std::string> GetAllIdsByProfileAndSourceOrigin(Profile* profile,
45 const GURL& source) 46 const GURL& source)
46 override; 47 override;
47 bool CancelAllBySourceOrigin(const GURL& source_origin) override; 48 bool CancelAllBySourceOrigin(const GURL& source_origin) override;
48 bool CancelAllByProfile(ProfileID profile_id) override; 49 bool CancelAllByProfile(ProfileID profile_id) override;
49 void CancelAll() override; 50 void CancelAll() override;
50 51
51 static bool RegisterNotificationUIManager(JNIEnv* env); 52 static bool RegisterNotificationUIManager(JNIEnv* env);
52 53
53 private: 54 private:
54 // Closes the Notification as displayed on the Android system. 55 // Closes the Notification as displayed on the Android system.
55 void PlatformCloseNotification(ProfileNotification* profile_notification); 56 void PlatformCloseNotification(const std::string& notification_id);
56 57
57 // Helpers that add/remove the notification from local map. 58 // Helpers that add/remove the notification from local map.
58 // The local map takes ownership of profile_notification object. 59 // The local map takes ownership of profile_notification object.
59 void AddProfileNotification(ProfileNotification* profile_notification); 60 void AddProfileNotification(ProfileNotification* profile_notification);
60 void RemoveProfileNotification(ProfileNotification* profile_notification); 61 void RemoveProfileNotification(ProfileNotification* profile_notification);
61 62
62 // Returns the ProfileNotification for the |id|, or NULL if no such 63 // Returns the ProfileNotification for the |id|, or NULL if no such
63 // notification is found. 64 // notification is found.
64 ProfileNotification* FindProfileNotification(const std::string& id) const; 65 ProfileNotification* FindProfileNotification(const std::string& id) const;
65 66
66 // Map from a notification id to the associated ProfileNotification*. 67 // Map from a notification id to the associated ProfileNotification*.
67 std::map<std::string, ProfileNotification*> profile_notifications_; 68 std::map<std::string, ProfileNotification*> profile_notifications_;
68 69
69 // Map from notification id to the associated platform Id. 70 // Map from notification id to the associated platform Id.
70 std::map<std::string, int> platform_notifications_; 71 std::map<std::string, int> platform_notifications_;
71 72
72 base::android::ScopedJavaGlobalRef<jobject> java_object_; 73 base::android::ScopedJavaGlobalRef<jobject> java_object_;
73 74
74 DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerAndroid); 75 DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerAndroid);
75 }; 76 };
76 77
77 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_ANDROID_H_ 78 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698