Index: components/bookmarks/browser/titled_url_match.h |
diff --git a/components/bookmarks/browser/titled_url_match.h b/components/bookmarks/browser/titled_url_match.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..07461f76fe554e781441427f56b37bc11711b786 |
--- /dev/null |
+++ b/components/bookmarks/browser/titled_url_match.h |
@@ -0,0 +1,51 @@ |
+// Copyright 2016 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. |
+ |
+#ifndef COMPONENTS_BOOKMARKS_BROWSER_TITLED_URL_MATCH_H_ |
+#define COMPONENTS_BOOKMARKS_BROWSER_TITLED_URL_MATCH_H_ |
+ |
+#include <stddef.h> |
+ |
+#include <cstddef> |
+#include <utility> |
+#include <vector> |
+ |
+#include "components/bookmarks/browser/titled_url_node.h" |
+ |
+namespace bookmarks { |
+ |
+struct TitledUrlMatch { |
sky
2016/12/01 20:24:51
Same comment here.
mattreynolds
2016/12/01 23:33:18
Done.
|
+ // Each MatchPosition is the [begin, end) positions of a match within a |
+ // string. |
+ typedef std::pair<size_t, size_t> MatchPosition; |
+ typedef std::vector<MatchPosition> MatchPositions; |
+ |
+ TitledUrlMatch(); |
+ TitledUrlMatch(const TitledUrlMatch& other); |
+ ~TitledUrlMatch(); |
+ |
+ // Extracts and returns the offsets from |match_positions|. |
+ static std::vector<size_t> OffsetsFromMatchPositions( |
+ const MatchPositions& match_positions); |
+ |
+ // Replaces the offsets in |match_positions| with those given in |offsets|, |
+ // deleting any which are npos, and returns the updated list of match |
+ // positions. |
+ static MatchPositions ReplaceOffsetsInMatchPositions( |
+ const MatchPositions& match_positions, |
+ const std::vector<size_t>& offsets); |
+ |
+ // The matching node of a query. |
+ const TitledUrlNode* node; |
+ |
+ // Location of the matching words in the title of the node. |
+ MatchPositions title_match_positions; |
+ |
+ // Location of the matching words in the URL of the node. |
+ MatchPositions url_match_positions; |
+}; |
+ |
+} // namespace bookmarks |
+ |
+#endif // COMPONENTS_BOOKMARKS_BROWSER_TITLED_URL_MATCH_H_ |