[a11y] Update caret blink interval immediately
Adds a native theme observer to the pref watcher that will be notified when the caret blink interval changes. Bug: b/259374492 Change-Id: I4f3097c115399bd848b250e1690cbc2a4b351495 AX-Relnotes: N/A Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5467975 Commit-Queue: Katie Dektar <katie@chromium.org> Reviewed-by: Dominic Battre <battre@chromium.org> Cr-Commit-Position: refs/heads/main@{#1290671}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
e761ca7d14
commit
fba12de9c5
@ -2713,12 +2713,12 @@ void AccessibilityController::UpdateCaretBlinkIntervalFromPrefs() const {
|
||||
active_user_prefs_->GetInteger(prefs::kAccessibilityCaretBlinkInterval));
|
||||
auto* native_theme_dark = ui::NativeTheme::GetInstanceForDarkUI();
|
||||
native_theme_dark->set_caret_blink_interval(caret_blink_interval);
|
||||
native_theme_dark->NotifyOnNativeThemeUpdated();
|
||||
auto* native_theme_web = ui::NativeTheme::GetInstanceForWeb();
|
||||
native_theme_web->set_caret_blink_interval(caret_blink_interval);
|
||||
native_theme_web->NotifyOnNativeThemeUpdated();
|
||||
auto* native_theme = ui::NativeTheme::GetInstanceForNativeUi();
|
||||
native_theme->set_caret_blink_interval(caret_blink_interval);
|
||||
native_theme_dark->NotifyOnNativeThemeUpdated();
|
||||
native_theme_web->NotifyOnNativeThemeUpdated();
|
||||
native_theme->NotifyOnNativeThemeUpdated();
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "components/live_caption/pref_names.h"
|
||||
#include "components/privacy_sandbox/tracking_protection_settings.h"
|
||||
#include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h"
|
||||
#include "ui/native_theme/native_theme.h"
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
#include "ash/constants/ash_pref_names.h"
|
||||
@ -84,6 +85,7 @@ PrefWatcher::PrefWatcher(Profile* profile)
|
||||
CHECK(tracking_protection_settings_);
|
||||
tracking_protection_settings_observation_.Observe(
|
||||
tracking_protection_settings_);
|
||||
native_theme_observation_.Observe(ui::NativeTheme::GetInstanceForWeb());
|
||||
|
||||
profile_pref_change_registrar_.Init(profile_->GetPrefs());
|
||||
|
||||
@ -149,6 +151,11 @@ void PrefWatcher::Shutdown() {
|
||||
local_state_pref_change_registrar_.RemoveAll();
|
||||
}
|
||||
|
||||
void PrefWatcher::OnNativeThemeUpdated(
|
||||
ui::NativeTheme* observed_theme) {
|
||||
UpdateRendererPreferences();
|
||||
}
|
||||
|
||||
void PrefWatcher::OnDoNotTrackEnabledChanged() {
|
||||
UpdateRendererPreferences();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/memory/singleton.h"
|
||||
#include "base/scoped_observation.h"
|
||||
#include "chrome/browser/profiles/profile_keyed_service_factory.h"
|
||||
#include "components/keyed_service/core/keyed_service.h"
|
||||
#include "components/prefs/pref_change_registrar.h"
|
||||
@ -14,6 +15,7 @@
|
||||
#include "components/privacy_sandbox/tracking_protection_settings_observer.h"
|
||||
#include "mojo/public/cpp/bindings/remote_set.h"
|
||||
#include "third_party/blink/public/mojom/renderer_preference_watcher.mojom.h"
|
||||
#include "ui/native_theme/native_theme_observer.h"
|
||||
|
||||
class Profile;
|
||||
class PrefsTabHelper;
|
||||
@ -21,7 +23,8 @@ class PrefsTabHelper;
|
||||
// Watches updates in WebKitPreferences and blink::RendererPreferences, and
|
||||
// notifies tab helpers and registered watchers of those updates.
|
||||
class PrefWatcher : public KeyedService,
|
||||
public privacy_sandbox::TrackingProtectionSettingsObserver {
|
||||
public privacy_sandbox::TrackingProtectionSettingsObserver,
|
||||
public ui::NativeThemeObserver {
|
||||
public:
|
||||
explicit PrefWatcher(Profile* profile);
|
||||
~PrefWatcher() override;
|
||||
@ -37,6 +40,9 @@ class PrefWatcher : public KeyedService,
|
||||
// KeyedService overrides:
|
||||
void Shutdown() override;
|
||||
|
||||
// ui::NativeThemeObserver:
|
||||
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
|
||||
|
||||
void OnDoNotTrackEnabledChanged() override;
|
||||
|
||||
void UpdateRendererPreferences();
|
||||
@ -62,6 +68,9 @@ class PrefWatcher : public KeyedService,
|
||||
// preference changes, use |tab_helpers_|.
|
||||
mojo::RemoteSet<blink::mojom::RendererPreferenceWatcher>
|
||||
renderer_preference_watchers_;
|
||||
|
||||
base::ScopedObservation<ui::NativeTheme, ui::NativeThemeObserver>
|
||||
native_theme_observation_{this};
|
||||
};
|
||||
|
||||
class PrefWatcherFactory : public ProfileKeyedServiceFactory {
|
||||
|
Reference in New Issue
Block a user