Fix syncing of system theme on Linux

Makes the "IsSystemThemeDistinctFromDefaultTheme()" detection logic
compatible with non-GTK (ie. Aura) Linux.  It moves the check out of
sync code and into the ThemeService so this kind of bug will be less
likely to recur if the themes logic changes again.

Re-enables an integration test that was disabled during the transition
to Aura.

BUG=304554,392934

Review URL: https://codereview.chromium.org/388563004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282491 0039d316-1c4b-4281-b951-d872f2087c98
parent e6a911dc
...@@ -68,8 +68,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomTheme) { ...@@ -68,8 +68,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomTheme) {
// TCM ID - 3599303. // TCM ID - 3599303.
// TODO(sync): Fails on Chrome OS. See http://crbug.com/84575. // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575.
// TODO(erg): Fails on linux_aura. See http://crbug.com/304554 #if defined(OS_CHROMEOS)
#if defined(OS_CHROMEOS) || defined(OS_LINUX)
IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DISABLED_NativeTheme) { IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DISABLED_NativeTheme) {
#else #else
IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, NativeTheme) { IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, NativeTheme) {
......
...@@ -119,6 +119,10 @@ gfx::Image ThemeService::GetImageNamed(int id) const { ...@@ -119,6 +119,10 @@ gfx::Image ThemeService::GetImageNamed(int id) const {
return image; return image;
} }
bool ThemeService::IsSystemThemeDistinctFromDefaultTheme() const {
return false;
}
bool ThemeService::UsingSystemTheme() const { bool ThemeService::UsingSystemTheme() const {
return UsingDefaultTheme(); return UsingDefaultTheme();
} }
......
...@@ -110,6 +110,10 @@ class ThemeService : public base::NonThreadSafe, ...@@ -110,6 +110,10 @@ class ThemeService : public base::NonThreadSafe,
// theme is the default theme. // theme is the default theme.
virtual void UseSystemTheme(); virtual void UseSystemTheme();
// Returns true if the default theme and system theme are not the same on
// this platform.
virtual bool IsSystemThemeDistinctFromDefaultTheme() const;
// Whether we're using the chrome default theme. Virtual so linux can check // Whether we're using the chrome default theme. Virtual so linux can check
// if we're using the GTK theme. // if we're using the GTK theme.
virtual bool UsingDefaultTheme() const; virtual bool UsingDefaultTheme() const;
......
...@@ -82,6 +82,10 @@ void ThemeServiceAuraX11::UseSystemTheme() { ...@@ -82,6 +82,10 @@ void ThemeServiceAuraX11::UseSystemTheme() {
SetCustomDefaultTheme(new SystemThemeX11(profile()->GetPrefs())); SetCustomDefaultTheme(new SystemThemeX11(profile()->GetPrefs()));
} }
bool ThemeServiceAuraX11::IsSystemThemeDistinctFromDefaultTheme() const {
return true;
}
bool ThemeServiceAuraX11::UsingDefaultTheme() const { bool ThemeServiceAuraX11::UsingDefaultTheme() const {
return ThemeService::UsingDefaultTheme() && !UsingSystemTheme(); return ThemeService::UsingDefaultTheme() && !UsingSystemTheme();
} }
......
...@@ -17,6 +17,7 @@ class ThemeServiceAuraX11 : public ThemeService { ...@@ -17,6 +17,7 @@ class ThemeServiceAuraX11 : public ThemeService {
// Overridden from ThemeService: // Overridden from ThemeService:
virtual bool ShouldInitWithSystemTheme() const OVERRIDE; virtual bool ShouldInitWithSystemTheme() const OVERRIDE;
virtual void UseSystemTheme() OVERRIDE; virtual void UseSystemTheme() OVERRIDE;
virtual bool IsSystemThemeDistinctFromDefaultTheme() const OVERRIDE;
virtual bool UsingDefaultTheme() const OVERRIDE; virtual bool UsingDefaultTheme() const OVERRIDE;
virtual bool UsingSystemTheme() const OVERRIDE; virtual bool UsingSystemTheme() const OVERRIDE;
......
...@@ -24,15 +24,6 @@ bool IsTheme(const extensions::Extension* extension) { ...@@ -24,15 +24,6 @@ bool IsTheme(const extensions::Extension* extension) {
return extension->is_theme(); return extension->is_theme();
} }
// TODO(akalin): Remove this.
bool IsSystemThemeDistinctFromDefaultTheme() {
#if defined(TOOLKIT_GTK)
return true;
#else
return false;
#endif
}
} // namespace } // namespace
const char ThemeSyncableService::kCurrentThemeClientTag[] = "current_theme"; const char ThemeSyncableService::kCurrentThemeClientTag[] = "current_theme";
...@@ -193,8 +184,10 @@ void ThemeSyncableService::MaybeSetTheme( ...@@ -193,8 +184,10 @@ void ThemeSyncableService::MaybeSetTheme(
const sync_pb::ThemeSpecifics& sync_theme = sync_data.GetSpecifics().theme(); const sync_pb::ThemeSpecifics& sync_theme = sync_data.GetSpecifics().theme();
use_system_theme_by_default_ = sync_theme.use_system_theme_by_default(); use_system_theme_by_default_ = sync_theme.use_system_theme_by_default();
DVLOG(1) << "Set current theme from specifics: " << sync_data.ToString(); DVLOG(1) << "Set current theme from specifics: " << sync_data.ToString();
if (!AreThemeSpecificsEqual(current_specs, sync_theme, if (!AreThemeSpecificsEqual(
IsSystemThemeDistinctFromDefaultTheme())) { current_specs,
sync_theme,
theme_service_->IsSystemThemeDistinctFromDefaultTheme())) {
SetCurrentThemeFromThemeSpecifics(sync_theme); SetCurrentThemeFromThemeSpecifics(sync_theme);
} else { } else {
DVLOG(1) << "Skip setting theme because specs are equal"; DVLOG(1) << "Skip setting theme because specs are equal";
...@@ -266,7 +259,7 @@ bool ThemeSyncableService::GetThemeSpecificsFromCurrentTheme( ...@@ -266,7 +259,7 @@ bool ThemeSyncableService::GetThemeSpecificsFromCurrentTheme(
} }
bool use_custom_theme = (current_theme != NULL); bool use_custom_theme = (current_theme != NULL);
theme_specifics->set_use_custom_theme(use_custom_theme); theme_specifics->set_use_custom_theme(use_custom_theme);
if (IsSystemThemeDistinctFromDefaultTheme()) { if (theme_service_->IsSystemThemeDistinctFromDefaultTheme()) {
// On platform where system theme is different from default theme, set // On platform where system theme is different from default theme, set
// use_system_theme_by_default to true if system theme is used, false // use_system_theme_by_default to true if system theme is used, false
// if default system theme is used. Otherwise restore it to value in sync. // if default system theme is used. Otherwise restore it to value in sync.
......
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