| 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 <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 class BookmarkModel : public content::NotificationObserver, | 227 class BookmarkModel : public content::NotificationObserver, |
| 228 public BookmarkService, | 228 public BookmarkService, |
| 229 public ProfileKeyedService { | 229 public ProfileKeyedService { |
| 230 public: | 230 public: |
| 231 explicit BookmarkModel(Profile* profile); | 231 explicit BookmarkModel(Profile* profile); |
| 232 virtual ~BookmarkModel(); | 232 virtual ~BookmarkModel(); |
| 233 | 233 |
| 234 // Invoked prior to destruction to release any necessary resources. | 234 // Invoked prior to destruction to release any necessary resources. |
| 235 virtual void Shutdown() OVERRIDE; | 235 virtual void Shutdown() OVERRIDE; |
| 236 | 236 |
| 237 // Loads the bookmarks. This is called upon creation of the | 237 // Loads the bookmarks. This is called upon creation of the BookmarkModel. |
| 238 // BookmarkModel. You need not invoke this directly. | 238 // You need not invoke this directly. |
| 239 void Load(); | 239 void Load(); |
| 240 | 240 |
| 241 // Returns true if the model finished loading. | 241 // Returns true if the model finished loading. |
| 242 // This is virtual so it can be mocked. | 242 // This is virtual so it can be mocked. |
| 243 virtual bool IsLoaded() const; | 243 virtual bool IsLoaded() const; |
| 244 | 244 |
| 245 virtual void AddObserver(BookmarkModelObserver* observer); |
| 246 virtual void RemoveObserver(BookmarkModelObserver* observer); |
| 247 |
| 245 // Returns the root node. The 'bookmark bar' node and 'other' node are | 248 // Returns the root node. The 'bookmark bar' node and 'other' node are |
| 246 // children of the root node. | 249 // children of the root node. |
| 247 const BookmarkNode* root_node() { return &root_; } | 250 const BookmarkNode* root_node() { return &root_; } |
| 248 | 251 |
| 249 // Returns the 'bookmark bar' node. This is NULL until loaded. | 252 // Returns the 'bookmark bar' node. This is NULL until loaded. |
| 250 const BookmarkNode* bookmark_bar_node() { return bookmark_bar_node_; } | 253 const BookmarkNode* bookmark_bar_node() { return bookmark_bar_node_; } |
| 251 | 254 |
| 252 // Returns the 'other' node. This is NULL until loaded. | 255 // Returns the 'other' node. This is NULL until loaded. |
| 253 const BookmarkNode* other_node() { return other_node_; } | 256 const BookmarkNode* other_node() { return other_node_; } |
| 254 | 257 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 265 node == other_node_ || | 268 node == other_node_ || |
| 266 node == mobile_node_; | 269 node == mobile_node_; |
| 267 } | 270 } |
| 268 | 271 |
| 269 Profile* profile() { return profile_; } | 272 Profile* profile() { return profile_; } |
| 270 | 273 |
| 271 // Returns the parent the last node was added to. This never returns NULL | 274 // Returns the parent the last node was added to. This never returns NULL |
| 272 // (as long as the model is loaded). | 275 // (as long as the model is loaded). |
| 273 const BookmarkNode* GetParentForNewNodes(); | 276 const BookmarkNode* GetParentForNewNodes(); |
| 274 | 277 |
| 275 void AddObserver(BookmarkModelObserver* observer); | |
| 276 void RemoveObserver(BookmarkModelObserver* observer); | |
| 277 | |
| 278 // Notifies the observers that an extensive set of changes is about to happen, | 278 // Notifies the observers that an extensive set of changes is about to happen, |
| 279 // such as during import or sync, so they can delay any expensive UI updates | 279 // such as during import or sync, so they can delay any expensive UI updates |
| 280 // until it's finished. | 280 // until it's finished. |
| 281 void BeginExtensiveChanges(); | 281 void BeginExtensiveChanges(); |
| 282 void EndExtensiveChanges(); | 282 void EndExtensiveChanges(); |
| 283 | 283 |
| 284 // Returns true if this bookmark model is currently in a mode where extensive | 284 // Returns true if this bookmark model is currently in a mode where extensive |
| 285 // changes might happen, such as for import and sync. This is helpful for | 285 // changes might happen, such as for import and sync. This is helpful for |
| 286 // observers that are created after the mode has started, and want to check | 286 // observers that are created after the mode has started, and want to check |
| 287 // state during their own initializer, such as the NTP. | 287 // state during their own initializer, such as the NTP. |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 | 525 |
| 526 // See description of IsDoingExtensiveChanges above. | 526 // See description of IsDoingExtensiveChanges above. |
| 527 int extensive_changes_; | 527 int extensive_changes_; |
| 528 | 528 |
| 529 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; | 529 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; |
| 530 | 530 |
| 531 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); | 531 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); |
| 532 }; | 532 }; |
| 533 | 533 |
| 534 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ | 534 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ |
| OLD | NEW |