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 7544e134e0e26ebbc6eaa5b817811820e69ef6ed..ce8b92ff88fe9a96f0107c14054b00a3c4400428 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 |
@@ -497,6 +497,7 @@ public class DownloadNotificationService extends Service { |
? DownloadSharedPreferenceEntry.ITEM_TYPE_OFFLINE_PAGE |
: DownloadSharedPreferenceEntry.ITEM_TYPE_DOWNLOAD); |
DownloadServiceDelegate downloadServiceDelegate = getServiceDelegate(itemType); |
+ boolean destroyImmediately = true; |
switch (intent.getAction()) { |
case ACTION_DOWNLOAD_CANCEL: |
// TODO(qinmin): Alternatively, we can delete the downloaded content on |
@@ -522,15 +523,27 @@ public class DownloadNotificationService extends Service { |
resumeAllPendingDownloads(); |
break; |
case ACTION_DOWNLOAD_OPEN: |
- assert entry == null; |
- String guid = IntentUtils.safeGetStringExtra(intent, EXTRA_DOWNLOAD_GUID); |
- downloadServiceDelegate.openItem(guid); |
+ 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(); |
+ } |
+ }); |
break; |
default: |
Log.e(TAG, "Unrecognized intent action.", intent); |
break; |
} |
- downloadServiceDelegate.destroyServiceDelegate(); |
+ if (destroyImmediately) { |
+ downloadServiceDelegate.destroyServiceDelegate(); |
+ } |
} |
}; |
try { |