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_BROWSER_BOOKMARK_MODEL_H_ | 5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ |
6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ | 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // Returns true if this bookmark model is currently in a mode where extensive | 124 // Returns true if this bookmark model is currently in a mode where extensive |
125 // changes might happen, such as for import and sync. This is helpful for | 125 // changes might happen, such as for import and sync. This is helpful for |
126 // observers that are created after the mode has started, and want to check | 126 // observers that are created after the mode has started, and want to check |
127 // state during their own initializer, such as the NTP. | 127 // state during their own initializer, such as the NTP. |
128 bool IsDoingExtensiveChanges() const { return extensive_changes_ > 0; } | 128 bool IsDoingExtensiveChanges() const { return extensive_changes_ > 0; } |
129 | 129 |
130 // Removes the node at the given |index| from |parent|. Removing a folder node | 130 // Removes the node at the given |index| from |parent|. Removing a folder node |
131 // recursively removes all nodes. Observers are notified immediately. | 131 // recursively removes all nodes. Observers are notified immediately. |
132 void Remove(const BookmarkNode* parent, int index); | 132 void Remove(const BookmarkNode* parent, int index); |
133 | 133 |
134 // Removes all the non-permanent bookmark nodes that are editable by the user. | 134 // Removes all the non-permanent bookmark nodes. Observers are only notified |
135 // Observers are only notified when all nodes have been removed. There is no | 135 // when all nodes have been removed. There is no notification for individual |
136 // notification for individual node removals. | 136 // node removals. |
137 void RemoveAll(); | 137 void RemoveAll(); |
138 | 138 |
139 // Moves |node| to |new_parent| and inserts it at the given |index|. | 139 // Moves |node| to |new_parent| and inserts it at the given |index|. |
140 void Move(const BookmarkNode* node, | 140 void Move(const BookmarkNode* node, |
141 const BookmarkNode* new_parent, | 141 const BookmarkNode* new_parent, |
142 int index); | 142 int index); |
143 | 143 |
144 // Inserts a copy of |node| into |new_parent| at |index|. | 144 // Inserts a copy of |node| into |new_parent| at |index|. |
145 void Copy(const BookmarkNode* node, | 145 void Copy(const BookmarkNode* node, |
146 const BookmarkNode* new_parent, | 146 const BookmarkNode* new_parent, |
(...skipping 12 matching lines...) Expand all Loading... |
159 | 159 |
160 // Sets the URL of |node|. | 160 // Sets the URL of |node|. |
161 void SetURL(const BookmarkNode* node, const GURL& url); | 161 void SetURL(const BookmarkNode* node, const GURL& url); |
162 | 162 |
163 // Sets the date added time of |node|. | 163 // Sets the date added time of |node|. |
164 void SetDateAdded(const BookmarkNode* node, base::Time date_added); | 164 void SetDateAdded(const BookmarkNode* node, base::Time date_added); |
165 | 165 |
166 // Returns the set of nodes with the |url|. | 166 // Returns the set of nodes with the |url|. |
167 void GetNodesByURL(const GURL& url, std::vector<const BookmarkNode*>* nodes); | 167 void GetNodesByURL(const GURL& url, std::vector<const BookmarkNode*>* nodes); |
168 | 168 |
169 // Returns the most recently added user node for the |url|; urls from any | 169 // Returns the most recently added node for the |url|. Returns NULL if |url| |
170 // nodes that are not editable by the user are never returned by this call. | 170 // is not bookmarked. |
171 // Returns NULL if |url| is not bookmarked. | 171 const BookmarkNode* GetMostRecentlyAddedNodeForURL(const GURL& url); |
172 const BookmarkNode* GetMostRecentlyAddedUserNodeForURL(const GURL& url); | |
173 | 172 |
174 // Returns true if there are bookmarks, otherwise returns false. | 173 // Returns true if there are bookmarks, otherwise returns false. |
175 // This method is thread safe. | 174 // This method is thread safe. |
176 bool HasBookmarks(); | 175 bool HasBookmarks(); |
177 | 176 |
178 // Returns true if the specified URL is bookmarked. | 177 // Returns true if the specified URL is bookmarked. |
179 // | 178 // |
180 // If not on the main thread you *must* invoke BlockTillLoaded first. | 179 // If not on the main thread you *must* invoke BlockTillLoaded first. |
181 bool IsBookmarked(const GURL& url); | 180 bool IsBookmarked(const GURL& url); |
182 | 181 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 423 |
425 // See description of IsDoingExtensiveChanges above. | 424 // See description of IsDoingExtensiveChanges above. |
426 int extensive_changes_; | 425 int extensive_changes_; |
427 | 426 |
428 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; | 427 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; |
429 | 428 |
430 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); | 429 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); |
431 }; | 430 }; |
432 | 431 |
433 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ | 432 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ |
OLD | NEW |