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/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_util.h" | 10 #include "base/file_util.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 } | 248 } |
249 | 249 |
250 STLDeleteValues(&saved_success_items_); | 250 STLDeleteValues(&saved_success_items_); |
251 STLDeleteValues(&in_progress_items_); | 251 STLDeleteValues(&in_progress_items_); |
252 STLDeleteValues(&saved_failed_items_); | 252 STLDeleteValues(&saved_failed_items_); |
253 | 253 |
254 file_manager_ = NULL; | 254 file_manager_ = NULL; |
255 } | 255 } |
256 | 256 |
257 GURL SavePackage::GetUrlToBeSaved() { | 257 GURL SavePackage::GetUrlToBeSaved() { |
258 // Instead of using web_contents_.GetURL here, we use url() (which is the | 258 // The URL to be saved is the real resource URL, not the one displayed to |
259 // "real" url of the page) from the NavigationEntry because it reflects its | 259 // the user, which can be a friendly format one. Use the NavigationEntry |
260 // origin rather than the displayed one (returned by GetURL) which may be | 260 // URL instead of WebContents, since the latter gives us the user visible URL. |
261 // different (like having "view-source:" on the front). | 261 NavigationEntry* last_committed_entry = |
262 NavigationEntry* active_entry = | 262 web_contents()->GetController().GetLastCommittedEntry(); |
263 web_contents()->GetController().GetActiveEntry(); | 263 return last_committed_entry ? last_committed_entry->GetURL() : GURL(); |
264 return active_entry->GetURL(); | |
265 } | 264 } |
266 | 265 |
267 void SavePackage::Cancel(bool user_action) { | 266 void SavePackage::Cancel(bool user_action) { |
268 if (!canceled()) { | 267 if (!canceled()) { |
269 if (user_action) | 268 if (user_action) |
270 user_canceled_ = true; | 269 user_canceled_ = true; |
271 else | 270 else |
272 disk_error_occurred_ = true; | 271 disk_error_occurred_ = true; |
273 Stop(); | 272 Stop(); |
274 } | 273 } |
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 | 1443 |
1445 void SavePackage::FinalizeDownloadEntry() { | 1444 void SavePackage::FinalizeDownloadEntry() { |
1446 DCHECK(download_); | 1445 DCHECK(download_); |
1447 DCHECK(download_manager_); | 1446 DCHECK(download_manager_); |
1448 | 1447 |
1449 download_manager_->OnSavePackageSuccessfullyFinished(download_); | 1448 download_manager_->OnSavePackageSuccessfullyFinished(download_); |
1450 StopObservation(); | 1449 StopObservation(); |
1451 } | 1450 } |
1452 | 1451 |
1453 } // namespace content | 1452 } // namespace content |
OLD | NEW |