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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/ContentSuggestionsNotificationHelper.java

Issue 2751913005: NTP: track shown/blocked suggestions notifications (Closed)
Patch Set: Created 3 years, 9 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 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.Notification; 8 import android.app.Notification;
9 import android.app.NotificationManager; 9 import android.app.NotificationManager;
10 import android.app.PendingIntent; 10 import android.app.PendingIntent;
11 import android.content.BroadcastReceiver; 11 import android.content.BroadcastReceiver;
12 import android.content.Context; 12 import android.content.Context;
13 import android.content.Intent; 13 import android.content.Intent;
14 import android.content.SharedPreferences; 14 import android.content.SharedPreferences;
15 import android.graphics.Bitmap; 15 import android.graphics.Bitmap;
16 import android.net.Uri; 16 import android.net.Uri;
17 import android.provider.Browser; 17 import android.provider.Browser;
18 18
19 import org.chromium.base.ContextUtils; 19 import org.chromium.base.ContextUtils;
20 import org.chromium.base.annotations.CalledByNative; 20 import org.chromium.base.annotations.CalledByNative;
21 import org.chromium.base.annotations.JNINamespace; 21 import org.chromium.base.annotations.JNINamespace;
22 import org.chromium.base.library_loader.LibraryLoader; 22 import org.chromium.base.library_loader.LibraryLoader;
23 import org.chromium.chrome.R; 23 import org.chromium.chrome.R;
24 import org.chromium.chrome.browser.AppHooks; 24 import org.chromium.chrome.browser.AppHooks;
25 import org.chromium.chrome.browser.IntentHandler; 25 import org.chromium.chrome.browser.IntentHandler;
26 import org.chromium.chrome.browser.ShortcutHelper; 26 import org.chromium.chrome.browser.ShortcutHelper;
27 import org.chromium.chrome.browser.document.ChromeLauncherActivity; 27 import org.chromium.chrome.browser.document.ChromeLauncherActivity;
28 import org.chromium.chrome.browser.notifications.ChromeNotificationBuilder; 28 import org.chromium.chrome.browser.notifications.ChromeNotificationBuilder;
29 import org.chromium.chrome.browser.notifications.NotificationConstants; 29 import org.chromium.chrome.browser.notifications.NotificationConstants;
30 import org.chromium.chrome.browser.notifications.NotificationUmaTracker;
30 import org.chromium.chrome.browser.ntp.snippets.ContentSuggestionsNotificationAc tion; 31 import org.chromium.chrome.browser.ntp.snippets.ContentSuggestionsNotificationAc tion;
31 32
32 import java.util.Collection; 33 import java.util.Collection;
33 import java.util.Collections; 34 import java.util.Collections;
34 import java.util.HashSet; 35 import java.util.HashSet;
35 import java.util.Set; 36 import java.util.Set;
36 37
37 /** 38 /**
38 * Provides functionality needed for content suggestion notifications. 39 * Provides functionality needed for content suggestion notifications.
39 * 40 *
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 .setContentTitle(title) 163 .setContentTitle(title)
163 .setContentText(text) 164 .setContentText(text)
164 .setGroup(NOTIFICATION_TAG) 165 .setGroup(NOTIFICATION_TAG)
165 .setPriority(priority) 166 .setPriority(priority)
166 .setLargeIcon(image) 167 .setLargeIcon(image)
167 .setSmallIcon(R.drawable.ic_chrome); 168 .setSmallIcon(R.drawable.ic_chrome);
168 if (priority >= 0) { 169 if (priority >= 0) {
169 builder.setDefaults(Notification.DEFAULT_ALL); 170 builder.setDefaults(Notification.DEFAULT_ALL);
170 } 171 }
171 manager.notify(NOTIFICATION_TAG, nextId, builder.build()); 172 manager.notify(NOTIFICATION_TAG, nextId, builder.build());
173 NotificationUmaTracker.getInstance().onNotificationShown(
174 NotificationUmaTracker.CONTENT_SUGGESTION);
172 addActiveNotification(new ActiveNotification(nextId, category, idWithinC ategory, uri)); 175 addActiveNotification(new ActiveNotification(nextId, category, idWithinC ategory, uri));
173 176
174 // Set timeout. 177 // Set timeout.
175 if (timeoutAtMillis != Long.MAX_VALUE) { 178 if (timeoutAtMillis != Long.MAX_VALUE) {
176 AlarmManager alarmManager = 179 AlarmManager alarmManager =
177 (AlarmManager) context.getSystemService(Context.ALARM_SERVIC E); 180 (AlarmManager) context.getSystemService(Context.ALARM_SERVIC E);
178 Intent timeoutIntent = 181 Intent timeoutIntent =
179 new Intent(context, TimeoutReceiver.class) 182 new Intent(context, TimeoutReceiver.class)
180 .setData(Uri.parse(url)) 183 .setData(Uri.parse(url))
181 .putExtra(NOTIFICATION_ID_EXTRA, nextId) 184 .putExtra(NOTIFICATION_ID_EXTRA, nextId)
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 .remove(PREF_CACHED_ACTION_HIDE_SHUTDOWN) 438 .remove(PREF_CACHED_ACTION_HIDE_SHUTDOWN)
436 .remove(PREF_CACHED_CONSECUTIVE_IGNORED) 439 .remove(PREF_CACHED_CONSECUTIVE_IGNORED)
437 .apply(); 440 .apply();
438 } 441 }
439 } 442 }
440 443
441 private static native void nativeReceiveFlushedMetrics(int tapCount, int dis missalCount, 444 private static native void nativeReceiveFlushedMetrics(int tapCount, int dis missalCount,
442 int hideDeadlineCount, int hideExpiryCount, int hideFrontmostCount, 445 int hideDeadlineCount, int hideExpiryCount, int hideFrontmostCount,
443 int hideDisabledCount, int hideShutdownCount, int consecutiveIgnored ); 446 int hideDisabledCount, int hideShutdownCount, int consecutiveIgnored );
444 } 447 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698