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

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

Issue 6931018: Initial implementation of "Synced Bookmarks" folder. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Merge Created 9 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 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_model_unittest.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 b372855a4e25060f7ff65a2bdbb71d83609f642f..e3de7c2af48cbfcb5666fcac3ddc5377d0e39e4b 100644
--- a/chrome/browser/bookmarks/bookmark_model.cc
+++ b/chrome/browser/bookmarks/bookmark_model.cc
@@ -8,6 +8,7 @@
#include <functional>
#include "base/callback.h"
+#include "base/command_line.h"
#include "base/memory/scoped_vector.h"
#include "build/build_config.h"
#include "chrome/browser/bookmarks/bookmark_index.h"
@@ -16,6 +17,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/history/history_notifications.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/chrome_switches.h"
#include "content/common/notification_service.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -75,6 +77,9 @@ void BookmarkNode::Reset(const history::StarredEntry& entry) {
case history::StarredEntry::BOOKMARK_BAR:
type_ = BookmarkNode::BOOKMARK_BAR;
break;
+ case history::StarredEntry::SYNCED:
+ type_ = BookmarkNode::SYNCED;
+ break;
case history::StarredEntry::OTHER:
type_ = BookmarkNode::OTHER_NODE;
break;
@@ -124,6 +129,7 @@ BookmarkModel::BookmarkModel(Profile* profile)
root_(GURL()),
bookmark_bar_node_(NULL),
other_node_(NULL),
+ synced_node_(NULL),
next_node_id_(1),
observers_(ObserverList<BookmarkModelObserver>::NOTIFY_EXISTING_ONLY),
loaded_signal_(TRUE, FALSE) {
@@ -259,7 +265,8 @@ void BookmarkModel::SetTitle(const BookmarkNode* node, const string16& title) {
if (node->GetTitle() == title)
return;
- if (node == bookmark_bar_node_ || node == other_node_) {
+ if (node == bookmark_bar_node_ || node == other_node_ ||
+ node == synced_node_) {
NOTREACHED();
return;
}
@@ -568,12 +575,17 @@ void BookmarkModel::DoneLoading(
}
bookmark_bar_node_ = details->release_bb_node();
other_node_ = details->release_other_folder_node();
+ 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.
root_.Add(bookmark_bar_node_, 0);
root_.Add(other_node_, 1);
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableSyncedBookmarksFolder)) {
+ root_.Add(synced_node_, 2);
+ }
{
base::AutoLock url_lock(url_lock_);
@@ -719,14 +731,24 @@ BookmarkNode* BookmarkModel::CreateOtherBookmarksNode() {
return CreateRootNodeFromStarredEntry(entry);
}
+BookmarkNode* BookmarkModel::CreateSyncedBookmarksNode() {
+ history::StarredEntry entry;
+ entry.type = history::StarredEntry::SYNCED;
+ return CreateRootNodeFromStarredEntry(entry);
+}
+
BookmarkNode* BookmarkModel::CreateRootNodeFromStarredEntry(
const history::StarredEntry& entry) {
DCHECK(entry.type == history::StarredEntry::BOOKMARK_BAR ||
- entry.type == history::StarredEntry::OTHER);
+ entry.type == history::StarredEntry::OTHER ||
+ entry.type == history::StarredEntry::SYNCED);
BookmarkNode* node = new BookmarkNode(generate_next_node_id(), GURL());
node->Reset(entry);
if (entry.type == history::StarredEntry::BOOKMARK_BAR) {
node->set_title(l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_FOLDER_NAME));
+ } else if (entry.type == history::StarredEntry::SYNCED) {
+ node->set_title(l10n_util::GetStringUTF16(
+ IDS_BOOMARK_BAR_SYNCED_FOLDER_NAME));
} else {
node->set_title(
l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_OTHER_FOLDER_NAME));
@@ -826,6 +848,8 @@ void BookmarkModel::SetFileChanged() {
BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() {
BookmarkNode* bb_node = CreateBookmarkNode();
BookmarkNode* other_folder_node = CreateOtherBookmarksNode();
+ BookmarkNode* synced_folder_node = CreateSyncedBookmarksNode();
return new BookmarkLoadDetails(
- bb_node, other_folder_node, new BookmarkIndex(profile()), next_node_id_);
+ bb_node, other_folder_node, synced_folder_node,
+ new BookmarkIndex(profile()), next_node_id_);
}
« no previous file with comments | « chrome/browser/bookmarks/bookmark_model.h ('k') | chrome/browser/bookmarks/bookmark_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698