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

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: 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 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 cd7634c8cee036a9d86cf721fb8c2c967b9f2d18..3b1a3faf14a30bf8082f89167e826b98c9964c3e 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"
@@ -19,6 +20,7 @@
#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/api/bookmarks/bookmark_service.h"
+#include "chrome/browser/autocomplete/autocomplete_field_trial.h"
#include "chrome/browser/autocomplete/autocomplete_provider.h"
#include "chrome/browser/autocomplete/url_prefix.h"
#include "chrome/browser/history/history_database.h"
@@ -68,7 +70,11 @@ bool LengthGreater(const string16& string_a, const string16& string_b) {
// Public Functions ------------------------------------------------------------
URLIndexPrivateData::URLIndexPrivateData()
- : restored_cache_version_(0),
+ : use_cursor_position_(
+ AutocompleteFieldTrial::InHQPUseCursorPositionFieldTrial() &&
+ AutocompleteFieldTrial::
+ InHQPUseCursorPositionFieldTrialExperimentGroup()),
+ restored_cache_version_(0),
saved_cache_version_(kCurrentCacheFileVersion),
pre_filter_item_count_(0),
post_filter_item_count_(0),
@@ -76,8 +82,19 @@ URLIndexPrivateData::URLIndexPrivateData()
}
ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms(
- const string16& search_string,
+ string16 search_string,
+ size_t cursor_position,
BookmarkService* bookmark_service) {
+ // If we're allowed to use the cursor position, then 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).
+ if (use_cursor_position_ && (cursor_position != string16::npos) &&
+ (cursor_position < search_string.length()) &&
+ (cursor_position > 0)) {
+ search_string.insert(cursor_position, ASCIIToUTF16(" "));
+ }
pre_filter_item_count_ = 0;
post_filter_item_count_ = 0;
post_scoring_item_count_ = 0;
« 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