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

Side by Side Diff: chrome/browser/sync/test/integration/bookmarks_helper.h

Issue 865163003: bookmarks: Move BookmarkNode into 'bookmarks' namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enhanced_bookmarks fix Created 5 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROME_BROWSER_SYNC_TEST_INTEGRATION_BOOKMARKS_HELPER_H_ 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_BOOKMARKS_HELPER_H_
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_BOOKMARKS_HELPER_H_ 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_BOOKMARKS_HELPER_H_
7 7
8 #include <set>
9 #include <string> 8 #include <string>
10 #include <vector>
11 9
12 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
13 #include "components/bookmarks/browser/bookmark_model.h" 11 #include "third_party/skia/include/core/SkColor.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/skia/include/core/SkBitmap.h"
16 #include "url/gurl.h"
17 12
18 class GURL; 13 class GURL;
19 14
15 namespace bookmarks {
16 class BookmarkModel;
17 class BookmarkNode;
18 }
19
20 namespace gfx {
21 class Image;
22 }
23
20 namespace bookmarks_helper { 24 namespace bookmarks_helper {
21 25
22 // Used to access the bookmark model within a particular sync profile. 26 // Used to access the bookmark model within a particular sync profile.
23 bookmarks::BookmarkModel* GetBookmarkModel(int index) WARN_UNUSED_RESULT; 27 bookmarks::BookmarkModel* GetBookmarkModel(int index) WARN_UNUSED_RESULT;
24 28
25 // Used to access the bookmark bar within a particular sync profile. 29 // Used to access the bookmark bar within a particular sync profile.
26 const BookmarkNode* GetBookmarkBarNode(int index) WARN_UNUSED_RESULT; 30 const bookmarks::BookmarkNode* GetBookmarkBarNode(int index) WARN_UNUSED_RESULT;
27 31
28 // Used to access the "other bookmarks" node within a particular sync profile. 32 // Used to access the "other bookmarks" node within a particular sync profile.
29 const BookmarkNode* GetOtherNode(int index) WARN_UNUSED_RESULT; 33 const bookmarks::BookmarkNode* GetOtherNode(int index) WARN_UNUSED_RESULT;
30 34
31 // Used to access the "Synced Bookmarks" node within a particular sync profile. 35 // Used to access the "Synced Bookmarks" node within a particular sync profile.
32 const BookmarkNode* GetSyncedBookmarksNode(int index) WARN_UNUSED_RESULT; 36 const bookmarks::BookmarkNode* GetSyncedBookmarksNode(int index)
37 WARN_UNUSED_RESULT;
33 38
34 // Used to access the "Managed Bookmarks" node for the given profile. 39 // Used to access the "Managed Bookmarks" node for the given profile.
35 const BookmarkNode* GetManagedNode(int index) WARN_UNUSED_RESULT; 40 const bookmarks::BookmarkNode* GetManagedNode(int index) WARN_UNUSED_RESULT;
36 41
37 // Used to access the bookmarks within the verifier sync profile. 42 // Used to access the bookmarks within the verifier sync profile.
38 bookmarks::BookmarkModel* GetVerifierBookmarkModel() WARN_UNUSED_RESULT; 43 bookmarks::BookmarkModel* GetVerifierBookmarkModel() WARN_UNUSED_RESULT;
39 44
40 // Adds a URL with address |url| and title |title| to the bookmark bar of 45 // Adds a URL with address |url| and title |title| to the bookmark bar of
41 // profile |profile|. Returns a pointer to the node that was added. 46 // profile |profile|. Returns a pointer to the node that was added.
42 const BookmarkNode* AddURL( 47 const bookmarks::BookmarkNode* AddURL(int profile,
43 int profile, 48 const std::string& title,
44 const std::string& title, 49 const GURL& url) WARN_UNUSED_RESULT;
45 const GURL& url) WARN_UNUSED_RESULT;
46 50
47 // Adds a URL with address |url| and title |title| to the bookmark bar of 51 // Adds a URL with address |url| and title |title| to the bookmark bar of
48 // profile |profile| at position |index|. Returns a pointer to the node that 52 // profile |profile| at position |index|. Returns a pointer to the node that
49 // was added. 53 // was added.
50 const BookmarkNode* AddURL( 54 const bookmarks::BookmarkNode* AddURL(int profile,
51 int profile, 55 int index,
52 int index, 56 const std::string& title,
53 const std::string& title, 57 const GURL& url) WARN_UNUSED_RESULT;
54 const GURL& url) WARN_UNUSED_RESULT;
55 58
56 // Adds a URL with address |url| and title |title| under the node |parent| of 59 // Adds a URL with address |url| and title |title| under the node |parent| of
57 // profile |profile| at position |index|. Returns a pointer to the node that 60 // profile |profile| at position |index|. Returns a pointer to the node that
58 // was added. 61 // was added.
59 const BookmarkNode* AddURL( 62 const bookmarks::BookmarkNode* AddURL(int profile,
60 int profile, 63 const bookmarks::BookmarkNode* parent,
61 const BookmarkNode* parent, 64 int index,
62 int index, 65 const std::string& title,
63 const std::string& title, 66 const GURL& url) WARN_UNUSED_RESULT;
64 const GURL& url) WARN_UNUSED_RESULT;
65 67
66 // Adds a folder named |title| to the bookmark bar of profile |profile|. 68 // Adds a folder named |title| to the bookmark bar of profile |profile|.
67 // Returns a pointer to the folder that was added. 69 // Returns a pointer to the folder that was added.
68 const BookmarkNode* AddFolder( 70 const bookmarks::BookmarkNode* AddFolder(int profile, const std::string& title)
69 int profile, 71 WARN_UNUSED_RESULT;
70 const std::string& title) WARN_UNUSED_RESULT;
71 72
72 // Adds a folder named |title| to the bookmark bar of profile |profile| at 73 // Adds a folder named |title| to the bookmark bar of profile |profile| at
73 // position |index|. Returns a pointer to the folder that was added. 74 // position |index|. Returns a pointer to the folder that was added.
74 const BookmarkNode* AddFolder( 75 const bookmarks::BookmarkNode* AddFolder(int profile,
75 int profile, 76 int index,
76 int index, 77 const std::string& title)
77 const std::string& title) WARN_UNUSED_RESULT; 78 WARN_UNUSED_RESULT;
78 79
79 // Adds a folder named |title| to the node |parent| in the bookmark model of 80 // Adds a folder named |title| to the node |parent| in the bookmark model of
80 // profile |profile| at position |index|. Returns a pointer to the node that 81 // profile |profile| at position |index|. Returns a pointer to the node that
81 // was added. 82 // was added.
82 const BookmarkNode* AddFolder( 83 const bookmarks::BookmarkNode* AddFolder(int profile,
83 int profile, 84 const bookmarks::BookmarkNode* parent,
84 const BookmarkNode* parent, 85 int index,
85 int index, 86 const std::string& title)
86 const std::string& title) WARN_UNUSED_RESULT; 87 WARN_UNUSED_RESULT;
87 88
88 // Changes the title of the node |node| in the bookmark model of profile 89 // Changes the title of the node |node| in the bookmark model of profile
89 // |profile| to |new_title|. 90 // |profile| to |new_title|.
90 void SetTitle(int profile, 91 void SetTitle(int profile,
91 const BookmarkNode* node, 92 const bookmarks::BookmarkNode* node,
92 const std::string& new_title); 93 const std::string& new_title);
93 94
94 // The source of the favicon. 95 // The source of the favicon.
95 enum FaviconSource { 96 enum FaviconSource {
96 FROM_UI, 97 FROM_UI,
97 FROM_SYNC 98 FROM_SYNC
98 }; 99 };
99 100
100 // Sets the |icon_url| and |image| data for the favicon for |node| in the 101 // Sets the |icon_url| and |image| data for the favicon for |node| in the
101 // bookmark model for |profile|. 102 // bookmark model for |profile|.
102 void SetFavicon(int profile, 103 void SetFavicon(int profile,
103 const BookmarkNode* node, 104 const bookmarks::BookmarkNode* node,
104 const GURL& icon_url, 105 const GURL& icon_url,
105 const gfx::Image& image, 106 const gfx::Image& image,
106 FaviconSource source); 107 FaviconSource source);
107 108
108 // Changes the url of the node |node| in the bookmark model of profile 109 // Changes the url of the node |node| in the bookmark model of profile
109 // |profile| to |new_url|. Returns a pointer to the node with the changed url. 110 // |profile| to |new_url|. Returns a pointer to the node with the changed url.
110 const BookmarkNode* SetURL( 111 const bookmarks::BookmarkNode* SetURL(int profile,
111 int profile, 112 const bookmarks::BookmarkNode* node,
112 const BookmarkNode* node, 113 const GURL& new_url) WARN_UNUSED_RESULT;
113 const GURL& new_url) WARN_UNUSED_RESULT;
114 114
115 // Moves the node |node| in the bookmark model of profile |profile| so it ends 115 // Moves the node |node| in the bookmark model of profile |profile| so it ends
116 // up under the node |new_parent| at position |index|. 116 // up under the node |new_parent| at position |index|.
117 void Move( 117 void Move(int profile,
118 int profile, 118 const bookmarks::BookmarkNode* node,
119 const BookmarkNode* node, 119 const bookmarks::BookmarkNode* new_parent,
120 const BookmarkNode* new_parent, 120 int index);
121 int index);
122 121
123 // Removes the node in the bookmark model of profile |profile| under the node 122 // Removes the node in the bookmark model of profile |profile| under the node
124 // |parent| at position |index|. 123 // |parent| at position |index|.
125 void Remove(int profile, const BookmarkNode* parent, int index); 124 void Remove(int profile, const bookmarks::BookmarkNode* parent, int index);
126 125
127 // Removes all non-permanent nodes in the bookmark model of profile |profile|. 126 // Removes all non-permanent nodes in the bookmark model of profile |profile|.
128 void RemoveAll(int profile); 127 void RemoveAll(int profile);
129 128
130 // Sorts the children of the node |parent| in the bookmark model of profile 129 // Sorts the children of the node |parent| in the bookmark model of profile
131 // |profile|. 130 // |profile|.
132 void SortChildren(int profile, const BookmarkNode* parent); 131 void SortChildren(int profile, const bookmarks::BookmarkNode* parent);
133 132
134 // Reverses the order of the children of the node |parent| in the bookmark 133 // Reverses the order of the children of the node |parent| in the bookmark
135 // model of profile |profile|. 134 // model of profile |profile|.
136 void ReverseChildOrder(int profile, const BookmarkNode* parent); 135 void ReverseChildOrder(int profile, const bookmarks::BookmarkNode* parent);
137 136
138 // Checks if the bookmark model of profile |profile| matches the verifier 137 // Checks if the bookmark model of profile |profile| matches the verifier
139 // bookmark model. Returns true if they match. 138 // bookmark model. Returns true if they match.
140 bool ModelMatchesVerifier(int profile) WARN_UNUSED_RESULT; 139 bool ModelMatchesVerifier(int profile) WARN_UNUSED_RESULT;
141 140
142 // Checks if the bookmark models of all sync profiles match the verifier 141 // Checks if the bookmark models of all sync profiles match the verifier
143 // bookmark model. Returns true if they match. 142 // bookmark model. Returns true if they match.
144 bool AllModelsMatchVerifier() WARN_UNUSED_RESULT; 143 bool AllModelsMatchVerifier() WARN_UNUSED_RESULT;
145 144
146 // Checks if the bookmark models of |profile_a| and |profile_b| match each 145 // Checks if the bookmark models of |profile_a| and |profile_b| match each
(...skipping 13 matching lines...) Expand all
160 // Checks if the bookmark model of profile |profile| contains any instances of 159 // Checks if the bookmark model of profile |profile| contains any instances of
161 // two bookmarks with the same URL under the same parent folder. Returns true 160 // two bookmarks with the same URL under the same parent folder. Returns true
162 // if even one instance is found. 161 // if even one instance is found.
163 bool ContainsDuplicateBookmarks(int profile); 162 bool ContainsDuplicateBookmarks(int profile);
164 163
165 // Returns whether a node exists with the specified url. 164 // Returns whether a node exists with the specified url.
166 bool HasNodeWithURL(int profile, const GURL& url); 165 bool HasNodeWithURL(int profile, const GURL& url);
167 166
168 // Gets the node in the bookmark model of profile |profile| that has the url 167 // Gets the node in the bookmark model of profile |profile| that has the url
169 // |url|. Note: Only one instance of |url| is assumed to be present. 168 // |url|. Note: Only one instance of |url| is assumed to be present.
170 const BookmarkNode* GetUniqueNodeByURL( 169 const bookmarks::BookmarkNode* GetUniqueNodeByURL(int profile, const GURL& url)
171 int profile, 170 WARN_UNUSED_RESULT;
172 const GURL& url) WARN_UNUSED_RESULT;
173 171
174 // Returns the number of bookmarks in bookmark model of profile |profile|. 172 // Returns the number of bookmarks in bookmark model of profile |profile|.
175 int CountAllBookmarks(int profile) WARN_UNUSED_RESULT; 173 int CountAllBookmarks(int profile) WARN_UNUSED_RESULT;
176 174
177 // Returns the number of bookmarks in bookmark model of profile |profile| 175 // Returns the number of bookmarks in bookmark model of profile |profile|
178 // whose titles match the string |title|. 176 // whose titles match the string |title|.
179 int CountBookmarksWithTitlesMatching( 177 int CountBookmarksWithTitlesMatching(
180 int profile, 178 int profile,
181 const std::string& title) WARN_UNUSED_RESULT; 179 const std::string& title) WARN_UNUSED_RESULT;
182 180
(...skipping 21 matching lines...) Expand all
204 202
205 // Returns a subfolder name identifiable by |i|. 203 // Returns a subfolder name identifiable by |i|.
206 std::string IndexedSubfolderName(int i); 204 std::string IndexedSubfolderName(int i);
207 205
208 // Returns a subsubfolder name identifiable by |i|. 206 // Returns a subsubfolder name identifiable by |i|.
209 std::string IndexedSubsubfolderName(int i); 207 std::string IndexedSubsubfolderName(int i);
210 208
211 } // namespace bookmarks_helper 209 } // namespace bookmarks_helper
212 210
213 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_BOOKMARKS_HELPER_H_ 211 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_BOOKMARKS_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698