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

Side by Side Diff: chrome/browser/history/url_index_private_data.cc

Issue 11757004: Omnibox: Add Mid-Input Matching to HistoryQuick Provider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo in comment Created 7 years, 10 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
« no previous file with comments | « chrome/browser/history/url_index_private_data.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/history/url_index_private_data.h" 5 #include "chrome/browser/history/url_index_private_data.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <iterator> 9 #include <iterator>
10 #include <limits> 10 #include <limits>
11 #include <numeric> 11 #include <numeric>
12 #include <string>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/basictypes.h" 15 #include "base/basictypes.h"
15 #include "base/file_util.h" 16 #include "base/file_util.h"
16 #include "base/i18n/case_conversion.h" 17 #include "base/i18n/case_conversion.h"
17 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
18 #include "base/string_util.h" 19 #include "base/string_util.h"
19 #include "base/time.h" 20 #include "base/time.h"
20 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
21 #include "chrome/browser/api/bookmarks/bookmark_service.h" 22 #include "chrome/browser/api/bookmarks/bookmark_service.h"
23 #include "chrome/browser/autocomplete/autocomplete_field_trial.h"
22 #include "chrome/browser/autocomplete/autocomplete_provider.h" 24 #include "chrome/browser/autocomplete/autocomplete_provider.h"
23 #include "chrome/browser/autocomplete/url_prefix.h" 25 #include "chrome/browser/autocomplete/url_prefix.h"
24 #include "chrome/browser/history/history_database.h" 26 #include "chrome/browser/history/history_database.h"
25 #include "chrome/browser/history/in_memory_url_index.h" 27 #include "chrome/browser/history/in_memory_url_index.h"
26 #include "content/public/browser/notification_details.h" 28 #include "content/public/browser/notification_details.h"
27 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
28 #include "content/public/browser/notification_source.h" 30 #include "content/public/browser/notification_source.h"
29 #include "net/base/net_util.h" 31 #include "net/base/net_util.h"
30 32
31 #if defined(USE_SYSTEM_PROTOBUF) 33 #if defined(USE_SYSTEM_PROTOBUF)
(...skipping 29 matching lines...) Expand all
61 // Algorithm Functions --------------------------------------------------------- 63 // Algorithm Functions ---------------------------------------------------------
62 64
63 // Comparison function for sorting search terms by descending length. 65 // Comparison function for sorting search terms by descending length.
64 bool LengthGreater(const string16& string_a, const string16& string_b) { 66 bool LengthGreater(const string16& string_a, const string16& string_b) {
65 return string_a.length() > string_b.length(); 67 return string_a.length() > string_b.length();
66 } 68 }
67 69
68 // Public Functions ------------------------------------------------------------ 70 // Public Functions ------------------------------------------------------------
69 71
70 URLIndexPrivateData::URLIndexPrivateData() 72 URLIndexPrivateData::URLIndexPrivateData()
71 : restored_cache_version_(0), 73 : use_cursor_position_(
74 AutocompleteFieldTrial::InHQPUseCursorPositionFieldTrial() &&
75 AutocompleteFieldTrial::
76 InHQPUseCursorPositionFieldTrialExperimentGroup()),
77 restored_cache_version_(0),
72 saved_cache_version_(kCurrentCacheFileVersion), 78 saved_cache_version_(kCurrentCacheFileVersion),
73 pre_filter_item_count_(0), 79 pre_filter_item_count_(0),
74 post_filter_item_count_(0), 80 post_filter_item_count_(0),
75 post_scoring_item_count_(0) { 81 post_scoring_item_count_(0) {
76 } 82 }
77 83
78 ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms( 84 ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms(
79 const string16& search_string, 85 string16 search_string,
86 size_t cursor_position,
80 BookmarkService* bookmark_service) { 87 BookmarkService* bookmark_service) {
88 // If we're allowed to use the cursor position, then if cursor
89 // position is set and useful (not at either end of the string),
90 // allow the search string to be broken at cursor position. We do
91 // this by pretending there's a space where the cursor is.
92 // TODO(figure out highlighting).
93 if (use_cursor_position_ && (cursor_position != string16::npos) &&
94 (cursor_position < search_string.length()) &&
95 (cursor_position > 0)) {
96 search_string.insert(cursor_position, ASCIIToUTF16(" "));
97 }
81 pre_filter_item_count_ = 0; 98 pre_filter_item_count_ = 0;
82 post_filter_item_count_ = 0; 99 post_filter_item_count_ = 0;
83 post_scoring_item_count_ = 0; 100 post_scoring_item_count_ = 0;
84 // The search string we receive may contain escaped characters. For reducing 101 // The search string we receive may contain escaped characters. For reducing
85 // the index we need individual, lower-cased words, ignoring escapings. For 102 // the index we need individual, lower-cased words, ignoring escapings. For
86 // the final filtering we need whitespace separated substrings possibly 103 // the final filtering we need whitespace separated substrings possibly
87 // containing escaped characters. 104 // containing escaped characters.
88 string16 lower_raw_string(base::i18n::ToLower(search_string)); 105 string16 lower_raw_string(base::i18n::ToLower(search_string));
89 string16 lower_unescaped_string = 106 string16 lower_unescaped_string =
90 net::UnescapeURLComponent(lower_raw_string, 107 net::UnescapeURLComponent(lower_raw_string,
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 } 1169 }
1153 1170
1154 // static 1171 // static
1155 bool URLIndexPrivateData::URLSchemeIsWhitelisted( 1172 bool URLIndexPrivateData::URLSchemeIsWhitelisted(
1156 const GURL& gurl, 1173 const GURL& gurl,
1157 const std::set<std::string>& whitelist) { 1174 const std::set<std::string>& whitelist) {
1158 return whitelist.find(gurl.scheme()) != whitelist.end(); 1175 return whitelist.find(gurl.scheme()) != whitelist.end();
1159 } 1176 }
1160 1177
1161 } // namespace history 1178 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/url_index_private_data.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698