Commit 50245fb1 authored by Trent Apted's avatar Trent Apted Committed by Commit Bot

Restore the blue highlight for GTK on Omnibox results.

The way GTK theming is plumbed through is very subtle, and we don't
know yet how that should influence new color schemes.

This CL tries to isolate (and make explicit) the complexity required
for GTK theming on Desktop Linux by introducing OmniboxTint::NATIVE,
as distinct from LIGHT and DARK used everywhere else.

Bug: 819425, 801583
Change-Id: I34ad8113f5e66843dab685c3ce3470dd7bd7f675
Reviewed-on: https://chromium-review.googlesource.com/952503
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541570}
parent ba4d1c49
......@@ -14,6 +14,10 @@
#include "ui/native_theme/native_theme_dark_aura.h"
#endif
#if defined(USE_X11)
#include "ui/views/linux_ui/linux_ui.h"
#endif
namespace {
constexpr ui::NativeTheme::ColorId kInvalidColorId =
......@@ -53,11 +57,18 @@ ui::NativeTheme::ColorId GetLegacyColorId(OmniboxPart part,
}
SkColor GetLegacyColor(OmniboxPart part, OmniboxTint tint, OmniboxState state) {
ui::NativeTheme* native_theme = ui::NativeTheme::GetInstanceForNativeUi();
ui::NativeTheme* native_theme = nullptr;
#if defined(USE_AURA)
if (tint == OmniboxTint::DARK)
native_theme = ui::NativeThemeDarkAura::instance();
#endif
#if defined(USE_X11)
// Note: passing null to GetNativeTheme() always returns the native GTK theme.
if (tint == OmniboxTint::NATIVE && views::LinuxUI::instance())
native_theme = views::LinuxUI::instance()->GetNativeTheme(nullptr);
#endif
if (!native_theme)
native_theme = ui::NativeTheme::GetInstanceForNativeUi();
ui::NativeTheme::ColorId color_id = GetLegacyColorId(part, state);
return color_id == kInvalidColorId ? gfx::kPlaceholderColor
......@@ -72,6 +83,8 @@ SkColor GetOmniboxColor(OmniboxPart part,
if (!ui::MaterialDesignController::IsTouchOptimizedUiEnabled())
return GetLegacyColor(part, tint, state);
// Note this will use LIGHT for OmniboxTint::NATIVE.
// TODO(https://crbug.com/819452): Determine the role GTK should play in this.
const bool dark = tint == OmniboxTint::DARK;
switch (part) {
......
......@@ -12,8 +12,9 @@ enum class OmniboxPart {
RESULTS_BACKGROUND, // Background of the results dropdown.
};
// The tint of the omnibox theme. E.g. Incognito may use a DARK tint.
enum class OmniboxTint { DARK, LIGHT };
// The tint of the omnibox theme. E.g. Incognito may use a DARK tint. NATIVE is
// only used on Desktop Linux.
enum class OmniboxTint { DARK, LIGHT, NATIVE };
// An optional state for a given |OmniboxPart|.
enum class OmniboxState { NORMAL, HOVERED, SELECTED, HOVERED_AND_SELECTED };
......
......@@ -126,11 +126,18 @@ bool InTouchableMode() {
}
OmniboxTint GetTintForProfile(Profile* profile) {
if (ThemeServiceFactory::GetForProfile(profile)->UsingDefaultTheme()) {
ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile);
if (theme_service->UsingDefaultTheme()) {
return profile->GetProfileType() == Profile::INCOGNITO_PROFILE
? OmniboxTint::DARK
: OmniboxTint::LIGHT;
}
// Check for GTK on Desktop Linux.
if (theme_service->IsSystemThemeDistinctFromDefaultTheme() &&
theme_service->UsingSystemTheme())
return OmniboxTint::NATIVE;
// TODO(tapted): Infer a tint from theme colors?
return OmniboxTint::LIGHT;
}
......
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