OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/tab_contents/web_drag_source_mac.h" | 5 #import "content/browser/tab_contents/web_drag_source_mac.h" |
6 | 6 |
7 #include <sys/param.h> | 7 #include <sys/param.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/pickle.h" | 11 #include "base/pickle.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.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 #include "content/browser/browser_thread_impl.h" | 17 #include "content/browser/browser_thread_impl.h" |
18 #include "content/browser/download/drag_download_file.h" | 18 #include "content/browser/download/drag_download_file.h" |
19 #include "content/browser/download/drag_download_util.h" | 19 #include "content/browser/download/drag_download_util.h" |
20 #include "content/browser/renderer_host/render_view_host.h" | 20 #include "content/browser/renderer_host/render_view_host.h" |
21 #include "content/browser/tab_contents/tab_contents.h" | 21 #include "content/browser/tab_contents/tab_contents.h" |
22 #include "content/public/browser/content_browser_client.h" | 22 #include "content/public/browser/content_browser_client.h" |
| 23 #include "content/public/common/content_client.h" |
23 #include "content/public/common/url_constants.h" | 24 #include "content/public/common/url_constants.h" |
24 #include "net/base/file_stream.h" | 25 #include "net/base/file_stream.h" |
25 #include "net/base/net_util.h" | 26 #include "net/base/net_util.h" |
26 #include "ui/base/clipboard/custom_data_helper.h" | 27 #include "ui/base/clipboard/custom_data_helper.h" |
27 #include "ui/gfx/mac/nsimage_cache.h" | 28 #include "ui/gfx/mac/nsimage_cache.h" |
28 #include "webkit/glue/webdropdata.h" | 29 #include "webkit/glue/webdropdata.h" |
29 | 30 |
30 using base::SysNSStringToUTF8; | 31 using base::SysNSStringToUTF8; |
31 using base::SysUTF8ToNSString; | 32 using base::SysUTF8ToNSString; |
32 using base::SysUTF16ToNSString; | 33 using base::SysUTF16ToNSString; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 FilePath fileName = downloadFileName_.empty() ? | 317 FilePath fileName = downloadFileName_.empty() ? |
317 GetFileNameFromDragData(*dropData_) : downloadFileName_; | 318 GetFileNameFromDragData(*dropData_) : downloadFileName_; |
318 FilePath filePath(SysNSStringToUTF8(path)); | 319 FilePath filePath(SysNSStringToUTF8(path)); |
319 filePath = filePath.Append(fileName); | 320 filePath = filePath.Append(fileName); |
320 | 321 |
321 // CreateFileStreamForDrop() will call file_util::PathExists(), | 322 // CreateFileStreamForDrop() will call file_util::PathExists(), |
322 // which is blocking. Since this operation is already blocking the | 323 // which is blocking. Since this operation is already blocking the |
323 // UI thread on OSX, it should be reasonable to let it happen. | 324 // UI thread on OSX, it should be reasonable to let it happen. |
324 base::ThreadRestrictions::ScopedAllowIO allowIO; | 325 base::ThreadRestrictions::ScopedAllowIO allowIO; |
325 FileStream* fileStream = | 326 FileStream* fileStream = |
326 drag_download_util::CreateFileStreamForDrop(&filePath); | 327 drag_download_util::CreateFileStreamForDrop( |
| 328 &filePath, content::GetContentClient()->browser()->GetNetLog()); |
327 if (!fileStream) | 329 if (!fileStream) |
328 return nil; | 330 return nil; |
329 | 331 |
330 if (downloadURL_.is_valid()) { | 332 if (downloadURL_.is_valid()) { |
331 scoped_refptr<DragDownloadFile> dragFileDownloader(new DragDownloadFile( | 333 scoped_refptr<DragDownloadFile> dragFileDownloader(new DragDownloadFile( |
332 filePath, | 334 filePath, |
333 linked_ptr<net::FileStream>(fileStream), | 335 linked_ptr<net::FileStream>(fileStream), |
334 downloadURL_, | 336 downloadURL_, |
335 contents_->GetURL(), | 337 contents_->GetURL(), |
336 contents_->GetEncoding(), | 338 contents_->GetEncoding(), |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 442 |
441 - (NSImage*)dragImage { | 443 - (NSImage*)dragImage { |
442 if (dragImage_) | 444 if (dragImage_) |
443 return dragImage_; | 445 return dragImage_; |
444 | 446 |
445 // Default to returning a generic image. | 447 // Default to returning a generic image. |
446 return gfx::GetCachedImageWithName(@"nav.pdf"); | 448 return gfx::GetCachedImageWithName(@"nav.pdf"); |
447 } | 449 } |
448 | 450 |
449 @end // @implementation WebDragSource (Private) | 451 @end // @implementation WebDragSource (Private) |
OLD | NEW |