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

Unified Diff: chrome/browser/extensions/api/downloads/downloads_api.cc

Issue 11566012: Implement chrome.downloads.drag() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r174808 Created 7 years, 12 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
« no previous file with comments | « no previous file | chrome/common/extensions/api/downloads.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/downloads/downloads_api.cc
diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc
index afc5fb7cb8dde580a590bf957f3f6bf0efbd11c4..c644bef8323ff0ef37541fcef2b94a6f89e7c9b5 100644
--- a/chrome/browser/extensions/api/downloads/downloads_api.cc
+++ b/chrome/browser/extensions/api/downloads/downloads_api.cc
@@ -32,6 +32,7 @@
#include "chrome/browser/download/download_util.h"
#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
+#include "chrome/browser/extensions/extension_function_dispatcher.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/icon_loader.h"
#include "chrome/browser/icon_manager.h"
@@ -50,6 +51,7 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/resource_dispatcher_host.h"
+#include "content/public/browser/web_contents.h"
#include "net/base/load_flags.h"
#include "net/http/http_util.h"
#include "net/url_request/url_request.h"
@@ -850,10 +852,24 @@ bool DownloadsDragFunction::RunImpl() {
scoped_ptr<extensions::api::downloads::Drag::Params> params(
extensions::api::downloads::Drag::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
- error_ = download_extension_errors::kNotImplementedError;
- if (error_.empty())
- RecordApiFunctions(DOWNLOADS_FUNCTION_DRAG);
- return error_.empty();
+ DownloadItem* download_item = GetDownload(
+ profile(), include_incognito(), params->download_id);
+ content::WebContents* web_contents =
+ dispatcher()->delegate()->GetAssociatedWebContents();
+ if (!download_item || !web_contents) {
+ error_ = download_extension_errors::kInvalidOperationError;
+ return false;
+ }
+ RecordApiFunctions(DOWNLOADS_FUNCTION_DRAG);
+ gfx::Image* icon = g_browser_process->icon_manager()->LookupIcon(
+ download_item->GetUserVerifiedFilePath(), IconLoader::NORMAL);
+ gfx::NativeView view = web_contents->GetNativeView();
+ {
+ // Enable nested tasks during DnD, while |DragDownload()| blocks.
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
+ download_util::DragDownload(download_item, icon, view);
+ }
+ return true;
}
DownloadsGetFileIconFunction::DownloadsGetFileIconFunction()
« no previous file with comments | « no previous file | chrome/common/extensions/api/downloads.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698