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 #include "content/browser/download/drag_download_file.h" | 5 #include "content/browser/download/drag_download_file.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/files/file.h" | 10 #include "base/files/file.h" |
9 #include "base/location.h" | 11 #include "base/location.h" |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
12 #include "build/build_config.h" | 14 #include "build/build_config.h" |
13 #include "content/browser/download/download_stats.h" | 15 #include "content/browser/download/download_stats.h" |
14 #include "content/browser/web_contents/web_contents_impl.h" | 16 #include "content/browser/web_contents/web_contents_impl.h" |
15 #include "content/public/browser/browser_context.h" | 17 #include "content/public/browser/browser_context.h" |
16 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 BrowserContext::GetDownloadManager(web_contents_->GetBrowserContext()); | 65 BrowserContext::GetDownloadManager(web_contents_->GetBrowserContext()); |
64 | 66 |
65 RecordDownloadSource(INITIATED_BY_DRAG_N_DROP); | 67 RecordDownloadSource(INITIATED_BY_DRAG_N_DROP); |
66 scoped_ptr<content::DownloadUrlParameters> params( | 68 scoped_ptr<content::DownloadUrlParameters> params( |
67 DownloadUrlParameters::FromWebContents(web_contents_, url_)); | 69 DownloadUrlParameters::FromWebContents(web_contents_, url_)); |
68 params->set_referrer(referrer_); | 70 params->set_referrer(referrer_); |
69 params->set_referrer_encoding(referrer_encoding_); | 71 params->set_referrer_encoding(referrer_encoding_); |
70 params->set_callback(base::Bind(&DragDownloadFileUI::OnDownloadStarted, | 72 params->set_callback(base::Bind(&DragDownloadFileUI::OnDownloadStarted, |
71 weak_ptr_factory_.GetWeakPtr())); | 73 weak_ptr_factory_.GetWeakPtr())); |
72 params->set_file_path(file_path); | 74 params->set_file_path(file_path); |
73 params->set_file(file.Pass()); // Nulls file. | 75 params->set_file(std::move(file)); // Nulls file. |
74 download_manager->DownloadUrl(params.Pass()); | 76 download_manager->DownloadUrl(std::move(params)); |
75 } | 77 } |
76 | 78 |
77 void Cancel() { | 79 void Cancel() { |
78 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 80 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
79 if (download_item_) | 81 if (download_item_) |
80 download_item_->Cancel(true); | 82 download_item_->Cancel(true); |
81 } | 83 } |
82 | 84 |
83 void Delete() { | 85 void Delete() { |
84 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 86 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 DISALLOW_COPY_AND_ASSIGN(DragDownloadFileUI); | 156 DISALLOW_COPY_AND_ASSIGN(DragDownloadFileUI); |
155 }; | 157 }; |
156 | 158 |
157 DragDownloadFile::DragDownloadFile(const base::FilePath& file_path, | 159 DragDownloadFile::DragDownloadFile(const base::FilePath& file_path, |
158 base::File file, | 160 base::File file, |
159 const GURL& url, | 161 const GURL& url, |
160 const Referrer& referrer, | 162 const Referrer& referrer, |
161 const std::string& referrer_encoding, | 163 const std::string& referrer_encoding, |
162 WebContents* web_contents) | 164 WebContents* web_contents) |
163 : file_path_(file_path), | 165 : file_path_(file_path), |
164 file_(file.Pass()), | 166 file_(std::move(file)), |
165 drag_message_loop_(base::MessageLoop::current()), | 167 drag_message_loop_(base::MessageLoop::current()), |
166 state_(INITIALIZED), | 168 state_(INITIALIZED), |
167 drag_ui_(NULL), | 169 drag_ui_(NULL), |
168 weak_ptr_factory_(this) { | 170 weak_ptr_factory_(this) { |
169 drag_ui_ = new DragDownloadFileUI( | 171 drag_ui_ = new DragDownloadFileUI( |
170 url, | 172 url, |
171 referrer, | 173 referrer, |
172 referrer_encoding, | 174 referrer_encoding, |
173 web_contents, | 175 web_contents, |
174 drag_message_loop_, | 176 drag_message_loop_, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 241 |
240 void DragDownloadFile::CheckThread() { | 242 void DragDownloadFile::CheckThread() { |
241 #if defined(OS_WIN) | 243 #if defined(OS_WIN) |
242 DCHECK(drag_message_loop_ == base::MessageLoop::current()); | 244 DCHECK(drag_message_loop_ == base::MessageLoop::current()); |
243 #else | 245 #else |
244 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 246 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
245 #endif | 247 #endif |
246 } | 248 } |
247 | 249 |
248 } // namespace content | 250 } // namespace content |
OLD | NEW |