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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // Creates a new node with an id of 0 and |url|. | 70 // Creates a new node with an id of 0 and |url|. |
71 explicit BookmarkNode(const GURL& url); | 71 explicit BookmarkNode(const GURL& url); |
72 // Creates a new node with |id| and |url|. | 72 // Creates a new node with |id| and |url|. |
73 BookmarkNode(int64 id, const GURL& url); | 73 BookmarkNode(int64 id, const GURL& url); |
74 | 74 |
75 virtual ~BookmarkNode(); | 75 virtual ~BookmarkNode(); |
76 | 76 |
77 // Set the node's internal title. Note that this neither invokes observers | 77 // Set the node's internal title. Note that this neither invokes observers |
78 // nor updates any bookmark model this node may be in. For that functionality, | 78 // nor updates any bookmark model this node may be in. For that functionality, |
79 // BookmarkModel::SetTitle(..) should be used instead. | 79 // BookmarkModel::SetTitle(..) should be used instead. |
80 virtual void SetTitle(const string16& title) OVERRIDE; | 80 virtual void SetTitle(const base::string16& title) OVERRIDE; |
81 | 81 |
82 // Returns an unique id for this node. | 82 // Returns an unique id for this node. |
83 // For bookmark nodes that are managed by the bookmark model, the IDs are | 83 // For bookmark nodes that are managed by the bookmark model, the IDs are |
84 // persisted across sessions. | 84 // persisted across sessions. |
85 int64 id() const { return id_; } | 85 int64 id() const { return id_; } |
86 void set_id(int64 id) { id_ = id; } | 86 void set_id(int64 id) { id_ = id; } |
87 | 87 |
88 const GURL& url() const { return url_; } | 88 const GURL& url() const { return url_; } |
89 void set_url(const GURL& url) { url_ = url; } | 89 void set_url(const GURL& url) { url_ = url; } |
90 | 90 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 // Inserts a copy of |node| into |new_parent| at |index|. | 315 // Inserts a copy of |node| into |new_parent| at |index|. |
316 void Copy(const BookmarkNode* node, | 316 void Copy(const BookmarkNode* node, |
317 const BookmarkNode* new_parent, | 317 const BookmarkNode* new_parent, |
318 int index); | 318 int index); |
319 | 319 |
320 // Returns the favicon for |node|. If the favicon has not yet been | 320 // Returns the favicon for |node|. If the favicon has not yet been |
321 // loaded it is loaded and the observer of the model notified when done. | 321 // loaded it is loaded and the observer of the model notified when done. |
322 const gfx::Image& GetFavicon(const BookmarkNode* node); | 322 const gfx::Image& GetFavicon(const BookmarkNode* node); |
323 | 323 |
324 // Sets the title of |node|. | 324 // Sets the title of |node|. |
325 void SetTitle(const BookmarkNode* node, const string16& title); | 325 void SetTitle(const BookmarkNode* node, const base::string16& title); |
326 | 326 |
327 // Sets the URL of |node|. | 327 // Sets the URL of |node|. |
328 void SetURL(const BookmarkNode* node, const GURL& url); | 328 void SetURL(const BookmarkNode* node, const GURL& url); |
329 | 329 |
330 // Sets the date added time of |node|. | 330 // Sets the date added time of |node|. |
331 void SetDateAdded(const BookmarkNode* node, base::Time date_added); | 331 void SetDateAdded(const BookmarkNode* node, base::Time date_added); |
332 | 332 |
333 // Returns the set of nodes with the |url|. | 333 // Returns the set of nodes with the |url|. |
334 void GetNodesByURL(const GURL& url, std::vector<const BookmarkNode*>* nodes); | 334 void GetNodesByURL(const GURL& url, std::vector<const BookmarkNode*>* nodes); |
335 | 335 |
(...skipping 19 matching lines...) Expand all Loading... |
355 // Blocks until loaded; this is NOT invoked on the main thread. | 355 // Blocks until loaded; this is NOT invoked on the main thread. |
356 // See BookmarkService for more details on this. | 356 // See BookmarkService for more details on this. |
357 virtual void BlockTillLoaded() OVERRIDE; | 357 virtual void BlockTillLoaded() OVERRIDE; |
358 | 358 |
359 // Returns the node with |id|, or NULL if there is no node with |id|. | 359 // Returns the node with |id|, or NULL if there is no node with |id|. |
360 const BookmarkNode* GetNodeByID(int64 id) const; | 360 const BookmarkNode* GetNodeByID(int64 id) const; |
361 | 361 |
362 // Adds a new folder node at the specified position. | 362 // Adds a new folder node at the specified position. |
363 const BookmarkNode* AddFolder(const BookmarkNode* parent, | 363 const BookmarkNode* AddFolder(const BookmarkNode* parent, |
364 int index, | 364 int index, |
365 const string16& title); | 365 const base::string16& title); |
366 | 366 |
367 // Adds a url at the specified position. | 367 // Adds a url at the specified position. |
368 const BookmarkNode* AddURL(const BookmarkNode* parent, | 368 const BookmarkNode* AddURL(const BookmarkNode* parent, |
369 int index, | 369 int index, |
370 const string16& title, | 370 const base::string16& title, |
371 const GURL& url); | 371 const GURL& url); |
372 | 372 |
373 // Adds a url with a specific creation date. | 373 // Adds a url with a specific creation date. |
374 const BookmarkNode* AddURLWithCreationTime(const BookmarkNode* parent, | 374 const BookmarkNode* AddURLWithCreationTime(const BookmarkNode* parent, |
375 int index, | 375 int index, |
376 const string16& title, | 376 const base::string16& title, |
377 const GURL& url, | 377 const GURL& url, |
378 const base::Time& creation_time); | 378 const base::Time& creation_time); |
379 | 379 |
380 // Sorts the children of |parent|, notifying observers by way of the | 380 // Sorts the children of |parent|, notifying observers by way of the |
381 // BookmarkNodeChildrenReordered method. | 381 // BookmarkNodeChildrenReordered method. |
382 void SortChildren(const BookmarkNode* parent); | 382 void SortChildren(const BookmarkNode* parent); |
383 | 383 |
384 // Order the children of |parent| as specified in |ordered_nodes|. This | 384 // Order the children of |parent| as specified in |ordered_nodes|. This |
385 // function should only be used to reorder the child nodes of |parent| and | 385 // function should only be used to reorder the child nodes of |parent| and |
386 // is not meant to move nodes between different parent. Notifies observers | 386 // is not meant to move nodes between different parent. Notifies observers |
387 // using the BookmarkNodeChildrenReordered method. | 387 // using the BookmarkNodeChildrenReordered method. |
388 void ReorderChildren(const BookmarkNode* parent, | 388 void ReorderChildren(const BookmarkNode* parent, |
389 const std::vector<const BookmarkNode*>& ordered_nodes); | 389 const std::vector<const BookmarkNode*>& ordered_nodes); |
390 | 390 |
391 // Sets the date when the folder was modified. | 391 // Sets the date when the folder was modified. |
392 void SetDateFolderModified(const BookmarkNode* node, const base::Time time); | 392 void SetDateFolderModified(const BookmarkNode* node, const base::Time time); |
393 | 393 |
394 // Resets the 'date modified' time of the node to 0. This is used during | 394 // Resets the 'date modified' time of the node to 0. This is used during |
395 // importing to exclude the newly created folders from showing up in the | 395 // importing to exclude the newly created folders from showing up in the |
396 // combobox of most recently modified folders. | 396 // combobox of most recently modified folders. |
397 void ResetDateFolderModified(const BookmarkNode* node); | 397 void ResetDateFolderModified(const BookmarkNode* node); |
398 | 398 |
399 void GetBookmarksWithTitlesMatching( | 399 void GetBookmarksWithTitlesMatching( |
400 const string16& text, | 400 const base::string16& text, |
401 size_t max_count, | 401 size_t max_count, |
402 std::vector<BookmarkTitleMatch>* matches); | 402 std::vector<BookmarkTitleMatch>* matches); |
403 | 403 |
404 // Sets the store to NULL, making it so the BookmarkModel does not persist | 404 // Sets the store to NULL, making it so the BookmarkModel does not persist |
405 // any changes to disk. This is only useful during testing to speed up | 405 // any changes to disk. This is only useful during testing to speed up |
406 // testing. | 406 // testing. |
407 void ClearStore(); | 407 void ClearStore(); |
408 | 408 |
409 // Returns the next node ID. | 409 // Returns the next node ID. |
410 int64 next_node_id() const { return next_node_id_; } | 410 int64 next_node_id() const { return next_node_id_; } |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 | 563 |
564 // See description of IsDoingExtensiveChanges above. | 564 // See description of IsDoingExtensiveChanges above. |
565 int extensive_changes_; | 565 int extensive_changes_; |
566 | 566 |
567 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; | 567 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; |
568 | 568 |
569 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); | 569 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); |
570 }; | 570 }; |
571 | 571 |
572 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ | 572 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ |
OLD | NEW |