| OLD | NEW |
| 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.Notification; | 7 import android.app.Notification; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.graphics.Bitmap; |
| 9 import android.util.Pair; | 10 import android.util.Pair; |
| 10 | 11 |
| 11 import org.chromium.base.ThreadUtils; | 12 import org.chromium.base.ThreadUtils; |
| 12 import org.chromium.components.offline_items_collection.ContentId; | 13 import org.chromium.components.offline_items_collection.ContentId; |
| 13 | 14 |
| 14 import java.util.ArrayList; | 15 import java.util.ArrayList; |
| 15 import java.util.List; | 16 import java.util.List; |
| 16 import java.util.concurrent.Callable; | 17 import java.util.concurrent.Callable; |
| 17 | 18 |
| 18 /** | 19 /** |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 90 } |
| 90 | 91 |
| 91 @Override | 92 @Override |
| 92 public Context getApplicationContext() { | 93 public Context getApplicationContext() { |
| 93 return mContext == null ? super.getApplicationContext() : mContext; | 94 return mContext == null ? super.getApplicationContext() : mContext; |
| 94 } | 95 } |
| 95 | 96 |
| 96 @Override | 97 @Override |
| 97 public int notifyDownloadSuccessful(final ContentId id, final String filePat
h, | 98 public int notifyDownloadSuccessful(final ContentId id, final String filePat
h, |
| 98 final String fileName, final long systemDownloadId, final boolean is
OffTheRecord, | 99 final String fileName, final long systemDownloadId, final boolean is
OffTheRecord, |
| 99 final boolean isSupportedMimeType, final boolean isOpenable) { | 100 final boolean isSupportedMimeType, final boolean isOpenable, final B
itmap icon) { |
| 100 return ThreadUtils.runOnUiThreadBlockingNoException(new Callable<Integer
>() { | 101 return ThreadUtils.runOnUiThreadBlockingNoException(new Callable<Integer
>() { |
| 101 @Override | 102 @Override |
| 102 public Integer call() throws Exception { | 103 public Integer call() throws Exception { |
| 103 return MockDownloadNotificationService.super.notifyDownloadSucce
ssful(id, filePath, | 104 return MockDownloadNotificationService.super.notifyDownloadSucce
ssful(id, filePath, |
| 104 fileName, systemDownloadId, isOffTheRecord, isSupportedM
imeType, | 105 fileName, systemDownloadId, isOffTheRecord, isSupportedM
imeType, isOpenable, |
| 105 isOpenable); | 106 icon); |
| 106 } | 107 } |
| 107 }); | 108 }); |
| 108 } | 109 } |
| 109 | 110 |
| 110 @Override | 111 @Override |
| 111 public void notifyDownloadProgress(final ContentId id, final String fileName
, | 112 public void notifyDownloadProgress(final ContentId id, final String fileName
, |
| 112 final int percentage, final long bytesReceived, final long timeRemai
ningInMillis, | 113 final int percentage, final long bytesReceived, final long timeRemai
ningInMillis, |
| 113 final long startTime, final boolean isOffTheRecord, | 114 final long startTime, final boolean isOffTheRecord, |
| 114 final boolean canDownloadWhileMetered, final boolean isTransient) { | 115 final boolean canDownloadWhileMetered, final boolean isTransient, fi
nal Bitmap icon) { |
| 115 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 116 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 116 @Override | 117 @Override |
| 117 public void run() { | 118 public void run() { |
| 118 MockDownloadNotificationService.super.notifyDownloadProgress(id,
fileName, | 119 MockDownloadNotificationService.super.notifyDownloadProgress(id,
fileName, |
| 119 percentage, bytesReceived, timeRemainingInMillis, startT
ime, isOffTheRecord, | 120 percentage, bytesReceived, timeRemainingInMillis, startT
ime, isOffTheRecord, |
| 120 canDownloadWhileMetered, isTransient); | 121 canDownloadWhileMetered, isTransient, icon); |
| 121 } | 122 } |
| 122 }); | 123 }); |
| 123 } | 124 } |
| 124 | 125 |
| 125 @Override | 126 @Override |
| 126 public void notifyDownloadFailed(final ContentId id, final String fileName)
{ | 127 public void notifyDownloadFailed(final ContentId id, final String fileName,
final Bitmap icon) { |
| 127 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 128 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 128 @Override | 129 @Override |
| 129 public void run() { | 130 public void run() { |
| 130 MockDownloadNotificationService.super.notifyDownloadFailed(id, f
ileName); | 131 MockDownloadNotificationService.super.notifyDownloadFailed(id, f
ileName, icon); |
| 131 } | 132 } |
| 132 }); | 133 }); |
| 133 } | 134 } |
| 134 | 135 |
| 135 @Override | 136 @Override |
| 136 public void notifyDownloadCanceled(final ContentId id) { | 137 public void notifyDownloadCanceled(final ContentId id) { |
| 137 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 138 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 138 @Override | 139 @Override |
| 139 public void run() { | 140 public void run() { |
| 140 MockDownloadNotificationService.super.notifyDownloadCanceled(id)
; | 141 MockDownloadNotificationService.super.notifyDownloadCanceled(id)
; |
| 141 } | 142 } |
| 142 }); | 143 }); |
| 143 } | 144 } |
| 144 } | 145 } |
| 145 | 146 |
| OLD | NEW |