| 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.ActivityManager; | 7 import android.app.ActivityManager; |
| 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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 } | 635 } |
| 636 | 636 |
| 637 if (ACTION_DOWNLOAD_PAUSE.equals(intent.getAction())) { | 637 if (ACTION_DOWNLOAD_PAUSE.equals(intent.getAction())) { |
| 638 // If browser process already goes away, the download should have al
ready paused. Do | 638 // If browser process already goes away, the download should have al
ready paused. Do |
| 639 // nothing in that case. | 639 // nothing in that case. |
| 640 if (!DownloadManagerService.hasDownloadManagerService()) { | 640 if (!DownloadManagerService.hasDownloadManagerService()) { |
| 641 notifyDownloadPaused(entry.downloadGuid, !entry.isOffTheRecord,
false); | 641 notifyDownloadPaused(entry.downloadGuid, !entry.isOffTheRecord,
false); |
| 642 return; | 642 return; |
| 643 } | 643 } |
| 644 } else if (ACTION_DOWNLOAD_RESUME.equals(intent.getAction())) { | 644 } else if (ACTION_DOWNLOAD_RESUME.equals(intent.getAction())) { |
| 645 boolean metered = DownloadManagerService.isActiveNetworkMetered(mCon
text); | 645 // If user manually resumes a download, update the network type if i
t |
| 646 if (!entry.canDownloadWhileMetered) { | 646 // is not metered previously. |
| 647 // If user manually resumes a download, update the network type
if it | 647 boolean canDownloadWhileMetered = entry.canDownloadWhileMetered |
| 648 // is not metered previously. | 648 || DownloadManagerService.isActiveNetworkMetered(mContext); |
| 649 entry.canDownloadWhileMetered = metered; | |
| 650 } | |
| 651 entry.isAutoResumable = true; | |
| 652 // Update the SharedPreference entry. | 649 // Update the SharedPreference entry. |
| 653 mDownloadSharedPreferenceHelper.addOrReplaceSharedPreferenceEntry(en
try); | 650 mDownloadSharedPreferenceHelper.addOrReplaceSharedPreferenceEntry( |
| 651 new DownloadSharedPreferenceEntry(entry.notificationId, entr
y.isOffTheRecord, |
| 652 canDownloadWhileMetered, entry.downloadGuid, entry.f
ileName, |
| 653 entry.itemType, true)); |
| 654 } else if (ACTION_DOWNLOAD_RESUME_ALL.equals(intent.getAction()) | 654 } else if (ACTION_DOWNLOAD_RESUME_ALL.equals(intent.getAction()) |
| 655 && (mDownloadSharedPreferenceHelper.getEntries().isEmpty() | 655 && (mDownloadSharedPreferenceHelper.getEntries().isEmpty() |
| 656 || DownloadManagerService.hasDownloadManagerService()))
{ | 656 || DownloadManagerService.hasDownloadManagerService()))
{ |
| 657 return; | 657 return; |
| 658 } else if (ACTION_DOWNLOAD_OPEN.equals(intent.getAction())) { | 658 } else if (ACTION_DOWNLOAD_OPEN.equals(intent.getAction())) { |
| 659 // TODO(fgorski): Do we even need to do anything special here, befor
e we launch Chrome? | 659 // TODO(fgorski): Do we even need to do anything special here, befor
e we launch Chrome? |
| 660 } | 660 } |
| 661 | 661 |
| 662 BrowserParts parts = new EmptyBrowserParts() { | 662 BrowserParts parts = new EmptyBrowserParts() { |
| 663 @Override | 663 @Override |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 return context.getString(R.string.remaining_duration_minutes, minute
s); | 877 return context.getString(R.string.remaining_duration_minutes, minute
s); |
| 878 } else if (minutes > 0) { | 878 } else if (minutes > 0) { |
| 879 return context.getString(R.string.remaining_duration_one_minute); | 879 return context.getString(R.string.remaining_duration_one_minute); |
| 880 } else if (seconds == 1) { | 880 } else if (seconds == 1) { |
| 881 return context.getString(R.string.remaining_duration_one_second); | 881 return context.getString(R.string.remaining_duration_one_second); |
| 882 } else { | 882 } else { |
| 883 return context.getString(R.string.remaining_duration_seconds, second
s); | 883 return context.getString(R.string.remaining_duration_seconds, second
s); |
| 884 } | 884 } |
| 885 } | 885 } |
| 886 } | 886 } |
| OLD | NEW |