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 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service_factory.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/grit/generated_resources.h"
#include "chromeos/constants/chromeos_features.h"
......@@ -307,7 +308,8 @@ void WallpaperPrivateGetSyncSettingFunction::CheckSyncServiceStatus() {
// OS-level sync as a whole and wallpaper sync must be enabled.
bool os_wallpaper_sync_enabled =
sync_service->GetUserSettings()->IsOsSyncFeatureEnabled() &&
profile->GetPrefs()->GetBoolean(syncer::prefs::kSyncOsWallpaper);
profile->GetPrefs()->GetBoolean(
chromeos::settings::prefs::kSyncOsWallpaper);
dict->SetBoolean(kSyncThemes, os_wallpaper_sync_enabled);
Respond(OneArgument(std::move(dict)));
return;
......
......@@ -314,6 +314,7 @@
#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/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 "chromeos/audio/audio_devices_pref_handler_impl.h"
#include "chromeos/components/account_manager/account_manager.h"
......@@ -978,6 +979,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
chromeos::RegisterSamlProfilePrefs(registry);
chromeos::ScreenTimeController::RegisterProfilePrefs(registry);
chromeos::ServicesCustomizationDocument::RegisterProfilePrefs(registry);
chromeos::settings::OSSettingsUI::RegisterProfilePrefs(registry);
chromeos::UserImageSyncObserver::RegisterProfilePrefs(registry);
crostini::prefs::RegisterProfilePrefs(registry);
chromeos::attestation::TpmChallengeKey::RegisterProfilePrefs(registry);
......
......@@ -1960,6 +1960,8 @@ jumbo_static_library("ui") {
"webui/settings/chromeos/parental_controls_handler.h",
"webui/settings/chromeos/plugin_vm_handler.cc",
"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.h",
"webui/settings/tts_handler.cc",
......
......@@ -10,6 +10,7 @@
#include "base/values.h"
#include "chrome/browser/profiles/profile.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/sync/base/pref_names.h"
#include "components/sync/base/user_selectable_type.h"
......@@ -99,7 +100,7 @@ void OSSyncHandler::HandleSetOsSyncDatatypes(const base::ListValue* args) {
// Wallpaper sync status is stored directly to the profile's prefs.
bool wallpaper_synced;
CHECK(result->GetBoolean(kWallpaperEnabledKey, &wallpaper_synced));
profile_->GetPrefs()->SetBoolean(syncer::prefs::kSyncOsWallpaper,
profile_->GetPrefs()->SetBoolean(chromeos::settings::prefs::kSyncOsWallpaper,
wallpaper_synced);
// Start configuring the SyncService using the configuration passed to us from
......@@ -171,10 +172,10 @@ void OSSyncHandler::PushSyncPrefs() {
// Wallpaper sync status is fetched from prefs and is considered enabled if
// all OS types are enabled; this mimics behavior of GetSelectedOsTypes().
args.SetBoolean(
kWallpaperEnabledKey,
user_settings->IsSyncAllOsTypesEnabled() ||
profile_->GetPrefs()->GetBoolean(syncer::prefs::kSyncOsWallpaper));
args.SetBoolean(kWallpaperEnabledKey,
user_settings->IsSyncAllOsTypesEnabled() ||
profile_->GetPrefs()->GetBoolean(
chromeos::settings::prefs::kSyncOsWallpaper));
FireWebUIListener("os-sync-prefs-changed", base::Value(feature_enabled_),
args);
......
......@@ -11,6 +11,7 @@
#include "base/values.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.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/test_chrome_web_ui_controller_factory.h"
#include "components/keyed_service/core/keyed_service.h"
......@@ -150,12 +151,13 @@ class OsSyncHandlerTest : public ChromeRenderViewHostTestHarness {
void NotifySyncStateChanged() { handler_->OnStateChanged(sync_service_); }
bool GetWallperEnabledPref() {
return profile()->GetPrefs()->GetBoolean(syncer::prefs::kSyncOsWallpaper);
return profile()->GetPrefs()->GetBoolean(
chromeos::settings::prefs::kSyncOsWallpaper);
}
void SetWallperEnabledPref(bool enabled) {
return profile()->GetPrefs()->SetBoolean(syncer::prefs::kSyncOsWallpaper,
enabled);
return profile()->GetPrefs()->SetBoolean(
chromeos::settings::prefs::kSyncOsWallpaper, enabled);
}
syncer::TestSyncService* sync_service_ = nullptr;
......
......@@ -61,6 +61,7 @@
#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/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/downloads_handler.h"
#include "chrome/browser/ui/webui/settings/extension_control_handler.h"
......@@ -91,6 +92,7 @@
#include "chromeos/services/multidevice_setup/public/cpp/prefs.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/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui_data_source.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
......@@ -100,6 +102,12 @@
namespace chromeos {
namespace settings {
// static
void OSSettingsUI::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(prefs::kSyncOsWallpaper, false);
}
OSSettingsUI::OSSettingsUI(content::WebUI* web_ui)
: ui::MojoWebUIController(web_ui, /*enable_chrome_send=*/true),
webui_load_timer_(web_ui->GetWebContents(),
......
......@@ -18,7 +18,11 @@
namespace content {
class WebUIDataSource;
class WebUIMessageHandler;
}
} // namespace content
namespace user_prefs {
class PrefRegistrySyncable;
} // namespace user_prefs
namespace chromeos {
namespace settings {
......@@ -26,6 +30,8 @@ namespace settings {
// The WebUI handler for chrome://os-settings.
class OSSettingsUI : public ui::MojoWebUIController {
public:
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
explicit OSSettingsUI(content::WebUI* web_ui);
~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";
// OS user selectable types.
const char kSyncOsApps[] = "sync.os_apps";
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
// Booleans specifying whether the user has selected to sync the following
......
......@@ -22,7 +22,6 @@ extern const char kOsSyncFeatureEnabled[];
extern const char kSyncAllOsTypes[];
extern const char kSyncOsApps[];
extern const char kSyncOsPreferences[];
extern const char kSyncOsWallpaper[];
#endif
extern const char kSyncApps[];
......
......@@ -291,7 +291,6 @@ void SyncPrefs::RegisterProfilePrefs(
for (UserSelectableOsType type : UserSelectableOsTypeSet::All()) {
registry->RegisterBooleanPref(GetPrefNameForOsType(type), false);
}
registry->RegisterBooleanPref(prefs::kSyncOsWallpaper, false);
#endif
// 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