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

Unified 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: Actual code + Peter's comments. Created 7 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/url_index_private_data.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/url_index_private_data.cc
diff --git a/chrome/browser/history/url_index_private_data.cc b/chrome/browser/history/url_index_private_data.cc
index ca38009bfd354a001da8f22fe28a903349a28754..c0e772dd7eb77336c8b53601b947da9de341428c 100644
--- a/chrome/browser/history/url_index_private_data.cc
+++ b/chrome/browser/history/url_index_private_data.cc
@@ -9,6 +9,7 @@
#include <iterator>
#include <limits>
#include <numeric>
+#include <string>
#include <vector>
#include "base/basictypes.h"
@@ -78,7 +79,18 @@ URLIndexPrivateData::URLIndexPrivateData()
ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms(
const string16& search_string,
+ size_t cursor_position,
BookmarkService* bookmark_service) {
+ // If cursor position is set and useful (not at either end of the string),
+ // allow the search string to be broken at cursor position. We do this
+ // by pretending there's a space where the cursor is.
+ // TODO(figure out highlighting).
+ const string16& search_string_with_cursor =
+ ((cursor_position != string16::npos) &&
+ (cursor_position < search_string.length()) &&
+ (cursor_position > 0)) ?
+ search_string.substr(0, cursor_position) + kWhitespaceUTF16 +
Peter Kasting 2013/01/04 23:47:39 This doesn't insert a space, it inserts a whole st
Mark P 2013/01/09 19:51:53 Done.
+ search_string.substr(cursor_position) : search_string;
pre_filter_item_count_ = 0;
post_filter_item_count_ = 0;
post_scoring_item_count_ = 0;
@@ -86,7 +98,7 @@ ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms(
// the index we need individual, lower-cased words, ignoring escapings. For
// the final filtering we need whitespace separated substrings possibly
// containing escaped characters.
- string16 lower_raw_string(base::i18n::ToLower(search_string));
+ string16 lower_raw_string(base::i18n::ToLower(search_string_with_cursor));
string16 lower_unescaped_string =
net::UnescapeURLComponent(lower_raw_string,
net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS);
« 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