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

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

Issue 2583763003: Factor out AutocompleteMatch creation from BookmarkProvider (Closed)
Patch Set: add unit test 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
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..a062f4e5a56165413a634c47cd86e2848910b34b 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,20 @@ 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)
+ return;
+ for (MatchPositions::iterator it = title_match_positions->begin();
+ it != title_match_positions->end(); ++it) {
+ it->first -= leading_whitespace_chars;
+ it->second -= leading_whitespace_chars;
+ }
+}
+
} // namespace bookmarks

Powered by Google App Engine
This is Rietveld 408576698