Revert "Replace usage of g_settings_new() with ui::GSettingsNew()"
This reverts commit58d541e8f7
. Reason for revert: Tree is closed (Automatic: "generate_build_files" on https://cr-buildbucket.appspot.com/build/8718224921696371473 linux-cast-x64-dbg from20d95a5232
) Original change's description: > Replace usage of g_settings_new() with ui::GSettingsNew() > > * Move //ui/base/glib to a separate source_set since to avoid a circular > dependency since //net needs to depend on it. > - Add build dependencies on //ui/base/glib > * Remove usages of g_settings_new() > > R=thestig > > Bug: None > Change-Id: I872e1c6a9da4ff10d2ee43009809d9ec5ac1edae > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6419125 > Reviewed-by: Aaron Leventhal <aleventhal@chromium.org> > Commit-Queue: Zonghan Xu <xzonghan@chromium.org> > Reviewed-by: Kenichi Ishibashi <bashi@chromium.org> > Reviewed-by: Lambros Lambrou <lambroslambrou@chromium.org> > Commit-Queue: Thomas Anderson <thomasanderson@chromium.org> > Reviewed-by: Lei Zhang <thestig@chromium.org> > Auto-Submit: Thomas Anderson <thomasanderson@chromium.org> > Reviewed-by: Zonghan Xu <xzonghan@chromium.org> > Cr-Commit-Position: refs/heads/main@{#1443631} Bug: None No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: Idc7dc3b456f4916dd83bf2bdfdb22c702d49e346 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6437840 Commit-Queue: Ahmed Moussa <ahmedmoussa@google.com> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Owners-Override: Ahmed Moussa <ahmedmoussa@google.com> Cr-Commit-Position: refs/heads/main@{#1443642}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
2d7d0b1332
commit
538a2bf45a
build/config
components/device_signals/core/common
content/test
net
remoting/host
ui
accessibility
base
gtk
@ -36,7 +36,7 @@ declare_args() {
|
||||
|
||||
use_dbus = is_linux || is_chromeos
|
||||
|
||||
use_gio = is_linux && !is_castos && target_os != "android"
|
||||
use_gio = is_linux && !is_castos
|
||||
|
||||
use_blink = !is_ios
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ static_library("common") {
|
||||
}
|
||||
|
||||
if (is_linux) {
|
||||
deps += [ "//ui/base/glib" ]
|
||||
sources += [ "linux/platform_utils_linux.cc" ]
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,3 @@
|
||||
include_rules = [
|
||||
"+components/policy/core/common",
|
||||
]
|
||||
|
||||
specific_include_rules = {
|
||||
"platform_utils_linux.cc": [
|
||||
"+ui/base/glib",
|
||||
],
|
||||
}
|
||||
]
|
@ -31,7 +31,6 @@
|
||||
#include "components/device_signals/core/common/common_types.h"
|
||||
#include "components/device_signals/core/common/platform_utils.h"
|
||||
#include "components/device_signals/core/common/signals_constants.h"
|
||||
#include "ui/base/glib/gsettings.h"
|
||||
|
||||
namespace {
|
||||
std::string ReadFile(std::string path_str) {
|
||||
@ -76,18 +75,20 @@ SettingValue GetScreenlockSecured() {
|
||||
desktop_env == base::nix::DESKTOP_ENVIRONMENT_CINNAMON ? "cinnamon"
|
||||
: "gnome");
|
||||
|
||||
auto screensaver_settings = ui::GSettingsNew(settings_schema.c_str());
|
||||
GSettingsSchema* screensaver_schema = g_settings_schema_source_lookup(
|
||||
g_settings_schema_source_get_default(), settings_schema.c_str(), FALSE);
|
||||
GSettings* screensaver_settings = nullptr;
|
||||
if (!screensaver_schema ||
|
||||
!g_settings_schema_has_key(screensaver_schema, kLockScreenKey)) {
|
||||
return SettingValue::UNKNOWN;
|
||||
}
|
||||
screensaver_settings = g_settings_new(settings_schema.c_str());
|
||||
if (!screensaver_settings) {
|
||||
return SettingValue::UNKNOWN;
|
||||
}
|
||||
GSettingsSchema* screensaver_schema = g_settings_schema_source_lookup(
|
||||
g_settings_schema_source_get_default(), settings_schema.c_str(), true);
|
||||
if (!g_settings_schema_has_key(screensaver_schema, kLockScreenKey)) {
|
||||
return SettingValue::UNKNOWN;
|
||||
}
|
||||
g_settings_schema_unref(screensaver_schema);
|
||||
gboolean lock_screen_enabled =
|
||||
g_settings_get_boolean(screensaver_settings, kLockScreenKey);
|
||||
g_object_unref(screensaver_settings);
|
||||
|
||||
return lock_screen_enabled ? SettingValue::ENABLED : SettingValue::DISABLED;
|
||||
#else
|
||||
|
@ -2141,7 +2141,6 @@ test("content_browsertests") {
|
||||
sources +=
|
||||
[ "../browser/accessibility/accessibility_auralinux_browsertest.cc" ]
|
||||
configs += [ "//build/config/linux/atk" ]
|
||||
deps += [ "//ui/base/glib" ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1301,9 +1301,6 @@ component("net") {
|
||||
"proxy_resolution/proxy_config_service_linux.cc",
|
||||
"proxy_resolution/proxy_config_service_linux.h",
|
||||
]
|
||||
if (use_glib) {
|
||||
deps += [ "//ui/base/glib" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (is_linux || is_chromeos || is_android) {
|
||||
|
4
net/DEPS
4
net/DEPS
@ -66,10 +66,6 @@ specific_include_rules = {
|
||||
"+mojo/public/cpp/bindings/default_construct_tag.h",
|
||||
],
|
||||
|
||||
"proxy_config_service_linux.cc": [
|
||||
"+ui/base/glib",
|
||||
],
|
||||
|
||||
# Dependencies specific for fuzz targets and other fuzzing-related code.
|
||||
".*fuzz.*": [
|
||||
"+third_party/fuzztest",
|
||||
|
@ -44,9 +44,6 @@
|
||||
|
||||
#if defined(USE_GIO)
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include "ui/base/glib/gsettings.h"
|
||||
#include "ui/base/glib/scoped_gobject.h"
|
||||
#endif // defined(USE_GIO)
|
||||
|
||||
namespace net {
|
||||
@ -271,14 +268,14 @@ class SettingGetterImplGSettings
|
||||
ShutDown();
|
||||
} else {
|
||||
LOG(WARNING) << "~SettingGetterImplGSettings: leaking gsettings client";
|
||||
client_.release();
|
||||
client_.ExtractAsDangling();
|
||||
}
|
||||
}
|
||||
DCHECK(!client_);
|
||||
}
|
||||
|
||||
// CheckVersion() must be called *before* Init()!
|
||||
bool CheckVersion();
|
||||
bool CheckVersion(base::Environment* env);
|
||||
|
||||
bool Init(const scoped_refptr<base::SingleThreadTaskRunner>& glib_task_runner)
|
||||
override {
|
||||
@ -286,8 +283,10 @@ class SettingGetterImplGSettings
|
||||
DCHECK(!client_);
|
||||
DCHECK(!task_runner_.get());
|
||||
|
||||
client_ = ui::GSettingsNew(kProxyGSettingsSchema);
|
||||
if (!client_) {
|
||||
if (!g_settings_schema_source_lookup(g_settings_schema_source_get_default(),
|
||||
kProxyGSettingsSchema, TRUE) ||
|
||||
!(client_ = g_settings_new(kProxyGSettingsSchema))) {
|
||||
// It's not clear whether/when this can return NULL.
|
||||
LOG(ERROR) << "Unable to create a gsettings client";
|
||||
return false;
|
||||
}
|
||||
@ -309,7 +308,9 @@ class SettingGetterImplGSettings
|
||||
g_object_unref(ftp_client_.ExtractAsDangling());
|
||||
g_object_unref(https_client_.ExtractAsDangling());
|
||||
g_object_unref(http_client_.ExtractAsDangling());
|
||||
client_.Reset();
|
||||
g_object_unref(client_.ExtractAsDangling());
|
||||
// We only need to null client_ because it's the only one that we check.
|
||||
client_ = nullptr;
|
||||
task_runner_ = nullptr;
|
||||
}
|
||||
debounce_timer_.reset();
|
||||
@ -474,7 +475,7 @@ class SettingGetterImplGSettings
|
||||
setting_getter->OnChangeNotification();
|
||||
}
|
||||
|
||||
ScopedGObject<GSettings> client_;
|
||||
raw_ptr<GSettings> client_ = nullptr;
|
||||
raw_ptr<GSettings> http_client_ = nullptr;
|
||||
raw_ptr<GSettings> https_client_ = nullptr;
|
||||
raw_ptr<GSettings> ftp_client_ = nullptr;
|
||||
@ -488,16 +489,23 @@ class SettingGetterImplGSettings
|
||||
scoped_refptr<base::SequencedTaskRunner> task_runner_;
|
||||
};
|
||||
|
||||
bool SettingGetterImplGSettings::CheckVersion() {
|
||||
bool SettingGetterImplGSettings::CheckVersion(
|
||||
base::Environment* env) {
|
||||
// CheckVersion() must be called *before* Init()!
|
||||
DCHECK(!client_);
|
||||
|
||||
if (!ui::GSettingsNew(kProxyGSettingsSchema)) {
|
||||
GSettings* client = nullptr;
|
||||
if (g_settings_schema_source_lookup(g_settings_schema_source_get_default(),
|
||||
kProxyGSettingsSchema, TRUE)) {
|
||||
client = g_settings_new(kProxyGSettingsSchema);
|
||||
}
|
||||
if (!client) {
|
||||
VLOG(1) << "Cannot create gsettings client.";
|
||||
return false;
|
||||
}
|
||||
g_object_unref(client);
|
||||
|
||||
VLOG(1) << "Will get proxy config from gsettings.";
|
||||
VLOG(1) << "All gsettings tests OK. Will get proxy config from gsettings.";
|
||||
return true;
|
||||
}
|
||||
#endif // defined(USE_GIO)
|
||||
@ -1245,16 +1253,15 @@ ProxyConfigServiceLinux::Delegate::Delegate(
|
||||
case base::nix::DESKTOP_ENVIRONMENT_UKUI:
|
||||
case base::nix::DESKTOP_ENVIRONMENT_UNITY:
|
||||
#if defined(USE_GIO)
|
||||
{
|
||||
{
|
||||
auto gs_getter = std::make_unique<SettingGetterImplGSettings>();
|
||||
// We have to load symbols and check the GNOME version in use to decide
|
||||
// if we should use the gsettings getter. See CheckVersion().
|
||||
if (gs_getter->CheckVersion()) {
|
||||
if (gs_getter->CheckVersion(env_var_getter_.get()))
|
||||
setting_getter_ = std::move(gs_getter);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
case base::nix::DESKTOP_ENVIRONMENT_KDE3:
|
||||
case base::nix::DESKTOP_ENVIRONMENT_KDE4:
|
||||
case base::nix::DESKTOP_ENVIRONMENT_KDE5:
|
||||
|
@ -606,8 +606,6 @@ static_library("common") {
|
||||
}
|
||||
|
||||
if (is_linux) {
|
||||
assert(use_glib)
|
||||
deps += [ "//ui/base/glib" ]
|
||||
sources += [
|
||||
"continue_window_linux.cc",
|
||||
"disconnect_window_linux.cc",
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "remoting/host/desktop_geometry.h"
|
||||
#include "remoting/host/linux/x11_display_util.h"
|
||||
#include "remoting/host/linux/x11_util.h"
|
||||
#include "ui/base/glib/gsettings.h"
|
||||
#include "ui/gfx/geometry/vector2d.h"
|
||||
#include "ui/gfx/x/future.h"
|
||||
#include "ui/gfx/x/randr.h"
|
||||
@ -58,7 +57,7 @@ DesktopResizerX11::DesktopResizerX11()
|
||||
RandR()->SelectInput({RootWindow(), x11::RandR::NotifyMask::ScreenChange});
|
||||
|
||||
gnome_display_config_.Init();
|
||||
registry_ = ui::GSettingsNew("org.gnome.desktop.interface");
|
||||
registry_ = TakeGObject(g_settings_new("org.gnome.desktop.interface"));
|
||||
}
|
||||
|
||||
DesktopResizerX11::~DesktopResizerX11() = default;
|
||||
@ -214,8 +213,7 @@ void DesktopResizerX11::SetResolutionForOutput(
|
||||
// Check to see if GNOME is using automatic-scaling. If the value is non-zero,
|
||||
// the user prefers a particular scaling, so don't adjust the
|
||||
// text-scaling-factor here.
|
||||
if (registry_ &&
|
||||
g_settings_get_uint(registry_.get(), "scaling-factor") == 0U) {
|
||||
if (g_settings_get_uint(registry_.get(), "scaling-factor") == 0U) {
|
||||
// Start the timer to update the text-scaling-factor. Any previously
|
||||
// started timer will be cancelled.
|
||||
requested_dpi_ = resolution.dpi().x();
|
||||
@ -270,8 +268,7 @@ void DesktopResizerX11::OnGnomeDisplayConfigReceived(
|
||||
<< ", GNOME scale = " << monitor.scale
|
||||
<< ", calculated text-scaling = " << text_scaling_factor;
|
||||
|
||||
if (!registry_ ||
|
||||
!g_settings_set_double(registry_.get(), "text-scaling-factor",
|
||||
if (!g_settings_set_double(registry_.get(), "text-scaling-factor",
|
||||
text_scaling_factor)) {
|
||||
// Just log a warning - failure is expected if the value falls outside the
|
||||
// interval [0.5, 3.0].
|
||||
|
@ -453,8 +453,6 @@ test("accessibility_unittests") {
|
||||
"platform/browser_accessibility_manager_auralinux_unittest.cc",
|
||||
]
|
||||
|
||||
deps += [ "//ui/base/glib" ]
|
||||
|
||||
configs += [ "//build/config/linux/atk" ]
|
||||
}
|
||||
}
|
||||
|
@ -350,7 +350,6 @@ component("platform") {
|
||||
|
||||
if (use_glib) {
|
||||
configs += [ "//build/config/linux:glib" ]
|
||||
deps += [ "//ui/base/glib" ]
|
||||
}
|
||||
if (use_gio) {
|
||||
configs += [ "//build/linux:gio_config" ]
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "ui/accessibility/platform/ax_platform.h"
|
||||
#include "ui/accessibility/platform/ax_platform_node.h"
|
||||
#include "ui/accessibility/platform/ax_platform_node_auralinux.h"
|
||||
#include "ui/base/glib/gsettings.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -167,9 +166,18 @@ bool AtkUtilAuraLinux::ShouldEnableAccessibility() {
|
||||
}
|
||||
|
||||
// Check enabled accessibility based on GSettings
|
||||
auto settings = ui::GSettingsNew("org.gnome.desktop.interface");
|
||||
if (settings) {
|
||||
return g_settings_get_boolean(settings, "toolkit-accessibility");
|
||||
GSettingsSchemaSource* source = g_settings_schema_source_get_default();
|
||||
GSettingsSchema* gschema = nullptr;
|
||||
|
||||
gschema = g_settings_schema_source_lookup(
|
||||
source, "org.gnome.desktop.interface", TRUE);
|
||||
if (gschema) {
|
||||
GSettings* settings = g_settings_new("org.gnome.desktop.interface");
|
||||
const bool accessibilityEnabled =
|
||||
g_settings_get_boolean(settings, "toolkit-accessibility");
|
||||
g_settings_schema_unref(gschema);
|
||||
g_object_unref(settings);
|
||||
return accessibilityEnabled;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -579,7 +579,21 @@ component("base") {
|
||||
}
|
||||
|
||||
if (use_glib) {
|
||||
public_deps += [ "//ui/base/glib" ]
|
||||
configs += [ "//build/config/linux:glib" ]
|
||||
sources += [
|
||||
"glib/glib_cast.h",
|
||||
"glib/glib_integers.h",
|
||||
"glib/scoped_gobject.h",
|
||||
"glib/scoped_gsignal.cc",
|
||||
"glib/scoped_gsignal.h",
|
||||
]
|
||||
if (use_gio) {
|
||||
configs += [ "//build/linux:gio_config" ]
|
||||
sources += [
|
||||
"glib/gsettings.cc",
|
||||
"glib/gsettings.h",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
if (is_chromeos || (use_aura && is_linux) || is_fuchsia) {
|
||||
@ -1311,7 +1325,6 @@ test("ui_base_unittests") {
|
||||
|
||||
if (use_glib) {
|
||||
sources += [ "glib/scoped_gsignal_unittest.cc" ]
|
||||
deps += [ "//ui/base/glib" ]
|
||||
}
|
||||
|
||||
if (is_linux) {
|
||||
|
@ -1,25 +0,0 @@
|
||||
# Copyright 2025 The Chromium Authors
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/config/ui.gni")
|
||||
|
||||
assert(use_glib)
|
||||
|
||||
source_set("glib") {
|
||||
deps = [ "//base" ]
|
||||
public_configs = [ "//build/config/linux:glib" ]
|
||||
public = [
|
||||
"glib_cast.h",
|
||||
"glib_integers.h",
|
||||
"scoped_gobject.h",
|
||||
"scoped_gsignal.h",
|
||||
]
|
||||
sources = [ "scoped_gsignal.cc" ]
|
||||
if (use_gio) {
|
||||
public_configs += [ "//build/linux:gio_config" ]
|
||||
public += [ "gsettings.h" ]
|
||||
sources += [ "gsettings.cc" ]
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
#ifndef UI_BASE_GLIB_GSETTINGS_H_
|
||||
#define UI_BASE_GLIB_GSETTINGS_H_
|
||||
|
||||
#include "base/component_export.h"
|
||||
#include "ui/base/glib/scoped_gobject.h"
|
||||
|
||||
using GSettings = struct _GSettings;
|
||||
@ -13,6 +14,7 @@ namespace ui {
|
||||
|
||||
// Creates a new GSettings object for the given schema. If the schema does not
|
||||
// exist, this will return nullptr.
|
||||
COMPONENT_EXPORT(UI_BASE)
|
||||
ScopedGObject<GSettings> GSettingsNew(const char* schema);
|
||||
|
||||
} // namespace ui
|
||||
|
@ -50,12 +50,6 @@ class ScopedGObject {
|
||||
}
|
||||
}
|
||||
|
||||
T* release() {
|
||||
T* obj = obj_;
|
||||
obj_ = nullptr;
|
||||
return obj;
|
||||
}
|
||||
|
||||
T* get() const { return obj_; }
|
||||
|
||||
// Deliberately implicit to allow easier interaction with C APIs.
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "base/component_export.h"
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
@ -20,7 +21,7 @@
|
||||
// ScopedGSignal manages the lifecycle of a GLib signal connection.
|
||||
// It disconnects the signal when this object is destroyed or goes out of scope.
|
||||
// This class should be used on a single sequence.
|
||||
class ScopedGSignal {
|
||||
class COMPONENT_EXPORT(UI_BASE) ScopedGSignal {
|
||||
public:
|
||||
// Constructs and connects a GLib signal with specified attributes.
|
||||
// Parameters:
|
||||
|
@ -124,7 +124,6 @@ component("gtk") {
|
||||
"//ui/base",
|
||||
"//ui/base:buildflags",
|
||||
"//ui/base:ozone_buildflags",
|
||||
"//ui/base/glib",
|
||||
"//ui/base/ime",
|
||||
"//ui/base/ime/linux",
|
||||
"//ui/color",
|
||||
|
Reference in New Issue
Block a user