| OLD | NEW |
| 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_BOOKMARKS_BOOKMARK_MODEL_H_ | 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ |
| 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // Loads the bookmarks. This is called upon creation of the | 67 // Loads the bookmarks. This is called upon creation of the |
| 68 // BookmarkModel. You need not invoke this directly. | 68 // BookmarkModel. You need not invoke this directly. |
| 69 // All load operations will be executed on |task_runner|. | 69 // All load operations will be executed on |task_runner|. |
| 70 void Load(const scoped_refptr<base::SequencedTaskRunner>& task_runner); | 70 void Load(const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
| 71 | 71 |
| 72 // Returns true if the model finished loading. | 72 // Returns true if the model finished loading. |
| 73 bool loaded() const { return loaded_; } | 73 bool loaded() const { return loaded_; } |
| 74 | 74 |
| 75 // Returns the root node. The 'bookmark bar' node and 'other' node are | 75 // Returns the root node. The 'bookmark bar' node and 'other' node are |
| 76 // children of the root node. | 76 // children of the root node. |
| 77 const BookmarkNode* root_node() { return &root_; } | 77 const BookmarkNode* root_node() const { return &root_; } |
| 78 | 78 |
| 79 // Returns the 'bookmark bar' node. This is NULL until loaded. | 79 // Returns the 'bookmark bar' node. This is NULL until loaded. |
| 80 const BookmarkNode* bookmark_bar_node() { return bookmark_bar_node_; } | 80 const BookmarkNode* bookmark_bar_node() const { return bookmark_bar_node_; } |
| 81 | 81 |
| 82 // Returns the 'other' node. This is NULL until loaded. | 82 // Returns the 'other' node. This is NULL until loaded. |
| 83 const BookmarkNode* other_node() { return other_node_; } | 83 const BookmarkNode* other_node() const { return other_node_; } |
| 84 | 84 |
| 85 // Returns the 'mobile' node. This is NULL until loaded. | 85 // Returns the 'mobile' node. This is NULL until loaded. |
| 86 const BookmarkNode* mobile_node() { return mobile_node_; } | 86 const BookmarkNode* mobile_node() const { return mobile_node_; } |
| 87 | 87 |
| 88 bool is_root_node(const BookmarkNode* node) const { return node == &root_; } | 88 bool is_root_node(const BookmarkNode* node) const { return node == &root_; } |
| 89 | 89 |
| 90 // Returns whether the given |node| is one of the permanent nodes - root node, | 90 // Returns whether the given |node| is one of the permanent nodes - root node, |
| 91 // 'bookmark bar' node, 'other' node or 'mobile' node. | 91 // 'bookmark bar' node, 'other' node or 'mobile' node. |
| 92 bool is_permanent_node(const BookmarkNode* node) const { | 92 bool is_permanent_node(const BookmarkNode* node) const { |
| 93 return node == &root_ || | 93 return node == &root_ || |
| 94 node == bookmark_bar_node_ || | 94 node == bookmark_bar_node_ || |
| 95 node == other_node_ || | 95 node == other_node_ || |
| 96 node == mobile_node_; | 96 node == mobile_node_; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 // Returns all the bookmarked urls and their titles. | 166 // Returns all the bookmarked urls and their titles. |
| 167 // This method is thread safe. | 167 // This method is thread safe. |
| 168 // See BookmarkService for more details on this. | 168 // See BookmarkService for more details on this. |
| 169 virtual void GetBookmarks( | 169 virtual void GetBookmarks( |
| 170 std::vector<BookmarkService::URLAndTitle>* urls) OVERRIDE; | 170 std::vector<BookmarkService::URLAndTitle>* urls) OVERRIDE; |
| 171 | 171 |
| 172 // Blocks until loaded; this is NOT invoked on the main thread. | 172 // Blocks until loaded; this is NOT invoked on the main thread. |
| 173 // See BookmarkService for more details on this. | 173 // See BookmarkService for more details on this. |
| 174 virtual void BlockTillLoaded() OVERRIDE; | 174 virtual void BlockTillLoaded() OVERRIDE; |
| 175 | 175 |
| 176 // Returns the node with |id|, or NULL if there is no node with |id|. | |
| 177 const BookmarkNode* GetNodeByID(int64 id) const; | |
| 178 | |
| 179 // Adds a new folder node at the specified position. | 176 // Adds a new folder node at the specified position. |
| 180 const BookmarkNode* AddFolder(const BookmarkNode* parent, | 177 const BookmarkNode* AddFolder(const BookmarkNode* parent, |
| 181 int index, | 178 int index, |
| 182 const base::string16& title); | 179 const base::string16& title); |
| 183 | 180 |
| 184 // Adds a url at the specified position. | 181 // Adds a url at the specified position. |
| 185 const BookmarkNode* AddURL(const BookmarkNode* parent, | 182 const BookmarkNode* AddURL(const BookmarkNode* parent, |
| 186 int index, | 183 int index, |
| 187 const base::string16& title, | 184 const base::string16& title, |
| 188 const GURL& url); | 185 const GURL& url); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 // Notifies the history backend about urls of removed bookmarks. | 296 // Notifies the history backend about urls of removed bookmarks. |
| 300 void NotifyHistoryAboutRemovedBookmarks( | 297 void NotifyHistoryAboutRemovedBookmarks( |
| 301 const std::set<GURL>& removed_bookmark_urls) const; | 298 const std::set<GURL>& removed_bookmark_urls) const; |
| 302 | 299 |
| 303 // Adds the |node| at |parent| in the specified |index| and notifies its | 300 // Adds the |node| at |parent| in the specified |index| and notifies its |
| 304 // observers. | 301 // observers. |
| 305 BookmarkNode* AddNode(BookmarkNode* parent, | 302 BookmarkNode* AddNode(BookmarkNode* parent, |
| 306 int index, | 303 int index, |
| 307 BookmarkNode* node); | 304 BookmarkNode* node); |
| 308 | 305 |
| 309 // Implementation of GetNodeByID. | |
| 310 const BookmarkNode* GetNodeByID(const BookmarkNode* node, int64 id) const; | |
| 311 | |
| 312 // Returns true if the parent and index are valid. | 306 // Returns true if the parent and index are valid. |
| 313 bool IsValidIndex(const BookmarkNode* parent, int index, bool allow_end); | 307 bool IsValidIndex(const BookmarkNode* parent, int index, bool allow_end); |
| 314 | 308 |
| 315 // Creates one of the possible permanent nodes (bookmark bar node, other node | 309 // Creates one of the possible permanent nodes (bookmark bar node, other node |
| 316 // and mobile node) from |type|. | 310 // and mobile node) from |type|. |
| 317 BookmarkPermanentNode* CreatePermanentNode(BookmarkNode::Type type); | 311 BookmarkPermanentNode* CreatePermanentNode(BookmarkNode::Type type); |
| 318 | 312 |
| 319 // Notification that a favicon has finished loading. If we can decode the | 313 // Notification that a favicon has finished loading. If we can decode the |
| 320 // favicon, FaviconLoaded is invoked. | 314 // favicon, FaviconLoaded is invoked. |
| 321 void OnFaviconDataAvailable( | 315 void OnFaviconDataAvailable( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 | 389 |
| 396 // See description of IsDoingExtensiveChanges above. | 390 // See description of IsDoingExtensiveChanges above. |
| 397 int extensive_changes_; | 391 int extensive_changes_; |
| 398 | 392 |
| 399 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; | 393 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; |
| 400 | 394 |
| 401 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); | 395 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); |
| 402 }; | 396 }; |
| 403 | 397 |
| 404 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ | 398 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ |
| OLD | NEW |