| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_SYNC_TEST_LIVE_SYNC_BOOKMARKS_HELPER_H_ | |
| 6 #define CHROME_BROWSER_SYNC_TEST_LIVE_SYNC_BOOKMARKS_HELPER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <set> | |
| 10 #include <string> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/compiler_specific.h" | |
| 14 #include "chrome/browser/bookmarks/bookmark_model.h" | |
| 15 #include "googleurl/src/gurl.h" | |
| 16 #include "testing/gtest/include/gtest/gtest.h" | |
| 17 #include "third_party/skia/include/core/SkBitmap.h" | |
| 18 | |
| 19 class GURL; | |
| 20 class Profile; | |
| 21 | |
| 22 namespace bookmarks_helper { | |
| 23 | |
| 24 // Used to access the bookmark model within a particular sync profile. | |
| 25 BookmarkModel* GetBookmarkModel(int index) WARN_UNUSED_RESULT; | |
| 26 | |
| 27 // Used to access the bookmark bar within a particular sync profile. | |
| 28 const BookmarkNode* GetBookmarkBarNode(int index) WARN_UNUSED_RESULT; | |
| 29 | |
| 30 // Used to access the "other bookmarks" node within a particular sync profile. | |
| 31 const BookmarkNode* GetOtherNode(int index) WARN_UNUSED_RESULT; | |
| 32 | |
| 33 // Used to access the bookmarks within the verifier sync profile. | |
| 34 BookmarkModel* GetVerifierBookmarkModel() WARN_UNUSED_RESULT; | |
| 35 | |
| 36 // Adds a URL with address |url| and title |title| to the bookmark bar of | |
| 37 // profile |profile|. Returns a pointer to the node that was added. | |
| 38 const BookmarkNode* AddURL( | |
| 39 int profile, | |
| 40 const std::wstring& title, | |
| 41 const GURL& url) WARN_UNUSED_RESULT; | |
| 42 | |
| 43 // Adds a URL with address |url| and title |title| to the bookmark bar of | |
| 44 // profile |profile| at position |index|. Returns a pointer to the node that | |
| 45 // was added. | |
| 46 const BookmarkNode* AddURL( | |
| 47 int profile, | |
| 48 int index, | |
| 49 const std::wstring& title, | |
| 50 const GURL& url) WARN_UNUSED_RESULT; | |
| 51 | |
| 52 // Adds a URL with address |url| and title |title| under the node |parent| of | |
| 53 // profile |profile| at position |index|. Returns a pointer to the node that | |
| 54 // was added. | |
| 55 const BookmarkNode* AddURL( | |
| 56 int profile, | |
| 57 const BookmarkNode* parent, | |
| 58 int index, | |
| 59 const std::wstring& title, | |
| 60 const GURL& url) WARN_UNUSED_RESULT; | |
| 61 | |
| 62 // Adds a folder named |title| to the bookmark bar of profile |profile|. | |
| 63 // Returns a pointer to the folder that was added. | |
| 64 const BookmarkNode* AddFolder( | |
| 65 int profile, | |
| 66 const std::wstring& title) WARN_UNUSED_RESULT; | |
| 67 | |
| 68 // Adds a folder named |title| to the bookmark bar of profile |profile| at | |
| 69 // position |index|. Returns a pointer to the folder that was added. | |
| 70 const BookmarkNode* AddFolder( | |
| 71 int profile, | |
| 72 int index, | |
| 73 const std::wstring& title) WARN_UNUSED_RESULT; | |
| 74 | |
| 75 // Adds a folder named |title| to the node |parent| in the bookmark model of | |
| 76 // profile |profile| at position |index|. Returns a pointer to the node that | |
| 77 // was added. | |
| 78 const BookmarkNode* AddFolder( | |
| 79 int profile, | |
| 80 const BookmarkNode* parent, | |
| 81 int index, | |
| 82 const std::wstring& title) WARN_UNUSED_RESULT; | |
| 83 | |
| 84 // Changes the title of the node |node| in the bookmark model of profile | |
| 85 // |profile| to |new_title|. | |
| 86 void SetTitle(int profile, | |
| 87 const BookmarkNode* node, | |
| 88 const std::wstring& new_title); | |
| 89 | |
| 90 // Sets the favicon of the node |node| (of type BookmarkNode::URL) in the | |
| 91 // bookmark model of profile |profile| using the data in |icon_bytes_vector|. | |
| 92 void SetFavicon( | |
| 93 int profile, | |
| 94 const BookmarkNode* node, | |
| 95 const std::vector<unsigned char>& icon_bytes_vector); | |
| 96 | |
| 97 // Changes the url of the node |node| in the bookmark model of profile | |
| 98 // |profile| to |new_url|. Returns a pointer to the node with the changed url. | |
| 99 const BookmarkNode* SetURL( | |
| 100 int profile, | |
| 101 const BookmarkNode* node, | |
| 102 const GURL& new_url) WARN_UNUSED_RESULT; | |
| 103 | |
| 104 // Moves the node |node| in the bookmark model of profile |profile| so it ends | |
| 105 // up under the node |new_parent| at position |index|. | |
| 106 void Move( | |
| 107 int profile, | |
| 108 const BookmarkNode* node, | |
| 109 const BookmarkNode* new_parent, | |
| 110 int index); | |
| 111 | |
| 112 // Removes the node in the bookmark model of profile |profile| under the node | |
| 113 // |parent| at position |index|. | |
| 114 void Remove(int profile, const BookmarkNode* parent, int index); | |
| 115 | |
| 116 // Sorts the children of the node |parent| in the bookmark model of profile | |
| 117 // |profile|. | |
| 118 void SortChildren(int profile, const BookmarkNode* parent); | |
| 119 | |
| 120 // Reverses the order of the children of the node |parent| in the bookmark | |
| 121 // model of profile |profile|. | |
| 122 void ReverseChildOrder(int profile, const BookmarkNode* parent); | |
| 123 | |
| 124 // Checks if the bookmark model of profile |profile| matches the verifier | |
| 125 // bookmark model. Returns true if they match. | |
| 126 bool ModelMatchesVerifier(int profile) WARN_UNUSED_RESULT; | |
| 127 | |
| 128 // Checks if the bookmark models of all sync profiles match the verifier | |
| 129 // bookmark model. Returns true if they match. | |
| 130 bool AllModelsMatchVerifier() WARN_UNUSED_RESULT; | |
| 131 | |
| 132 // Checks if the bookmark models of |profile_a| and |profile_b| match each | |
| 133 // other. Returns true if they match. | |
| 134 bool ModelsMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT; | |
| 135 | |
| 136 // Checks if the bookmark models of all sync profiles match each other. Does | |
| 137 // not compare them with the verifier bookmark model. Returns true if they | |
| 138 // match. | |
| 139 bool AllModelsMatch() WARN_UNUSED_RESULT; | |
| 140 | |
| 141 // Checks if the bookmark model of profile |profile| contains any instances of | |
| 142 // two bookmarks with the same URL under the same parent folder. Returns true | |
| 143 // if even one instance is found. | |
| 144 bool ContainsDuplicateBookmarks(int profile); | |
| 145 | |
| 146 // Gets the node in the bookmark model of profile |profile| that has the url | |
| 147 // |url|. Note: Only one instance of |url| is assumed to be present. | |
| 148 const BookmarkNode* GetUniqueNodeByURL( | |
| 149 int profile, | |
| 150 const GURL& url) WARN_UNUSED_RESULT; | |
| 151 | |
| 152 // Returns the number of bookmarks in bookmark model of profile |profile| | |
| 153 // whose titles match the string |title|. | |
| 154 int CountBookmarksWithTitlesMatching( | |
| 155 int profile, | |
| 156 const std::wstring& title) WARN_UNUSED_RESULT; | |
| 157 | |
| 158 // Returns the number of bookmark folders in the bookmark model of profile | |
| 159 // |profile| whose titles contain the query string |title|. | |
| 160 int CountFoldersWithTitlesMatching( | |
| 161 int profile, | |
| 162 const std::wstring& title) WARN_UNUSED_RESULT; | |
| 163 | |
| 164 // Creates a unique favicon using |seed|. | |
| 165 std::vector<unsigned char> CreateFavicon(int seed); | |
| 166 | |
| 167 // Returns a URL identifiable by |i|. | |
| 168 std::string IndexedURL(int i); | |
| 169 | |
| 170 // Returns a URL title identifiable by |i|. | |
| 171 std::wstring IndexedURLTitle(int i); | |
| 172 | |
| 173 // Returns a folder name identifiable by |i|. | |
| 174 std::wstring IndexedFolderName(int i); | |
| 175 | |
| 176 // Returns a subfolder name identifiable by |i|. | |
| 177 std::wstring IndexedSubfolderName(int i); | |
| 178 | |
| 179 // Returns a subsubfolder name identifiable by |i|. | |
| 180 std::wstring IndexedSubsubfolderName(int i); | |
| 181 | |
| 182 } // namespace bookmarks_helper | |
| 183 | |
| 184 #endif // CHROME_BROWSER_SYNC_TEST_LIVE_SYNC_BOOKMARKS_HELPER_H_ | |
| OLD | NEW |