Commit 3706f3fd authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS Settings] Move synced wallpaper pref.

In [1], treib@ suggested moving this to settings pref instead of
including it within sync prefs.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/1977956

Change-Id: Ide9c1c4e8b1ede12e3324db96db44293bc8ec703
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2008302
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734273}
parent 96665a83
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/ash/wallpaper_controller_client.h" #include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "chrome/browser/ui/webui/settings/chromeos/pref_names.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_features.h"
...@@ -307,7 +308,8 @@ void WallpaperPrivateGetSyncSettingFunction::CheckSyncServiceStatus() { ...@@ -307,7 +308,8 @@ void WallpaperPrivateGetSyncSettingFunction::CheckSyncServiceStatus() {
// OS-level sync as a whole and wallpaper sync must be enabled. // OS-level sync as a whole and wallpaper sync must be enabled.
bool os_wallpaper_sync_enabled = bool os_wallpaper_sync_enabled =
sync_service->GetUserSettings()->IsOsSyncFeatureEnabled() && sync_service->GetUserSettings()->IsOsSyncFeatureEnabled() &&
profile->GetPrefs()->GetBoolean(syncer::prefs::kSyncOsWallpaper); profile->GetPrefs()->GetBoolean(
chromeos::settings::prefs::kSyncOsWallpaper);
dict->SetBoolean(kSyncThemes, os_wallpaper_sync_enabled); dict->SetBoolean(kSyncThemes, os_wallpaper_sync_enabled);
Respond(OneArgument(std::move(dict))); Respond(OneArgument(std::move(dict)));
return; return;
......
...@@ -314,6 +314,7 @@ ...@@ -314,6 +314,7 @@
#include "chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h"
#include "chrome/browser/upgrade_detector/upgrade_detector_chromeos.h" #include "chrome/browser/upgrade_detector/upgrade_detector_chromeos.h"
#include "chromeos/audio/audio_devices_pref_handler_impl.h" #include "chromeos/audio/audio_devices_pref_handler_impl.h"
#include "chromeos/components/account_manager/account_manager.h" #include "chromeos/components/account_manager/account_manager.h"
...@@ -978,6 +979,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry, ...@@ -978,6 +979,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
chromeos::RegisterSamlProfilePrefs(registry); chromeos::RegisterSamlProfilePrefs(registry);
chromeos::ScreenTimeController::RegisterProfilePrefs(registry); chromeos::ScreenTimeController::RegisterProfilePrefs(registry);
chromeos::ServicesCustomizationDocument::RegisterProfilePrefs(registry); chromeos::ServicesCustomizationDocument::RegisterProfilePrefs(registry);
chromeos::settings::OSSettingsUI::RegisterProfilePrefs(registry);
chromeos::UserImageSyncObserver::RegisterProfilePrefs(registry); chromeos::UserImageSyncObserver::RegisterProfilePrefs(registry);
crostini::prefs::RegisterProfilePrefs(registry); crostini::prefs::RegisterProfilePrefs(registry);
chromeos::attestation::TpmChallengeKey::RegisterProfilePrefs(registry); chromeos::attestation::TpmChallengeKey::RegisterProfilePrefs(registry);
......
...@@ -1960,6 +1960,8 @@ jumbo_static_library("ui") { ...@@ -1960,6 +1960,8 @@ jumbo_static_library("ui") {
"webui/settings/chromeos/parental_controls_handler.h", "webui/settings/chromeos/parental_controls_handler.h",
"webui/settings/chromeos/plugin_vm_handler.cc", "webui/settings/chromeos/plugin_vm_handler.cc",
"webui/settings/chromeos/plugin_vm_handler.h", "webui/settings/chromeos/plugin_vm_handler.h",
"webui/settings/chromeos/pref_names.cc",
"webui/settings/chromeos/pref_names.h",
"webui/settings/chromeos/wallpaper_handler.cc", "webui/settings/chromeos/wallpaper_handler.cc",
"webui/settings/chromeos/wallpaper_handler.h", "webui/settings/chromeos/wallpaper_handler.h",
"webui/settings/tts_handler.cc", "webui/settings/tts_handler.cc",
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/webui/settings/chromeos/pref_names.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/sync/base/pref_names.h" #include "components/sync/base/pref_names.h"
#include "components/sync/base/user_selectable_type.h" #include "components/sync/base/user_selectable_type.h"
...@@ -99,7 +100,7 @@ void OSSyncHandler::HandleSetOsSyncDatatypes(const base::ListValue* args) { ...@@ -99,7 +100,7 @@ void OSSyncHandler::HandleSetOsSyncDatatypes(const base::ListValue* args) {
// Wallpaper sync status is stored directly to the profile's prefs. // Wallpaper sync status is stored directly to the profile's prefs.
bool wallpaper_synced; bool wallpaper_synced;
CHECK(result->GetBoolean(kWallpaperEnabledKey, &wallpaper_synced)); CHECK(result->GetBoolean(kWallpaperEnabledKey, &wallpaper_synced));
profile_->GetPrefs()->SetBoolean(syncer::prefs::kSyncOsWallpaper, profile_->GetPrefs()->SetBoolean(chromeos::settings::prefs::kSyncOsWallpaper,
wallpaper_synced); wallpaper_synced);
// Start configuring the SyncService using the configuration passed to us from // Start configuring the SyncService using the configuration passed to us from
...@@ -171,10 +172,10 @@ void OSSyncHandler::PushSyncPrefs() { ...@@ -171,10 +172,10 @@ void OSSyncHandler::PushSyncPrefs() {
// Wallpaper sync status is fetched from prefs and is considered enabled if // Wallpaper sync status is fetched from prefs and is considered enabled if
// all OS types are enabled; this mimics behavior of GetSelectedOsTypes(). // all OS types are enabled; this mimics behavior of GetSelectedOsTypes().
args.SetBoolean( args.SetBoolean(kWallpaperEnabledKey,
kWallpaperEnabledKey, user_settings->IsSyncAllOsTypesEnabled() ||
user_settings->IsSyncAllOsTypesEnabled() || profile_->GetPrefs()->GetBoolean(
profile_->GetPrefs()->GetBoolean(syncer::prefs::kSyncOsWallpaper)); chromeos::settings::prefs::kSyncOsWallpaper));
FireWebUIListener("os-sync-prefs-changed", base::Value(feature_enabled_), FireWebUIListener("os-sync-prefs-changed", base::Value(feature_enabled_),
args); args);
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h" #include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/webui/settings/chromeos/pref_names.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/test_chrome_web_ui_controller_factory.h" #include "chrome/test/base/test_chrome_web_ui_controller_factory.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
...@@ -150,12 +151,13 @@ class OsSyncHandlerTest : public ChromeRenderViewHostTestHarness { ...@@ -150,12 +151,13 @@ class OsSyncHandlerTest : public ChromeRenderViewHostTestHarness {
void NotifySyncStateChanged() { handler_->OnStateChanged(sync_service_); } void NotifySyncStateChanged() { handler_->OnStateChanged(sync_service_); }
bool GetWallperEnabledPref() { bool GetWallperEnabledPref() {
return profile()->GetPrefs()->GetBoolean(syncer::prefs::kSyncOsWallpaper); return profile()->GetPrefs()->GetBoolean(
chromeos::settings::prefs::kSyncOsWallpaper);
} }
void SetWallperEnabledPref(bool enabled) { void SetWallperEnabledPref(bool enabled) {
return profile()->GetPrefs()->SetBoolean(syncer::prefs::kSyncOsWallpaper, return profile()->GetPrefs()->SetBoolean(
enabled); chromeos::settings::prefs::kSyncOsWallpaper, enabled);
} }
syncer::TestSyncService* sync_service_ = nullptr; syncer::TestSyncService* sync_service_ = nullptr;
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_localized_strings_provider.h" #include "chrome/browser/ui/webui/settings/chromeos/os_settings_localized_strings_provider.h"
#include "chrome/browser/ui/webui/settings/chromeos/parental_controls_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/parental_controls_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/pref_names.h"
#include "chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h"
#include "chrome/browser/ui/webui/settings/downloads_handler.h" #include "chrome/browser/ui/webui/settings/downloads_handler.h"
#include "chrome/browser/ui/webui/settings/extension_control_handler.h" #include "chrome/browser/ui/webui/settings/extension_control_handler.h"
...@@ -91,6 +92,7 @@ ...@@ -91,6 +92,7 @@
#include "chromeos/services/multidevice_setup/public/cpp/prefs.h" #include "chromeos/services/multidevice_setup/public/cpp/prefs.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h" #include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h"
#include "components/password_manager/core/common/password_manager_features.h" #include "components/password_manager/core/common/password_manager_features.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_data_source.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
...@@ -100,6 +102,12 @@ ...@@ -100,6 +102,12 @@
namespace chromeos { namespace chromeos {
namespace settings { namespace settings {
// static
void OSSettingsUI::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(prefs::kSyncOsWallpaper, false);
}
OSSettingsUI::OSSettingsUI(content::WebUI* web_ui) OSSettingsUI::OSSettingsUI(content::WebUI* web_ui)
: ui::MojoWebUIController(web_ui, /*enable_chrome_send=*/true), : ui::MojoWebUIController(web_ui, /*enable_chrome_send=*/true),
webui_load_timer_(web_ui->GetWebContents(), webui_load_timer_(web_ui->GetWebContents(),
......
...@@ -18,7 +18,11 @@ ...@@ -18,7 +18,11 @@
namespace content { namespace content {
class WebUIDataSource; class WebUIDataSource;
class WebUIMessageHandler; class WebUIMessageHandler;
} } // namespace content
namespace user_prefs {
class PrefRegistrySyncable;
} // namespace user_prefs
namespace chromeos { namespace chromeos {
namespace settings { namespace settings {
...@@ -26,6 +30,8 @@ namespace settings { ...@@ -26,6 +30,8 @@ namespace settings {
// The WebUI handler for chrome://os-settings. // The WebUI handler for chrome://os-settings.
class OSSettingsUI : public ui::MojoWebUIController { class OSSettingsUI : public ui::MojoWebUIController {
public: public:
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
explicit OSSettingsUI(content::WebUI* web_ui); explicit OSSettingsUI(content::WebUI* web_ui);
~OSSettingsUI() override; ~OSSettingsUI() override;
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/webui/settings/chromeos/pref_names.h"
namespace chromeos {
namespace settings {
namespace prefs {
// Boolean specifying whether OS wallpaper sync is enabled. This is stored
// separately from the other OS sync preferences because it's an edge case;
// wallpaper does not have its own ModelType, so it cannot be part of
// UserSelectableOsType like the other OS sync types.
// TODO(https://crbug.com/967987): Break this dependency.
const char kSyncOsWallpaper[] = "sync.os_wallpaper";
} // namespace prefs
} // namespace settings
} // namespace chromeos
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PREF_NAMES_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PREF_NAMES_H_
namespace chromeos {
namespace settings {
namespace prefs {
extern const char kSyncOsWallpaper[];
} // namespace prefs
} // namespace settings
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PREF_NAMES_H_
...@@ -41,13 +41,6 @@ const char kSyncAllOsTypes[] = "sync.all_os_types"; ...@@ -41,13 +41,6 @@ const char kSyncAllOsTypes[] = "sync.all_os_types";
// OS user selectable types. // OS user selectable types.
const char kSyncOsApps[] = "sync.os_apps"; const char kSyncOsApps[] = "sync.os_apps";
const char kSyncOsPreferences[] = "sync.os_preferences"; const char kSyncOsPreferences[] = "sync.os_preferences";
// Boolean specifying whether OS wallpaper sync is enabled. This is stored
// separately from |kSyncOsPreferences| because it's an edge case - wallpaper
// does not have its own ModelType, so it cannot be part of UserSelectableOsType
// like the other OS sync types.
// TODO(https://crbug.com/967987): Break this dependency.
const char kSyncOsWallpaper[] = "sync.os_wallpaper";
#endif #endif
// Booleans specifying whether the user has selected to sync the following // Booleans specifying whether the user has selected to sync the following
......
...@@ -22,7 +22,6 @@ extern const char kOsSyncFeatureEnabled[]; ...@@ -22,7 +22,6 @@ extern const char kOsSyncFeatureEnabled[];
extern const char kSyncAllOsTypes[]; extern const char kSyncAllOsTypes[];
extern const char kSyncOsApps[]; extern const char kSyncOsApps[];
extern const char kSyncOsPreferences[]; extern const char kSyncOsPreferences[];
extern const char kSyncOsWallpaper[];
#endif #endif
extern const char kSyncApps[]; extern const char kSyncApps[];
......
...@@ -291,7 +291,6 @@ void SyncPrefs::RegisterProfilePrefs( ...@@ -291,7 +291,6 @@ void SyncPrefs::RegisterProfilePrefs(
for (UserSelectableOsType type : UserSelectableOsTypeSet::All()) { for (UserSelectableOsType type : UserSelectableOsTypeSet::All()) {
registry->RegisterBooleanPref(GetPrefNameForOsType(type), false); registry->RegisterBooleanPref(GetPrefNameForOsType(type), false);
} }
registry->RegisterBooleanPref(prefs::kSyncOsWallpaper, false);
#endif #endif
// Internal or bookkeeping prefs. // Internal or bookkeeping prefs.
......
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