diff options
-rw-r--r-- | chrome/browser/sync/engine/DEPS | 4 | ||||
-rw-r--r-- | chrome/browser/sync/engine/download_updates_command.cc | 12 | ||||
-rw-r--r-- | chrome/browser/sync/engine/download_updates_command.h | 8 | ||||
-rw-r--r-- | chrome/browser/sync/engine/download_updates_command_unittest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/sync/engine/syncer.cc | 10 | ||||
-rw-r--r-- | chrome/browser/sync/glue/bookmark_model_associator.cc | 17 | ||||
-rw-r--r-- | chrome/browser/sync/glue/bookmark_model_associator.h | 7 | ||||
-rw-r--r-- | chrome/browser/sync/profile_sync_components_factory_impl.cc | 10 | ||||
-rw-r--r-- | chrome/browser/sync/profile_sync_service_bookmark_unittest.cc | 5 | ||||
-rw-r--r-- | chrome/browser/sync/protocol/sync.proto | 5 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 |
12 files changed, 51 insertions, 34 deletions
diff --git a/chrome/browser/sync/engine/DEPS b/chrome/browser/sync/engine/DEPS index 6610f50..4ddf242 100644 --- a/chrome/browser/sync/engine/DEPS +++ b/chrome/browser/sync/engine/DEPS @@ -14,8 +14,4 @@ include_rules = [ # TODO(rlarocque) 19878: Move remaining syncapi-related headers to # internal_api/, then remove this DEPS rule. "+chrome/browser/sync/internal_api", - - # various command line flags - "+chrome/common/chrome_switches.h", ] - diff --git a/chrome/browser/sync/engine/download_updates_command.cc b/chrome/browser/sync/engine/download_updates_command.cc index e66adae..2e02e96 100644 --- a/chrome/browser/sync/engine/download_updates_command.cc +++ b/chrome/browser/sync/engine/download_updates_command.cc @@ -12,7 +12,6 @@ #include "chrome/browser/sync/engine/syncproto.h" #include "chrome/browser/sync/syncable/model_type_payload_map.h" #include "chrome/browser/sync/syncable/syncable.h" -#include "chrome/common/chrome_switches.h" using sync_pb::DebugInfo; @@ -25,7 +24,10 @@ using syncable::MODEL_TYPE_COUNT; using syncable::ModelTypeSet; using syncable::ModelTypeSetToString; -DownloadUpdatesCommand::DownloadUpdatesCommand() {} +DownloadUpdatesCommand::DownloadUpdatesCommand( + bool create_mobile_bookmarks_folder) + : create_mobile_bookmarks_folder_(create_mobile_bookmarks_folder) {} + DownloadUpdatesCommand::~DownloadUpdatesCommand() {} SyncerError DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) { @@ -37,10 +39,8 @@ SyncerError DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) { ClientToServerMessage::GET_UPDATES); GetUpdatesMessage* get_updates = client_to_server_message.mutable_get_updates(); - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kCreateMobileBookmarksFolder)) { - get_updates->set_include_syncable_bookmarks(true); - } + get_updates->set_create_mobile_bookmarks_folder( + create_mobile_bookmarks_folder_); syncable::Directory* dir = session->context()->directory(); diff --git a/chrome/browser/sync/engine/download_updates_command.h b/chrome/browser/sync/engine/download_updates_command.h index 3b12c71..6494ecb 100644 --- a/chrome/browser/sync/engine/download_updates_command.h +++ b/chrome/browser/sync/engine/download_updates_command.h @@ -40,7 +40,10 @@ namespace browser_sync { // is encountered. class DownloadUpdatesCommand : public SyncerCommand { public: - DownloadUpdatesCommand(); + // |create_mobile_bookmarks_folder| controls whether or not to + // create the mobile bookmarks folder if it's not already created. + // Should be set to true only by mobile clients. + explicit DownloadUpdatesCommand(bool create_mobile_bookmarks_folder); virtual ~DownloadUpdatesCommand(); // SyncerCommand implementation. @@ -50,6 +53,9 @@ class DownloadUpdatesCommand : public SyncerCommand { FRIEND_TEST_ALL_PREFIXES(DownloadUpdatesCommandTest, VerifyAppendDebugInfo); void AppendClientDebugInfoIfNeeded(sessions::SyncSession* session, sync_pb::DebugInfo* debug_info); + + const bool create_mobile_bookmarks_folder_; + DISALLOW_COPY_AND_ASSIGN(DownloadUpdatesCommand); }; diff --git a/chrome/browser/sync/engine/download_updates_command_unittest.cc b/chrome/browser/sync/engine/download_updates_command_unittest.cc index 60ad452..3998ee0a 100644 --- a/chrome/browser/sync/engine/download_updates_command_unittest.cc +++ b/chrome/browser/sync/engine/download_updates_command_unittest.cc @@ -20,7 +20,8 @@ using syncable::MODEL_TYPE_COUNT; // A test fixture for tests exercising DownloadUpdatesCommandTest. class DownloadUpdatesCommandTest : public SyncerCommandTest { protected: - DownloadUpdatesCommandTest() {} + DownloadUpdatesCommandTest() + : command_(true /* create_mobile_bookmarks_folder */) {} virtual void SetUp() { workers()->clear(); diff --git a/chrome/browser/sync/engine/syncer.cc b/chrome/browser/sync/engine/syncer.cc index 877ff96..9750fac 100644 --- a/chrome/browser/sync/engine/syncer.cc +++ b/chrome/browser/sync/engine/syncer.cc @@ -9,6 +9,7 @@ #include "base/logging.h" #include "base/message_loop.h" #include "base/time.h" +#include "build/build_config.h" #include "chrome/browser/sync/engine/apply_updates_command.h" #include "chrome/browser/sync/engine/build_commit_command.h" #include "chrome/browser/sync/engine/cleanup_disabled_types_command.h" @@ -132,7 +133,14 @@ void Syncer::SyncShare(sessions::SyncSession* session, break; } case DOWNLOAD_UPDATES: { - DownloadUpdatesCommand download_updates; + // TODO(akalin): We may want to propagate this switch up + // eventually. +#if defined(OS_ANDROID) + const bool kCreateMobileBookmarksFolder = true; +#else + const bool kCreateMobileBookmarksFolder = false; +#endif + DownloadUpdatesCommand download_updates(kCreateMobileBookmarksFolder); session->mutable_status_controller()->set_last_download_updates_result( download_updates.Execute(session)); next_step = PROCESS_CLIENT_COMMAND; diff --git a/chrome/browser/sync/glue/bookmark_model_associator.cc b/chrome/browser/sync/glue/bookmark_model_associator.cc index a7d212c..42c730b 100644 --- a/chrome/browser/sync/glue/bookmark_model_associator.cc +++ b/chrome/browser/sync/glue/bookmark_model_associator.cc @@ -21,7 +21,6 @@ #include "chrome/browser/sync/internal_api/write_node.h" #include "chrome/browser/sync/internal_api/write_transaction.h" #include "chrome/browser/sync/util/cryptographer.h" -#include "chrome/common/chrome_switches.h" #include "content/public/browser/browser_thread.h" using content::BrowserThread; @@ -187,10 +186,12 @@ const BookmarkNode* BookmarkNodeIdIndex::Find(int64 id) const { BookmarkModelAssociator::BookmarkModelAssociator( BookmarkModel* bookmark_model, sync_api::UserShare* user_share, - DataTypeErrorHandler* unrecoverable_error_handler) + DataTypeErrorHandler* unrecoverable_error_handler, + bool expect_mobile_bookmarks_folder) : bookmark_model_(bookmark_model), user_share_(user_share), unrecoverable_error_handler_(unrecoverable_error_handler), + expect_mobile_bookmarks_folder_(expect_mobile_bookmarks_folder), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), number_of_new_sync_nodes_created_at_association_(0) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -399,13 +400,11 @@ bool BookmarkModelAssociator::BuildAssociations(SyncError* error) { } if (!AssociateTaggedPermanentNode(bookmark_model_->mobile_node(), kMobileBookmarksTag) && - // The mobile folder only need exist if kCreateMobileBookmarksFolder is - // set. - CommandLine::ForCurrentProcess()->HasSwitch( - switches::kCreateMobileBookmarksFolder)) { + expect_mobile_bookmarks_folder_) { 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); @@ -414,8 +413,7 @@ 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)) { + if (expect_mobile_bookmarks_folder_) { DCHECK_NE(sync_api::kInvalidId, mobile_bookmarks_sync_id); } @@ -571,8 +569,7 @@ bool BookmarkModelAssociator::LoadAssociations() { } int64 mobile_bookmarks_id = -1; if (!GetSyncIdForTaggedNode(kMobileBookmarksTag, &mobile_bookmarks_id) && - CommandLine::ForCurrentProcess()->HasSwitch( - switches::kCreateMobileBookmarksFolder)) { + expect_mobile_bookmarks_folder_) { return false; } diff --git a/chrome/browser/sync/glue/bookmark_model_associator.h b/chrome/browser/sync/glue/bookmark_model_associator.h index c5554ea..34fa2c8 100644 --- a/chrome/browser/sync/glue/bookmark_model_associator.h +++ b/chrome/browser/sync/glue/bookmark_model_associator.h @@ -36,10 +36,14 @@ class BookmarkModelAssociator : public PerDataTypeAssociatorInterface<BookmarkNode, int64> { public: static syncable::ModelType model_type() { return syncable::BOOKMARKS; } + // |expect_mobile_bookmarks_folder| controls whether or not we + // expect the mobile bookmarks permanent folder to be created. + // Should be set to true only by mobile clients. BookmarkModelAssociator( BookmarkModel* bookmark_model, sync_api::UserShare* user_share, - DataTypeErrorHandler* unrecoverable_error_handler); + DataTypeErrorHandler* unrecoverable_error_handler, + bool expect_mobile_bookmarks_folder); virtual ~BookmarkModelAssociator(); // Updates the visibility of the permanents node in the BookmarkModel. @@ -130,6 +134,7 @@ class BookmarkModelAssociator BookmarkModel* bookmark_model_; sync_api::UserShare* user_share_; DataTypeErrorHandler* unrecoverable_error_handler_; + const bool expect_mobile_bookmarks_folder_; BookmarkIdToSyncIdMap id_map_; SyncIdToBookmarkNodeMap id_map_inverse_; // Stores sync ids for dirty associations. diff --git a/chrome/browser/sync/profile_sync_components_factory_impl.cc b/chrome/browser/sync/profile_sync_components_factory_impl.cc index 09aa389..f630f02 100644 --- a/chrome/browser/sync/profile_sync_components_factory_impl.cc +++ b/chrome/browser/sync/profile_sync_components_factory_impl.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/command_line.h" +#include "build/build_config.h" #include "chrome/browser/extensions/app_notification_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/settings/settings_frontend.h" @@ -256,10 +257,17 @@ ProfileSyncComponentsFactory::SyncComponents BookmarkModel* bookmark_model = profile_sync_service->profile()->GetBookmarkModel(); sync_api::UserShare* user_share = profile_sync_service->GetUserShare(); + // TODO(akalin): We may want to propagate this switch up eventually. +#if defined(OS_ANDROID) + const bool kExpectMobileBookmarksFolder = true; +#else + const bool kExpectMobileBookmarksFolder = false; +#endif BookmarkModelAssociator* model_associator = new BookmarkModelAssociator(bookmark_model, user_share, - error_handler); + error_handler, + kExpectMobileBookmarksFolder); BookmarkChangeProcessor* change_processor = new BookmarkChangeProcessor(model_associator, error_handler); diff --git a/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc b/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc index 3588ef5..7186678 100644 --- a/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc @@ -55,7 +55,8 @@ class TestBookmarkModelAssociator : public BookmarkModelAssociator { sync_api::UserShare* user_share, DataTypeErrorHandler* error_handler) : BookmarkModelAssociator(bookmark_model, user_share, - error_handler), + error_handler, + true /* expect_mobile_bookmarks_folder */), user_share_(user_share) {} // TODO(akalin): This logic lazily creates any tagged node that is @@ -332,8 +333,6 @@ class ProfileSyncServiceBookmarkTest : public testing::Test { virtual void SetUp() { test_user_share_.SetUp(); - CommandLine::ForCurrentProcess()->AppendSwitch( - switches::kCreateMobileBookmarksFolder); } virtual void TearDown() { diff --git a/chrome/browser/sync/protocol/sync.proto b/chrome/browser/sync/protocol/sync.proto index 41ef933..bc866fe 100644 --- a/chrome/browser/sync/protocol/sync.proto +++ b/chrome/browser/sync/protocol/sync.proto @@ -405,8 +405,9 @@ message GetUpdatesMessage { // delimited by a length prefix, which is encoded as a varint. optional bool streaming = 7 [default = false]; - // Whether to request the syncable_bookmarks permanent item. - optional bool include_syncable_bookmarks = 1000 [default = false]; + // Whether to create the mobile bookmarks folder if it's not + // already created. Should be set to true only by mobile clients. + optional bool create_mobile_bookmarks_folder = 1000 [default = false]; }; message AuthenticateMessage { diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 369bb2a..3c36aa4 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -208,9 +208,6 @@ 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"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index a31b0b3..fc30093 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -67,7 +67,6 @@ 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[]; |