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_BAR_MODEL_H_ | 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_BAR_MODEL_H_ |
6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_BAR_MODEL_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_BAR_MODEL_H_ |
7 | 7 |
8 #include "base/lock.h" | 8 #include "base/lock.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "base/scoped_handle.h" | 10 #include "base/scoped_handle.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // Returns the type of this node. | 62 // Returns the type of this node. |
63 history::StarredEntry::Type GetType() const { return type_; } | 63 history::StarredEntry::Type GetType() const { return type_; } |
64 | 64 |
65 // Called when the favicon becomes invalid. | 65 // Called when the favicon becomes invalid. |
66 void InvalidateFavicon() { | 66 void InvalidateFavicon() { |
67 loaded_favicon_ = false; | 67 loaded_favicon_ = false; |
68 favicon_ = SkBitmap(); | 68 favicon_ = SkBitmap(); |
69 } | 69 } |
70 | 70 |
71 // Returns the time the bookmark/group was added. | 71 // Returns the time the bookmark/group was added. |
72 Time date_added() const { return date_added_; } | 72 base::Time date_added() const { return date_added_; } |
73 | 73 |
74 // Returns the last time the group was modified. This is only maintained | 74 // Returns the last time the group was modified. This is only maintained |
75 // for folders (including the bookmark and other folder). | 75 // for folders (including the bookmark and other folder). |
76 Time date_group_modified() const { return date_group_modified_; } | 76 base::Time date_group_modified() const { return date_group_modified_; } |
77 | 77 |
78 // Convenience for testing if this nodes represents a group. A group is | 78 // Convenience for testing if this nodes represents a group. A group is |
79 // a node whose type is not URL. | 79 // a node whose type is not URL. |
80 bool is_folder() const { return type_ != history::StarredEntry::URL; } | 80 bool is_folder() const { return type_ != history::StarredEntry::URL; } |
81 | 81 |
82 // Is this a URL? | 82 // Is this a URL? |
83 bool is_url() const { return type_ == history::StarredEntry::URL; } | 83 bool is_url() const { return type_ == history::StarredEntry::URL; } |
84 | 84 |
85 // TODO(sky): Consider adding last visit time here, it'll greatly simplify | 85 // TODO(sky): Consider adding last visit time here, it'll greatly simplify |
86 // HistoryContentsProvider. | 86 // HistoryContentsProvider. |
(...skipping 20 matching lines...) Expand all Loading... |
107 | 107 |
108 // The URL. BookmarkModel maintains maps off this URL, it is important that | 108 // The URL. BookmarkModel maintains maps off this URL, it is important that |
109 // it not change once the node has been created. | 109 // it not change once the node has been created. |
110 const GURL url_; | 110 const GURL url_; |
111 | 111 |
112 // Type of node. | 112 // Type of node. |
113 // TODO(sky): bug 1256202, convert this into a type defined here. | 113 // TODO(sky): bug 1256202, convert this into a type defined here. |
114 history::StarredEntry::Type type_; | 114 history::StarredEntry::Type type_; |
115 | 115 |
116 // Date we were created. | 116 // Date we were created. |
117 Time date_added_; | 117 base::Time date_added_; |
118 | 118 |
119 // Time last modified. Only used for groups. | 119 // Time last modified. Only used for groups. |
120 Time date_group_modified_; | 120 base::Time date_group_modified_; |
121 | 121 |
122 DISALLOW_COPY_AND_ASSIGN(BookmarkNode); | 122 DISALLOW_COPY_AND_ASSIGN(BookmarkNode); |
123 }; | 123 }; |
124 | 124 |
125 // BookmarkModelObserver ------------------------------------------------------ | 125 // BookmarkModelObserver ------------------------------------------------------ |
126 | 126 |
127 // Observer for the BookmarkModel. | 127 // Observer for the BookmarkModel. |
128 // | 128 // |
129 class BookmarkModelObserver { | 129 class BookmarkModelObserver { |
130 public: | 130 public: |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 BookmarkNode* AddURL(BookmarkNode* parent, | 285 BookmarkNode* AddURL(BookmarkNode* parent, |
286 int index, | 286 int index, |
287 const std::wstring& title, | 287 const std::wstring& title, |
288 const GURL& url); | 288 const GURL& url); |
289 | 289 |
290 // Adds a url with a specific creation date. | 290 // Adds a url with a specific creation date. |
291 BookmarkNode* AddURLWithCreationTime(BookmarkNode* parent, | 291 BookmarkNode* AddURLWithCreationTime(BookmarkNode* parent, |
292 int index, | 292 int index, |
293 const std::wstring& title, | 293 const std::wstring& title, |
294 const GURL& url, | 294 const GURL& url, |
295 const Time& creation_time); | 295 const base::Time& creation_time); |
296 | 296 |
297 // This is the convenience that makes sure the url is starred or not starred. | 297 // This is the convenience that makes sure the url is starred or not starred. |
298 // If is_starred is false, all bookmarks for URL are removed. If is_starred is | 298 // If is_starred is false, all bookmarks for URL are removed. If is_starred is |
299 // true and there are no bookmarks for url, a bookmark is created. | 299 // true and there are no bookmarks for url, a bookmark is created. |
300 void SetURLStarred(const GURL& url, | 300 void SetURLStarred(const GURL& url, |
301 const std::wstring& title, | 301 const std::wstring& title, |
302 bool is_starred); | 302 bool is_starred); |
303 | 303 |
304 // Resets the 'date modified' time of the node to 0. This is used during | 304 // Resets the 'date modified' time of the node to 0. This is used during |
305 // importing to exclude the newly created groups from showing up in the | 305 // importing to exclude the newly created groups from showing up in the |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 BookmarkNode* node, | 366 BookmarkNode* node, |
367 bool was_bookmarked); | 367 bool was_bookmarked); |
368 | 368 |
369 // Implementation of GetNodeByID. | 369 // Implementation of GetNodeByID. |
370 BookmarkNode* GetNodeByID(BookmarkNode* node, int id); | 370 BookmarkNode* GetNodeByID(BookmarkNode* node, int id); |
371 | 371 |
372 // Returns true if the parent and index are valid. | 372 // Returns true if the parent and index are valid. |
373 bool IsValidIndex(BookmarkNode* parent, int index, bool allow_end); | 373 bool IsValidIndex(BookmarkNode* parent, int index, bool allow_end); |
374 | 374 |
375 // Sets the date modified time of the specified node. | 375 // Sets the date modified time of the specified node. |
376 void SetDateGroupModified(BookmarkNode* parent, const Time time); | 376 void SetDateGroupModified(BookmarkNode* parent, const base::Time time); |
377 | 377 |
378 // Creates the bookmark bar/other nodes. These call into | 378 // Creates the bookmark bar/other nodes. These call into |
379 // CreateRootNodeFromStarredEntry. | 379 // CreateRootNodeFromStarredEntry. |
380 void CreateBookmarkNode(); | 380 void CreateBookmarkNode(); |
381 void CreateOtherBookmarksNode(); | 381 void CreateOtherBookmarksNode(); |
382 | 382 |
383 // Creates a root node (either the bookmark bar node or other node) from the | 383 // Creates a root node (either the bookmark bar node or other node) from the |
384 // specified starred entry. | 384 // specified starred entry. |
385 BookmarkNode* CreateRootNodeFromStarredEntry( | 385 BookmarkNode* CreateRootNodeFromStarredEntry( |
386 const history::StarredEntry& entry); | 386 const history::StarredEntry& entry); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 // doesn't exist and the history service hasn't finished loading. | 446 // doesn't exist and the history service hasn't finished loading. |
447 bool waiting_for_history_load_; | 447 bool waiting_for_history_load_; |
448 | 448 |
449 // Handle to event signaled when loading is done. | 449 // Handle to event signaled when loading is done. |
450 ScopedHandle loaded_signal_; | 450 ScopedHandle loaded_signal_; |
451 | 451 |
452 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); | 452 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); |
453 }; | 453 }; |
454 | 454 |
455 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_BAR_MODEL_H_ | 455 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_BAR_MODEL_H_ |
OLD | NEW |