| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 // BookmarkNode --------------------------------------------------------------- | 38 // BookmarkNode --------------------------------------------------------------- |
| 39 | 39 |
| 40 // BookmarkNode contains information about a starred entry: title, URL, favicon, | 40 // BookmarkNode contains information about a starred entry: title, URL, favicon, |
| 41 // star id and type. BookmarkNodes are returned from a BookmarkModel. | 41 // star id and type. BookmarkNodes are returned from a BookmarkModel. |
| 42 // | 42 // |
| 43 class BookmarkNode : public TreeNode<BookmarkNode> { | 43 class BookmarkNode : public TreeNode<BookmarkNode> { |
| 44 friend class BookmarkModel; | 44 friend class BookmarkModel; |
| 45 | 45 |
| 46 public: | 46 public: |
| 47 enum Type { |
| 48 URL, |
| 49 FOLDER, |
| 50 BOOKMARK_BAR, |
| 51 OTHER_NODE |
| 52 }; |
| 47 // Creates a new node with the specified url and id of 0 | 53 // Creates a new node with the specified url and id of 0 |
| 48 explicit BookmarkNode(const GURL& url); | 54 explicit BookmarkNode(const GURL& url); |
| 49 // Creates a new node with the specified url and id. | 55 // Creates a new node with the specified url and id. |
| 50 BookmarkNode(int id, const GURL& url); | 56 BookmarkNode(int id, const GURL& url); |
| 51 virtual ~BookmarkNode() {} | 57 virtual ~BookmarkNode() {} |
| 52 | 58 |
| 53 // Returns the URL. | 59 // Returns the URL. |
| 54 const GURL& GetURL() const { return url_; } | 60 const GURL& GetURL() const { return url_; } |
| 55 | 61 |
| 56 // Returns a unique id for this node. | 62 // Returns a unique id for this node. |
| 57 // | 63 // |
| 58 // NOTE: this id is only unique for the session and NOT unique across | 64 // NOTE: this id is only unique for the session and NOT unique across |
| 59 // sessions. Don't persist it! | 65 // sessions. Don't persist it! |
| 60 int id() const { return id_; } | 66 int id() const { return id_; } |
| 61 // Sets the id to the given value. | 67 // Sets the id to the given value. |
| 62 void set_id(int id) { id_ = id; } | 68 void set_id(int id) { id_ = id; } |
| 63 | 69 |
| 64 // Returns the type of this node. | 70 // Returns the type of this node. |
| 65 history::StarredEntry::Type GetType() const { return type_; } | 71 BookmarkNode::Type GetType() const { return type_; } |
| 66 void SetType(history::StarredEntry::Type type) { type_ = type; } | 72 void SetType(BookmarkNode::Type type) { type_ = type; } |
| 67 | 73 |
| 68 // Returns the time the bookmark/group was added. | 74 // Returns the time the bookmark/group was added. |
| 69 const base::Time& date_added() const { return date_added_; } | 75 const base::Time& date_added() const { return date_added_; } |
| 70 // Sets the time the bookmark/group was added. | 76 // Sets the time the bookmark/group was added. |
| 71 void set_date_added(const base::Time& date) { date_added_ = date; } | 77 void set_date_added(const base::Time& date) { date_added_ = date; } |
| 72 | 78 |
| 73 // Returns the last time the group was modified. This is only maintained | 79 // Returns the last time the group was modified. This is only maintained |
| 74 // for folders (including the bookmark and other folder). | 80 // for folders (including the bookmark and other folder). |
| 75 const base::Time& date_group_modified() const { return date_group_modified_; } | 81 const base::Time& date_group_modified() const { return date_group_modified_; } |
| 76 // Sets the last time the group was modified. | 82 // Sets the last time the group was modified. |
| 77 void set_date_group_modified(const base::Time& date) { | 83 void set_date_group_modified(const base::Time& date) { |
| 78 date_group_modified_ = date; | 84 date_group_modified_ = date; |
| 79 } | 85 } |
| 80 | 86 |
| 81 // Convenience for testing if this nodes represents a group. A group is | 87 // Convenience for testing if this nodes represents a group. A group is |
| 82 // a node whose type is not URL. | 88 // a node whose type is not URL. |
| 83 bool is_folder() const { return type_ != history::StarredEntry::URL; } | 89 bool is_folder() const { return type_ != URL; } |
| 84 | 90 |
| 85 // Is this a URL? | 91 // Is this a URL? |
| 86 bool is_url() const { return type_ == history::StarredEntry::URL; } | 92 bool is_url() const { return type_ == URL; } |
| 87 | 93 |
| 88 // Returns the favicon. In nearly all cases you should use the method | 94 // Returns the favicon. In nearly all cases you should use the method |
| 89 // BookmarkModel::GetFavicon rather than this. BookmarkModel::GetFavicon | 95 // BookmarkModel::GetFavicon rather than this. BookmarkModel::GetFavicon |
| 90 // takes care of loading the favicon if it isn't already loaded, where as | 96 // takes care of loading the favicon if it isn't already loaded, where as |
| 91 // this does not. | 97 // this does not. |
| 92 const SkBitmap& favicon() const { return favicon_; } | 98 const SkBitmap& favicon() const { return favicon_; } |
| 93 void set_favicon(const SkBitmap& icon) { favicon_ = icon; } | 99 void set_favicon(const SkBitmap& icon) { favicon_ = icon; } |
| 94 | 100 |
| 95 // The following methods are used by the bookmark model, and are not | 101 // The following methods are used by the bookmark model, and are not |
| 96 // really useful outside of it. | 102 // really useful outside of it. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 139 |
| 134 // If non-zero, it indicates we're loading the favicon and this is the handle | 140 // If non-zero, it indicates we're loading the favicon and this is the handle |
| 135 // from the HistoryService. | 141 // from the HistoryService. |
| 136 HistoryService::Handle favicon_load_handle_; | 142 HistoryService::Handle favicon_load_handle_; |
| 137 | 143 |
| 138 // The URL. BookmarkModel maintains maps off this URL, it is important that | 144 // The URL. BookmarkModel maintains maps off this URL, it is important that |
| 139 // it not change once the node has been created. | 145 // it not change once the node has been created. |
| 140 const GURL url_; | 146 const GURL url_; |
| 141 | 147 |
| 142 // Type of node. | 148 // Type of node. |
| 143 // TODO(sky): bug 1256202, convert this into a type defined here. | 149 BookmarkNode::Type type_; |
| 144 history::StarredEntry::Type type_; | |
| 145 | 150 |
| 146 // Date we were created. | 151 // Date we were created. |
| 147 base::Time date_added_; | 152 base::Time date_added_; |
| 148 | 153 |
| 149 // Time last modified. Only used for groups. | 154 // Time last modified. Only used for groups. |
| 150 base::Time date_group_modified_; | 155 base::Time date_group_modified_; |
| 151 | 156 |
| 152 DISALLOW_COPY_AND_ASSIGN(BookmarkNode); | 157 DISALLOW_COPY_AND_ASSIGN(BookmarkNode); |
| 153 }; | 158 }; |
| 154 | 159 |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 scoped_refptr<BookmarkStorage> store_; | 506 scoped_refptr<BookmarkStorage> store_; |
| 502 | 507 |
| 503 scoped_ptr<BookmarkIndex> index_; | 508 scoped_ptr<BookmarkIndex> index_; |
| 504 | 509 |
| 505 base::WaitableEvent loaded_signal_; | 510 base::WaitableEvent loaded_signal_; |
| 506 | 511 |
| 507 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); | 512 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); |
| 508 }; | 513 }; |
| 509 | 514 |
| 510 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ | 515 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ |
| OLD | NEW |