OLD | NEW |
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" |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 GetFileNameFromDragData(*dropData_) : downloadFileName_; | 300 GetFileNameFromDragData(*dropData_) : downloadFileName_; |
301 FilePath filePath(SysNSStringToUTF8(path)); | 301 FilePath filePath(SysNSStringToUTF8(path)); |
302 filePath = filePath.Append(fileName); | 302 filePath = filePath.Append(fileName); |
303 FileStream* fileStream = | 303 FileStream* fileStream = |
304 drag_download_util::CreateFileStreamForDrop(&filePath); | 304 drag_download_util::CreateFileStreamForDrop(&filePath); |
305 if (!fileStream) | 305 if (!fileStream) |
306 return nil; | 306 return nil; |
307 | 307 |
308 if (downloadURL_.is_valid()) { | 308 if (downloadURL_.is_valid()) { |
309 TabContents* tabContents = [contentsView_ tabContents]; | 309 TabContents* tabContents = [contentsView_ tabContents]; |
310 scoped_refptr<DragDownloadFile> dragFileDownloader = new DragDownloadFile( | 310 scoped_refptr<DragDownloadFile> dragFileDownloader(new DragDownloadFile( |
311 filePath, | 311 filePath, |
312 linked_ptr<net::FileStream>(fileStream), | 312 linked_ptr<net::FileStream>(fileStream), |
313 downloadURL_, | 313 downloadURL_, |
314 tabContents->GetURL(), | 314 tabContents->GetURL(), |
315 tabContents->encoding(), | 315 tabContents->encoding(), |
316 tabContents); | 316 tabContents)); |
317 | 317 |
318 // The finalizer will take care of closing and deletion. | 318 // The finalizer will take care of closing and deletion. |
319 dragFileDownloader->Start( | 319 dragFileDownloader->Start( |
320 new drag_download_util::PromiseFileFinalizer(dragFileDownloader)); | 320 new drag_download_util::PromiseFileFinalizer(dragFileDownloader)); |
321 } else { | 321 } else { |
322 // The writer will take care of closing and deletion. | 322 // The writer will take care of closing and deletion. |
323 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, | 323 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, |
324 new PromiseWriterTask(*dropData_, fileStream)); | 324 new PromiseWriterTask(*dropData_, fileStream)); |
325 } | 325 } |
326 | 326 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 | 403 |
404 - (NSImage*)dragImage { | 404 - (NSImage*)dragImage { |
405 if (dragImage_) | 405 if (dragImage_) |
406 return dragImage_; | 406 return dragImage_; |
407 | 407 |
408 // Default to returning a generic image. | 408 // Default to returning a generic image. |
409 return nsimage_cache::ImageNamed(@"nav.pdf"); | 409 return nsimage_cache::ImageNamed(@"nav.pdf"); |
410 } | 410 } |
411 | 411 |
412 @end // @implementation WebDragSource (Private) | 412 @end // @implementation WebDragSource (Private) |
OLD | NEW |