Chromium Code Reviews| Index: chrome/browser/bookmarks/bookmark_model.cc |
| diff --git a/chrome/browser/bookmarks/bookmark_model.cc b/chrome/browser/bookmarks/bookmark_model.cc |
| index 6fb0cdf1d34b3c96782535d2a7b7fa25fada87b8..dba0e11c801c3cb3e1e507a7026b0cd8862a8a9f 100644 |
| --- a/chrome/browser/bookmarks/bookmark_model.cc |
| +++ b/chrome/browser/bookmarks/bookmark_model.cc |
| @@ -56,14 +56,7 @@ BookmarkNode::~BookmarkNode() { |
| } |
| bool BookmarkNode::IsVisible() const { |
| - // The synced bookmark folder is invisible if the flag isn't set and there are |
| - // no bookmarks under it. |
| - if (type_ != BookmarkNode::SYNCED || |
| - CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kEnableSyncedBookmarksFolder) || !empty()) { |
| - return true; |
| - } |
| - return false; |
| + return true; |
| } |
| void BookmarkNode::Initialize(int64 id) { |
| @@ -79,6 +72,29 @@ void BookmarkNode::InvalidateFavicon() { |
| is_favicon_loaded_ = false; |
| } |
| +// BookmarkPermanentNode ------------------------------------------------------ |
| + |
| +BookmarkPermanentNode::BookmarkPermanentNode( |
| + int64 id, const GURL& url, Profile* profile) |
|
sky
2011/10/14 19:50:23
each param on its own line.
noyau (Ping after 24h)
2011/10/17 12:42:48
Done.
|
| + : BookmarkNode(id, url), |
| + profile_(profile) { |
| +} |
| + |
| +BookmarkPermanentNode::~BookmarkPermanentNode() { |
| +} |
| + |
| + |
|
sky
2011/10/14 19:50:23
remove one of these lines.
noyau (Ping after 24h)
2011/10/17 12:42:48
Done.
|
| +bool BookmarkPermanentNode::IsVisible() const { |
| + // The synced bookmark folder is invisible if the flag isn't set and there are |
| + // no bookmarks under it. |
| + if (type() != BookmarkNode::SYNCED || |
| + CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableSyncedBookmarksFolder) || !empty()) { |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| // BookmarkModel -------------------------------------------------------------- |
| namespace { |
| @@ -172,7 +188,8 @@ bool BookmarkModel::IsLoaded() const { |
| const BookmarkNode* BookmarkModel::GetParentForNewNodes() { |
| std::vector<const BookmarkNode*> nodes = |
| bookmark_utils::GetMostRecentlyModifiedFolders(this, 1); |
| - return nodes.empty() ? bookmark_bar_node_ : nodes[0]; |
| + DCHECK(!nodes.empty()); // This list is always padded with default folders. |
| + return nodes[0]; |
| } |
| void BookmarkModel::AddObserver(BookmarkModelObserver* observer) { |
| @@ -566,8 +583,8 @@ void BookmarkModel::DoneLoading( |
| synced_node_ = details->release_synced_folder_node(); |
| index_.reset(details->release_index()); |
| - // WARNING: order is important here, various places assume bookmark bar then |
| - // other node. |
| + // WARNING: order is important here, various places assume the order is |
| + // constant. |
| root_.Add(bookmark_bar_node_, 0); |
| root_.Add(other_node_, 1); |
| root_.Add(synced_node_, 2); |
| @@ -695,7 +712,8 @@ BookmarkNode* BookmarkModel::CreatePermanentNode(BookmarkNode::Type type) { |
| DCHECK(type == BookmarkNode::BOOKMARK_BAR || |
| type == BookmarkNode::OTHER_NODE || |
| type == BookmarkNode::SYNCED); |
| - BookmarkNode* node = new BookmarkNode(generate_next_node_id(), GURL()); |
| + BookmarkPermanentNode* node = new BookmarkPermanentNode( |
| + generate_next_node_id(), GURL(), profile_); |
| node->set_type(type); |
| if (type == BookmarkNode::BOOKMARK_BAR) { |
| node->set_title(l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_FOLDER_NAME)); |