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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | |
9 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
10 #include "content/browser/download/download_stats.h" | 9 #include "content/browser/download/download_stats.h" |
11 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
12 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
13 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/download_item.h" | 13 #include "content/public/browser/download_item.h" |
15 #include "content/public/browser/download_save_info.h" | 14 #include "content/public/browser/download_save_info.h" |
16 #include "content/public/browser/download_url_parameters.h" | 15 #include "content/public/browser/download_url_parameters.h" |
17 #include "net/base/file_stream.h" | 16 #include "net/base/file_stream.h" |
18 | 17 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 BrowserContext::GetDownloadManager(web_contents_->GetBrowserContext()); | 60 BrowserContext::GetDownloadManager(web_contents_->GetBrowserContext()); |
62 | 61 |
63 RecordDownloadSource(INITIATED_BY_DRAG_N_DROP); | 62 RecordDownloadSource(INITIATED_BY_DRAG_N_DROP); |
64 scoped_ptr<content::DownloadUrlParameters> params( | 63 scoped_ptr<content::DownloadUrlParameters> params( |
65 DownloadUrlParameters::FromWebContents(web_contents_, url_)); | 64 DownloadUrlParameters::FromWebContents(web_contents_, url_)); |
66 params->set_referrer(referrer_); | 65 params->set_referrer(referrer_); |
67 params->set_referrer_encoding(referrer_encoding_); | 66 params->set_referrer_encoding(referrer_encoding_); |
68 params->set_callback(base::Bind(&DragDownloadFileUI::OnDownloadStarted, | 67 params->set_callback(base::Bind(&DragDownloadFileUI::OnDownloadStarted, |
69 weak_ptr_factory_.GetWeakPtr())); | 68 weak_ptr_factory_.GetWeakPtr())); |
70 params->set_file_path(file_path); | 69 params->set_file_path(file_path); |
71 params->set_file_stream(file_stream.Pass()); // Nulls file_stream. | 70 params->set_file_stream(file_stream.Pass()); // Nulls file_stream. |
72 download_manager->DownloadUrl(params.Pass()); | 71 download_manager->DownloadUrl(params.Pass()); |
73 } | 72 } |
74 | 73 |
75 void Cancel() { | 74 void Cancel() { |
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
77 if (download_item_) | 76 if (download_item_) |
78 download_item_->Cancel(true); | 77 download_item_->Cancel(true); |
79 } | 78 } |
80 | 79 |
81 void Delete() { | 80 void Delete() { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 230 |
232 void DragDownloadFile::CheckThread() { | 231 void DragDownloadFile::CheckThread() { |
233 #if defined(OS_WIN) | 232 #if defined(OS_WIN) |
234 DCHECK(drag_message_loop_ == base::MessageLoop::current()); | 233 DCHECK(drag_message_loop_ == base::MessageLoop::current()); |
235 #else | 234 #else |
236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
237 #endif | 236 #endif |
238 } | 237 } |
239 | 238 |
240 } // namespace content | 239 } // namespace content |
OLD | NEW |