OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_BOOKMARKS_TEST_TEST_BOOKMARK_CLIENT_H_ | 5 #ifndef COMPONENTS_BOOKMARKS_TEST_TEST_BOOKMARK_CLIENT_H_ |
6 #define COMPONENTS_BOOKMARKS_TEST_TEST_BOOKMARK_CLIENT_H_ | 6 #define COMPONENTS_BOOKMARKS_TEST_TEST_BOOKMARK_CLIENT_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "components/bookmarks/browser/bookmark_client.h" | 9 #include "components/bookmarks/browser/bookmark_client.h" |
10 | 10 |
11 class BookmarkModel; | 11 class BookmarkModel; |
12 | 12 |
13 namespace test { | 13 namespace test { |
14 | 14 |
15 class TestBookmarkClient : public BookmarkClient { | 15 class TestBookmarkClient : public BookmarkClient { |
16 public: | 16 public: |
17 TestBookmarkClient(); | 17 TestBookmarkClient(); |
18 virtual ~TestBookmarkClient(); | 18 virtual ~TestBookmarkClient(); |
19 | 19 |
20 // Create a BookmarkModel using this object as its client. The returned | 20 // Create a BookmarkModel using this object as its client. The returned |
21 // BookmarkModel* is owned by the caller. | 21 // BookmarkModel* is owned by the caller. |
22 scoped_ptr<BookmarkModel> CreateModel(bool index_urls); | 22 scoped_ptr<BookmarkModel> CreateModel(bool index_urls); |
23 | 23 |
24 // Sets the list of extra nodes to be returned by the next call to | 24 // Sets the list of extra nodes to be returned by the next call to |
25 // CreateModel() or GetLoadExtraNodesCallback(). | 25 // GetLoadExtraNodesCallback(). CreateModel() won't pick this up; the model |
| 26 // needs to get Load() invoked to reach to the client for this call. |
26 void SetExtraNodesToLoad(bookmarks::BookmarkPermanentNodeList extra_nodes); | 27 void SetExtraNodesToLoad(bookmarks::BookmarkPermanentNodeList extra_nodes); |
27 | 28 |
28 // Returns the current extra_nodes, set via SetExtraNodesToLoad(). | 29 // Returns the current extra_nodes, set via SetExtraNodesToLoad(). |
29 const std::vector<BookmarkPermanentNode*>& extra_nodes() { | 30 const std::vector<BookmarkPermanentNode*>& extra_nodes() { |
30 return extra_nodes_; | 31 return extra_nodes_; |
31 } | 32 } |
32 | 33 |
33 // Returns true if |node| is one of the |extra_nodes_|. | 34 // Returns true if |node| is one of the |extra_nodes_|. |
34 bool IsExtraNodeRoot(const BookmarkNode* node); | 35 bool IsExtraNodeRoot(const BookmarkNode* node); |
35 | 36 |
36 // Returns true if |node| belongs to the tree of one of the |extra_nodes_|. | 37 // Returns true if |node| belongs to the tree of one of the |extra_nodes_|. |
37 bool IsAnExtraNode(const BookmarkNode* node); | 38 bool IsAnExtraNode(const BookmarkNode* node); |
38 | 39 |
39 private: | 40 private: |
40 // BookmarkClient: | 41 // BookmarkClient: |
41 virtual bool IsPermanentNodeVisible( | 42 virtual bool IsPermanentNodeVisible( |
42 const BookmarkPermanentNode* node) OVERRIDE; | 43 const BookmarkPermanentNode* node) OVERRIDE; |
43 virtual void RecordAction(const base::UserMetricsAction& action) OVERRIDE; | 44 virtual void RecordAction(const base::UserMetricsAction& action) OVERRIDE; |
44 virtual bookmarks::LoadExtraCallback GetLoadExtraNodesCallback() OVERRIDE; | 45 virtual bookmarks::LoadExtraCallback GetLoadExtraNodesCallback() OVERRIDE; |
| 46 virtual bool CanRemovePermanentNodeChildren( |
| 47 const BookmarkNode* node) OVERRIDE; |
45 virtual bool CanSetPermanentNodeTitle( | 48 virtual bool CanSetPermanentNodeTitle( |
46 const BookmarkNode* permanent_node) OVERRIDE; | 49 const BookmarkNode* permanent_node) OVERRIDE; |
47 virtual bool CanSyncNode(const BookmarkNode* node) OVERRIDE; | 50 virtual bool CanSyncNode(const BookmarkNode* node) OVERRIDE; |
48 virtual bool CanBeEditedByUser(const BookmarkNode* node) OVERRIDE; | 51 virtual bool CanReorderChildren(const BookmarkNode* parent) OVERRIDE; |
49 | 52 |
50 // Helpers for GetLoadExtraNodesCallback(). | 53 // Helpers for GetLoadExtraNodesCallback(). |
51 static bookmarks::BookmarkPermanentNodeList LoadExtraNodes( | 54 static bookmarks::BookmarkPermanentNodeList LoadExtraNodes( |
52 bookmarks::BookmarkPermanentNodeList extra_nodes, | 55 bookmarks::BookmarkPermanentNodeList extra_nodes, |
53 int64* next_id); | 56 int64* next_id); |
54 | 57 |
55 bookmarks::BookmarkPermanentNodeList extra_nodes_to_load_; | 58 bookmarks::BookmarkPermanentNodeList extra_nodes_to_load_; |
56 std::vector<BookmarkPermanentNode*> extra_nodes_; | 59 std::vector<BookmarkPermanentNode*> extra_nodes_; |
57 | 60 |
58 DISALLOW_COPY_AND_ASSIGN(TestBookmarkClient); | 61 DISALLOW_COPY_AND_ASSIGN(TestBookmarkClient); |
59 }; | 62 }; |
60 | 63 |
61 } // namespace test | 64 } // namespace test |
62 | 65 |
63 #endif // COMPONENTS_BOOKMARKS_TEST_TEST_BOOKMARK_CLIENT_H_ | 66 #endif // COMPONENTS_BOOKMARKS_TEST_TEST_BOOKMARK_CLIENT_H_ |
OLD | NEW |