OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/plugin_download_helper.h" | 5 #include "chrome/browser/plugin_download_helper.h" |
6 | 6 |
7 #if defined(OS_WIN) && !defined(USE_AURA) | 7 #if defined(OS_WIN) && !defined(USE_AURA) |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 | 24 |
25 PluginDownloadUrlHelper::~PluginDownloadUrlHelper() { | 25 PluginDownloadUrlHelper::~PluginDownloadUrlHelper() { |
26 } | 26 } |
27 | 27 |
28 void PluginDownloadUrlHelper::InitiateDownload( | 28 void PluginDownloadUrlHelper::InitiateDownload( |
29 net::URLRequestContextGetter* request_context, | 29 net::URLRequestContextGetter* request_context, |
30 base::MessageLoopProxy* file_thread_proxy) { | 30 base::MessageLoopProxy* file_thread_proxy) { |
31 download_file_fetcher_.reset( | 31 download_file_fetcher_.reset( |
32 new URLFetcher(GURL(download_url_), URLFetcher::GET, this)); | 32 new URLFetcher(GURL(download_url_), URLFetcher::GET, this)); |
33 download_file_fetcher_->set_request_context(request_context); | 33 download_file_fetcher_->SetRequestContext(request_context); |
34 download_file_fetcher_->SaveResponseToTemporaryFile(file_thread_proxy); | 34 download_file_fetcher_->SaveResponseToTemporaryFile(file_thread_proxy); |
35 download_file_fetcher_->Start(); | 35 download_file_fetcher_->Start(); |
36 } | 36 } |
37 | 37 |
38 void PluginDownloadUrlHelper::OnURLFetchComplete(const URLFetcher* source) { | 38 void PluginDownloadUrlHelper::OnURLFetchComplete( |
39 bool success = source->status().is_success(); | 39 const content::URLFetcher* source) { |
| 40 bool success = source->GetStatus().is_success(); |
40 FilePath response_file; | 41 FilePath response_file; |
41 | 42 |
42 if (success) { | 43 if (success) { |
43 if (source->GetResponseAsFilePath(true, &response_file)) { | 44 if (source->GetResponseAsFilePath(true, &response_file)) { |
44 FilePath new_download_file_path = | 45 FilePath new_download_file_path = |
45 response_file.DirName().AppendASCII( | 46 response_file.DirName().AppendASCII( |
46 download_file_fetcher_->url().ExtractFileName()); | 47 download_file_fetcher_->GetUrl().ExtractFileName()); |
47 | 48 |
48 file_util::Delete(new_download_file_path, false); | 49 file_util::Delete(new_download_file_path, false); |
49 | 50 |
50 if (!file_util::ReplaceFileW(response_file, | 51 if (!file_util::ReplaceFileW(response_file, |
51 new_download_file_path)) { | 52 new_download_file_path)) { |
52 DLOG(ERROR) << "Failed to rename file:" | 53 DLOG(ERROR) << "Failed to rename file:" |
53 << response_file.value() | 54 << response_file.value() |
54 << " to file:" | 55 << " to file:" |
55 << new_download_file_path.value(); | 56 << new_download_file_path.value(); |
56 } else { | 57 } else { |
(...skipping 18 matching lines...) Expand all Loading... |
75 if (::IsWindow(download_file_caller_window_)) { | 76 if (::IsWindow(download_file_caller_window_)) { |
76 ::SendMessage(download_file_caller_window_, WM_COPYDATA, NULL, | 77 ::SendMessage(download_file_caller_window_, WM_COPYDATA, NULL, |
77 reinterpret_cast<LPARAM>(&download_file_data)); | 78 reinterpret_cast<LPARAM>(&download_file_data)); |
78 } | 79 } |
79 } | 80 } |
80 // Don't access any members after this. | 81 // Don't access any members after this. |
81 delete this; | 82 delete this; |
82 } | 83 } |
83 | 84 |
84 #endif // defined(OS_WIN) && !defined(USE_AURA) | 85 #endif // defined(OS_WIN) && !defined(USE_AURA) |
OLD | NEW |