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_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_MODEL_H_ | 5 #ifndef COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_MODEL_H_ |
6 #define COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_MODEL_H_ | 6 #define COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_MODEL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 // Wrapper around BookmarkModel providing utility functions for enhanced | 32 // Wrapper around BookmarkModel providing utility functions for enhanced |
33 // bookmarks. | 33 // bookmarks. |
34 class EnhancedBookmarkModel : public KeyedService, | 34 class EnhancedBookmarkModel : public KeyedService, |
35 public BaseBookmarkModelObserver { | 35 public BaseBookmarkModelObserver { |
36 public: | 36 public: |
37 EnhancedBookmarkModel(BookmarkModel* bookmark_model, | 37 EnhancedBookmarkModel(BookmarkModel* bookmark_model, |
38 const std::string& version); | 38 const std::string& version); |
39 virtual ~EnhancedBookmarkModel(); | 39 virtual ~EnhancedBookmarkModel(); |
40 | 40 |
41 virtual void Shutdown() OVERRIDE; | 41 virtual void Shutdown() override; |
42 | 42 |
43 void AddObserver(EnhancedBookmarkModelObserver* observer); | 43 void AddObserver(EnhancedBookmarkModelObserver* observer); |
44 void RemoveObserver(EnhancedBookmarkModelObserver* observer); | 44 void RemoveObserver(EnhancedBookmarkModelObserver* observer); |
45 | 45 |
46 // Moves |node| to |new_parent| and inserts it at the given |index|. | 46 // Moves |node| to |new_parent| and inserts it at the given |index|. |
47 void Move(const BookmarkNode* node, | 47 void Move(const BookmarkNode* node, |
48 const BookmarkNode* new_parent, | 48 const BookmarkNode* new_parent, |
49 int index); | 49 int index); |
50 | 50 |
51 // Adds a new folder node at the specified position. | 51 // Adds a new folder node at the specified position. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // Returns true if the enhanced bookmark model is done loading. | 127 // Returns true if the enhanced bookmark model is done loading. |
128 bool loaded() { return loaded_; } | 128 bool loaded() { return loaded_; } |
129 | 129 |
130 private: | 130 private: |
131 FRIEND_TEST_ALL_PREFIXES(::EnhancedBookmarkModelTest, SetMultipleMetaInfo); | 131 FRIEND_TEST_ALL_PREFIXES(::EnhancedBookmarkModelTest, SetMultipleMetaInfo); |
132 | 132 |
133 typedef std::map<std::string, const BookmarkNode*> IdToNodeMap; | 133 typedef std::map<std::string, const BookmarkNode*> IdToNodeMap; |
134 typedef std::map<const BookmarkNode*, std::string> NodeToIdMap; | 134 typedef std::map<const BookmarkNode*, std::string> NodeToIdMap; |
135 | 135 |
136 // BaseBookmarkModelObserver: | 136 // BaseBookmarkModelObserver: |
137 virtual void BookmarkModelChanged() OVERRIDE; | 137 virtual void BookmarkModelChanged() override; |
138 virtual void BookmarkModelLoaded(BookmarkModel* model, | 138 virtual void BookmarkModelLoaded(BookmarkModel* model, |
139 bool ids_reassigned) OVERRIDE; | 139 bool ids_reassigned) override; |
140 virtual void BookmarkNodeAdded(BookmarkModel* model, | 140 virtual void BookmarkNodeAdded(BookmarkModel* model, |
141 const BookmarkNode* parent, | 141 const BookmarkNode* parent, |
142 int index) OVERRIDE; | 142 int index) override; |
143 virtual void BookmarkNodeRemoved(BookmarkModel* model, | 143 virtual void BookmarkNodeRemoved(BookmarkModel* model, |
144 const BookmarkNode* parent, | 144 const BookmarkNode* parent, |
145 int old_index, | 145 int old_index, |
146 const BookmarkNode* node, | 146 const BookmarkNode* node, |
147 const std::set<GURL>& removed_urls) OVERRIDE; | 147 const std::set<GURL>& removed_urls) override; |
148 virtual void OnWillChangeBookmarkMetaInfo(BookmarkModel* model, | 148 virtual void OnWillChangeBookmarkMetaInfo(BookmarkModel* model, |
149 const BookmarkNode* node) OVERRIDE; | 149 const BookmarkNode* node) override; |
150 virtual void BookmarkMetaInfoChanged(BookmarkModel* model, | 150 virtual void BookmarkMetaInfoChanged(BookmarkModel* model, |
151 const BookmarkNode* node) OVERRIDE; | 151 const BookmarkNode* node) override; |
152 virtual void BookmarkAllUserNodesRemoved( | 152 virtual void BookmarkAllUserNodesRemoved( |
153 BookmarkModel* model, | 153 BookmarkModel* model, |
154 const std::set<GURL>& removed_urls) OVERRIDE; | 154 const std::set<GURL>& removed_urls) override; |
155 | 155 |
156 // Initialize the mapping from remote ids to nodes. | 156 // Initialize the mapping from remote ids to nodes. |
157 void InitializeIdMap(); | 157 void InitializeIdMap(); |
158 | 158 |
159 // Adds a node to the id map if it has a (unique) remote id. Must be followed | 159 // Adds a node to the id map if it has a (unique) remote id. Must be followed |
160 // by a (Schedule)ResetDuplicateRemoteIds call when done adding nodes. | 160 // by a (Schedule)ResetDuplicateRemoteIds call when done adding nodes. |
161 void AddToIdMap(const BookmarkNode* node); | 161 void AddToIdMap(const BookmarkNode* node); |
162 | 162 |
163 // If there are nodes that needs to reset their remote ids, schedules | 163 // If there are nodes that needs to reset their remote ids, schedules |
164 // ResetDuplicateRemoteIds to be run asynchronously. | 164 // ResetDuplicateRemoteIds to be run asynchronously. |
(...skipping 30 matching lines...) Expand all Loading... |
195 // Caches the remote id of a node before its meta info changes. | 195 // Caches the remote id of a node before its meta info changes. |
196 std::string prev_remote_id_; | 196 std::string prev_remote_id_; |
197 | 197 |
198 std::string version_; | 198 std::string version_; |
199 std::string version_suffix_; | 199 std::string version_suffix_; |
200 }; | 200 }; |
201 | 201 |
202 } // namespace enhanced_bookmarks | 202 } // namespace enhanced_bookmarks |
203 | 203 |
204 #endif // COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_MODEL_H_ | 204 #endif // COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_MODEL_H_ |
OLD | NEW |