| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef SYNC_TEST_FAKE_SERVER_BOOKMARK_ENTITY_BUILDER_H_ | |
| 6 #define SYNC_TEST_FAKE_SERVER_BOOKMARK_ENTITY_BUILDER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "sync/internal_api/public/base/model_type.h" | |
| 12 #include "sync/test/fake_server/fake_server_entity.h" | |
| 13 #include "url/gurl.h" | |
| 14 | |
| 15 namespace fake_server { | |
| 16 | |
| 17 // Builder for BookmarkEntity objects. | |
| 18 class BookmarkEntityBuilder { | |
| 19 public: | |
| 20 BookmarkEntityBuilder(const std::string& title, | |
| 21 const std::string& originator_cache_guid, | |
| 22 const std::string& originator_client_item_id); | |
| 23 | |
| 24 BookmarkEntityBuilder(const BookmarkEntityBuilder& other); | |
| 25 | |
| 26 ~BookmarkEntityBuilder(); | |
| 27 | |
| 28 // Sets the parent ID of the bookmark to be built. If this is not called, | |
| 29 // the bookmark will be included in the bookmarks bar. | |
| 30 void SetParentId(const std::string& parent_id); | |
| 31 | |
| 32 // Builds and returns a FakeServerEntity representing a bookmark. Returns null | |
| 33 // if the entity could not be built. | |
| 34 std::unique_ptr<FakeServerEntity> BuildBookmark(const GURL& url); | |
| 35 | |
| 36 // Builds and returns a FakeServerEntity representing a bookmark folder. | |
| 37 // Returns null if the entity could not be built. | |
| 38 std::unique_ptr<FakeServerEntity> BuildFolder(); | |
| 39 | |
| 40 private: | |
| 41 // Creates an EntitySpecifics and pre-populates its BookmarkSpecifics with | |
| 42 // the entity's title. | |
| 43 sync_pb::EntitySpecifics CreateBaseEntitySpecifics() const; | |
| 44 | |
| 45 // Builds the parts of a FakeServerEntity common to both normal bookmarks and | |
| 46 // folders. | |
| 47 std::unique_ptr<FakeServerEntity> Build( | |
| 48 const sync_pb::EntitySpecifics& entity_specifics, | |
| 49 bool is_folder); | |
| 50 | |
| 51 // The bookmark entity's title. This value is also used as the entity's name. | |
| 52 const std::string title_; | |
| 53 | |
| 54 // Information that associates the bookmark with its original client. | |
| 55 const std::string originator_cache_guid_; | |
| 56 const std::string originator_client_item_id_; | |
| 57 | |
| 58 // The ID of the parent bookmark folder. | |
| 59 std::string parent_id_; | |
| 60 }; | |
| 61 | |
| 62 } // namespace fake_server | |
| 63 | |
| 64 #endif // SYNC_TEST_FAKE_SERVER_BOOKMARK_ENTITY_BUILDER_H_ | |
| OLD | NEW |