Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/cocoa/tab_contents/web_drag_source.h" | 5 #import "chrome/browser/ui/cocoa/tab_contents/web_drag_source.h" |
| 6 | 6 |
| 7 #include <sys/param.h> | 7 #include <sys/param.h> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/mac/crash_logging.h" | 10 #include "base/mac/crash_logging.h" |
|
Robert Sesek
2011/10/24 16:59:52
Can you remove this, too?
| |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/sys_string_conversions.h" | 12 #include "base/sys_string_conversions.h" |
| 13 #include "base/task.h" | 13 #include "base/task.h" |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #import "chrome/app/breakpad_mac.h" | |
| 18 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/download/download_util.h" | 18 #include "chrome/browser/download/download_util.h" |
| 20 #include "chrome/browser/tab_contents/tab_contents_view_mac.h" | 19 #include "chrome/browser/tab_contents/tab_contents_view_mac.h" |
| 21 #include "content/browser/download/download_manager.h" | 20 #include "content/browser/download/download_manager.h" |
| 22 #include "content/browser/download/drag_download_file.h" | 21 #include "content/browser/download/drag_download_file.h" |
| 23 #include "content/browser/download/drag_download_util.h" | 22 #include "content/browser/download/drag_download_util.h" |
| 24 #include "content/browser/renderer_host/render_view_host.h" | 23 #include "content/browser/renderer_host/render_view_host.h" |
| 25 #include "content/browser/tab_contents/tab_contents.h" | 24 #include "content/browser/tab_contents/tab_contents.h" |
| 26 #include "content/public/common/url_constants.h" | 25 #include "content/public/common/url_constants.h" |
| 27 #include "net/base/file_stream.h" | 26 #include "net/base/file_stream.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 50 char buf[MAXPATHLEN]; | 49 char buf[MAXPATHLEN]; |
| 51 if (![str getFileSystemRepresentation:buf maxLength:sizeof(buf)]) | 50 if (![str getFileSystemRepresentation:buf maxLength:sizeof(buf)]) |
| 52 return FilePath(); | 51 return FilePath(); |
| 53 return FilePath(buf); | 52 return FilePath(buf); |
| 54 } | 53 } |
| 55 | 54 |
| 56 // Returns a filename appropriate for the drop data | 55 // Returns a filename appropriate for the drop data |
| 57 // TODO(viettrungluu): Refactor to make it common across platforms, | 56 // TODO(viettrungluu): Refactor to make it common across platforms, |
| 58 // and move it somewhere sensible. | 57 // and move it somewhere sensible. |
| 59 FilePath GetFileNameFromDragData(const WebDropData& drop_data) { | 58 FilePath GetFileNameFromDragData(const WebDropData& drop_data) { |
| 60 // Set a breakpad key for the scope of this function to help debug | |
| 61 // http://crbug.com/78782 | |
| 62 static NSString* const kUrlKey = @"drop_data_url"; | |
| 63 NSString* value = SysUTF8ToNSString(drop_data.url.spec()); | |
| 64 base::mac::ScopedCrashKey key(kUrlKey, value); | |
| 65 | |
| 66 // Images without ALT text will only have a file extension so we need to | 59 // Images without ALT text will only have a file extension so we need to |
| 67 // synthesize one from the provided extension and URL. | 60 // synthesize one from the provided extension and URL. |
| 68 FilePath file_name(FilePathFromFilename(drop_data.file_description_filename)); | 61 FilePath file_name(FilePathFromFilename(drop_data.file_description_filename)); |
| 69 file_name = file_name.BaseName().RemoveExtension(); | 62 file_name = file_name.BaseName().RemoveExtension(); |
| 70 | 63 |
| 71 if (file_name.empty()) { | 64 if (file_name.empty()) { |
| 72 // Retrieve the name from the URL. | 65 // Retrieve the name from the URL. |
| 73 string16 suggested_filename = | 66 string16 suggested_filename = |
| 74 net::GetSuggestedFilename(drop_data.url, "", "", "", "", std::string()); | 67 net::GetSuggestedFilename(drop_data.url, "", "", "", "", std::string()); |
| 75 file_name = FilePathFromFilename(suggested_filename); | 68 file_name = FilePathFromFilename(suggested_filename); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 | 441 |
| 449 - (NSImage*)dragImage { | 442 - (NSImage*)dragImage { |
| 450 if (dragImage_) | 443 if (dragImage_) |
| 451 return dragImage_; | 444 return dragImage_; |
| 452 | 445 |
| 453 // Default to returning a generic image. | 446 // Default to returning a generic image. |
| 454 return gfx::GetCachedImageWithName(@"nav.pdf"); | 447 return gfx::GetCachedImageWithName(@"nav.pdf"); |
| 455 } | 448 } |
| 456 | 449 |
| 457 @end // @implementation WebDragSource (Private) | 450 @end // @implementation WebDragSource (Private) |
| OLD | NEW |