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..ffcf3cb823ea0578a9aefe2c4855dfbbede2dcc8 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,27 @@ void BookmarkNode::InvalidateFavicon() { |
is_favicon_loaded_ = false; |
} |
+// BookmarkPermanentNode ------------------------------------------------------ |
+ |
+BookmarkPermanentNode::BookmarkPermanentNode(int64 id, |
+ const GURL& url, |
+ Profile* profile) |
+ : BookmarkNode(id, url), |
+ profile_(profile) { |
+} |
+ |
+BookmarkPermanentNode::~BookmarkPermanentNode() { |
+} |
+ |
+bool BookmarkPermanentNode::IsVisible() const { |
+ // The synced bookmark folder is invisible if the flag isn't set and there are |
+ // no bookmarks under it. |
+ return type() != BookmarkNode::SYNCED || |
+ CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableSyncedBookmarksFolder) || |
+ !empty(); |
+} |
+ |
// BookmarkModel -------------------------------------------------------------- |
namespace { |
@@ -172,7 +186,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 +581,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 +710,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)); |