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

Unified Diff: components/bookmarks/browser/titled_url_match.cc

Issue 2583763003: Factor out AutocompleteMatch creation from BookmarkProvider (Closed)
Patch Set: Created 4 years 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 | « components/bookmarks/browser/titled_url_match.h ('k') | components/omnibox/browser/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/bookmarks/browser/titled_url_match.cc
diff --git a/components/bookmarks/browser/titled_url_match.cc b/components/bookmarks/browser/titled_url_match.cc
index 313ae4ef17704659e8cc8fa45a64447a4202bf14..2c2b1d2b4163da793d2c8b763ee38f8be52879ea 100644
--- a/components/bookmarks/browser/titled_url_match.cc
+++ b/components/bookmarks/browser/titled_url_match.cc
@@ -5,7 +5,7 @@
#include "components/bookmarks/browser/titled_url_match.h"
#include "base/logging.h"
-#include "base/strings/string16.h"
+#include "base/strings/string_util.h"
namespace bookmarks {
@@ -47,4 +47,21 @@ TitledUrlMatch::MatchPositions TitledUrlMatch::ReplaceOffsetsInMatchPositions(
return new_match_positions;
}
+// static
+void TitledUrlMatch::CorrectTitleAndMatchPositions(
+ base::string16* title,
+ MatchPositions* title_match_positions) {
+ size_t leading_whitespace_chars = title->length();
+ base::TrimWhitespace(*title, base::TRIM_LEADING, title);
+ leading_whitespace_chars -= title->length();
+ if (leading_whitespace_chars == 0) {
sky 2016/12/16 19:32:54 no {}
mattreynolds 2016/12/19 20:09:15 Done.
+ return;
+ }
+ for (MatchPositions::iterator it = title_match_positions->begin();
+ it != title_match_positions->end(); ++it) {
+ (*it) = MatchPosition(it->first - leading_whitespace_chars,
sky 2016/12/16 19:32:54 optional: do an in place update, e.g. it->first -=
mattreynolds 2016/12/19 20:09:15 Done.
+ it->second - leading_whitespace_chars);
+ }
+}
+
} // namespace bookmarks
« no previous file with comments | « components/bookmarks/browser/titled_url_match.h ('k') | components/omnibox/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698