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 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 // component or if there is none, the domain as the file name. | 1215 // component or if there is none, the domain as the file name. |
1216 // Normally we want to base the filename on the page title, or if it doesn't | 1216 // Normally we want to base the filename on the page title, or if it doesn't |
1217 // exist, on the URL. It's not easy to tell if the page has no title, because | 1217 // exist, on the URL. It's not easy to tell if the page has no title, because |
1218 // if the page has no title, WebContents::GetTitle() will return the page's | 1218 // if the page has no title, WebContents::GetTitle() will return the page's |
1219 // URL (adjusted for display purposes). Therefore, we convert the "title" | 1219 // URL (adjusted for display purposes). Therefore, we convert the "title" |
1220 // back to a URL, and if it matches the original page URL, we know the page | 1220 // back to a URL, and if it matches the original page URL, we know the page |
1221 // had no title (or had a title equal to its URL, which is fine to treat | 1221 // had no title (or had a title equal to its URL, which is fine to treat |
1222 // similarly). | 1222 // similarly). |
1223 if (title_ == net::FormatUrl(page_url_, accept_langs)) { | 1223 if (title_ == net::FormatUrl(page_url_, accept_langs)) { |
1224 std::string url_path; | 1224 std::string url_path; |
1225 if (!page_url_.SchemeIs(kDataScheme)) { | 1225 if (!page_url_.SchemeIs(url::kDataScheme)) { |
1226 std::vector<std::string> url_parts; | 1226 std::vector<std::string> url_parts; |
1227 base::SplitString(page_url_.path(), '/', &url_parts); | 1227 base::SplitString(page_url_.path(), '/', &url_parts); |
1228 if (!url_parts.empty()) { | 1228 if (!url_parts.empty()) { |
1229 for (int i = static_cast<int>(url_parts.size()) - 1; i >= 0; --i) { | 1229 for (int i = static_cast<int>(url_parts.size()) - 1; i >= 0; --i) { |
1230 url_path = url_parts[i]; | 1230 url_path = url_parts[i]; |
1231 if (!url_path.empty()) | 1231 if (!url_path.empty()) |
1232 break; | 1232 break; |
1233 } | 1233 } |
1234 } | 1234 } |
1235 if (url_path.empty()) | 1235 if (url_path.empty()) |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 | 1444 |
1445 void SavePackage::FinalizeDownloadEntry() { | 1445 void SavePackage::FinalizeDownloadEntry() { |
1446 DCHECK(download_); | 1446 DCHECK(download_); |
1447 DCHECK(download_manager_); | 1447 DCHECK(download_manager_); |
1448 | 1448 |
1449 download_manager_->OnSavePackageSuccessfullyFinished(download_); | 1449 download_manager_->OnSavePackageSuccessfullyFinished(download_); |
1450 StopObservation(); | 1450 StopObservation(); |
1451 } | 1451 } |
1452 | 1452 |
1453 } // namespace content | 1453 } // namespace content |
OLD | NEW |