Commit 36b2a7ba authored by minch's avatar minch Committed by Commit Bot

dark_mode: Remove restart while switching between dark and light mode.

- Remove restart the chrome while switching between dark and light mode.
- Preference will retain the value once it has been registered and set
  the value before. Go back to the |kDefaultDarkModeEnabled| if the flag
  is disabled.

Bug: 1146531, 1131543
Change-Id: Ie32da506f61fe78e31820456fe8ffc92d862ba8f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2530249Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825988}
parent 3baf2260
...@@ -64,12 +64,6 @@ constexpr SkColor kBackgroundColorDefaultDark = gfx::kGoogleGrey900; ...@@ -64,12 +64,6 @@ constexpr SkColor kBackgroundColorDefaultDark = gfx::kGoogleGrey900;
// The spacing between a pill button's icon and label, if it has both. // The spacing between a pill button's icon and label, if it has both.
constexpr int kPillButtonImageLabelSpacingDp = 8; constexpr int kPillButtonImageLabelSpacingDp = 8;
// TODO(minch): Let colors can be live updated on color mode/theme changes.
// Restart the chrome browser to let the color mode/theme changes take effect.
void AttemptRestartChrome() {
Shell::Get()->session_controller()->AttemptRestartChrome();
}
// AshColorProvider is kind of NativeTheme of ChromeOS. This will notify the // AshColorProvider is kind of NativeTheme of ChromeOS. This will notify the
// View::OnThemeChanged to live update the colors on color mode/theme changes. // View::OnThemeChanged to live update the colors on color mode/theme changes.
void NotifyThemeChanges() { void NotifyThemeChanges() {
...@@ -356,7 +350,7 @@ bool AshColorProvider::IsDarkModeEnabled() const { ...@@ -356,7 +350,7 @@ bool AshColorProvider::IsDarkModeEnabled() const {
if (!features::IsDarkLightModeEnabled() && override_light_mode_as_default_) if (!features::IsDarkLightModeEnabled() && override_light_mode_as_default_)
return false; return false;
if (!active_user_pref_service_) if (!active_user_pref_service_ || !features::IsDarkLightModeEnabled())
return kDefaultDarkModeEnabled; return kDefaultDarkModeEnabled;
return active_user_pref_service_->GetBoolean(prefs::kDarkModeEnabled); return active_user_pref_service_->GetBoolean(prefs::kDarkModeEnabled);
} }
...@@ -375,8 +369,6 @@ void AshColorProvider::ToggleColorMode() { ...@@ -375,8 +369,6 @@ void AshColorProvider::ToggleColorMode() {
ui::NativeTheme::GetInstanceForNativeUi()->set_use_dark_colors( ui::NativeTheme::GetInstanceForNativeUi()->set_use_dark_colors(
IsDarkModeEnabled()); IsDarkModeEnabled());
AttemptRestartChrome();
} }
void AshColorProvider::UpdateColorModeThemed(bool is_themed) { void AshColorProvider::UpdateColorModeThemed(bool is_themed) {
...@@ -386,8 +378,6 @@ void AshColorProvider::UpdateColorModeThemed(bool is_themed) { ...@@ -386,8 +378,6 @@ void AshColorProvider::UpdateColorModeThemed(bool is_themed) {
DCHECK(active_user_pref_service_); DCHECK(active_user_pref_service_);
active_user_pref_service_->SetBoolean(prefs::kColorModeThemed, is_themed); active_user_pref_service_->SetBoolean(prefs::kColorModeThemed, is_themed);
active_user_pref_service_->CommitPendingWrite(); active_user_pref_service_->CommitPendingWrite();
AttemptRestartChrome();
} }
SkColor AshColorProvider::GetBackgroundDefaultColor() const { SkColor AshColorProvider::GetBackgroundDefaultColor() const {
......
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