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

Unified Diff: chrome/browser/bookmarks/bookmark_match.cc

Issue 184663002: Omnibox: Make URLs of Bookmarks Searchable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tested; works Created 6 years, 8 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
Index: chrome/browser/bookmarks/bookmark_match.cc
diff --git a/chrome/browser/bookmarks/bookmark_match.cc b/chrome/browser/bookmarks/bookmark_match.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1dac98bff17fe1f0e8279950e96621f33908f32f
--- /dev/null
+++ b/chrome/browser/bookmarks/bookmark_match.cc
@@ -0,0 +1,44 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/bookmarks/bookmark_match.h"
+
+#include "base/logging.h"
+#include "base/strings/string16.h"
+
+BookmarkMatch::BookmarkMatch() : node(NULL) {}
+
+BookmarkMatch::~BookmarkMatch() {}
+
+// static
+std::vector<size_t> BookmarkMatch::OffsetsFromMatchPositions(
+ const MatchPositions& match_positions) {
+ std::vector<size_t> offsets;
+ for (MatchPositions::const_iterator i = match_positions.begin();
+ i != match_positions.end(); ++i) {
+ offsets.push_back(i->first);
+ offsets.push_back(i->second);
+ }
+ return offsets;
+}
+
+// static
+BookmarkMatch::MatchPositions BookmarkMatch::ReplaceOffsetsInMatchPositions(
+ const MatchPositions& match_positions,
+ const std::vector<size_t>& offsets) {
+ DCHECK_EQ(2 * match_positions.size(), offsets.size());
+ MatchPositions new_match_positions;
+ std::vector<size_t>::const_iterator offset_iter = offsets.begin();
+ for (MatchPositions::const_iterator match_iter = match_positions.begin();
+ match_iter != match_positions.end(); ++match_iter, ++offset_iter) {
+ const size_t begin = *offset_iter;
+ ++offset_iter;
+ const size_t end = *offset_iter;
+ if ((begin != base::string16::npos) && (end != base::string16::npos)) {
+ const MatchPosition new_match_position(begin, end);
+ new_match_positions.push_back(new_match_position);
+ }
+ }
+ return new_match_positions;
+}

Powered by Google App Engine
This is Rietveld 408576698