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/web_contents/web_drag_source_mac.h" | 5 #import "content/browser/web_contents/web_drag_source_mac.h" |
6 | 6 |
7 #include <sys/param.h> | 7 #include <sys/param.h> |
8 | 8 |
| 9 #include <utility> |
| 10 |
9 #include "base/bind.h" | 11 #include "base/bind.h" |
10 #include "base/files/file.h" | 12 #include "base/files/file.h" |
11 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
12 #include "base/mac/foundation_util.h" | 14 #include "base/mac/foundation_util.h" |
13 #include "base/pickle.h" | 15 #include "base/pickle.h" |
14 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
15 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
16 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
17 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
18 #include "base/threading/thread_restrictions.h" | 20 #include "base/threading/thread_restrictions.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 308 |
307 // CreateFileForDrop() will call base::PathExists(), | 309 // CreateFileForDrop() will call base::PathExists(), |
308 // which is blocking. Since this operation is already blocking the | 310 // which is blocking. Since this operation is already blocking the |
309 // UI thread on OSX, it should be reasonable to let it happen. | 311 // UI thread on OSX, it should be reasonable to let it happen. |
310 base::ThreadRestrictions::ScopedAllowIO allowIO; | 312 base::ThreadRestrictions::ScopedAllowIO allowIO; |
311 base::File file(content::CreateFileForDrop(&filePath)); | 313 base::File file(content::CreateFileForDrop(&filePath)); |
312 if (!file.IsValid()) | 314 if (!file.IsValid()) |
313 return nil; | 315 return nil; |
314 | 316 |
315 if (downloadURL_.is_valid() && contents_) { | 317 if (downloadURL_.is_valid() && contents_) { |
316 scoped_refptr<DragDownloadFile> dragFileDownloader(new DragDownloadFile( | 318 scoped_refptr<DragDownloadFile> dragFileDownloader( |
317 filePath, | 319 new DragDownloadFile(filePath, std::move(file), downloadURL_, |
318 file.Pass(), | 320 content::Referrer(contents_->GetLastCommittedURL(), |
319 downloadURL_, | 321 dropData_->referrer_policy), |
320 content::Referrer(contents_->GetLastCommittedURL(), | 322 contents_->GetEncoding(), contents_)); |
321 dropData_->referrer_policy), | |
322 contents_->GetEncoding(), | |
323 contents_)); | |
324 | 323 |
325 // The finalizer will take care of closing and deletion. | 324 // The finalizer will take care of closing and deletion. |
326 dragFileDownloader->Start(new PromiseFileFinalizer( | 325 dragFileDownloader->Start(new PromiseFileFinalizer( |
327 dragFileDownloader.get())); | 326 dragFileDownloader.get())); |
328 } else { | 327 } else { |
329 // The writer will take care of closing and deletion. | 328 // The writer will take care of closing and deletion. |
330 BrowserThread::PostTask(BrowserThread::FILE, | 329 BrowserThread::PostTask(BrowserThread::FILE, |
331 FROM_HERE, | 330 FROM_HERE, |
332 base::Bind(&PromiseWriterHelper, | 331 base::Bind(&PromiseWriterHelper, |
333 *dropData_, | 332 *dropData_, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 - (NSImage*)dragImage { | 462 - (NSImage*)dragImage { |
464 if (dragImage_) | 463 if (dragImage_) |
465 return dragImage_; | 464 return dragImage_; |
466 | 465 |
467 // Default to returning a generic image. | 466 // Default to returning a generic image. |
468 return content::GetContentClient()->GetNativeImageNamed( | 467 return content::GetContentClient()->GetNativeImageNamed( |
469 IDR_DEFAULT_FAVICON).ToNSImage(); | 468 IDR_DEFAULT_FAVICON).ToNSImage(); |
470 } | 469 } |
471 | 470 |
472 @end // @implementation WebDragSource (Private) | 471 @end // @implementation WebDragSource (Private) |
OLD | NEW |