Index: chrome/browser/ui/views/location_bar/location_bar_view.cc |
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
index eaf2d4d1ce96ca2e1d3eb7614682c3531589a3d4..205c88fcfbc982fd3e65884f04b1929632360936 100644 |
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc |
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
@@ -78,6 +78,10 @@ |
#include "ui/views/controls/label.h" |
#include "ui/views/widget/widget.h" |
+#if defined(OS_WIN) |
+#include "ui/base/native_theme/native_theme_win.h" |
+#endif |
+ |
#if defined(OS_WIN) && !defined(USE_AURA) |
#include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" |
#endif |
@@ -88,6 +92,7 @@ |
#endif |
#if defined(USE_AURA) |
+#include "ui/base/native_theme/native_theme_aura.h" |
#include "ui/compositor/layer.h" |
#include "ui/compositor/scoped_layer_animation_settings.h" |
#endif |
@@ -240,6 +245,10 @@ LocationBarView::~LocationBarView() { |
} |
void LocationBarView::Init() { |
+ // We need to be in a Widget, otherwise GetNativeTheme() may change and we're |
+ // not prepared for that. |
+ DCHECK(GetWidget()); |
+ |
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
if (mode_ == POPUP) { |
font_ = rb.GetFont(ui::ResourceBundle::BaseFont); |
@@ -258,9 +267,12 @@ void LocationBarView::Init() { |
location_icon_view_->SetVisible(true); |
location_icon_view_->set_drag_controller(this); |
+ const ui::NativeTheme* theme = GetNativeTheme(); |
+ |
ev_bubble_view_ = |
new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, |
- GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), this); |
+ GetColor(theme, ToolbarModel::EV_SECURE, SECURITY_TEXT), |
+ this); |
AddChildView(ev_bubble_view_); |
ev_bubble_view_->SetVisible(false); |
ev_bubble_view_->set_drag_controller(this); |
@@ -276,7 +288,7 @@ void LocationBarView::Init() { |
selected_keyword_view_ = new SelectedKeywordView( |
kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, |
- GetColor(ToolbarModel::NONE, TEXT), |
+ GetColor(theme, ToolbarModel::NONE, TEXT), |
profile_); |
AddChildView(selected_keyword_view_); |
selected_keyword_view_->SetFont(font_); |
@@ -292,7 +304,7 @@ void LocationBarView::Init() { |
new ContentSettingImageView(static_cast<ContentSettingsType>(i), |
kCSBubbleBackgroundImages, this, |
font_, |
- GetColor(ToolbarModel::NONE, TEXT)); |
+ GetColor(theme, ToolbarModel::NONE, TEXT)); |
content_setting_views_.push_back(content_blocked_view); |
AddChildView(content_blocked_view); |
content_blocked_view->SetVisible(false); |
@@ -304,7 +316,7 @@ void LocationBarView::Init() { |
web_intents_button_view_ = |
new WebIntentsButtonView(this, kWIBubbleBackgroundImages, font_, |
- GetColor(ToolbarModel::NONE, TEXT)); |
+ GetColor(theme, ToolbarModel::NONE, TEXT)); |
AddChildView(web_intents_button_view_); |
open_pdf_in_reader_view_ = new OpenPDFInReaderView(this); |
@@ -343,24 +355,34 @@ bool LocationBarView::IsInitialized() const { |
} |
// static |
-SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level, |
+SkColor LocationBarView::GetColor(const ui::NativeTheme* theme, |
+ ToolbarModel::SecurityLevel security_level, |
ColorKind kind) { |
- switch (kind) { |
#if defined(OS_WIN) |
- case BACKGROUND: return color_utils::GetSysSkColor(COLOR_WINDOW); |
- case TEXT: return color_utils::GetSysSkColor(COLOR_WINDOWTEXT); |
- case SELECTED_TEXT: return color_utils::GetSysSkColor(COLOR_HIGHLIGHTTEXT); |
-#else |
+ if (theme == ui::NativeThemeWin::instance()) { |
+ switch (kind) { |
+ case BACKGROUND: |
+ return color_utils::GetSysSkColor(COLOR_WINDOW); |
+ case TEXT: |
+ return color_utils::GetSysSkColor(COLOR_WINDOWTEXT); |
+ case SELECTED_TEXT: |
+ return color_utils::GetSysSkColor(COLOR_HIGHLIGHTTEXT); |
+ default: |
+ // Other cases are handled below. |
+ break; |
+ } |
+ } |
+#endif |
+ switch (kind) { |
// TODO(beng): source from theme provider. |
case BACKGROUND: return kOmniboxBackgroundColor; |
case TEXT: return SK_ColorBLACK; |
case SELECTED_TEXT: return SK_ColorWHITE; |
-#endif |
case DEEMPHASIZED_TEXT: |
return color_utils::AlphaBlend( |
- GetColor(security_level, TEXT), |
- GetColor(security_level, BACKGROUND), |
+ GetColor(theme, security_level, TEXT), |
+ GetColor(theme, security_level, BACKGROUND), |
128); |
case SECURITY_TEXT: { |
@@ -372,7 +394,7 @@ SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level, |
break; |
case ToolbarModel::SECURITY_WARNING: |
- return GetColor(security_level, DEEMPHASIZED_TEXT); |
+ return GetColor(theme, security_level, DEEMPHASIZED_TEXT); |
break; |
case ToolbarModel::SECURITY_ERROR: |
@@ -381,15 +403,16 @@ SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level, |
default: |
NOTREACHED(); |
- return GetColor(security_level, TEXT); |
+ return GetColor(theme, security_level, TEXT); |
} |
- return color_utils::GetReadableColor(color, GetColor(security_level, |
+ return color_utils::GetReadableColor(color, GetColor(theme, |
Peter Kasting
2012/11/08 18:55:47
Nit: Or
return color_utils::GetReadableColo
|
+ security_level, |
BACKGROUND)); |
} |
default: |
NOTREACHED(); |
- return GetColor(security_level, TEXT); |
+ return GetColor(theme, security_level, TEXT); |
} |
} |
@@ -613,7 +636,8 @@ void LocationBarView::SetInstantSuggestion(const string16& text) { |
suggested_text_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
suggested_text_view_->SetAutoColorReadabilityEnabled(false); |
suggested_text_view_->SetEnabledColor(LocationBarView::GetColor( |
- ToolbarModel::NONE, LocationBarView::DEEMPHASIZED_TEXT)); |
+ GetNativeTheme(), ToolbarModel::NONE, |
+ LocationBarView::DEEMPHASIZED_TEXT)); |
suggested_text_view_->SetText(text); |
suggested_text_view_->SetFont(location_entry_->GetFont()); |
AddChildView(suggested_text_view_); |
@@ -970,7 +994,7 @@ void LocationBarView::OnPaint(gfx::Canvas* canvas) { |
// OmniboxPopupContentsView::OnPaint()). |
gfx::Rect bounds(GetContentsBounds()); |
bounds.Inset(0, kVerticalEdgeThickness); |
- SkColor color(GetColor(ToolbarModel::NONE, BACKGROUND)); |
+ SkColor color(GetColor(GetNativeTheme(), ToolbarModel::NONE, BACKGROUND)); |
if (mode_ == NORMAL) { |
SkPaint paint; |
paint.setStyle(SkPaint::kFill_Style); |
@@ -1272,8 +1296,9 @@ void LocationBarView::PaintPageActionBackgrounds(gfx::Canvas* canvas) { |
const int32 tab_id = SessionID::IdForTab(tab_contents->web_contents()); |
const ToolbarModel::SecurityLevel security_level = model_->GetSecurityLevel(); |
- const SkColor text_color = GetColor(security_level, TEXT); |
- const SkColor background_color = GetColor(security_level, BACKGROUND); |
+ const ui::NativeTheme* theme = GetNativeTheme(); |
+ const SkColor text_color = GetColor(theme, security_level, TEXT); |
+ const SkColor background_color = GetColor(theme, security_level, BACKGROUND); |
for (PageActionViews::const_iterator |
page_action_view = page_action_views_.begin(); |