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_NODE_H_ | 5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_H_ |
6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_H_ | 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // For bookmark nodes that are managed by the bookmark model, the IDs are | 62 // For bookmark nodes that are managed by the bookmark model, the IDs are |
63 // persisted across sessions. | 63 // persisted across sessions. |
64 int64_t id() const { return id_; } | 64 int64_t id() const { return id_; } |
65 void set_id(int64_t id) { id_ = id; } | 65 void set_id(int64_t id) { id_ = id; } |
66 | 66 |
67 const GURL& url() const { return url_; } | 67 const GURL& url() const { return url_; } |
68 void set_url(const GURL& url) { url_ = url; } | 68 void set_url(const GURL& url) { url_ = url; } |
69 | 69 |
70 // Returns the favicon's URL. Returns an empty URL if there is no favicon | 70 // Returns the favicon's URL. Returns an empty URL if there is no favicon |
71 // associated with this bookmark. | 71 // associated with this bookmark. |
72 const GURL& icon_url() const { return icon_url_; } | 72 const GURL* icon_url() const { return icon_url_ ? icon_url_.get() : nullptr; } |
73 | 73 |
74 Type type() const { return type_; } | 74 Type type() const { return type_; } |
75 void set_type(Type type) { type_ = type; } | 75 void set_type(Type type) { type_ = type; } |
76 | 76 |
77 // Returns the time the node was added. | 77 // Returns the time the node was added. |
78 const base::Time& date_added() const { return date_added_; } | 78 const base::Time& date_added() const { return date_added_; } |
79 void set_date_added(const base::Time& date) { date_added_ = date; } | 79 void set_date_added(const base::Time& date) { date_added_ = date; } |
80 | 80 |
81 // Returns the last time the folder was modified. This is only maintained | 81 // Returns the last time the folder was modified. This is only maintained |
82 // for folders (including the bookmark bar and other folder). | 82 // for folders (including the bookmark bar and other folder). |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 friend class BookmarkModel; | 127 friend class BookmarkModel; |
128 | 128 |
129 // A helper function to initialize various fields during construction. | 129 // A helper function to initialize various fields during construction. |
130 void Initialize(int64_t id); | 130 void Initialize(int64_t id); |
131 | 131 |
132 // Called when the favicon becomes invalid. | 132 // Called when the favicon becomes invalid. |
133 void InvalidateFavicon(); | 133 void InvalidateFavicon(); |
134 | 134 |
135 // Sets the favicon's URL. | 135 // Sets the favicon's URL. |
136 void set_icon_url(const GURL& icon_url) { | 136 void set_icon_url(const GURL& icon_url) { |
137 icon_url_ = icon_url; | 137 icon_url_.reset(new GURL(icon_url)); |
138 } | 138 } |
139 | 139 |
140 // Returns the favicon. In nearly all cases you should use the method | 140 // Returns the favicon. In nearly all cases you should use the method |
141 // BookmarkModel::GetFavicon rather than this one as it takes care of | 141 // BookmarkModel::GetFavicon rather than this one as it takes care of |
142 // loading the favicon if it isn't already loaded. | 142 // loading the favicon if it isn't already loaded. |
143 const gfx::Image& favicon() const { return favicon_; } | 143 const gfx::Image& favicon() const { return favicon_; } |
144 void set_favicon(const gfx::Image& icon) { favicon_ = icon; } | 144 void set_favicon(const gfx::Image& icon) { favicon_ = icon; } |
145 | 145 |
146 favicon_base::IconType favicon_type() const { return favicon_type_; } | 146 favicon_base::IconType favicon_type() const { return favicon_type_; } |
147 void set_favicon_type(favicon_base::IconType type) { favicon_type_ = type; } | 147 void set_favicon_type(favicon_base::IconType type) { favicon_type_ = type; } |
(...skipping 24 matching lines...) Expand all Loading... |
172 // Date of the last modification. Only used for folders. | 172 // Date of the last modification. Only used for folders. |
173 base::Time date_folder_modified_; | 173 base::Time date_folder_modified_; |
174 | 174 |
175 // The favicon of this node. | 175 // The favicon of this node. |
176 gfx::Image favicon_; | 176 gfx::Image favicon_; |
177 | 177 |
178 // The type of favicon currently loaded. | 178 // The type of favicon currently loaded. |
179 favicon_base::IconType favicon_type_; | 179 favicon_base::IconType favicon_type_; |
180 | 180 |
181 // The URL of the node's favicon. | 181 // The URL of the node's favicon. |
182 GURL icon_url_; | 182 std::unique_ptr<GURL> icon_url_; |
183 | 183 |
184 // The loading state of the favicon. | 184 // The loading state of the favicon. |
185 FaviconState favicon_state_; | 185 FaviconState favicon_state_; |
186 | 186 |
187 // If not base::CancelableTaskTracker::kBadTaskId, it indicates | 187 // If not base::CancelableTaskTracker::kBadTaskId, it indicates |
188 // we're loading the | 188 // we're loading the |
189 // favicon and the task is tracked by CancelabelTaskTracker. | 189 // favicon and the task is tracked by CancelabelTaskTracker. |
190 base::CancelableTaskTracker::TaskId favicon_load_task_id_; | 190 base::CancelableTaskTracker::TaskId favicon_load_task_id_; |
191 | 191 |
192 // A map that stores arbitrary meta information about the node. | 192 // A map that stores arbitrary meta information about the node. |
(...skipping 21 matching lines...) Expand all Loading... |
214 | 214 |
215 private: | 215 private: |
216 bool visible_; | 216 bool visible_; |
217 | 217 |
218 DISALLOW_COPY_AND_ASSIGN(BookmarkPermanentNode); | 218 DISALLOW_COPY_AND_ASSIGN(BookmarkPermanentNode); |
219 }; | 219 }; |
220 | 220 |
221 } // namespace bookmarks | 221 } // namespace bookmarks |
222 | 222 |
223 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_H_ | 223 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_H_ |
OLD | NEW |