OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.ntp; | 5 package org.chromium.chrome.browser.ntp; |
6 | 6 |
7 import android.app.AlarmManager; | 7 import android.app.AlarmManager; |
8 import android.app.NotificationManager; | 8 import android.app.NotificationManager; |
9 import android.app.PendingIntent; | 9 import android.app.PendingIntent; |
10 import android.content.BroadcastReceiver; | 10 import android.content.BroadcastReceiver; |
11 import android.content.Context; | 11 import android.content.Context; |
12 import android.content.Intent; | 12 import android.content.Intent; |
13 import android.content.SharedPreferences; | 13 import android.content.SharedPreferences; |
14 import android.graphics.Bitmap; | 14 import android.graphics.Bitmap; |
15 import android.net.Uri; | 15 import android.net.Uri; |
16 import android.provider.Browser; | 16 import android.provider.Browser; |
17 import android.support.v4.app.NotificationCompat; | |
18 | 17 |
19 import org.chromium.base.ContextUtils; | 18 import org.chromium.base.ContextUtils; |
20 import org.chromium.base.annotations.CalledByNative; | 19 import org.chromium.base.annotations.CalledByNative; |
21 import org.chromium.base.annotations.JNINamespace; | 20 import org.chromium.base.annotations.JNINamespace; |
22 import org.chromium.base.library_loader.LibraryLoader; | 21 import org.chromium.base.library_loader.LibraryLoader; |
23 import org.chromium.chrome.R; | 22 import org.chromium.chrome.R; |
| 23 import org.chromium.chrome.browser.ChromeApplication; |
24 import org.chromium.chrome.browser.IntentHandler; | 24 import org.chromium.chrome.browser.IntentHandler; |
25 import org.chromium.chrome.browser.ShortcutHelper; | 25 import org.chromium.chrome.browser.ShortcutHelper; |
26 import org.chromium.chrome.browser.document.ChromeLauncherActivity; | 26 import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
| 27 import org.chromium.chrome.browser.notifications.ChromeNotificationBuilder; |
| 28 import org.chromium.chrome.browser.notifications.NotificationConstants; |
27 import org.chromium.chrome.browser.ntp.snippets.ContentSuggestionsNotificationAc
tion; | 29 import org.chromium.chrome.browser.ntp.snippets.ContentSuggestionsNotificationAc
tion; |
28 | 30 |
29 import java.util.Collection; | 31 import java.util.Collection; |
30 import java.util.Collections; | 32 import java.util.Collections; |
31 import java.util.HashSet; | 33 import java.util.HashSet; |
32 import java.util.Set; | 34 import java.util.Set; |
33 | 35 |
34 /** | 36 /** |
35 * Provides functionality needed for content suggestion notifications. | 37 * Provides functionality needed for content suggestion notifications. |
36 * | 38 * |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 Intent contentIntent = | 141 Intent contentIntent = |
140 new Intent(context, OpenUrlReceiver.class) | 142 new Intent(context, OpenUrlReceiver.class) |
141 .setData(uri) | 143 .setData(uri) |
142 .putExtra(NOTIFICATION_CATEGORY_EXTRA, category) | 144 .putExtra(NOTIFICATION_CATEGORY_EXTRA, category) |
143 .putExtra(NOTIFICATION_ID_WITHIN_CATEGORY_EXTRA, idWithi
nCategory); | 145 .putExtra(NOTIFICATION_ID_WITHIN_CATEGORY_EXTRA, idWithi
nCategory); |
144 Intent deleteIntent = | 146 Intent deleteIntent = |
145 new Intent(context, DeleteReceiver.class) | 147 new Intent(context, DeleteReceiver.class) |
146 .setData(uri) | 148 .setData(uri) |
147 .putExtra(NOTIFICATION_CATEGORY_EXTRA, category) | 149 .putExtra(NOTIFICATION_CATEGORY_EXTRA, category) |
148 .putExtra(NOTIFICATION_ID_WITHIN_CATEGORY_EXTRA, idWithi
nCategory); | 150 .putExtra(NOTIFICATION_ID_WITHIN_CATEGORY_EXTRA, idWithi
nCategory); |
149 NotificationCompat.Builder builder = | 151 ChromeNotificationBuilder builder = |
150 new NotificationCompat.Builder(context) | 152 ((ChromeApplication) context) |
| 153 .createChromeNotificationBuilder(true /* preferCompat */
, |
| 154 NotificationConstants.CATEGORY_ID_BROWSER, |
| 155 context.getString(R.string.notification_category
_browser), |
| 156 NotificationConstants.CATEGORY_GROUP_ID_GENERAL, |
| 157 context.getString(R.string.notification_category
_group_general)) |
151 .setAutoCancel(true) | 158 .setAutoCancel(true) |
152 .setContentIntent(PendingIntent.getBroadcast(context, 0,
contentIntent, 0)) | 159 .setContentIntent(PendingIntent.getBroadcast(context, 0,
contentIntent, 0)) |
153 .setDeleteIntent(PendingIntent.getBroadcast(context, 0,
deleteIntent, 0)) | 160 .setDeleteIntent(PendingIntent.getBroadcast(context, 0,
deleteIntent, 0)) |
154 .setContentTitle(title) | 161 .setContentTitle(title) |
155 .setContentText(text) | 162 .setContentText(text) |
156 .setGroup(NOTIFICATION_TAG) | 163 .setGroup(NOTIFICATION_TAG) |
157 .setPriority(-1) | 164 .setPriority(-1) |
158 .setLargeIcon(image) | 165 .setLargeIcon(image) |
159 .setSmallIcon(R.drawable.ic_chrome); | 166 .setSmallIcon(R.drawable.ic_chrome); |
160 manager.notify(NOTIFICATION_TAG, nextId, builder.build()); | 167 manager.notify(NOTIFICATION_TAG, nextId, builder.build()); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 .remove(PREF_CACHED_ACTION_HIDE_SHUTDOWN) | 431 .remove(PREF_CACHED_ACTION_HIDE_SHUTDOWN) |
425 .remove(PREF_CACHED_CONSECUTIVE_IGNORED) | 432 .remove(PREF_CACHED_CONSECUTIVE_IGNORED) |
426 .apply(); | 433 .apply(); |
427 } | 434 } |
428 } | 435 } |
429 | 436 |
430 private static native void nativeReceiveFlushedMetrics(int tapCount, int dis
missalCount, | 437 private static native void nativeReceiveFlushedMetrics(int tapCount, int dis
missalCount, |
431 int hideDeadlineCount, int hideExpiryCount, int hideFrontmostCount, | 438 int hideDeadlineCount, int hideExpiryCount, int hideFrontmostCount, |
432 int hideDisabledCount, int hideShutdownCount, int consecutiveIgnored
); | 439 int hideDisabledCount, int hideShutdownCount, int consecutiveIgnored
); |
433 } | 440 } |
OLD | NEW |