summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-06 05:52:26 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-06 05:52:26 +0000
commit1da5f71715083669a994c6f7346f149510bf5db7 (patch)
treea36fda731f55f4b568524c5dc78e548ba65f4161
parent4f8c5e036600c56b23f62b3fefeefa95ff96a221 (diff)
downloadchromium_src-1da5f71715083669a994c6f7346f149510bf5db7.zip
chromium_src-1da5f71715083669a994c6f7346f149510bf5db7.tar.gz
chromium_src-1da5f71715083669a994c6f7346f149510bf5db7.tar.bz2
Revert 113112 - Revert 113103 - Changes the visibility of the 'mobile' node based on whether there is a node on the sync side.
BUG=102714 TEST=none Review URL: http://codereview.chromium.org/8786006 TBR=sky@chromium.org Review URL: http://codereview.chromium.org/8819008 TBR=sky@chromium.org Review URL: http://codereview.chromium.org/8818004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113117 0039d316-1c4b-4281-b951-d872f2087c98
-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
-rw-r--r--chrome/common/chrome_switches.cc6
-rw-r--r--chrome/common/chrome_switches.h2
-rwxr-xr-xnet/tools/testserver/chromiumsync.py2
10 files changed, 56 insertions, 15 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() {
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 3928cf0..c595d6c 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -190,6 +190,9 @@ const char kCrashOnHangThreads[] = "crash-on-hang-threads";
// other threads are not responsive.
const char kCrashOnLive[] = "crash-on-live";
+// If true the mobile bookmarks folder is created on the sync side.
+const char kCreateMobileBookmarksFolder[] = "create-mobile-bookmarks-folder";
+
// Path to the inspector files on disk (allows reloading of devtool files
// without having to restart the browser).
const char kDebugDevToolsFrontend[] = "debug-devtools-frontend";
@@ -567,9 +570,6 @@ const char kEnableSyncTabsForOtherClients[] =
// Enables context menu for selecting groups of tabs.
const char kEnableTabGroupsContextMenu[] = "enable-tab-groups-context-menu";
-// Enables the "synced bookmarks" folder.
-const char kEnableSyncedBookmarksFolder[] = "enable-synced-bookmarks-folder";
-
// Spawns threads to watch for excessive delays in specified message loops.
// User should set breakpoints on Alarm() to examine problematic thread.
//
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 961be54..1c40904 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -64,6 +64,7 @@ extern const char kCountry[];
extern const char kCrashOnHangSeconds[];
extern const char kCrashOnHangThreads[];
extern const char kCrashOnLive[];
+extern const char kCreateMobileBookmarksFolder[];
extern const char kDebugDevToolsFrontend[];
extern const char kDebugEnableFrameToggle[];
extern const char kDebugPrint[];
@@ -162,7 +163,6 @@ extern const char kEnableSyncExtensionSettings[];
extern const char kEnableSyncOAuth[];
extern const char kEnableSyncTabs[];
extern const char kEnableSyncTabsForOtherClients[];
-extern const char kEnableSyncedBookmarksFolder[];
extern const char kEnableTabGroupsContextMenu[];
extern const char kEnableTopSites[];
extern const char kEnableWatchdog[];
diff --git a/net/tools/testserver/chromiumsync.py b/net/tools/testserver/chromiumsync.py
index 07497ea..cabbb7d 100755
--- a/net/tools/testserver/chromiumsync.py
+++ b/net/tools/testserver/chromiumsync.py
@@ -394,8 +394,6 @@ class SyncDataModel(object):
parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK),
PermanentItem('other_bookmarks', name='Other Bookmarks',
parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK),
- PermanentItem('synced_bookmarks', name='Mobile Bookmarks',
- parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK),
PermanentItem('google_chrome_preferences', name='Preferences',
parent_tag='google_chrome', sync_type=PREFERENCE),
PermanentItem('google_chrome_autofill', name='Autofill',