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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java

Issue 2737723002: Downloads : Last access time update for NTP, duplicate infobar and notifications (Closed)
Patch Set: more 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.download; 5 package org.chromium.chrome.browser.download;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.app.DownloadManager; 8 import android.app.DownloadManager;
9 import android.app.Notification; 9 import android.app.Notification;
10 import android.app.NotificationManager; 10 import android.app.NotificationManager;
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 * @param downloadGuid GUID of the download. 869 * @param downloadGuid GUID of the download.
870 * @param filePath Full path to the download. 870 * @param filePath Full path to the download.
871 * @param fileName Filename of the download. 871 * @param fileName Filename of the download.
872 * @param systemDownloadId Download ID assigned by system DownloadManager. 872 * @param systemDownloadId Download ID assigned by system DownloadManager.
873 * @param isOfflinePage Whether the download is for offline page. 873 * @param isOfflinePage Whether the download is for offline page.
874 * @param isSupportedMimeType Whether the MIME type can be viewed inside bro wser. 874 * @param isSupportedMimeType Whether the MIME type can be viewed inside bro wser.
875 * @return ID of the successful download notification. Used for removing the notification when 875 * @return ID of the successful download notification. Used for removing the notification when
876 * user click on the snackbar. 876 * user click on the snackbar.
877 */ 877 */
878 @VisibleForTesting 878 @VisibleForTesting
879 public int notifyDownloadSuccessful( 879 public int notifyDownloadSuccessful(String downloadGuid, String filePath, St ring fileName,
880 String downloadGuid, String filePath, String fileName, long systemDo wnloadId, 880 long systemDownloadId, boolean isOffTheRecord, boolean isOfflinePage ,
881 boolean isOfflinePage, boolean isSupportedMimeType) { 881 boolean isSupportedMimeType) {
882 int notificationId = getNotificationId(downloadGuid); 882 int notificationId = getNotificationId(downloadGuid);
883 ChromeNotificationBuilder builder = buildNotification(R.drawable.offline _pin, fileName, 883 ChromeNotificationBuilder builder = buildNotification(R.drawable.offline _pin, fileName,
884 mContext.getResources().getString(R.string.download_notification _completed)); 884 mContext.getResources().getString(R.string.download_notification _completed));
885 ComponentName component = new ComponentName( 885 ComponentName component = new ComponentName(
886 mContext.getPackageName(), DownloadBroadcastReceiver.class.getNa me()); 886 mContext.getPackageName(), DownloadBroadcastReceiver.class.getNa me());
887 Intent intent; 887 Intent intent;
888 if (isOfflinePage) { 888 if (isOfflinePage) {
889 intent = buildActionIntent(mContext, ACTION_DOWNLOAD_OPEN, downloadG uid, false, true); 889 intent = buildActionIntent(mContext, ACTION_DOWNLOAD_OPEN, downloadG uid, false, true);
890 } else { 890 } else {
891 intent = new Intent(DownloadManager.ACTION_NOTIFICATION_CLICKED); 891 intent = new Intent(DownloadManager.ACTION_NOTIFICATION_CLICKED);
892 long[] idArray = {systemDownloadId}; 892 long[] idArray = {systemDownloadId};
893 intent.putExtra(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_ID S, idArray); 893 intent.putExtra(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_ID S, idArray);
894 intent.putExtra(EXTRA_DOWNLOAD_FILE_PATH, filePath); 894 intent.putExtra(EXTRA_DOWNLOAD_FILE_PATH, filePath);
895 intent.putExtra(EXTRA_IS_SUPPORTED_MIME_TYPE, isSupportedMimeType); 895 intent.putExtra(EXTRA_IS_SUPPORTED_MIME_TYPE, isSupportedMimeType);
896 intent.putExtra(EXTRA_IS_OFF_THE_RECORD, isOffTheRecord);
897 intent.putExtra(EXTRA_DOWNLOAD_GUID, downloadGuid);
896 } 898 }
897 intent.setComponent(component); 899 intent.setComponent(component);
898 builder.setContentIntent(PendingIntent.getBroadcast( 900 builder.setContentIntent(PendingIntent.getBroadcast(
899 mContext, notificationId, intent, PendingIntent.FLAG_UPDATE_CURR ENT)); 901 mContext, notificationId, intent, PendingIntent.FLAG_UPDATE_CURR ENT));
900 if (mDownloadSuccessLargeIcon == null) { 902 if (mDownloadSuccessLargeIcon == null) {
901 Bitmap bitmap = BitmapFactory.decodeResource( 903 Bitmap bitmap = BitmapFactory.decodeResource(
902 mContext.getResources(), R.drawable.offline_pin); 904 mContext.getResources(), R.drawable.offline_pin);
903 mDownloadSuccessLargeIcon = getLargeNotificationIcon(bitmap); 905 mDownloadSuccessLargeIcon = getLargeNotificationIcon(bitmap);
904 } 906 }
905 builder.setLargeIcon(mDownloadSuccessLargeIcon); 907 builder.setLargeIcon(mDownloadSuccessLargeIcon);
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 return context.getString(R.string.remaining_duration_minutes, minute s); 1328 return context.getString(R.string.remaining_duration_minutes, minute s);
1327 } else if (minutes > 0) { 1329 } else if (minutes > 0) {
1328 return context.getString(R.string.remaining_duration_one_minute); 1330 return context.getString(R.string.remaining_duration_one_minute);
1329 } else if (seconds == 1) { 1331 } else if (seconds == 1) {
1330 return context.getString(R.string.remaining_duration_one_second); 1332 return context.getString(R.string.remaining_duration_one_second);
1331 } else { 1333 } else {
1332 return context.getString(R.string.remaining_duration_seconds, second s); 1334 return context.getString(R.string.remaining_duration_seconds, second s);
1333 } 1335 }
1334 } 1336 }
1335 } 1337 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698