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

Side by Side Diff: chrome/browser/download/download_query.cc

Issue 13409003: Hide ContentClient getters from embedders so that they they don't reuse content's embedder API. The… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 years, 8 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 #include "chrome/browser/download/download_query.h" 5 #include "chrome/browser/download/download_query.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/i18n/case_conversion.h" 14 #include "base/i18n/case_conversion.h"
15 #include "base/i18n/string_search.h" 15 #include "base/i18n/string_search.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/prefs/pref_service.h"
18 #include "base/stl_util.h" 19 #include "base/stl_util.h"
19 #include "base/string16.h" 20 #include "base/string16.h"
20 #include "base/stringprintf.h" 21 #include "base/stringprintf.h"
21 #include "base/strings/string_split.h" 22 #include "base/strings/string_split.h"
22 #include "base/time.h" 23 #include "base/time.h"
23 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
24 #include "base/values.h" 25 #include "base/values.h"
26 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/common/pref_names.h"
25 #include "content/public/browser/content_browser_client.h" 28 #include "content/public/browser/content_browser_client.h"
26 #include "content/public/browser/download_item.h" 29 #include "content/public/browser/download_item.h"
27 #include "googleurl/src/gurl.h" 30 #include "googleurl/src/gurl.h"
28 #include "net/base/net_util.h" 31 #include "net/base/net_util.h"
29 #include "third_party/icu/public/i18n/unicode/regex.h" 32 #include "third_party/icu/public/i18n/unicode/regex.h"
30 33
31 using content::DownloadDangerType; 34 using content::DownloadDangerType;
32 using content::DownloadItem; 35 using content::DownloadItem;
33 36
34 namespace { 37 namespace {
(...skipping 23 matching lines...) Expand all
58 DCHECK_EQ(query, base::i18n::ToLower(query)); 61 DCHECK_EQ(query, base::i18n::ToLower(query));
59 62
60 string16 url_raw(UTF8ToUTF16(item.GetOriginalUrl().spec())); 63 string16 url_raw(UTF8ToUTF16(item.GetOriginalUrl().spec()));
61 if (base::i18n::StringSearchIgnoringCaseAndAccents( 64 if (base::i18n::StringSearchIgnoringCaseAndAccents(
62 query, url_raw, NULL, NULL)) { 65 query, url_raw, NULL, NULL)) {
63 return true; 66 return true;
64 } 67 }
65 68
66 string16 url_formatted = url_raw; 69 string16 url_formatted = url_raw;
67 if (item.GetBrowserContext()) { 70 if (item.GetBrowserContext()) {
71 Profile* profile = Profile::FromBrowserContext(item.GetBrowserContext());
68 url_formatted = net::FormatUrl( 72 url_formatted = net::FormatUrl(
69 item.GetOriginalUrl(), 73 item.GetOriginalUrl(),
70 content::GetContentClient()->browser()->GetAcceptLangs( 74 profile->GetPrefs()->GetString(prefs::kAcceptLanguages));
71 item.GetBrowserContext()));
72 } 75 }
73 if (base::i18n::StringSearchIgnoringCaseAndAccents( 76 if (base::i18n::StringSearchIgnoringCaseAndAccents(
74 query, url_formatted, NULL, NULL)) { 77 query, url_formatted, NULL, NULL)) {
75 return true; 78 return true;
76 } 79 }
77 80
78 string16 path(item.GetTargetFilePath().LossyDisplayName()); 81 string16 path(item.GetTargetFilePath().LossyDisplayName());
79 return base::i18n::StringSearchIgnoringCaseAndAccents( 82 return base::i18n::StringSearchIgnoringCaseAndAccents(
80 query, path, NULL, NULL); 83 query, path, NULL, NULL);
81 } 84 }
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 422
420 void DownloadQuery::FinishSearch(DownloadQuery::DownloadVector* results) const { 423 void DownloadQuery::FinishSearch(DownloadQuery::DownloadVector* results) const {
421 if (!sorters_.empty()) 424 if (!sorters_.empty())
422 std::partial_sort(results->begin(), 425 std::partial_sort(results->begin(),
423 results->begin() + std::min(limit_, results->size()), 426 results->begin() + std::min(limit_, results->size()),
424 results->end(), 427 results->end(),
425 DownloadComparator(sorters_)); 428 DownloadComparator(sorters_));
426 if (results->size() > limit_) 429 if (results->size() > limit_)
427 results->resize(limit_); 430 results->resize(limit_);
428 } 431 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698