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

Unified Diff: chrome/browser/download/download_ui_controller.cc

Issue 230103002: [Downloads] Ask DownloadHistory if a download was from history. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_ui_controller.cc
diff --git a/chrome/browser/download/download_ui_controller.cc b/chrome/browser/download/download_ui_controller.cc
index 89a3694d8b5592ffca30fb61979f64df5e22a32a..f584ef7959c3dda7bc31a15e31a9231c64795f9b 100644
--- a/chrome/browser/download/download_ui_controller.cc
+++ b/chrome/browser/download/download_ui_controller.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/download/download_ui_controller.h"
+#include "base/callback.h"
#include "base/stl_util.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -32,11 +33,17 @@ class DefaultUIControllerDelegateAndroid
private:
// DownloadUIController::Delegate
- virtual void NotifyDownloadStarting(content::DownloadItem* item) OVERRIDE;
+ virtual void OnNewDownloadReady(content::DownloadItem* item) OVERRIDE;
};
-void DefaultUIControllerDelegateAndroid::NotifyDownloadStarting(
+void DefaultUIControllerDelegateAndroid::OnNewDownloadReady(
content::DownloadItem* item) {
+ // The Android DownloadController is only interested in IN_PROGRESS downloads.
+ // Ones which are INTERRUPTED etc. can't be handed over to the Android
+ // DownloadManager.
+ if (item->GetState() != content::DownloadItem::IN_PROGRESS)
+ return;
+
// GET downloads without authentication are delegated to the Android
// DownloadManager. Chrome is responsible for the rest. See
// InterceptDownloadResourceThrottle::ProcessDownloadRequest().
@@ -54,12 +61,12 @@ class DefaultUIControllerDelegate : public DownloadUIController::Delegate {
private:
// DownloadUIController::Delegate
- virtual void NotifyDownloadStarting(content::DownloadItem* item) OVERRIDE;
+ virtual void OnNewDownloadReady(content::DownloadItem* item) OVERRIDE;
Profile* profile_;
};
-void DefaultUIControllerDelegate::NotifyDownloadStarting(
+void DefaultUIControllerDelegate::OnNewDownloadReady(
content::DownloadItem* item) {
content::WebContents* web_contents = item->GetWebContents();
Browser* browser =
@@ -105,11 +112,6 @@ DownloadUIController::~DownloadUIController() {
void DownloadUIController::OnDownloadCreated(content::DownloadManager* manager,
content::DownloadItem* item) {
- // If this isn't a new download, there's nothing to do.
- if (item->GetState() != content::DownloadItem::IN_PROGRESS)
- return;
-
- DownloadItemModel(item).SetShouldNotifyUI(true);
// SavePackage downloads are created in a state where they can be shown in the
// browser. Call OnDownloadUpdated() once to notify the UI immediately.
OnDownloadUpdated(manager, item);
@@ -117,19 +119,17 @@ void DownloadUIController::OnDownloadCreated(content::DownloadManager* manager,
void DownloadUIController::OnDownloadUpdated(content::DownloadManager* manager,
content::DownloadItem* item) {
+ DownloadItemModel item_model(item);
+
// Ignore if we've already notified the UI about |item| or if it isn't a new
// download.
- if (!DownloadItemModel(item).ShouldNotifyUI())
+ if (item_model.WasUINotified() || !item_model.ShouldNotifyUI())
return;
// Wait until the target path is determined.
if (item->GetTargetFilePath().empty())
return;
- // Can't be complete. That would imply that we didn't receive an
- // OnDownloadUpdated() after the target was determined.
- DCHECK_NE(content::DownloadItem::COMPLETE, item->GetState());
-
- DownloadItemModel(item).SetShouldNotifyUI(false);
- delegate_->NotifyDownloadStarting(item);
+ DownloadItemModel(item).SetWasUINotified(true);
+ delegate_->OnNewDownloadReady(item);
}
« no previous file with comments | « chrome/browser/download/download_ui_controller.h ('k') | chrome/browser/download/download_ui_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698