Index: chrome/browser/notifications/notification_ui_manager_android.cc |
diff --git a/chrome/browser/notifications/notification_ui_manager_android.cc b/chrome/browser/notifications/notification_ui_manager_android.cc |
index d4b2f6f360dd683508045d5915d641e887dcb678..0b4408ef17f84ab2b1889ad172e3756800e2138d 100644 |
--- a/chrome/browser/notifications/notification_ui_manager_android.cc |
+++ b/chrome/browser/notifications/notification_ui_manager_android.cc |
@@ -66,16 +66,10 @@ static void InitializeNotificationUIManager(JNIEnv* env, |
} |
// static |
-NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) { |
+NotificationPlatformBridge* NotificationPlatformBridge::Create() { |
return new NotificationUIManagerAndroid(); |
} |
-// static |
-NotificationUIManager* |
-NotificationUIManager::CreateNativeNotificationManager() { |
- return nullptr; |
-} |
- |
NotificationUIManagerAndroid::NotificationUIManagerAndroid() { |
java_object_.Reset( |
Java_NotificationUIManager_create( |
@@ -132,9 +126,10 @@ void NotificationUIManagerAndroid::OnNotificationClosed( |
incognito, origin, persistent_notification_id, -1); |
} |
-void NotificationUIManagerAndroid::Add(const Notification& notification, |
- Profile* profile) { |
- DCHECK(profile); |
+void NotificationUIManagerAndroid::Display(const std::string& notification_id, |
+ const std::string& profile_id, |
+ bool incognito, |
+ const Notification& notification) { |
JNIEnv* env = AttachCurrentThread(); |
// The Android notification UI manager only supports Web Notifications, which |
@@ -182,13 +177,13 @@ void NotificationUIManagerAndroid::Add(const Notification& notification, |
ScopedJavaLocalRef<jintArray> vibration_pattern = |
base::android::ToJavaIntArray(env, notification.vibration_pattern()); |
- ScopedJavaLocalRef<jstring> profile_id = |
- ConvertUTF8ToJavaString(env, profile->GetPath().BaseName().value()); |
+ ScopedJavaLocalRef<jstring> j_profile_id = |
+ ConvertUTF8ToJavaString(env, profile_id); |
Java_NotificationUIManager_displayNotification( |
env, java_object_.obj(), persistent_notification_id, origin.obj(), |
- profile_id.obj(), profile->IsOffTheRecord(), tag.obj(), title.obj(), |
- body.obj(), notification_icon.obj(), badge.obj(), vibration_pattern.obj(), |
+ j_profile_id.obj(), incognito, tag.obj(), title.obj(), body.obj(), |
+ notification_icon.obj(), badge.obj(), vibration_pattern.obj(), |
notification.timestamp().ToJavaTime(), notification.renotify(), |
notification.silent(), action_titles.obj(), action_icons.obj()); |
@@ -198,32 +193,21 @@ void NotificationUIManagerAndroid::Add(const Notification& notification, |
notification.delegate()->Display(); |
} |
-bool NotificationUIManagerAndroid::Update(const Notification& notification, |
- Profile* profile) { |
- NOTREACHED(); |
- return false; |
-} |
- |
-const Notification* NotificationUIManagerAndroid::FindById( |
- const std::string& delegate_id, |
- ProfileID profile_id) const { |
- NOTREACHED(); |
- return nullptr; |
-} |
- |
-bool NotificationUIManagerAndroid::CancelById(const std::string& delegate_id, |
- ProfileID profile_id) { |
+void NotificationUIManagerAndroid::Close(const std::string& profile_id, |
+ const std::string& notification_id) { |
int64_t persistent_notification_id = 0; |
// TODO(peter): Use the |delegate_id| directly when notification ids are being |
// generated by content/ instead of us. |
- if (!base::StringToInt64(delegate_id, &persistent_notification_id)) |
- return false; |
+ if (!base::StringToInt64(notification_id, &persistent_notification_id)) { |
+ LOG(WARNING) << "Unable to decode notification_id " << notification_id; |
+ return; |
+ } |
const auto iterator = |
regenerated_notification_infos_.find(persistent_notification_id); |
if (iterator == regenerated_notification_infos_.end()) |
- return false; |
+ return; |
const RegeneratedNotificationInfo& notification_info = iterator->second; |
@@ -233,46 +217,29 @@ bool NotificationUIManagerAndroid::CancelById(const std::string& delegate_id, |
ConvertUTF8ToJavaString(env, notification_info.first); |
ScopedJavaLocalRef<jstring> tag = |
ConvertUTF8ToJavaString(env, notification_info.second); |
+ ScopedJavaLocalRef<jstring> j_profile_id = |
+ ConvertUTF8ToJavaString(env, profile_id); |
regenerated_notification_infos_.erase(iterator); |
- Java_NotificationUIManager_closeNotification(env, |
- java_object_.obj(), |
- persistent_notification_id, |
- origin.obj(), |
- tag.obj()); |
- return true; |
-} |
- |
-std::set<std::string> |
-NotificationUIManagerAndroid::GetAllIdsByProfileAndSourceOrigin( |
- ProfileID profile_id, |
- const GURL& source) { |
- NOTREACHED(); |
- return std::set<std::string>(); |
-} |
- |
-std::set<std::string> NotificationUIManagerAndroid::GetAllIdsByProfile( |
- ProfileID profile_id) { |
- NOTREACHED(); |
- return std::set<std::string>(); |
+ Java_NotificationUIManager_closeNotification( |
+ env, java_object_.obj(), j_profile_id.obj(), persistent_notification_id, |
+ origin.obj(), tag.obj()); |
} |
-bool NotificationUIManagerAndroid::CancelAllBySourceOrigin( |
- const GURL& source_origin) { |
- NOTREACHED(); |
+bool NotificationUIManagerAndroid::GetDisplayed( |
+ const std::string& profile_id, |
+ bool incognito, |
+ std::set<std::string>* notifications) const { |
+ // TODO(miguelg): This can actually be implemented for M+ |
return false; |
} |
-bool NotificationUIManagerAndroid::CancelAllByProfile(ProfileID profile_id) { |
- NOTREACHED(); |
- return false; |
-} |
- |
-void NotificationUIManagerAndroid::CancelAll() { |
- NOTREACHED(); |
+bool NotificationUIManagerAndroid::SupportsNotificationCenter() const { |
+ return true; |
} |
-bool NotificationUIManagerAndroid::RegisterNotificationUIManager(JNIEnv* env) { |
+bool NotificationUIManagerAndroid::RegisterNotificationPlatformBridge( |
+ JNIEnv* env) { |
return RegisterNativesImpl(env); |
} |