Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: content/browser/download/download_item_impl.cc

Issue 10905215: Kill DownloadManager::SearchDownloads, DownloadItem::MatchesQuery (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 } 686 }
689 687
690 bool DownloadItemImpl::GetAutoOpened() { 688 bool DownloadItemImpl::GetAutoOpened() {
691 return auto_opened_; 689 return auto_opened_;
692 } 690 }
693 691
694 bool DownloadItemImpl::GetOpened() const { 692 bool DownloadItemImpl::GetOpened() const {
695 return opened_; 693 return opened_;
696 } 694 }
697 695
698 bool DownloadItemImpl::MatchesQuery(const string16& query) const {
699 if (query.empty())
700 return true;
701
702 DCHECK_EQ(query, base::i18n::ToLower(query));
703
704 string16 url_raw(UTF8ToUTF16(GetURL().spec()));
705 if (base::i18n::StringSearchIgnoringCaseAndAccents(
706 query, url_raw, NULL, NULL)) {
707 return true;
708 }
709
710 // TODO(phajdan.jr): write a test case for the following code.
711 // A good test case would be:
712 // "/\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xbd\xa0\xe5\xa5\xbd",
713 // L"/\x4f60\x597d\x4f60\x597d",
714 // "/%E4%BD%A0%E5%A5%BD%E4%BD%A0%E5%A5%BD"
715 std::string languages;
716 languages = content::GetContentClient()->browser()->GetAcceptLangs(
717 GetBrowserContext());
718 string16 url_formatted(net::FormatUrl(GetURL(), languages));
719 if (base::i18n::StringSearchIgnoringCaseAndAccents(
720 query, url_formatted, NULL, NULL)) {
721 return true;
722 }
723
724 // TODO(asanka): Change this to GetTargetFilePath() once DownloadQuery has
725 // been modified to work with target paths.
726 string16 path(GetFullPath().LossyDisplayName());
727 return base::i18n::StringSearchIgnoringCaseAndAccents(
728 query, path, NULL, NULL);
729 }
730
731 DownloadPersistentStoreInfo DownloadItemImpl::GetPersistentStoreInfo() const { 696 DownloadPersistentStoreInfo DownloadItemImpl::GetPersistentStoreInfo() const {
732 // TODO(asanka): Persist GetTargetFilePath() as well. 697 // TODO(asanka): Persist GetTargetFilePath() as well.
733 return DownloadPersistentStoreInfo(GetFullPath(), 698 return DownloadPersistentStoreInfo(GetFullPath(),
734 GetURL(), 699 GetURL(),
735 GetReferrerUrl(), 700 GetReferrerUrl(),
736 GetStartTime(), 701 GetStartTime(),
737 GetEndTime(), 702 GetEndTime(),
738 GetReceivedBytes(), 703 GetReceivedBytes(),
739 GetTotalBytes(), 704 GetTotalBytes(),
740 GetState(), 705 GetState(),
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 1208
1244 bound_net_log_.AddEvent( 1209 bound_net_log_.AddEvent(
1245 net::NetLog::TYPE_DOWNLOAD_ITEM_RENAMED, 1210 net::NetLog::TYPE_DOWNLOAD_ITEM_RENAMED,
1246 base::Bind(&download_net_logs::ItemRenamedCallback, 1211 base::Bind(&download_net_logs::ItemRenamedCallback,
1247 &current_path_, &new_path)); 1212 &current_path_, &new_path));
1248 } 1213 }
1249 1214
1250 1215
1251 1216
1252 1217
OLDNEW
« no previous file with comments | « content/browser/download/download_item_impl.h ('k') | content/browser/download/download_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698