Index: chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java |
index b1eae15591a407831b1b75b2d5b63101cdef30bf..83bbc83c85b5503330af0f1eef055900f72b2212 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java |
@@ -505,8 +505,9 @@ public class DownloadNotificationService extends Service { |
: (intent.getAction() == ACTION_DOWNLOAD_OPEN |
? DownloadSharedPreferenceEntry.ITEM_TYPE_OFFLINE_PAGE |
: DownloadSharedPreferenceEntry.ITEM_TYPE_DOWNLOAD); |
- DownloadServiceDelegate downloadServiceDelegate = getServiceDelegate(itemType); |
- boolean destroyImmediately = true; |
+ DownloadServiceDelegate downloadServiceDelegate = |
+ intent.getAction() == ACTION_DOWNLOAD_OPEN ? null |
+ : getServiceDelegate(itemType); |
switch (intent.getAction()) { |
case ACTION_DOWNLOAD_CANCEL: |
// TODO(qinmin): Alternatively, we can delete the downloaded content on |
@@ -532,25 +533,14 @@ public class DownloadNotificationService extends Service { |
resumeAllPendingDownloads(); |
break; |
case ACTION_DOWNLOAD_OPEN: |
- final OfflinePageDownloadBridge bridge = |
- (OfflinePageDownloadBridge) downloadServiceDelegate; |
- destroyImmediately = false; |
- bridge.addObserver( |
- new OfflinePageDownloadBridge.Observer() { |
- @Override |
- public void onItemsLoaded() { |
- String guid = IntentUtils.safeGetStringExtra( |
- intent, EXTRA_DOWNLOAD_GUID); |
- bridge.openItem(guid); |
- bridge.destroyServiceDelegate(); |
- } |
- }); |
+ OfflinePageDownloadBridge.openDownloadedPage( |
+ IntentUtils.safeGetStringExtra(intent, EXTRA_DOWNLOAD_GUID)); |
break; |
default: |
Log.e(TAG, "Unrecognized intent action.", intent); |
break; |
} |
- if (destroyImmediately) { |
+ if (intent.getAction() != ACTION_DOWNLOAD_OPEN) { |
downloadServiceDelegate.destroyServiceDelegate(); |
} |
} |