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 965a3871c195be90ca9e3e9ca1d00160dd1f0d5a..15c4c995cf46a2d6363cf5d2d116ea2d2a0c263d 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 |
@@ -14,17 +14,18 @@ |
import android.graphics.Color; |
import android.net.Uri; |
import android.os.Bundle; |
-import android.support.v4.app.NotificationCompat; |
import android.text.Spannable; |
import android.text.SpannableStringBuilder; |
import android.text.TextUtils; |
import android.text.style.StyleSpan; |
import android.util.Log; |
+import org.chromium.base.CommandLine; |
import org.chromium.base.VisibleForTesting; |
import org.chromium.base.annotations.CalledByNative; |
import org.chromium.base.metrics.RecordUserAction; |
import org.chromium.chrome.R; |
+import org.chromium.chrome.browser.ChromeSwitches; |
import org.chromium.chrome.browser.preferences.Preferences; |
import org.chromium.chrome.browser.preferences.PreferencesLauncher; |
import org.chromium.chrome.browser.preferences.website.SingleCategoryPreferences; |
@@ -418,12 +419,11 @@ private void displayNotification(long persistentNotificationId, String origin, S |
PendingIntent pendingSettingsIntent = PendingIntent.getActivity(mAppContext, |
PENDING_INTENT_REQUEST_CODE, settingsIntent, PendingIntent.FLAG_UPDATE_CURRENT); |
- NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mAppContext) |
- .setContentTitle(title) |
- .setContentText(body) |
- .setStyle(new NotificationCompat.BigTextStyle().bigText(body)) |
- .setLargeIcon(ensureNormalizedIcon(icon, origin)) |
+ NotificationBuilder notificationBuilder = createNotificationBuilder() |
.setSmallIcon(R.drawable.ic_chrome) |
+ .setTitle(title) |
+ .setBody(body) |
+ .setLargeIcon(ensureNormalizedIcon(icon, origin)) |
.setContentIntent(makePendingIntent( |
NotificationConstants.ACTION_CLICK_NOTIFICATION, |
persistentNotificationId, origin, tag, -1 /* actionIndex */)) |
@@ -431,7 +431,7 @@ private void displayNotification(long persistentNotificationId, String origin, S |
NotificationConstants.ACTION_CLOSE_NOTIFICATION, |
persistentNotificationId, origin, tag, -1 /* actionIndex */)) |
.setTicker(createTickerText(title, body)) |
- .setSubText(origin); |
+ .setOrigin(origin); |
for (int actionIndex = 0; actionIndex < actionTitles.length; actionIndex++) { |
notificationBuilder.addAction( |
@@ -454,6 +454,13 @@ private void displayNotification(long persistentNotificationId, String origin, S |
mNotificationManager.notify(platformTag, PLATFORM_ID, notificationBuilder.build()); |
} |
+ private NotificationBuilder createNotificationBuilder() { |
+ if (useCustomLayouts()) { |
+ return new CustomNotificationBuilder(mAppContext); |
+ } |
+ return new StandardNotificationBuilder(mAppContext); |
+ } |
+ |
/** |
* Creates the ticker text for a notification having |title| and |body|. The notification's |
* title will be printed in bold, followed by the text of the body. |
@@ -510,6 +517,14 @@ public Bitmap ensureNormalizedIcon(Bitmap icon, String origin) { |
return icon; |
} |
+ private static boolean useCustomLayouts() { |
+ CommandLine commandLine = CommandLine.getInstance(); |
Peter Beverloo
2015/10/13 12:31:50
nit: Add a TODO for adding finch so that other rev
Michael van Ouwerkerk
2015/10/13 15:22:42
Done.
|
+ if (commandLine.hasSwitch(ChromeSwitches.DISABLE_WEB_NOTIFICATION_CUSTOM_LAYOUTS)) { |
+ return false; |
+ } |
+ return commandLine.hasSwitch(ChromeSwitches.ENABLE_WEB_NOTIFICATION_CUSTOM_LAYOUTS); |
+ } |
+ |
/** |
* Returns whether a notification has been clicked in the last 5 seconds. |
* Used for Startup.BringToForegroundReason UMA histogram. |