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

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

Issue 2230603003: [Offline pages] Downloads UI: Extening DownloadSharedPreferenceEntry to include offline page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding OWNERS file to the tests Created 4 years, 4 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
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/download/DownloadSharedPreferenceEntry.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.app.DownloadManager; 7 import android.app.DownloadManager;
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;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 String duration = formatRemainingTime(mContext, timeRemainingInMilli s); 212 String duration = formatRemainingTime(mContext, timeRemainingInMilli s);
213 builder.setContentText(duration); 213 builder.setContentText(duration);
214 if (Build.VERSION.CODENAME.equals("N") 214 if (Build.VERSION.CODENAME.equals("N")
215 || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) { 215 || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
216 builder.setSubText(percentText); 216 builder.setSubText(percentText);
217 } else { 217 } else {
218 builder.setContentInfo(percentText); 218 builder.setContentInfo(percentText);
219 } 219 }
220 } 220 }
221 int notificationId = getNotificationId(downloadGuid); 221 int notificationId = getNotificationId(downloadGuid);
222 addOrReplaceSharedPreferenceEntry(new DownloadSharedPreferenceEntry( 222 addOrReplaceSharedPreferenceEntry(new DownloadSharedPreferenceEntry(noti ficationId,
223 notificationId, isOffTheRecord, canDownloadWhileMetered, downloa dGuid, fileName)); 223 isOffTheRecord, canDownloadWhileMetered, downloadGuid, fileName,
224 DownloadSharedPreferenceEntry.ITEM_TYPE_DOWNLOAD));
224 if (startTime > 0) builder.setWhen(startTime); 225 if (startTime > 0) builder.setWhen(startTime);
225 Intent cancelIntent = buildActionIntent( 226 Intent cancelIntent = buildActionIntent(
226 ACTION_DOWNLOAD_CANCEL, notificationId, downloadGuid, fileName); 227 ACTION_DOWNLOAD_CANCEL, notificationId, downloadGuid, fileName);
227 builder.addAction(R.drawable.bookmark_cancel_active, 228 builder.addAction(R.drawable.bookmark_cancel_active,
228 mContext.getResources().getString(R.string.download_notification _cancel_button), 229 mContext.getResources().getString(R.string.download_notification _cancel_button),
229 buildPendingIntent(cancelIntent, notificationId)); 230 buildPendingIntent(cancelIntent, notificationId));
230 Intent pauseIntent = buildActionIntent( 231 Intent pauseIntent = buildActionIntent(
231 ACTION_DOWNLOAD_PAUSE, notificationId, downloadGuid, fileName); 232 ACTION_DOWNLOAD_PAUSE, notificationId, downloadGuid, fileName);
232 builder.addAction(R.drawable.ic_vidcontrol_pause, 233 builder.addAction(R.drawable.ic_vidcontrol_pause,
233 mContext.getResources().getString(R.string.download_notification _pause_button), 234 mContext.getResources().getString(R.string.download_notification _pause_button),
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 if (intent.getAction() == ACTION_DOWNLOAD_RESUME_ALL) return null; 417 if (intent.getAction() == ACTION_DOWNLOAD_RESUME_ALL) return null;
417 String guid = IntentUtils.safeGetStringExtra(intent, EXTRA_DOWNLOAD_GUID ); 418 String guid = IntentUtils.safeGetStringExtra(intent, EXTRA_DOWNLOAD_GUID );
418 DownloadSharedPreferenceEntry entry = getDownloadSharedPreferenceEntry(g uid); 419 DownloadSharedPreferenceEntry entry = getDownloadSharedPreferenceEntry(g uid);
419 if (entry != null) return entry; 420 if (entry != null) return entry;
420 int notificationId = IntentUtils.safeGetIntExtra( 421 int notificationId = IntentUtils.safeGetIntExtra(
421 intent, EXTRA_DOWNLOAD_NOTIFICATION_ID, -1); 422 intent, EXTRA_DOWNLOAD_NOTIFICATION_ID, -1);
422 String fileName = IntentUtils.safeGetStringExtra(intent, EXTRA_DOWNLOAD_ FILE_NAME); 423 String fileName = IntentUtils.safeGetStringExtra(intent, EXTRA_DOWNLOAD_ FILE_NAME);
423 boolean metered = DownloadManagerService.isActiveNetworkMetered(mContext ); 424 boolean metered = DownloadManagerService.isActiveNetworkMetered(mContext );
424 boolean isOffTheRecord = IntentUtils.safeGetBooleanExtra( 425 boolean isOffTheRecord = IntentUtils.safeGetBooleanExtra(
425 intent, EXTRA_DOWNLOAD_IS_OFF_THE_RECORD, false); 426 intent, EXTRA_DOWNLOAD_IS_OFF_THE_RECORD, false);
426 return new DownloadSharedPreferenceEntry( 427 return new DownloadSharedPreferenceEntry(notificationId, isOffTheRecord, metered, guid,
427 notificationId, isOffTheRecord, metered, guid, fileName); 428 fileName, DownloadSharedPreferenceEntry.ITEM_TYPE_DOWNLOAD);
428 } 429 }
429 430
430 /** 431 /**
431 * Helper method to launch the browser process and handle a download operati on that is included 432 * Helper method to launch the browser process and handle a download operati on that is included
432 * in the given intent. 433 * in the given intent.
433 * @param intent Intent with the download operation. 434 * @param intent Intent with the download operation.
434 */ 435 */
435 private void handleDownloadOperation(final Intent intent) { 436 private void handleDownloadOperation(final Intent intent) {
436 final DownloadSharedPreferenceEntry entry = getDownloadEntryFromIntent(i ntent); 437 final DownloadSharedPreferenceEntry entry = getDownloadEntryFromIntent(i ntent);
437 if (intent.getAction() == ACTION_DOWNLOAD_PAUSE) { 438 if (intent.getAction() == ACTION_DOWNLOAD_PAUSE) {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 return context.getString(R.string.remaining_duration_minutes, minute s); 710 return context.getString(R.string.remaining_duration_minutes, minute s);
710 } else if (minutes > 0) { 711 } else if (minutes > 0) {
711 return context.getString(R.string.remaining_duration_one_minute); 712 return context.getString(R.string.remaining_duration_one_minute);
712 } else if (seconds == 1) { 713 } else if (seconds == 1) {
713 return context.getString(R.string.remaining_duration_one_second); 714 return context.getString(R.string.remaining_duration_one_second);
714 } else { 715 } else {
715 return context.getString(R.string.remaining_duration_seconds, second s); 716 return context.getString(R.string.remaining_duration_seconds, second s);
716 } 717 }
717 } 718 }
718 } 719 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/download/DownloadSharedPreferenceEntry.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698