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

Side by Side Diff: chrome/browser/cocoa/web_drag_source.mm

Issue 3043048: Clean up download code: (Closed)
Patch Set: Created 10 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
« no previous file with comments | « no previous file | chrome/browser/download/download_exe.cc » ('j') | 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 #import "chrome/browser/cocoa/web_drag_source.h" 5 #import "chrome/browser/cocoa/web_drag_source.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/nsimage_cache_mac.h" 8 #include "base/nsimage_cache_mac.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
11 #include "base/task.h" 11 #include "base/task.h"
12 #include "base/thread.h" 12 #include "base/thread.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/download/download_manager.h" 15 #include "chrome/browser/download/download_manager.h"
16 #include "chrome/browser/download/download_util.h"
16 #include "chrome/browser/download/drag_download_file.h" 17 #include "chrome/browser/download/drag_download_file.h"
17 #include "chrome/browser/download/drag_download_util.h" 18 #include "chrome/browser/download/drag_download_util.h"
18 #include "chrome/browser/renderer_host/render_view_host.h" 19 #include "chrome/browser/renderer_host/render_view_host.h"
19 #include "chrome/browser/tab_contents/tab_contents.h" 20 #include "chrome/browser/tab_contents/tab_contents.h"
20 #include "chrome/browser/tab_contents/tab_contents_view_mac.h" 21 #include "chrome/browser/tab_contents/tab_contents_view_mac.h"
21 #include "net/base/file_stream.h" 22 #include "net/base/file_stream.h"
22 #include "net/base/net_util.h" 23 #include "net/base/net_util.h"
23 #import "third_party/mozilla/NSPasteboard+Utils.h" 24 #import "third_party/mozilla/NSPasteboard+Utils.h"
24 #include "webkit/glue/webdropdata.h" 25 #include "webkit/glue/webdropdata.h"
25 26
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 } else { 361 } else {
361 string16 mimeType; 362 string16 mimeType;
362 FilePath fileName; 363 FilePath fileName;
363 if (drag_download_util::ParseDownloadMetadata( 364 if (drag_download_util::ParseDownloadMetadata(
364 dropData_->download_metadata, 365 dropData_->download_metadata,
365 &mimeType, 366 &mimeType,
366 &fileName, 367 &fileName,
367 &downloadURL_)) { 368 &downloadURL_)) {
368 std::string contentDisposition = 369 std::string contentDisposition =
369 "attachment; filename=" + fileName.value(); 370 "attachment; filename=" + fileName.value();
370 DownloadManager::GenerateFileName(downloadURL_, 371 download_util::GenerateFileName(downloadURL_,
371 contentDisposition, 372 contentDisposition,
372 std::string(), 373 std::string(),
373 UTF16ToUTF8(mimeType), 374 UTF16ToUTF8(mimeType),
374 &downloadFileName_); 375 &downloadFileName_);
375 fileExtension = SysUTF8ToNSString(downloadFileName_.Extension()); 376 fileExtension = SysUTF8ToNSString(downloadFileName_.Extension());
376 } 377 }
377 } 378 }
378 379
379 if (fileExtension) { 380 if (fileExtension) {
380 // File contents (with and without specific type), file (HFS) promise, 381 // File contents (with and without specific type), file (HFS) promise,
381 // TIFF. 382 // TIFF.
382 // TODO(viettrungluu): others? 383 // TODO(viettrungluu): others?
383 [pasteboard_ addTypes:[NSArray arrayWithObjects: 384 [pasteboard_ addTypes:[NSArray arrayWithObjects:
384 NSFileContentsPboardType, 385 NSFileContentsPboardType,
(...skipping 17 matching lines...) Expand all
402 403
403 - (NSImage*)dragImage { 404 - (NSImage*)dragImage {
404 if (dragImage_) 405 if (dragImage_)
405 return dragImage_; 406 return dragImage_;
406 407
407 // Default to returning a generic image. 408 // Default to returning a generic image.
408 return nsimage_cache::ImageNamed(@"nav.pdf"); 409 return nsimage_cache::ImageNamed(@"nav.pdf");
409 } 410 }
410 411
411 @end // @implementation WebDragSource (Private) 412 @end // @implementation WebDragSource (Private)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/download_exe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698