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 "content/browser/download/save_package.h" | 5 #include "content/browser/download/save_package.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "content/public/common/url_constants.h" | 39 #include "content/public/common/url_constants.h" |
40 #include "net/base/io_buffer.h" | 40 #include "net/base/io_buffer.h" |
41 #include "net/base/mime_util.h" | 41 #include "net/base/mime_util.h" |
42 #include "net/base/net_util.h" | 42 #include "net/base/net_util.h" |
43 #include "net/url_request/url_request_context.h" | 43 #include "net/url_request/url_request_context.h" |
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClie
nt.h" | 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClie
nt.h" |
45 | 45 |
46 using base::Time; | 46 using base::Time; |
47 using content::BrowserThread; | 47 using content::BrowserThread; |
48 using content::DownloadItem; | 48 using content::DownloadItem; |
| 49 using content::NavigationEntry; |
49 using WebKit::WebPageSerializerClient; | 50 using WebKit::WebPageSerializerClient; |
50 | 51 |
51 namespace { | 52 namespace { |
52 | 53 |
53 // A counter for uniquely identifying each save package. | 54 // A counter for uniquely identifying each save package. |
54 int g_save_package_id = 0; | 55 int g_save_package_id = 0; |
55 | 56 |
56 // Default name which will be used when we can not get proper name from | 57 // Default name which will be used when we can not get proper name from |
57 // resource URL. | 58 // resource URL. |
58 const char kDefaultSaveName[] = "saved_resource"; | 59 const char kDefaultSaveName[] = "saved_resource"; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 218 |
218 file_manager_ = NULL; | 219 file_manager_ = NULL; |
219 } | 220 } |
220 | 221 |
221 GURL SavePackage::GetUrlToBeSaved() { | 222 GURL SavePackage::GetUrlToBeSaved() { |
222 // Instead of using tab_contents_.GetURL here, we use url() | 223 // Instead of using tab_contents_.GetURL here, we use url() |
223 // (which is the "real" url of the page) | 224 // (which is the "real" url of the page) |
224 // from the NavigationEntry because it reflects its' origin | 225 // from the NavigationEntry because it reflects its' origin |
225 // rather than the displayed one (returned by GetURL) which may be | 226 // rather than the displayed one (returned by GetURL) which may be |
226 // different (like having "view-source:" on the front). | 227 // different (like having "view-source:" on the front). |
227 content::NavigationEntry* active_entry = | 228 NavigationEntry* active_entry = |
228 web_contents()->GetController().GetActiveEntry(); | 229 web_contents()->GetController().GetActiveEntry(); |
229 return active_entry->GetURL(); | 230 return active_entry->GetURL(); |
230 } | 231 } |
231 | 232 |
232 void SavePackage::Cancel(bool user_action) { | 233 void SavePackage::Cancel(bool user_action) { |
233 if (!canceled()) { | 234 if (!canceled()) { |
234 if (user_action) | 235 if (user_action) |
235 user_canceled_ = true; | 236 user_canceled_ = true; |
236 else | 237 else |
237 disk_error_occurred_ = true; | 238 disk_error_occurred_ = true; |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 StopObservation(); | 1295 StopObservation(); |
1295 } | 1296 } |
1296 | 1297 |
1297 void SavePackage::FinalizeDownloadEntry() { | 1298 void SavePackage::FinalizeDownloadEntry() { |
1298 DCHECK(download_); | 1299 DCHECK(download_); |
1299 DCHECK(download_manager_); | 1300 DCHECK(download_manager_); |
1300 | 1301 |
1301 download_manager_->SavePageDownloadFinished(download_); | 1302 download_manager_->SavePageDownloadFinished(download_); |
1302 StopObservation(); | 1303 StopObservation(); |
1303 } | 1304 } |
OLD | NEW |