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

Side by Side Diff: chrome/browser/download/download_util.cc

Issue 164119: Items in the Downloads page should be loaded like a normal OS file when dragg... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Download utility implementation 5 // Download utility implementation
6 6
7 #include "chrome/browser/download/download_util.h" 7 #include "chrome/browser/download/download_util.h"
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "app/gfx/canvas.h" 11 #include "app/gfx/canvas.h"
12 #include "app/l10n_util.h" 12 #include "app/l10n_util.h"
13 #include "app/resource_bundle.h" 13 #include "app/resource_bundle.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/download/download_item_model.h" 17 #include "chrome/browser/download/download_item_model.h"
18 #include "chrome/browser/download/download_manager.h" 18 #include "chrome/browser/download/download_manager.h"
19 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
20 #include "grit/locale_settings.h" 20 #include "grit/locale_settings.h"
21 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
22 #include "net/base/mime_util.h"
22 #include "skia/ext/image_operations.h" 23 #include "skia/ext/image_operations.h"
23 #include "third_party/skia/include/core/SkPath.h" 24 #include "third_party/skia/include/core/SkPath.h"
24 #include "third_party/skia/include/core/SkShader.h" 25 #include "third_party/skia/include/core/SkShader.h"
25 26
26 #if defined(OS_WIN) || defined(TOOLKIT_VIEWS) 27 #if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
27 #include "app/os_exchange_data.h" 28 #include "app/os_exchange_data.h"
28 #endif 29 #endif
29 30
30 #if defined(OS_WIN) 31 #if defined(OS_WIN)
31 #include "base/base_drag_source.h" 32 #include "base/base_drag_source.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 236 }
236 237
237 #if defined(OS_WIN) || defined(TOOLKIT_VIEWS) 238 #if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
238 // Download dragging 239 // Download dragging
239 void DragDownload(const DownloadItem* download, SkBitmap* icon) { 240 void DragDownload(const DownloadItem* download, SkBitmap* icon) {
240 #if defined(OS_WIN) 241 #if defined(OS_WIN)
241 DCHECK(download); 242 DCHECK(download);
242 243
243 // Set up our OLE machinery 244 // Set up our OLE machinery
244 scoped_refptr<OSExchangeData> data(new OSExchangeData); 245 scoped_refptr<OSExchangeData> data(new OSExchangeData);
246
247 const FilePath::StringType file_name = download->file_name().value();
245 if (icon) 248 if (icon)
246 drag_utils::CreateDragImageForFile(download->file_name().ToWStringHack(), 249 drag_utils::CreateDragImageForFile(file_name, icon, data);
247 icon, data); 250
248 data->SetFilename(download->full_path().ToWStringHack()); 251 const FilePath full_path = download->full_path();
252 data->SetFilename(full_path.value());
253
254 std::string mime_type = download->mime_type();
255 if (mime_type.empty())
256 net::GetMimeTypeFromFile(full_path, &mime_type);
257
258 // Add URL so that we can load supported files when dragged to TabContents.
259 if (net::IsSupportedMimeType(mime_type))
260 data->SetURL(GURL(full_path.value()), file_name);
261
249 scoped_refptr<BaseDragSource> drag_source(new BaseDragSource); 262 scoped_refptr<BaseDragSource> drag_source(new BaseDragSource);
250 263
251 // Run the drag and drop loop 264 // Run the drag and drop loop
252 DWORD effects; 265 DWORD effects;
253 DoDragDrop(data.get(), drag_source.get(), DROPEFFECT_COPY | DROPEFFECT_LINK, 266 DoDragDrop(data.get(), drag_source.get(), DROPEFFECT_COPY | DROPEFFECT_LINK,
254 &effects); 267 &effects);
255 #else 268 #else
256 NOTIMPLEMENTED(); 269 NOTIMPLEMENTED();
257 #endif 270 #endif
258 } 271 }
259 #endif 272 #endif
260 273
261 } // namespace download_util 274 } // namespace download_util
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698