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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java

Issue 1422673002: Extract Notifications kClickWasNotAnAction constant Base URL: https://chromium.googlesource.com/chromium/src.git@actions_spec_sync
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
index 73ed7e637435e7c005253a2d181002876d69c249..7b1a31692f6eab14f2b6adac13775d82b40d026f 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
@@ -63,6 +63,11 @@ public class NotificationUIManager {
// uniqueness of pending intents when necessary.
private static final int PENDING_INTENT_REQUEST_CODE = 0;
+ // When a notification is clicked, passing this value for {@code actionIndex} indicates that the
+ // main body of the notification was clicked, rather than an action button. Must be kept in sync
+ // with {@code content::kNotificationClickWasNotAnAction}.
+ private static final int CLICK_WAS_NOT_AN_ACTION = -1;
+
private static NotificationUIManager sInstance;
private static NotificationManagerProxy sNotificationManagerOverride;
@@ -172,7 +177,8 @@ public class NotificationUIManager {
if (NotificationConstants.ACTION_CLICK_NOTIFICATION.equals(intent.getAction())) {
int actionIndex = intent.getIntExtra(
- NotificationConstants.EXTRA_NOTIFICATION_INFO_ACTION_INDEX, -1);
+ NotificationConstants.EXTRA_NOTIFICATION_INFO_ACTION_INDEX,
+ CLICK_WAS_NOT_AN_ACTION);
return sInstance.onNotificationClicked(persistentNotificationId, origin, tag,
actionIndex);
} else if (NotificationConstants.ACTION_CLOSE_NOTIFICATION.equals(intent.getAction())) {
@@ -240,7 +246,8 @@ public class NotificationUIManager {
*
* @param persistentNotificationId The persistent id of the notification.
* @param origin The origin to whom the notification belongs.
- * @param actionIndex The zero-based index of the action button, or -1 if not applicable.
+ * @param actionIndex The zero-based index of the action button, or
+ * {@link CLICK_WAS_NOT_AN_ACTION} if not applicable.
*/
private Uri makeIntentData(long persistentNotificationId, String origin, int actionIndex) {
return Uri.parse(origin).buildUpon().fragment(
@@ -255,7 +262,8 @@ public class NotificationUIManager {
* @param persistentNotificationId The persistent id of the notification.
* @param origin The origin to whom the notification belongs.
* @param tag The tag of the notification. May be NULL.
- * @param actionIndex The zero-based index of the action button, or -1 if not applicable.
+ * @param actionIndex The zero-based index of the action button, or
+ * {@link CLICK_WAS_NOT_AN_ACTION} if not applicable.
*/
private PendingIntent makePendingIntent(String action, long persistentNotificationId,
String origin, @Nullable String tag, int actionIndex) {
@@ -412,7 +420,7 @@ public class NotificationUIManager {
Intent settingsIntent = PreferencesLauncher.createIntentForSettingsPage(
mAppContext, SingleWebsitePreferences.class.getName());
settingsIntent.setData(makeIntentData(persistentNotificationId, origin,
- -1 /* actionIndex */));
+ CLICK_WAS_NOT_AN_ACTION));
settingsIntent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS,
SingleWebsitePreferences.createFragmentArgsForSite(origin));
@@ -426,10 +434,10 @@ public class NotificationUIManager {
.setSmallIcon(R.drawable.ic_chrome)
.setContentIntent(makePendingIntent(
NotificationConstants.ACTION_CLICK_NOTIFICATION,
- persistentNotificationId, origin, tag, -1 /* actionIndex */))
+ persistentNotificationId, origin, tag, CLICK_WAS_NOT_AN_ACTION))
.setDeleteIntent(makePendingIntent(
NotificationConstants.ACTION_CLOSE_NOTIFICATION,
- persistentNotificationId, origin, tag, -1 /* actionIndex */))
+ persistentNotificationId, origin, tag, CLICK_WAS_NOT_AN_ACTION))
.setTicker(createTickerText(title, body))
.setOrigin(origin);
« no previous file with comments | « no previous file | chrome/browser/notifications/persistent_notification_delegate.cc » ('j') | components/test_runner/DEPS » ('J')

Powered by Google App Engine
This is Rietveld 408576698