Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: chrome/browser/bookmarks/bookmark_model.h

Issue 99217: Implement ID persistence for bookmarks:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 25 matching lines...) Expand all
36 // BookmarkNode --------------------------------------------------------------- 36 // BookmarkNode ---------------------------------------------------------------
37 37
38 // BookmarkNode contains information about a starred entry: title, URL, favicon, 38 // BookmarkNode contains information about a starred entry: title, URL, favicon,
39 // star id and type. BookmarkNodes are returned from a BookmarkModel. 39 // star id and type. BookmarkNodes are returned from a BookmarkModel.
40 // 40 //
41 class BookmarkNode : public views::TreeNode<BookmarkNode> { 41 class BookmarkNode : public views::TreeNode<BookmarkNode> {
42 friend class BookmarkEditorView; 42 friend class BookmarkEditorView;
43 friend class BookmarkModel; 43 friend class BookmarkModel;
44 friend class BookmarkCodec; 44 friend class BookmarkCodec;
45 friend class history::StarredURLDatabase; 45 friend class history::StarredURLDatabase;
46 FRIEND_TEST(BookmarkCodecTest, PersistIDsTest);
46 FRIEND_TEST(BookmarkEditorViewTest, ChangeParentAndURL); 47 FRIEND_TEST(BookmarkEditorViewTest, ChangeParentAndURL);
47 FRIEND_TEST(BookmarkEditorViewTest, EditURLKeepsPosition); 48 FRIEND_TEST(BookmarkEditorViewTest, EditURLKeepsPosition);
48 FRIEND_TEST(BookmarkModelTest, MostRecentlyAddedEntries); 49 FRIEND_TEST(BookmarkModelTest, MostRecentlyAddedEntries);
49 FRIEND_TEST(BookmarkModelTest, GetMostRecentlyAddedNodeForURL); 50 FRIEND_TEST(BookmarkModelTest, GetMostRecentlyAddedNodeForURL);
50 51
51 public: 52 public:
53 // Creates a new node with the given properties. If the ID is not given or is
54 // 0, it is automatically assigned.
52 BookmarkNode(BookmarkModel* model, const GURL& url); 55 BookmarkNode(BookmarkModel* model, const GURL& url);
56 BookmarkNode(BookmarkModel* model, int id, const GURL& url);
53 virtual ~BookmarkNode() {} 57 virtual ~BookmarkNode() {}
54 58
55 // Returns the favicon for the this node. If the favicon has not yet been 59 // Returns the favicon for the this node. If the favicon has not yet been
56 // loaded it is loaded and the observer of the model notified when done. 60 // loaded it is loaded and the observer of the model notified when done.
57 const SkBitmap& GetFavIcon(); 61 const SkBitmap& GetFavIcon();
58 62
59 // Returns the URL. 63 // Returns the URL.
60 const GURL& GetURL() const { return url_; } 64 const GURL& GetURL() const { return url_; }
61 65
62 // Returns a unique id for this node. 66 // Returns a unique id for this node.
(...skipping 22 matching lines...) Expand all
85 // a node whose type is not URL. 89 // a node whose type is not URL.
86 bool is_folder() const { return type_ != history::StarredEntry::URL; } 90 bool is_folder() const { return type_ != history::StarredEntry::URL; }
87 91
88 // Is this a URL? 92 // Is this a URL?
89 bool is_url() const { return type_ == history::StarredEntry::URL; } 93 bool is_url() const { return type_ == history::StarredEntry::URL; }
90 94
91 // TODO(sky): Consider adding last visit time here, it'll greatly simplify 95 // TODO(sky): Consider adding last visit time here, it'll greatly simplify
92 // HistoryContentsProvider. 96 // HistoryContentsProvider.
93 97
94 private: 98 private:
99 // Sets the next ID for bookmark node ID generation.
100 static void SetNextId(int next_id);
101
102 // helper to initialize various fields during construction.
103 void Initialize(BookmarkModel* model, int id);
104
95 // Resets the properties of the node from the supplied entry. 105 // Resets the properties of the node from the supplied entry.
96 void Reset(const history::StarredEntry& entry); 106 void Reset(const history::StarredEntry& entry);
97 107
108 // Sets the id to the given value.
109 void set_id(int id) { id_ = id; }
110
98 // The model. This is NULL when created by StarredURLDatabase for migration. 111 // The model. This is NULL when created by StarredURLDatabase for migration.
99 BookmarkModel* model_; 112 BookmarkModel* model_;
100 113
101 // Unique identifier for this node. 114 // Unique identifier for this node.
102 const int id_; 115 int id_;
103 116
104 // Whether the favicon has been loaded. 117 // Whether the favicon has been loaded.
105 bool loaded_favicon_; 118 bool loaded_favicon_;
106 119
107 // The favicon. 120 // The favicon.
108 SkBitmap favicon_; 121 SkBitmap favicon_;
109 122
110 // If non-zero, it indicates we're loading the favicon and this is the handle 123 // If non-zero, it indicates we're loading the favicon and this is the handle
111 // from the HistoryService. 124 // from the HistoryService.
112 HistoryService::Handle favicon_load_handle_; 125 HistoryService::Handle favicon_load_handle_;
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 // NOTIFY_HISTORY_LOADED? A listener is installed if the bookmarks file 444 // NOTIFY_HISTORY_LOADED? A listener is installed if the bookmarks file
432 // doesn't exist and the history service hasn't finished loading. 445 // doesn't exist and the history service hasn't finished loading.
433 bool waiting_for_history_load_; 446 bool waiting_for_history_load_;
434 447
435 base::WaitableEvent loaded_signal_; 448 base::WaitableEvent loaded_signal_;
436 449
437 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); 450 DISALLOW_COPY_AND_ASSIGN(BookmarkModel);
438 }; 451 };
439 452
440 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ 453 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_codec_unittest.cc ('k') | chrome/browser/bookmarks/bookmark_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698