Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / components / bookmarks / test / test_bookmark_client.cc
blobb8b38e98313528d1c62984219c91b3c19223b5e5
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/bookmarks/test/test_bookmark_client.h"
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/logging.h"
10 #include "components/bookmarks/browser/bookmark_model.h"
11 #include "components/bookmarks/browser/bookmark_node.h"
12 #include "components/bookmarks/browser/bookmark_storage.h"
14 namespace bookmarks {
16 TestBookmarkClient::TestBookmarkClient() {}
18 TestBookmarkClient::~TestBookmarkClient() {}
20 scoped_ptr<BookmarkModel> TestBookmarkClient::CreateModel() {
21 scoped_ptr<BookmarkModel> bookmark_model(new BookmarkModel(this));
22 scoped_ptr<BookmarkLoadDetails> details =
23 bookmark_model->CreateLoadDetails(std::string());
24 details->LoadExtraNodes();
25 bookmark_model->DoneLoading(details.Pass());
26 return bookmark_model.Pass();
29 void TestBookmarkClient::SetExtraNodesToLoad(
30 BookmarkPermanentNodeList extra_nodes) {
31 extra_nodes_to_load_ = extra_nodes.Pass();
32 // Keep a copy in |extra_nodes_| for the acessor.
33 extra_nodes_ = extra_nodes_to_load_.get();
36 bool TestBookmarkClient::IsExtraNodeRoot(const BookmarkNode* node) {
37 for (size_t i = 0; i < extra_nodes_.size(); ++i) {
38 if (node == extra_nodes_[i])
39 return true;
41 return false;
44 bool TestBookmarkClient::IsAnExtraNode(const BookmarkNode* node) {
45 if (!node)
46 return false;
47 for (size_t i = 0; i < extra_nodes_.size(); ++i) {
48 if (node->HasAncestor(extra_nodes_[i]))
49 return true;
51 return false;
54 bool TestBookmarkClient::IsPermanentNodeVisible(
55 const BookmarkPermanentNode* node) {
56 DCHECK(node->type() == BookmarkNode::BOOKMARK_BAR ||
57 node->type() == BookmarkNode::OTHER_NODE ||
58 node->type() == BookmarkNode::MOBILE ||
59 IsExtraNodeRoot(node));
60 return node->type() != BookmarkNode::MOBILE && !IsExtraNodeRoot(node);
63 void TestBookmarkClient::RecordAction(const base::UserMetricsAction& action) {
66 LoadExtraCallback TestBookmarkClient::GetLoadExtraNodesCallback() {
67 return base::Bind(&TestBookmarkClient::LoadExtraNodes,
68 base::Passed(&extra_nodes_to_load_));
71 bool TestBookmarkClient::CanSetPermanentNodeTitle(
72 const BookmarkNode* permanent_node) {
73 return IsExtraNodeRoot(permanent_node);
76 bool TestBookmarkClient::CanSyncNode(const BookmarkNode* node) {
77 return !IsAnExtraNode(node);
80 bool TestBookmarkClient::CanBeEditedByUser(const BookmarkNode* node) {
81 return !IsAnExtraNode(node);
84 // static
85 BookmarkPermanentNodeList TestBookmarkClient::LoadExtraNodes(
86 BookmarkPermanentNodeList extra_nodes,
87 int64* next_id) {
88 return extra_nodes.Pass();
91 } // namespace bookmarks