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

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

Issue 1388483002: Implement the Notification `timestamp` property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 package org.chromium.chrome.browser.notifications; 5 package org.chromium.chrome.browser.notifications;
6 6
7 import android.app.Notification; 7 import android.app.Notification;
8 import android.app.NotificationManager; 8 import android.app.NotificationManager;
9 import android.app.PendingIntent; 9 import android.app.PendingIntent;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 * @param tag A string identifier for this notification. If the tag is not e mpty, the new 413 * @param tag A string identifier for this notification. If the tag is not e mpty, the new
414 * notification will replace the previous notification with the s ame tag and origin, 414 * notification will replace the previous notification with the s ame tag and origin,
415 * if present. If no matching previous notification is present, t he new one will just 415 * if present. If no matching previous notification is present, t he new one will just
416 * be added. 416 * be added.
417 * @param title Title to be displayed in the notification. 417 * @param title Title to be displayed in the notification.
418 * @param body Message to be displayed in the notification. Will be trimmed to one line of 418 * @param body Message to be displayed in the notification. Will be trimmed to one line of
419 * text by the Android notification system. 419 * text by the Android notification system.
420 * @param icon Icon to be displayed in the notification. Valid Bitmap icons will be scaled to 420 * @param icon Icon to be displayed in the notification. Valid Bitmap icons will be scaled to
421 * the platforms, whereas a default icon will be generated for i nvalid Bitmaps. 421 * the platforms, whereas a default icon will be generated for i nvalid Bitmaps.
422 * @param vibrationPattern Vibration pattern following the Web Vibration syn tax. 422 * @param vibrationPattern Vibration pattern following the Web Vibration syn tax.
423 * @param timestamp The timestamp of the event for which the notification is being shown.
423 * @param silent Whether the default sound, vibration and lights should be s uppressed. 424 * @param silent Whether the default sound, vibration and lights should be s uppressed.
424 * @param actionTitles Titles of actions to display alongside the notificati on. 425 * @param actionTitles Titles of actions to display alongside the notificati on.
425 * @see https://developer.android.com/reference/android/app/Notification.htm l 426 * @see https://developer.android.com/reference/android/app/Notification.htm l
426 */ 427 */
427 @CalledByNative 428 @CalledByNative
428 private void displayNotification(long persistentNotificationId, String origi n, String profileId, 429 private void displayNotification(long persistentNotificationId, String origi n, String profileId,
429 boolean incognito, String tag, String title, String body, Bitmap ico n, 430 boolean incognito, String tag, String title, String body, Bitmap ico n,
430 int[] vibrationPattern, boolean silent, String[] actionTitles) { 431 int[] vibrationPattern, long timestamp, boolean silent, String[] act ionTitles) {
431 Resources res = mAppContext.getResources(); 432 Resources res = mAppContext.getResources();
432 433
433 // Record whether it's known whether notifications can be shown to the u ser at all. 434 // Record whether it's known whether notifications can be shown to the u ser at all.
434 RecordHistogram.recordEnumeratedHistogram( 435 RecordHistogram.recordEnumeratedHistogram(
435 "Notifications.AppNotificationStatus", 436 "Notifications.AppNotificationStatus",
436 NotificationSystemStatusUtil.determineAppNotificationStatus(mApp Context), 437 NotificationSystemStatusUtil.determineAppNotificationStatus(mApp Context),
437 NotificationSystemStatusUtil.APP_NOTIFICATIONS_STATUS_BOUNDARY); 438 NotificationSystemStatusUtil.APP_NOTIFICATIONS_STATUS_BOUNDARY);
438 439
439 // Set up a pending intent for going to the settings screen for |origin| . 440 // Set up a pending intent for going to the settings screen for |origin| .
440 Intent settingsIntent = PreferencesLauncher.createIntentForSettingsPage( 441 Intent settingsIntent = PreferencesLauncher.createIntentForSettingsPage(
(...skipping 15 matching lines...) Expand all
456 457
457 NotificationBuilderBase notificationBuilder = 458 NotificationBuilderBase notificationBuilder =
458 createNotificationBuilder() 459 createNotificationBuilder()
459 .setTitle(title) 460 .setTitle(title)
460 .setBody(body) 461 .setBody(body)
461 .setLargeIcon(ensureNormalizedIcon(icon, origin)) 462 .setLargeIcon(ensureNormalizedIcon(icon, origin))
462 .setSmallIcon(R.drawable.ic_chrome) 463 .setSmallIcon(R.drawable.ic_chrome)
463 .setContentIntent(clickIntent) 464 .setContentIntent(clickIntent)
464 .setDeleteIntent(closeIntent) 465 .setDeleteIntent(closeIntent)
465 .setTicker(createTickerText(title, body)) 466 .setTicker(createTickerText(title, body))
467 .setTimestamp(timestamp)
466 .setOrigin(UrlUtilities.formatUrlForSecurityDisplay( 468 .setOrigin(UrlUtilities.formatUrlForSecurityDisplay(
467 origin, false /* showScheme */)); 469 origin, false /* showScheme */));
468 470
469 for (int actionIndex = 0; actionIndex < actionTitles.length; actionIndex ++) { 471 for (int actionIndex = 0; actionIndex < actionTitles.length; actionIndex ++) {
470 notificationBuilder.addAction(0 /* actionIcon */, actionTitles[actio nIndex], 472 notificationBuilder.addAction(0 /* actionIcon */, actionTitles[actio nIndex],
471 makePendingIntent(NotificationConstants.ACTION_CLICK_NOTIFIC ATION, 473 makePendingIntent(NotificationConstants.ACTION_CLICK_NOTIFIC ATION,
472 persistentNotificationId, orig in, profileId, 474 persistentNotificationId, orig in, profileId,
473 incognito, tag, actionIndex)); 475 incognito, tag, actionIndex));
474 } 476 }
475 477
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 652
651 private static native void nativeInitializeNotificationUIManager(); 653 private static native void nativeInitializeNotificationUIManager();
652 654
653 private native void nativeOnNotificationClicked(long nativeNotificationUIMan agerAndroid, 655 private native void nativeOnNotificationClicked(long nativeNotificationUIMan agerAndroid,
654 long persistentNotificationId, String origin, String profileId, bool ean incognito, 656 long persistentNotificationId, String origin, String profileId, bool ean incognito,
655 String tag, int actionIndex); 657 String tag, int actionIndex);
656 private native void nativeOnNotificationClosed(long nativeNotificationUIMana gerAndroid, 658 private native void nativeOnNotificationClosed(long nativeNotificationUIMana gerAndroid,
657 long persistentNotificationId, String origin, String profileId, bool ean incognito, 659 long persistentNotificationId, String origin, String profileId, bool ean incognito,
658 String tag, boolean byUser); 660 String tag, boolean byUser);
659 } 661 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698