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

Unified Diff: chrome/browser/bookmarks/bookmark_model.cc

Issue 8273041: Permanent folders changes (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Nit fixing. Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/bookmarks/bookmark_model.h ('k') | chrome/browser/bookmarks/bookmark_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « chrome/browser/bookmarks/bookmark_model.h ('k') | chrome/browser/bookmarks/bookmark_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698