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 // File method ordering: Methods in this file are in the same order | 5 // File method ordering: Methods in this file are in the same order |
6 // as in download_item_impl.h, with the following exception: The public | 6 // as in download_item_impl.h, with the following exception: The public |
7 // interfaces DelayedDownloadOpened, OnDownloadTargetDetermined, and | 7 // interfaces DelayedDownloadOpened, OnDownloadTargetDetermined, and |
8 // OnDownloadCompleting are placed in chronological order with the other | 8 // OnDownloadCompleting are placed in chronological order with the other |
9 // (private) routines that together define a DownloadItem's state transitions | 9 // (private) routines that together define a DownloadItem's state transitions |
10 // as the download progresses. See "Download progression cascade" later in | 10 // as the download progresses. See "Download progression cascade" later in |
(...skipping 12 matching lines...) Expand all Loading... |
23 // auto-opened. | 23 // auto-opened. |
24 | 24 |
25 #include "content/browser/download/download_item_impl.h" | 25 #include "content/browser/download/download_item_impl.h" |
26 | 26 |
27 #include <vector> | 27 #include <vector> |
28 | 28 |
29 #include "base/basictypes.h" | 29 #include "base/basictypes.h" |
30 #include "base/bind.h" | 30 #include "base/bind.h" |
31 #include "base/file_util.h" | 31 #include "base/file_util.h" |
32 #include "base/format_macros.h" | 32 #include "base/format_macros.h" |
33 #include "base/i18n/case_conversion.h" | |
34 #include "base/i18n/string_search.h" | |
35 #include "base/logging.h" | 33 #include "base/logging.h" |
36 #include "base/metrics/histogram.h" | 34 #include "base/metrics/histogram.h" |
37 #include "base/stl_util.h" | 35 #include "base/stl_util.h" |
38 #include "base/stringprintf.h" | 36 #include "base/stringprintf.h" |
39 #include "base/utf_string_conversions.h" | 37 #include "base/utf_string_conversions.h" |
40 #include "content/browser/download/download_create_info.h" | 38 #include "content/browser/download/download_create_info.h" |
41 #include "content/browser/download/download_file.h" | 39 #include "content/browser/download/download_file.h" |
42 #include "content/browser/download/download_file_manager.h" | 40 #include "content/browser/download/download_file_manager.h" |
43 #include "content/browser/download/download_interrupt_reasons_impl.h" | 41 #include "content/browser/download/download_interrupt_reasons_impl.h" |
44 #include "content/browser/download/download_item_impl_delegate.h" | 42 #include "content/browser/download/download_item_impl_delegate.h" |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 } | 690 } |
693 | 691 |
694 bool DownloadItemImpl::GetAutoOpened() { | 692 bool DownloadItemImpl::GetAutoOpened() { |
695 return auto_opened_; | 693 return auto_opened_; |
696 } | 694 } |
697 | 695 |
698 bool DownloadItemImpl::GetOpened() const { | 696 bool DownloadItemImpl::GetOpened() const { |
699 return opened_; | 697 return opened_; |
700 } | 698 } |
701 | 699 |
702 bool DownloadItemImpl::MatchesQuery(const string16& query) const { | |
703 if (query.empty()) | |
704 return true; | |
705 | |
706 DCHECK_EQ(query, base::i18n::ToLower(query)); | |
707 | |
708 string16 url_raw(UTF8ToUTF16(GetURL().spec())); | |
709 if (base::i18n::StringSearchIgnoringCaseAndAccents( | |
710 query, url_raw, NULL, NULL)) { | |
711 return true; | |
712 } | |
713 | |
714 // TODO(phajdan.jr): write a test case for the following code. | |
715 // A good test case would be: | |
716 // "/\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xbd\xa0\xe5\xa5\xbd", | |
717 // L"/\x4f60\x597d\x4f60\x597d", | |
718 // "/%E4%BD%A0%E5%A5%BD%E4%BD%A0%E5%A5%BD" | |
719 std::string languages; | |
720 languages = content::GetContentClient()->browser()->GetAcceptLangs( | |
721 GetBrowserContext()); | |
722 string16 url_formatted(net::FormatUrl(GetURL(), languages)); | |
723 if (base::i18n::StringSearchIgnoringCaseAndAccents( | |
724 query, url_formatted, NULL, NULL)) { | |
725 return true; | |
726 } | |
727 | |
728 // TODO(asanka): Change this to GetTargetFilePath() once DownloadQuery has | |
729 // been modified to work with target paths. | |
730 string16 path(GetFullPath().LossyDisplayName()); | |
731 return base::i18n::StringSearchIgnoringCaseAndAccents( | |
732 query, path, NULL, NULL); | |
733 } | |
734 | |
735 DownloadPersistentStoreInfo DownloadItemImpl::GetPersistentStoreInfo() const { | 700 DownloadPersistentStoreInfo DownloadItemImpl::GetPersistentStoreInfo() const { |
736 // TODO(asanka): Persist GetTargetFilePath() as well. | 701 // TODO(asanka): Persist GetTargetFilePath() as well. |
737 return DownloadPersistentStoreInfo(GetFullPath(), | 702 return DownloadPersistentStoreInfo(GetFullPath(), |
738 GetURL(), | 703 GetURL(), |
739 GetReferrerUrl(), | 704 GetReferrerUrl(), |
740 GetStartTime(), | 705 GetStartTime(), |
741 GetEndTime(), | 706 GetEndTime(), |
742 GetReceivedBytes(), | 707 GetReceivedBytes(), |
743 GetTotalBytes(), | 708 GetTotalBytes(), |
744 GetState(), | 709 GetState(), |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 | 1211 |
1247 bound_net_log_.AddEvent( | 1212 bound_net_log_.AddEvent( |
1248 net::NetLog::TYPE_DOWNLOAD_ITEM_RENAMED, | 1213 net::NetLog::TYPE_DOWNLOAD_ITEM_RENAMED, |
1249 base::Bind(&download_net_logs::ItemRenamedCallback, | 1214 base::Bind(&download_net_logs::ItemRenamedCallback, |
1250 ¤t_path_, &new_path)); | 1215 ¤t_path_, &new_path)); |
1251 } | 1216 } |
1252 | 1217 |
1253 | 1218 |
1254 | 1219 |
1255 | 1220 |
OLD | NEW |