summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpaul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 00:24:20 +0000
committerpaul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 00:24:20 +0000
commit93b552eb1179e797613e64e4dd7eac4ac8fbb8bd (patch)
tree1d4241b7ce281a996dfdda860261ab38e949ba0a /chrome
parente2dc90d2515e013f493fade45da468cfae9c2187 (diff)
downloadchromium_src-93b552eb1179e797613e64e4dd7eac4ac8fbb8bd.zip
chromium_src-93b552eb1179e797613e64e4dd7eac4ac8fbb8bd.tar.gz
chromium_src-93b552eb1179e797613e64e4dd7eac4ac8fbb8bd.tar.bz2
Commit patch for Pierre-Antoine LaFayette, original CL:
http://codereview.chromium.org/164119 Items in the Downloads page should be loaded like a normal OS file when dragged to a Tab content area. We need the URL to be set to the file path in the IDataObject so that WebDropData can properly handle the file. BUG=9266 TEST=Drag an item with a supported MIME type from the Downloads page to a Tab content area. It should load within the browser. Drag an item with an unsupported MIME type and it should not open it. Review URL: http://codereview.chromium.org/165260 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22983 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/download/download_util.cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index af6ca99..0d9b5a9 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -19,6 +19,7 @@
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
+#include "net/base/mime_util.h"
#include "skia/ext/image_operations.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkShader.h"
@@ -242,10 +243,22 @@ void DragDownload(const DownloadItem* download, SkBitmap* icon) {
// Set up our OLE machinery
scoped_refptr<OSExchangeData> data(new OSExchangeData);
+
+ const FilePath::StringType file_name = download->file_name().value();
if (icon)
- drag_utils::CreateDragImageForFile(download->file_name().ToWStringHack(),
- icon, data);
- data->SetFilename(download->full_path().ToWStringHack());
+ drag_utils::CreateDragImageForFile(file_name, icon, data);
+
+ const FilePath full_path = download->full_path();
+ data->SetFilename(full_path.value());
+
+ std::string mime_type = download->mime_type();
+ if (mime_type.empty())
+ net::GetMimeTypeFromFile(full_path, &mime_type);
+
+ // Add URL so that we can load supported files when dragged to TabContents.
+ if (net::IsSupportedMimeType(mime_type))
+ data->SetURL(GURL(full_path.value()), file_name);
+
scoped_refptr<BaseDragSource> drag_source(new BaseDragSource);
// Run the drag and drop loop