Commit 4cb9d73d authored by James Cook's avatar James Cook Committed by Commit Bot

sync: Use transport mode for PRINTERS and WIFI_CONFIGURATIONS

Chrome OS SplitSettingsSync has a separate control for syncing OS data
types that isn't controlled by the browser's sync-the-feature. Change
ModelType::PRINTERS and WIFI_CONFIGURATIONS to run when the transport
layer is enabled when kSplitSettingsSync is enabled. They already have
checks for the OS sync feature being enabled.

Bug: 1013466, 1031549
Test: updated sync_integration_tests
Change-Id: If7fae05bda53bb68d2bcde0ce2fab6a9a7f7d416
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1954361
Commit-Queue: James Cook <jamescook@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722632}
parent 1248ad3b
......@@ -16,12 +16,17 @@
#include "components/sync/driver/sync_service.h"
#include "components/sync/model/model_type_controller_delegate.h"
using syncer::ModelTypeControllerDelegate;
OsSyncModelTypeController::OsSyncModelTypeController(
syncer::ModelType type,
std::unique_ptr<syncer::ModelTypeControllerDelegate> delegate,
std::unique_ptr<ModelTypeControllerDelegate> delegate_for_full_sync_mode,
std::unique_ptr<ModelTypeControllerDelegate> delegate_for_transport_mode,
PrefService* pref_service,
syncer::SyncService* sync_service)
: syncer::ModelTypeController(type, std::move(delegate)),
: syncer::ModelTypeController(type,
std::move(delegate_for_full_sync_mode),
std::move(delegate_for_transport_mode)),
pref_service_(pref_service),
sync_service_(sync_service) {
DCHECK(chromeos::features::IsSplitSettingsSyncEnabled());
......
......@@ -17,15 +17,17 @@ class ModelTypeControllerDelegate;
class SyncService;
} // namespace syncer
// Controls sync of Chrome OS ModelTypes that depend on the system-wide
// kOsSyncFeatureEnabled preference.
// Controls sync of Chrome OS ModelTypes that can run in transport-mode and
// depend on the system-wide kOsSyncFeatureEnabled preference.
class OsSyncModelTypeController : public syncer::ModelTypeController {
public:
OsSyncModelTypeController(
syncer::ModelType type,
std::unique_ptr<syncer::ModelTypeControllerDelegate> delegate,
PrefService* pref_service,
syncer::SyncService* sync_service);
OsSyncModelTypeController(syncer::ModelType type,
std::unique_ptr<syncer::ModelTypeControllerDelegate>
delegate_for_full_sync_mode,
std::unique_ptr<syncer::ModelTypeControllerDelegate>
delegate_for_transport_mode,
PrefService* pref_service,
syncer::SyncService* sync_service);
~OsSyncModelTypeController() override;
OsSyncModelTypeController(const OsSyncModelTypeController&) = delete;
......
......@@ -132,6 +132,8 @@
#endif // defined(OS_CHROMEOS)
using content::BrowserThread;
using syncer::ForwardingModelTypeControllerDelegate;
#if BUILDFLAG(ENABLE_EXTENSIONS)
using browser_sync::ExtensionModelTypeController;
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
......@@ -442,23 +444,28 @@ ChromeSyncClient::CreateDataTypeControllers(syncer::SyncService* sync_service) {
dump_stack, profile_->GetPrefs(), sync_service));
}
if (!disabled_types.Has(syncer::PRINTERS)) {
// TODO(https://crbug.com/1031549): Make this type run in transport-only
// mode for SplitSettingsSync.
// Use the same delegate in full-sync and transport-only modes.
syncer::ModelTypeControllerDelegate* delegate =
GetControllerDelegateForModelType(syncer::PRINTERS).get();
controllers.push_back(std::make_unique<OsSyncModelTypeController>(
syncer::PRINTERS,
std::make_unique<syncer::ForwardingModelTypeControllerDelegate>(
GetControllerDelegateForModelType(syncer::PRINTERS).get()),
/*delegate_for_full_sync_mode=*/
std::make_unique<ForwardingModelTypeControllerDelegate>(delegate),
/*delegate_for_transport_mode=*/
std::make_unique<ForwardingModelTypeControllerDelegate>(delegate),
profile_->GetPrefs(), sync_service));
}
if (!disabled_types.Has(syncer::WIFI_CONFIGURATIONS) &&
base::FeatureList::IsEnabled(switches::kSyncWifiConfigurations)) {
// TODO(https://crbug.com/1031549): Make this type run in transport-only
// mode for SplitSettingsSync.
// Use the same delegate in full-sync and transport-only modes.
syncer::ModelTypeControllerDelegate* delegate =
GetControllerDelegateForModelType(syncer::WIFI_CONFIGURATIONS).get();
controllers.push_back(std::make_unique<OsSyncModelTypeController>(
syncer::WIFI_CONFIGURATIONS,
std::make_unique<syncer::ForwardingModelTypeControllerDelegate>(
GetControllerDelegateForModelType(syncer::WIFI_CONFIGURATIONS)
.get()),
/*delegate_for_full_sync_mode=*/
std::make_unique<ForwardingModelTypeControllerDelegate>(delegate),
/*delegate_for_transport_mode=*/
std::make_unique<ForwardingModelTypeControllerDelegate>(delegate),
profile_->GetPrefs(), sync_service));
}
}
......
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/feature_list.h"
#include "base/files/file_util.h"
#include "base/macros.h"
#include "base/path_service.h"
......@@ -296,8 +297,10 @@ IN_PROC_BROWSER_TEST_F(SingleClientStandaloneTransportSyncTest,
class SingleClientStandaloneTransportOsSyncTest : public OsSyncTest {
public:
SingleClientStandaloneTransportOsSyncTest() : OsSyncTest(SINGLE_CLIENT) {
// Don't auto-start sync.
scoped_features_.InitAndEnableFeature(switches::kSyncManualStartChromeOS);
// Enable the Wi-Fi type and don't auto-start browser sync.
scoped_features_.InitWithFeatures(
{switches::kSyncWifiConfigurations, switches::kSyncManualStartChromeOS},
{});
}
~SingleClientStandaloneTransportOsSyncTest() override = default;
......@@ -328,6 +331,8 @@ IN_PROC_BROWSER_TEST_F(SingleClientStandaloneTransportOsSyncTest,
EXPECT_TRUE(active_types.Has(syncer::ARC_PACKAGE));
EXPECT_TRUE(active_types.Has(syncer::OS_PREFERENCES));
EXPECT_TRUE(active_types.Has(syncer::OS_PRIORITY_PREFERENCES));
EXPECT_TRUE(active_types.Has(syncer::PRINTERS));
EXPECT_TRUE(active_types.Has(syncer::WIFI_CONFIGURATIONS));
// Verify that a few browser non-transport-mode types are not active.
EXPECT_FALSE(active_types.Has(syncer::BOOKMARKS));
......@@ -358,6 +363,8 @@ IN_PROC_BROWSER_TEST_F(SingleClientStandaloneTransportOsSyncTest,
EXPECT_FALSE(active_types.Has(syncer::ARC_PACKAGE));
EXPECT_FALSE(active_types.Has(syncer::OS_PREFERENCES));
EXPECT_FALSE(active_types.Has(syncer::OS_PRIORITY_PREFERENCES));
EXPECT_FALSE(active_types.Has(syncer::PRINTERS));
EXPECT_FALSE(active_types.Has(syncer::WIFI_CONFIGURATIONS));
// Browser non-transport-mode types are active.
EXPECT_TRUE(active_types.Has(syncer::BOOKMARKS));
......
......@@ -1399,9 +1399,9 @@ ModelTypeSet ProfileSyncService::GetModelTypesForTransportOnlyMode() const {
#if defined(OS_CHROMEOS)
// Chrome OS system types are not tied to browser sync-the-feature.
if (chromeos::features::IsSplitSettingsSyncEnabled()) {
// TODO(jamescook): APP_LIST, PRINTERS, WIFI_CONFIGURATIONS.
allowed_types.PutAll(
{ARC_PACKAGE, OS_PREFERENCES, OS_PRIORITY_PREFERENCES});
// TODO(jamescook): APP_LIST.
allowed_types.PutAll({ARC_PACKAGE, OS_PREFERENCES, OS_PRIORITY_PREFERENCES,
PRINTERS, WIFI_CONFIGURATIONS});
}
#endif // defined(OS_CHROMEOS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment