Chromium Code Reviews| 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 #include "chrome/browser/notifications/notification_ui_manager_android.h" | 5 #include "chrome/browser/notifications/notification_ui_manager_android.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 | 88 |
| 89 return true; | 89 return true; |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool NotificationUIManagerAndroid::OnNotificationClosed( | 92 bool NotificationUIManagerAndroid::OnNotificationClosed( |
| 93 JNIEnv* env, | 93 JNIEnv* env, |
| 94 jobject java_object, | 94 jobject java_object, |
| 95 jlong persistent_notification_id, | 95 jlong persistent_notification_id, |
| 96 jstring java_origin, | 96 jstring java_origin, |
| 97 jstring java_tag) { | 97 jstring java_tag) { |
| 98 // TODO(peter): Implement handling when a notification has been closed. The | 98 GURL origin(ConvertJavaStringToUTF8(env, java_origin)); |
| 99 // notification database has to reflect this in its own state. | 99 std::string tag = ConvertJavaStringToUTF8(env, java_tag); |
| 100 | |
| 101 // The notification was closed by the platform, so clear all local state. | |
| 102 regenerated_notification_infos_.erase(persistent_notification_id); | |
| 103 | |
| 104 // TODO(peter): Rather than assuming that the last used profile is the | |
|
dewittj
2015/04/10 17:18:30
can this happen sooner rather than later? Or do a
Peter Beverloo
2015/04/20 16:47:20
Chrome for Android only supports a single profile,
| |
| 105 // appropriate one for this notification, the used profile should be | |
| 106 // stored as part of the notification's data. See https://crbug.com/437574. | |
| 107 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClose( | |
| 108 ProfileManager::GetLastUsedProfile(), | |
| 109 persistent_notification_id, | |
| 110 origin); | |
| 111 | |
| 100 return true; | 112 return true; |
| 101 } | 113 } |
| 102 | 114 |
| 103 void NotificationUIManagerAndroid::Add(const Notification& notification, | 115 void NotificationUIManagerAndroid::Add(const Notification& notification, |
| 104 Profile* profile) { | 116 Profile* profile) { |
| 105 // If the given notification is replacing an older one, drop its associated | 117 // If the given notification is replacing an older one, drop its associated |
| 106 // profile notification object without closing the platform notification. | 118 // profile notification object without closing the platform notification. |
| 107 // We'll use the native Android system to perform a smoother replacement. | 119 // We'll use the native Android system to perform a smoother replacement. |
| 108 ProfileNotification* notification_to_replace = | 120 ProfileNotification* notification_to_replace = |
| 109 FindNotificationToReplace(notification, profile); | 121 FindNotificationToReplace(notification, profile); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 for (const auto& iterator : profile_notifications_) { | 346 for (const auto& iterator : profile_notifications_) { |
| 335 ProfileNotification* profile_notification = iterator.second; | 347 ProfileNotification* profile_notification = iterator.second; |
| 336 if (profile_notification->notification().tag() == tag || | 348 if (profile_notification->notification().tag() == tag || |
| 337 profile_notification->notification().origin_url() == origin_url || | 349 profile_notification->notification().origin_url() == origin_url || |
| 338 profile_notification->profile() == profile) { | 350 profile_notification->profile() == profile) { |
| 339 return profile_notification; | 351 return profile_notification; |
| 340 } | 352 } |
| 341 } | 353 } |
| 342 return nullptr; | 354 return nullptr; |
| 343 } | 355 } |
| OLD | NEW |