Commit d8aa2783 authored by minch's avatar minch Committed by Commit Bot

dark_mode: Restart after toggle color mode.

Restart the chrome to let the color mode changes take effect. This is
added to provide a method for UX to do color audit, which will be
helpful for us to correct the incorrect colors in each color mode.

Will do colors live update in the next step.

Bug: 1106012
Change-Id: I451efd94e648680a55bf6f1f77cc9d92209d67ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2392935Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805539}
parent 094f165f
...@@ -23,6 +23,9 @@ class ASH_PUBLIC_EXPORT SessionControllerClient { ...@@ -23,6 +23,9 @@ class ASH_PUBLIC_EXPORT SessionControllerClient {
// Requests signing out all users, ending the current session. // Requests signing out all users, ending the current session.
virtual void RequestSignOut() = 0; virtual void RequestSignOut() = 0;
// Attempts to restart the chrome browser.
virtual void AttemptRestartChrome() = 0;
// Switch to the active user with |account_id| (if the user has already signed // Switch to the active user with |account_id| (if the user has already signed
// in). // in).
virtual void SwitchActiveUser(const AccountId& account_id) = 0; virtual void SwitchActiveUser(const AccountId& account_id) = 0;
......
...@@ -217,6 +217,11 @@ void SessionControllerImpl::RequestSignOut() { ...@@ -217,6 +217,11 @@ void SessionControllerImpl::RequestSignOut() {
client_->RequestSignOut(); client_->RequestSignOut();
} }
void SessionControllerImpl::AttemptRestartChrome() {
if (client_)
client_->AttemptRestartChrome();
}
void SessionControllerImpl::SwitchActiveUser(const AccountId& account_id) { void SessionControllerImpl::SwitchActiveUser(const AccountId& account_id) {
if (client_) if (client_)
client_->SwitchActiveUser(account_id); client_->SwitchActiveUser(account_id);
......
...@@ -138,6 +138,9 @@ class ASH_EXPORT SessionControllerImpl : public SessionController { ...@@ -138,6 +138,9 @@ class ASH_EXPORT SessionControllerImpl : public SessionController {
// should use LockStateController::RequestSignOut() instead. // should use LockStateController::RequestSignOut() instead.
void RequestSignOut(); void RequestSignOut();
// Attempts to restart the chrome browser.
void AttemptRestartChrome();
// Switches to another active user with |account_id| (if that user has // Switches to another active user with |account_id| (if that user has
// already signed in). // already signed in).
void SwitchActiveUser(const AccountId& account_id); void SwitchActiveUser(const AccountId& account_id);
......
...@@ -217,6 +217,8 @@ void TestSessionControllerClient::RequestSignOut() { ...@@ -217,6 +217,8 @@ void TestSessionControllerClient::RequestSignOut() {
++request_sign_out_count_; ++request_sign_out_count_;
} }
void TestSessionControllerClient::AttemptRestartChrome() {}
void TestSessionControllerClient::SwitchActiveUser( void TestSessionControllerClient::SwitchActiveUser(
const AccountId& account_id) { const AccountId& account_id) {
controller_->CanSwitchActiveUser( controller_->CanSwitchActiveUser(
......
...@@ -110,6 +110,7 @@ class TestSessionControllerClient : public SessionControllerClient { ...@@ -110,6 +110,7 @@ class TestSessionControllerClient : public SessionControllerClient {
// ash::SessionControllerClient: // ash::SessionControllerClient:
void RequestLockScreen() override; void RequestLockScreen() override;
void RequestSignOut() override; void RequestSignOut() override;
void AttemptRestartChrome() override;
void SwitchActiveUser(const AccountId& account_id) override; void SwitchActiveUser(const AccountId& account_id) override;
void CycleActiveUser(CycleUserDirection direction) override; void CycleActiveUser(CycleUserDirection direction) override;
void ShowMultiProfileLogin() override; void ShowMultiProfileLogin() override;
......
...@@ -64,6 +64,12 @@ constexpr SkColor kBackgroundColorDefaultDark = gfx::kGoogleGrey900; ...@@ -64,6 +64,12 @@ 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();
}
} // namespace } // namespace
AshColorProvider::AshColorProvider() { AshColorProvider::AshColorProvider() {
...@@ -351,6 +357,8 @@ void AshColorProvider::ToggleColorMode() { ...@@ -351,6 +357,8 @@ void AshColorProvider::ToggleColorMode() {
active_user_pref_service_->SetBoolean(prefs::kDarkModeEnabled, active_user_pref_service_->SetBoolean(prefs::kDarkModeEnabled,
!IsDarkModeEnabled()); !IsDarkModeEnabled());
active_user_pref_service_->CommitPendingWrite(); active_user_pref_service_->CommitPendingWrite();
AttemptRestartChrome();
} }
void AshColorProvider::UpdateColorModeThemed(bool is_themed) { void AshColorProvider::UpdateColorModeThemed(bool is_themed) {
...@@ -360,6 +368,8 @@ void AshColorProvider::UpdateColorModeThemed(bool is_themed) { ...@@ -360,6 +368,8 @@ 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::GetLoginBackgroundBaseColor() const { SkColor AshColorProvider::GetLoginBackgroundBaseColor() const {
......
...@@ -246,6 +246,10 @@ void SessionControllerClientImpl::RequestSignOut() { ...@@ -246,6 +246,10 @@ void SessionControllerClientImpl::RequestSignOut() {
chrome::AttemptUserExit(); chrome::AttemptUserExit();
} }
void SessionControllerClientImpl::AttemptRestartChrome() {
chrome::AttemptRestart();
}
void SessionControllerClientImpl::SwitchActiveUser( void SessionControllerClientImpl::SwitchActiveUser(
const AccountId& account_id) { const AccountId& account_id) {
DoSwitchActiveUser(account_id); DoSwitchActiveUser(account_id);
......
...@@ -76,6 +76,7 @@ class SessionControllerClientImpl ...@@ -76,6 +76,7 @@ class SessionControllerClientImpl
// ash::SessionControllerClient: // ash::SessionControllerClient:
void RequestLockScreen() override; void RequestLockScreen() override;
void RequestSignOut() override; void RequestSignOut() override;
void AttemptRestartChrome() override;
void SwitchActiveUser(const AccountId& account_id) override; void SwitchActiveUser(const AccountId& account_id) override;
void CycleActiveUser(ash::CycleUserDirection direction) override; void CycleActiveUser(ash::CycleUserDirection direction) override;
void ShowMultiProfileLogin() override; void ShowMultiProfileLogin() override;
......
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