| Index: chrome/browser/bookmarks/bookmark_index.cc
|
| diff --git a/chrome/browser/bookmarks/bookmark_index.cc b/chrome/browser/bookmarks/bookmark_index.cc
|
| index feb2384f9d82ef473a929867b52a089a87118a47..85d4f645e747cb9db27ba6f23ed598c47b3aa06a 100644
|
| --- a/chrome/browser/bookmarks/bookmark_index.cc
|
| +++ b/chrome/browser/bookmarks/bookmark_index.cc
|
| @@ -10,10 +10,8 @@
|
|
|
| #include "base/i18n/case_conversion.h"
|
| #include "base/strings/string16.h"
|
| -#include "chrome/browser/bookmarks/bookmark_model.h"
|
| -#include "chrome/browser/history/history_service.h"
|
| -#include "chrome/browser/history/history_service_factory.h"
|
| -#include "chrome/browser/history/url_database.h"
|
| +#include "components/bookmarks/core/browser/bookmark_client.h"
|
| +#include "components/bookmarks/core/browser/bookmark_node.h"
|
| #include "components/bookmarks/core/browser/bookmark_title_match.h"
|
| #include "components/query_parser/query_parser.h"
|
| #include "third_party/icu/source/common/unicode/normalizer2.h"
|
| @@ -71,8 +69,7 @@ BookmarkIndex::NodeSet::const_iterator BookmarkIndex::Match::nodes_end() const {
|
| return nodes.empty() ? terms.front()->second.end() : nodes.end();
|
| }
|
|
|
| -BookmarkIndex::BookmarkIndex(content::BrowserContext* browser_context)
|
| - : browser_context_(browser_context) {
|
| +BookmarkIndex::BookmarkIndex(BookmarkClient* client) : client_(client) {
|
| }
|
|
|
| BookmarkIndex::~BookmarkIndex() {
|
| @@ -134,43 +131,26 @@ void BookmarkIndex::GetBookmarksWithTitlesMatching(
|
|
|
| void BookmarkIndex::SortMatches(const Matches& matches,
|
| NodeTypedCountPairs* node_typed_counts) const {
|
| - HistoryService* const history_service = browser_context_ ?
|
| - HistoryServiceFactory::GetForProfile(
|
| - Profile::FromBrowserContext(browser_context_),
|
| - Profile::EXPLICIT_ACCESS) : NULL;
|
| -
|
| - history::URLDatabase* url_db = history_service ?
|
| - history_service->InMemoryDatabase() : NULL;
|
| -
|
| - for (Matches::const_iterator i = matches.begin(); i != matches.end(); ++i)
|
| - ExtractBookmarkNodePairs(url_db, *i, node_typed_counts);
|
| -
|
| - std::sort(node_typed_counts->begin(), node_typed_counts->end(),
|
| - &NodeTypedCountPairSortFunc);
|
| - // Eliminate duplicates.
|
| - node_typed_counts->erase(std::unique(node_typed_counts->begin(),
|
| - node_typed_counts->end()),
|
| - node_typed_counts->end());
|
| -}
|
| -
|
| -void BookmarkIndex::ExtractBookmarkNodePairs(
|
| - history::URLDatabase* url_db,
|
| - const Match& match,
|
| - NodeTypedCountPairs* node_typed_counts) const {
|
| -
|
| - for (NodeSet::const_iterator i = match.nodes_begin();
|
| - i != match.nodes_end(); ++i) {
|
| - int typed_count = 0;
|
| -
|
| - // If |url_db| is the InMemoryDatabase, it might not cache all URLRows, but
|
| - // it guarantees to contain those with |typed_count| > 0. Thus, if we cannot
|
| - // fetch the URLRow, it is safe to assume that its |typed_count| is 0.
|
| - history::URLRow url;
|
| - if (url_db && url_db->GetRowForURL((*i)->url(), &url))
|
| - typed_count = url.typed_count();
|
| + for (Matches::const_iterator i = matches.begin(); i != matches.end(); ++i) {
|
| + const NodeSet& nodes =
|
| + i->nodes.empty() ? i->terms.front()->second : i->nodes;
|
| + if (client_->SupportsTypedCountForNodes()) {
|
| + client_->GetTypedCountForNodes(nodes, node_typed_counts);
|
| + } else {
|
| + for (NodeSet::const_iterator n = nodes.begin(); n != nodes.end(); ++n) {
|
| + node_typed_counts->push_back(NodeTypedCountPair(*n, 0));
|
| + }
|
| + }
|
| + }
|
|
|
| - NodeTypedCountPair pair(*i, typed_count);
|
| - node_typed_counts->push_back(pair);
|
| + if (client_->SupportsTypedCountForNodes()) {
|
| + std::sort(node_typed_counts->begin(),
|
| + node_typed_counts->end(),
|
| + &NodeTypedCountPairSortFunc);
|
| + // Eliminate duplicates.
|
| + node_typed_counts->erase(
|
| + std::unique(node_typed_counts->begin(), node_typed_counts->end()),
|
| + node_typed_counts->end());
|
| }
|
| }
|
|
|
|
|