summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/bookmarks/bookmark_model.cc7
-rw-r--r--chrome/browser/bookmarks/bookmark_model.h3
-rw-r--r--chrome/browser/sync/engine/download_updates_command.cc8
-rw-r--r--chrome/browser/sync/glue/bookmark_change_processor.cc3
-rw-r--r--chrome/browser/sync/glue/bookmark_model_associator.cc34
-rw-r--r--chrome/browser/sync/glue/bookmark_model_associator.h4
-rw-r--r--chrome/browser/sync/profile_sync_service_bookmark_unittest.cc2
7 files changed, 52 insertions, 9 deletions
diff --git a/chrome/browser/bookmarks/bookmark_model.cc b/chrome/browser/bookmarks/bookmark_model.cc
index b0dfada..2d735bc 100644
--- a/chrome/browser/bookmarks/bookmark_model.cc
+++ b/chrome/browser/bookmarks/bookmark_model.cc
@@ -108,6 +108,8 @@ class MobileNode : public BookmarkNode {
explicit MobileNode(int64 id);
virtual ~MobileNode();
+ void set_visible(bool value) { visible_ = value; }
+
// BookmarkNode overrides:
virtual bool IsVisible() const OVERRIDE;
@@ -546,6 +548,11 @@ void BookmarkModel::ClearStore() {
store_ = NULL;
}
+void BookmarkModel::SetMobileFolderVisible(bool value) {
+ DCHECK(loaded_);
+ static_cast<MobileNode*>(mobile_node_)->set_visible(value);
+}
+
bool BookmarkModel::IsBookmarkedNoLock(const GURL& url) {
BookmarkNode tmp_node(url);
return (nodes_ordered_by_url_set_.find(&tmp_node) !=
diff --git a/chrome/browser/bookmarks/bookmark_model.h b/chrome/browser/bookmarks/bookmark_model.h
index e6d7c8f..1b7eec8 100644
--- a/chrome/browser/bookmarks/bookmark_model.h
+++ b/chrome/browser/bookmarks/bookmark_model.h
@@ -329,6 +329,9 @@ class BookmarkModel : public content::NotificationObserver,
return expanded_state_tracker_.get();
}
+ // Sets whether the mobile folder is visible. This is set by sync.
+ void SetMobileFolderVisible(bool value);
+
private:
friend class BookmarkCodecTest;
friend class BookmarkModelTest;
diff --git a/chrome/browser/sync/engine/download_updates_command.cc b/chrome/browser/sync/engine/download_updates_command.cc
index f0ceb30..e712d9e 100644
--- a/chrome/browser/sync/engine/download_updates_command.cc
+++ b/chrome/browser/sync/engine/download_updates_command.cc
@@ -6,11 +6,13 @@
#include <string>
+#include "base/command_line.h"
#include "chrome/browser/sync/engine/syncer.h"
#include "chrome/browser/sync/engine/syncer_proto_util.h"
#include "chrome/browser/sync/engine/syncproto.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/model_type_payload_map.h"
+#include "chrome/common/chrome_switches.h"
using syncable::ScopedDirLookup;
@@ -35,8 +37,10 @@ void DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) {
ClientToServerMessage::GET_UPDATES);
GetUpdatesMessage* get_updates =
client_to_server_message.mutable_get_updates();
- // TODO: make this default to true.
- get_updates->set_include_syncable_bookmarks(true);
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kCreateMobileBookmarksFolder)) {
+ get_updates->set_include_syncable_bookmarks(true);
+ }
ScopedDirLookup dir(session->context()->directory_manager(),
session->context()->account_name());
diff --git a/chrome/browser/sync/glue/bookmark_change_processor.cc b/chrome/browser/sync/glue/bookmark_change_processor.cc
index a5e619a..9518686 100644
--- a/chrome/browser/sync/glue/bookmark_change_processor.cc
+++ b/chrome/browser/sync/glue/bookmark_change_processor.cc
@@ -451,6 +451,9 @@ void BookmarkChangeProcessor::ApplyChangesFromSyncModel(
foster_parent = NULL;
}
+ // The visibility of the mobile node may need to change.
+ model_associator_->UpdateMobileNodeVisibility();
+
// We are now ready to hear about bookmarks changes again.
model->AddObserver(this);
}
diff --git a/chrome/browser/sync/glue/bookmark_model_associator.cc b/chrome/browser/sync/glue/bookmark_model_associator.cc
index bbdbff8..8d3066a 100644
--- a/chrome/browser/sync/glue/bookmark_model_associator.cc
+++ b/chrome/browser/sync/glue/bookmark_model_associator.cc
@@ -186,6 +186,14 @@ BookmarkModelAssociator::~BookmarkModelAssociator() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
+void BookmarkModelAssociator::UpdateMobileNodeVisibility() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(bookmark_model_->IsLoaded());
+
+ bookmark_model_->SetMobileFolderVisible(
+ id_map_.find(bookmark_model_->mobile_node()->id()) != id_map_.end());
+}
+
bool BookmarkModelAssociator::DisassociateModels(SyncError* error) {
id_map_.clear();
id_map_inverse_.clear();
@@ -228,6 +236,7 @@ void BookmarkModelAssociator::Associate(const BookmarkNode* node,
id_map_inverse_[sync_id] = node;
dirty_associations_sync_ids_.insert(sync_id);
PostPersistAssociationsTask();
+ UpdateMobileNodeVisibility();
}
void BookmarkModelAssociator::Disassociate(int64 sync_id) {
@@ -368,10 +377,15 @@ bool BookmarkModelAssociator::BuildAssociations(SyncError* error) {
error->Reset(FROM_HERE, kServerError, model_type());
return false;
}
- // The mobile folder isn't always present on the backend, so we don't fail if
- // it doesn't exist.
- ignore_result(AssociateTaggedPermanentNode(bookmark_model_->mobile_node(),
- kMobileBookmarksTag));
+ if (!AssociateTaggedPermanentNode(bookmark_model_->mobile_node(),
+ kMobileBookmarksTag) &&
+ // The mobile folder only need exist if kCreateMobileBookmarksFolder is
+ // set.
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kCreateMobileBookmarksFolder)) {
+ error->Reset(FROM_HERE, kServerError, model_type());
+ return false;
+ }
int64 bookmark_bar_sync_id = GetSyncIdFromChromeId(
bookmark_model_->bookmark_bar_node()->id());
DCHECK_NE(bookmark_bar_sync_id, sync_api::kInvalidId);
@@ -380,6 +394,10 @@ bool BookmarkModelAssociator::BuildAssociations(SyncError* error) {
DCHECK_NE(other_bookmarks_sync_id, sync_api::kInvalidId);
int64 mobile_bookmarks_sync_id = GetSyncIdFromChromeId(
bookmark_model_->mobile_node()->id());
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kCreateMobileBookmarksFolder)) {
+ DCHECK_NE(sync_api::kInvalidId, mobile_bookmarks_sync_id);
+ }
std::stack<int64> dfs_stack;
if (mobile_bookmarks_sync_id != sync_api::kInvalidId)
@@ -523,9 +541,11 @@ bool BookmarkModelAssociator::LoadAssociations() {
return false;
}
int64 mobile_bookmarks_id = -1;
- // Can't fail here as the mobile folder may not exist.
- ignore_result(
- GetSyncIdForTaggedNode(kMobileBookmarksTag, &mobile_bookmarks_id));
+ if (!GetSyncIdForTaggedNode(kMobileBookmarksTag, &mobile_bookmarks_id) &&
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kCreateMobileBookmarksFolder)) {
+ return false;
+ }
// Build a bookmark node ID index since we are going to repeatedly search for
// bookmark nodes by their IDs.
diff --git a/chrome/browser/sync/glue/bookmark_model_associator.h b/chrome/browser/sync/glue/bookmark_model_associator.h
index 400b98e..e83b05a 100644
--- a/chrome/browser/sync/glue/bookmark_model_associator.h
+++ b/chrome/browser/sync/glue/bookmark_model_associator.h
@@ -40,6 +40,10 @@ class BookmarkModelAssociator
UnrecoverableErrorHandler* unrecoverable_error_handler);
virtual ~BookmarkModelAssociator();
+ // Invokes BookmarkModel::SetMobileFolderVisible() based on whether the mobile
+ // node exists.
+ void UpdateMobileNodeVisibility();
+
// AssociatorInterface implementation.
//
// AssociateModels iterates through both the sync and the browser
diff --git a/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc b/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc
index 57bdf2f..1b87769 100644
--- a/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc
@@ -296,6 +296,8 @@ class ProfileSyncServiceBookmarkTest : public testing::Test {
virtual void SetUp() {
test_user_share_.SetUp();
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kCreateMobileBookmarksFolder);
}
virtual void TearDown() {