diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc | 17 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_win.cc | 46 | ||||
-rw-r--r-- | chrome/browser/toolbar_model.cc | 12 | ||||
-rw-r--r-- | chrome/browser/toolbar_model.h | 7 | ||||
-rw-r--r-- | chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc | 141 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.cc | 129 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.h | 16 |
7 files changed, 216 insertions, 152 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc index cbeb156..fa1ba27 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc @@ -20,7 +20,6 @@ #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h" #include "chrome/browser/command_updater.h" #include "chrome/browser/defaults.h" -#include "chrome/browser/gtk/location_bar_view_gtk.h" #include "chrome/browser/gtk/view_id_util.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/toolbar_model.h" @@ -29,8 +28,12 @@ #include "googleurl/src/gurl.h" #include "grit/generated_resources.h" -#if !defined(TOOLKIT_VIEWS) +#if defined(TOOLKIT_VIEWS) +#include "chrome/browser/views/location_bar_view.h" +#include "skia/ext/skia_utils_gtk.h" +#else #include "chrome/browser/gtk/gtk_theme_provider.h" +#include "chrome/browser/gtk/location_bar_view_gtk.h" #endif namespace { @@ -509,7 +512,8 @@ void AutocompleteEditViewGtk::SetBaseColor() { // If we're on a secure connection, ignore what the theme wants us to do // and use a yellow background. - if (use_gtk && scheme_security_level_ != ToolbarModel::SECURE) { + bool is_secure = (scheme_security_level_ == ToolbarModel::SECURE); + if (use_gtk && !is_secure) { gtk_widget_modify_base(text_view_, GTK_STATE_NORMAL, NULL); // Grab the text colors out of the style and set our tags to use them. @@ -525,8 +529,15 @@ void AutocompleteEditViewGtk::SetBaseColor() { g_object_set(G_OBJECT(normal_text_tag_), "foreground-gdk", &style->text[GTK_STATE_NORMAL], NULL); } else { +#if defined(TOOLKIT_VIEWS) + const GdkColor background_color = skia::SkColorToGdkColor( + LocationBarView::GetColor(is_secure, LocationBarView::BACKGROUND)); + gtk_widget_modify_base(text_view_, GTK_STATE_NORMAL, + &background_color); +#else gtk_widget_modify_base(text_view_, GTK_STATE_NORMAL, &LocationBarViewGtk::kBackgroundColorByLevel[scheme_security_level_]); +#endif g_object_set(G_OBJECT(faded_text_tag_), "foreground", kTextBaseColor, NULL); g_object_set(G_OBJECT(normal_text_tag_), "foreground", "#000000", NULL); diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc index 1e0b3b6..329e4dd 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc @@ -313,20 +313,8 @@ AutocompleteEditViewWin::ScopedSuspendUndo::~ScopedSuspendUndo() { /////////////////////////////////////////////////////////////////////////////// // AutocompleteEditViewWin -// TODO (jcampan): these colors should be derived from the system colors to -// ensure they show properly. Bug #948807. -// Colors used to emphasize the scheme in the URL. - namespace { -const COLORREF kSecureSchemeColor = RGB(0, 150, 20); -const COLORREF kInsecureSchemeColor = RGB(200, 0, 0); - -// Colors used to strike-out the scheme when it is insecure. -const SkColor kSchemeStrikeoutColor = SkColorSetRGB(210, 0, 0); -const SkColor kSchemeSelectedStrikeoutColor = - SkColorSetRGB(255, 255, 255); - // These are used to hook the CRichEditCtrl's calls to BeginPaint() and // EndPaint() and provide a memory DC instead. See OnPaint(). HWND edit_hwnd = NULL; @@ -465,12 +453,10 @@ AutocompleteEditViewWin::AutocompleteEditViewWin( const long kTwipsPerPixel = kTwipsPerInch / GetDeviceCaps(dc, LOGPIXELSY); ::ReleaseDC(NULL, dc); - // Set the default character style -- adjust to our desired baseline and make - // text grey. + // Set the default character style -- adjust to our desired baseline. CHARFORMAT cf = {0}; - cf.dwMask = CFM_OFFSET | CFM_COLOR; + cf.dwMask = CFM_OFFSET; cf.yOffset = -font_y_adjustment_ * kTwipsPerPixel; - cf.crTextColor = GetSysColor(COLOR_GRAYTEXT); SetDefaultCharFormat(cf); // By default RichEdit has a drop target. Revoke it so that we can install our @@ -518,8 +504,9 @@ void AutocompleteEditViewWin::Update( const ToolbarModel::SecurityLevel security_level = toolbar_model_->GetSchemeSecurityLevel(); - const COLORREF background_color = skia::SkColorToCOLORREF( - LocationBarView::kBackgroundColorByLevel[security_level]); + const COLORREF background_color = + skia::SkColorToCOLORREF(LocationBarView::GetColor( + security_level == ToolbarModel::SECURE, LocationBarView::BACKGROUND)); const bool changed_security_level = (security_level != scheme_security_level_); @@ -2016,13 +2003,19 @@ void AutocompleteEditViewWin::EmphasizeURLComponents() { CHARFORMAT cf = {0}; cf.dwMask = CFM_COLOR; cf.dwEffects = 0; - cf.crTextColor = GetSysColor(emphasize ? COLOR_GRAYTEXT : COLOR_WINDOWTEXT); + const bool is_secure = (scheme_security_level_ == ToolbarModel::SECURE); + // If we're going to emphasize parts of the text, then the baseline state + // should be "de-emphasized". If not, then everything should be rendered in + // the standard text color. + cf.crTextColor = skia::SkColorToCOLORREF(LocationBarView::GetColor(is_secure, + emphasize ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT)); SelectAll(false); SetSelectionCharFormat(cf); if (emphasize) { // We've found a host name, give it more emphasis. - cf.crTextColor = GetSysColor(COLOR_WINDOWTEXT); + cf.crTextColor = skia::SkColorToCOLORREF(LocationBarView::GetColor( + is_secure, LocationBarView::TEXT)); SetSelection(host.begin, host.end()); SetSelectionCharFormat(cf); } @@ -2031,13 +2024,12 @@ void AutocompleteEditViewWin::EmphasizeURLComponents() { insecure_scheme_component_.reset(); if (!model_->user_input_in_progress() && scheme.is_nonempty() && (scheme_security_level_ != ToolbarModel::NORMAL)) { - if (scheme_security_level_ == ToolbarModel::SECURE) { - cf.crTextColor = kSecureSchemeColor; - } else { + if (!is_secure) { insecure_scheme_component_.begin = scheme.begin; insecure_scheme_component_.len = scheme.len; - cf.crTextColor = kInsecureSchemeColor; } + cf.crTextColor = skia::SkColorToCOLORREF(LocationBarView::GetColor( + is_secure, LocationBarView::SECURITY_TEXT)); SetSelection(scheme.begin, scheme.end()); SetSelectionCharFormat(cf); } @@ -2134,7 +2126,8 @@ void AutocompleteEditViewWin::DrawSlashForInsecureScheme( canvas.save(); if (selection_rect.isEmpty() || canvas.clipRect(selection_rect, SkRegion::kDifference_Op)) { - paint.setColor(kSchemeStrikeoutColor); + paint.setColor(LocationBarView::GetColor(false, + LocationBarView::SCHEME_STRIKEOUT)); canvas.drawLine(start_point.fX, start_point.fY, end_point.fX, end_point.fY, paint); } @@ -2142,7 +2135,8 @@ void AutocompleteEditViewWin::DrawSlashForInsecureScheme( // Draw the selected portion of the stroke. if (!selection_rect.isEmpty() && canvas.clipRect(selection_rect)) { - paint.setColor(kSchemeSelectedStrikeoutColor); + paint.setColor(LocationBarView::GetColor(false, + LocationBarView::SELECTED_TEXT)); canvas.drawLine(start_point.fX, start_point.fY, end_point.fX, end_point.fY, paint); } diff --git a/chrome/browser/toolbar_model.cc b/chrome/browser/toolbar_model.cc index 9d6715f..ec7ee2e 100644 --- a/chrome/browser/toolbar_model.cc +++ b/chrome/browser/toolbar_model.cc @@ -106,13 +106,8 @@ ToolbarModel::Icon ToolbarModel::GetIcon() { } } -void ToolbarModel::GetIconHoverText(std::wstring* text, SkColor* text_color) { - static const SkColor kOKHttpsInfoBubbleTextColor = - SkColorSetRGB(0, 153, 51); // Green. - static const SkColor kBrokenHttpsInfoBubbleTextColor = - SkColorSetRGB(255, 0, 0); // Red. - - DCHECK(text && text_color); +void ToolbarModel::GetIconHoverText(std::wstring* text) { + DCHECK(text); NavigationController* navigation_controller = GetNavigationController(); // We don't expect to be called during initialization, so the controller @@ -130,12 +125,10 @@ void ToolbarModel::GetIconHoverText(std::wstring* text, SkColor* text_color) { SSLErrorInfo::CreateError(SSLErrorInfo::MIXED_CONTENTS, NULL, GURL::EmptyGURL()); text->assign(error_info.short_description()); - *text_color = kBrokenHttpsInfoBubbleTextColor; } else { DCHECK(entry->url().has_host()); text->assign(l10n_util::GetStringF(IDS_SECURE_CONNECTION, UTF8ToWide(entry->url().host()))); - *text_color = kOKHttpsInfoBubbleTextColor; } break; } @@ -147,7 +140,6 @@ void ToolbarModel::GetIconHoverText(std::wstring* text, SkColor* text_color) { NOTREACHED(); return; } - *text_color = kBrokenHttpsInfoBubbleTextColor; break; } default: diff --git a/chrome/browser/toolbar_model.h b/chrome/browser/toolbar_model.h index 357f7d2..dbcea27 100644 --- a/chrome/browser/toolbar_model.h +++ b/chrome/browser/toolbar_model.h @@ -8,7 +8,6 @@ #include <string> #include "base/basictypes.h" -#include "third_party/skia/include/core/SkColor.h" class NavigationController; class NavigationEntry; @@ -57,10 +56,10 @@ class ToolbarModel { // Default value: NO_ICON. virtual Icon GetIcon(); - // Sets the text and color of the text displayed in the info bubble that - // appears when the user hovers the mouse over the icon. + // Sets the text displayed in the info bubble that appears when the user + // hovers the mouse over the icon. // Default value: empty string. - virtual void GetIconHoverText(std::wstring* text, SkColor* text_color); + virtual void GetIconHoverText(std::wstring* text); // Sets |text| to contain the text that should be displayed on the right of // the location bar, and |tooltip| to the tooltip text that should be shown diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc index e51993d..34e8831 100644 --- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc +++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc @@ -28,55 +28,79 @@ #include "app/win_util.h" #endif -// Colors for various components of the view. +namespace { + +enum ResultViewState { + NORMAL = 0, + SELECTED, + HOVERED, + NUM_STATES +}; + +enum ColorKind { + BACKGROUND = 0, + TEXT, + DIMMED_TEXT, + URL, + NUM_KINDS +}; + +SkColor GetColor(ResultViewState state, ColorKind kind) { + static bool initialized = false; + static SkColor colors[NUM_STATES][NUM_KINDS]; + if (!initialized) { #if defined(OS_WIN) -static const SkColor kBackgroundColor = - color_utils::GetSysSkColor(COLOR_WINDOW); -static const SkColor kSelectedBackgroundColor = - color_utils::GetSysSkColor(COLOR_HIGHLIGHT); -static const SkColor kHoverBackgroundColor = - SkColorSetA(kSelectedBackgroundColor, 127); -static const SkColor kTextColor = - color_utils::GetSysSkColor(COLOR_WINDOWTEXT); -static const SkColor kSelectedTextColor = - color_utils::GetSysSkColor(COLOR_HIGHLIGHTTEXT); -static const SkColor kDimTextColor = - color_utils::GetSysSkColor(COLOR_GRAYTEXT); -static const SkColor kSelectedDimTextColor = - color_utils::GetSysSkColor(COLOR_HIGHLIGHTTEXT); + colors[NORMAL][BACKGROUND] = color_utils::GetSysSkColor(COLOR_WINDOW); + colors[SELECTED][BACKGROUND] = color_utils::GetSysSkColor(COLOR_HIGHLIGHT); + colors[NORMAL][TEXT] = color_utils::GetSysSkColor(COLOR_WINDOWTEXT); + colors[SELECTED][TEXT] = color_utils::GetSysSkColor(COLOR_HIGHLIGHTTEXT); #else -// TODO(beng): source from theme provider. -static const SkColor kBackgroundColor = SK_ColorWHITE; -static const SkColor kSelectedBackgroundColor = SK_ColorBLUE; -static const SkColor kHoverBackgroundColor = SK_ColorCYAN; -static const SkColor kTextColor = SK_ColorBLACK; -static const SkColor kSelectedTextColor = SK_ColorWHITE; -static const SkColor kDimTextColor = SK_ColorGRAY; -static const SkColor kSelectedDimTextColor = SK_ColorWHITE; + // TODO(beng): source from theme provider. + colors[NORMAL][BACKGROUND] = SK_ColorWHITE; + colors[SELECTED][BACKGROUND] = SK_ColorBLUE; + colors[NORMAL][TEXT] = SK_ColorBLACK; + colors[SELECTED][TEXT] = SK_ColorWHITE; #endif -static const SkColor kStandardURLColor = SkColorSetRGB(0, 0x80, 0); -static const SkColor kHighlightURLColor = SkColorSetRGB(0xD0, 0xFF, 0xD0); -static const int kGlassPopupTransparency = 240; -static const int kOpaquePopupTransparency = 255; -static const int kHoverRowAlpha = 0x40; + colors[HOVERED][BACKGROUND] = + color_utils::AlphaBlend(colors[SELECTED][BACKGROUND], + colors[NORMAL][BACKGROUND], 64); + colors[HOVERED][TEXT] = colors[NORMAL][TEXT]; + const SkColor kDarkURL = SkColorSetRGB(0, 128, 0); + const SkColor kLightURL = SkColorSetRGB(128, 255, 128); + for (int i = 0; i < NUM_STATES; ++i) { + colors[i][DIMMED_TEXT] = + color_utils::AlphaBlend(colors[i][TEXT], colors[i][BACKGROUND], 128); + colors[i][URL] = color_utils::PickMoreReadableColor(kDarkURL, kLightURL, + colors[i][BACKGROUND]); + } + initialized = true; + } + + return colors[state][kind]; +} + +const SkAlpha kGlassPopupAlpha = 240; +const SkAlpha kOpaquePopupAlpha = 255; // The minimum distance between the top and bottom of the icon and the top or // bottom of the row. "Minimum" is used because the vertical padding may be // larger, depending on the size of the text. -static const int kIconVerticalPadding = 2; +const int kIconVerticalPadding = 2; // The minimum distance between the top and bottom of the text and the top or // bottom of the row. See comment about the use of "minimum" for // kIconVerticalPadding. -static const int kTextVerticalPadding = 3; +const int kTextVerticalPadding = 3; // The padding at the left edge of the row, left of the icon. -static const int kRowLeftPadding = 6; +const int kRowLeftPadding = 6; // The padding on the right edge of the row, right of the text. -static const int kRowRightPadding = 3; +const int kRowRightPadding = 3; // The horizontal distance between the right edge of the icon and the left edge // of the text. -static const int kIconTextSpacing = 9; +const int kIconTextSpacing = 9; // The size delta between the font used for the edit and the result rows. Passed // to gfx::Font::DeriveFont. -static const int kEditFontAdjust = -1; +const int kEditFontAdjust = -1; + +} class AutocompleteResultView : public views::View { public: @@ -102,9 +126,7 @@ class AutocompleteResultView : public views::View { virtual bool OnMouseDragged(const views::MouseEvent& event); private: - // Get colors for row backgrounds and text for different row states. - SkColor GetBackgroundColor() const; - SkColor GetTextColor() const; + ResultViewState GetState() const; SkBitmap* GetIcon() const; @@ -305,7 +327,9 @@ AutocompleteResultView::~AutocompleteResultView() { } void AutocompleteResultView::Paint(gfx::Canvas* canvas) { - canvas->FillRectInt(GetBackgroundColor(), 0, 0, width(), height()); + const ResultViewState state = GetState(); + if (state != NORMAL) + canvas->drawColor(GetColor(state, BACKGROUND)); int x = MirroredLeftPointForRect(icon_bounds_); @@ -394,16 +418,10 @@ bool AutocompleteResultView::OnMouseDragged(const views::MouseEvent& event) { return false; } -SkColor AutocompleteResultView::GetBackgroundColor() const { +ResultViewState AutocompleteResultView::GetState() const { if (model_->IsSelectedIndex(model_index_)) - return kSelectedBackgroundColor; - return model_->IsHoveredIndex(model_index_) ? - kHoverBackgroundColor : kBackgroundColor; -} - -SkColor AutocompleteResultView::GetTextColor() const { - return model_->IsSelectedIndex(model_index_) ? kSelectedTextColor - : kTextColor; + return SELECTED; + return model_->IsHoveredIndex(model_index_) ? HOVERED : NORMAL; } SkBitmap* AutocompleteResultView::GetIcon() const { @@ -529,16 +547,11 @@ gfx::Font AutocompleteResultView::GetFragmentFont(int style) const { } SkColor AutocompleteResultView::GetFragmentTextColor(int style) const { - bool selected = model_->IsSelectedIndex(model_index_); - if (style & ACMatchClassification::URL) { - // TODO(beng): bring over the contrast logic from the old popup and massage - // these values. See autocomplete_popup_view_win.cc and - // LuminosityContrast etc. - return selected ? kHighlightURLColor : kStandardURLColor; - } - if (style & ACMatchClassification::DIM) - return selected ? kSelectedDimTextColor : kDimTextColor; - return GetTextColor(); + const ResultViewState state = GetState(); + if (style & ACMatchClassification::URL) + return GetColor(state, URL); + return GetColor(state, + (style & ACMatchClassification::DIM) ? DIMMED_TEXT : TEXT); } void AutocompleteResultView::InitClass() { @@ -838,7 +851,7 @@ void AutocompletePopupContentsView::PaintChildren(gfx::Canvas* canvas) { // shader to fill a path representing the round-rect clipping region. This // yields a nice anti-aliased edge. gfx::Canvas contents_canvas(width(), height(), true); - contents_canvas.FillRectInt(kBackgroundColor, 0, 0, width(), height()); + contents_canvas.drawColor(GetColor(NORMAL, BACKGROUND)); View::PaintChildren(&contents_canvas); // We want the contents background to be slightly transparent so we can see // the blurry glass effect on DWM systems behind. We do this _after_ we paint @@ -937,14 +950,10 @@ void AutocompletePopupContentsView::UpdateBlurRegion() { void AutocompletePopupContentsView::MakeCanvasTransparent( gfx::Canvas* canvas) { // Allow the window blur effect to show through the popup background. - SkPaint paint; - SkColor transparency = GetThemeProvider()->ShouldUseNativeFrame() ? - kGlassPopupTransparency : kOpaquePopupTransparency; - paint.setColor(SkColorSetARGB(transparency, 255, 255, 255)); - paint.setXfermodeMode(SkXfermode::kDstIn_Mode); - paint.setStyle(SkPaint::kFill_Style); - canvas->FillRectInt(0, 0, canvas->getDevice()->width(), - canvas->getDevice()->height(), paint); + SkAlpha alpha = GetThemeProvider()->ShouldUseNativeFrame() ? + kGlassPopupAlpha : kOpaquePopupAlpha; + canvas->drawColor(SkColorSetA(GetColor(NORMAL, BACKGROUND), alpha), + SkXfermode::kDstIn_Mode); } // static diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index 5dbcad8..a41b040 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -11,6 +11,7 @@ #include "build/build_config.h" #include "app/gfx/canvas.h" +#include "app/gfx/color_utils.h" #include "app/gfx/favicon_size.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" @@ -47,28 +48,12 @@ #if defined(OS_WIN) #include "app/win_util.h" #include "chrome/browser/views/first_run_bubble.h" -#else -#include "base/gfx/gtk_util.h" -#include "chrome/browser/gtk/location_bar_view_gtk.h" #endif using views::View; -const int LocationBarView::kVertMargin = 2; - -const SkColor LocationBarView::kBackgroundColorByLevel[] = { - SkColorSetRGB(255, 245, 195), // SecurityLevel SECURE: Yellow. - SkColorSetRGB(255, 255, 255), // SecurityLevel NORMAL: White. - SkColorSetRGB(255, 255, 255), // SecurityLevel INSECURE: White. -}; -#if defined(OS_LINUX) // static -const GdkColor LocationBarViewGtk::kBackgroundColorByLevel[3] = { - GDK_COLOR_RGB(255, 245, 195), // SecurityLevel SECURE: Yellow. - GDK_COLOR_RGB(255, 255, 255), // SecurityLevel NORMAL: White. - GDK_COLOR_RGB(255, 255, 255), // SecurityLevel INSECURE: White. -}; -#endif +const int LocationBarView::kVertMargin = 2; // Padding on the right and left of the entry field. static const int kEntryPadding = 3; @@ -140,10 +125,6 @@ LocationBarView::~LocationBarView() { DeletePageActionViews(); } -bool LocationBarView::IsInitialized() const { - return location_entry_view_ != NULL; -} - void LocationBarView::Init() { if (popup_window_mode_) { font_ = ResourceBundle::GetSharedInstance().GetFont( @@ -192,25 +173,18 @@ void LocationBarView::Init() { selected_keyword_view_.SetVisible(false); selected_keyword_view_.SetParentOwned(false); -#if defined(OS_WIN) - DWORD sys_color = GetSysColor(COLOR_GRAYTEXT); - SkColor gray = SkColorSetRGB(GetRValue(sys_color), GetGValue(sys_color), - GetBValue(sys_color)); -#else - NOTIMPLEMENTED(); - SkColor gray = SK_ColorGRAY; -#endif + SkColor dimmed_text = GetColor(false, DEEMPHASIZED_TEXT); AddChildView(&type_to_search_view_); type_to_search_view_.SetVisible(false); type_to_search_view_.SetFont(font_); - type_to_search_view_.SetColor(gray); + type_to_search_view_.SetColor(dimmed_text); type_to_search_view_.SetParentOwned(false); AddChildView(&keyword_hint_view_); keyword_hint_view_.SetVisible(false); keyword_hint_view_.SetFont(font_); - keyword_hint_view_.SetColor(gray); + keyword_hint_view_.SetColor(dimmed_text); keyword_hint_view_.SetParentOwned(false); AddChildView(&security_image_view_); @@ -232,6 +206,74 @@ void LocationBarView::Init() { OnChanged(); } +bool LocationBarView::IsInitialized() const { + return location_entry_view_ != NULL; +} + +// static +SkColor LocationBarView::GetColor(bool is_secure, ColorKind kind) { + enum SecurityState { + NOT_SECURE = 0, + SECURE, + NUM_STATES + }; + + static bool initialized = false; + static SkColor colors[NUM_STATES][NUM_KINDS]; + if (!initialized) { +#if defined(OS_WIN) + colors[NOT_SECURE][BACKGROUND] = color_utils::GetSysSkColor(COLOR_WINDOW); + colors[NOT_SECURE][TEXT] = color_utils::GetSysSkColor(COLOR_WINDOWTEXT); + colors[NOT_SECURE][SELECTED_TEXT] = + color_utils::GetSysSkColor(COLOR_HIGHLIGHTTEXT); +#else + // TODO(beng): source from theme provider. + colors[NOT_SECURE][BACKGROUND] = SK_ColorWHITE; + colors[NOT_SECURE][TEXT] = SK_ColorBLACK; + colors[NOT_SECURE][SELECTED_TEXT] = SK_ColorWHITE; +#endif + colors[SECURE][BACKGROUND] = SkColorSetRGB(255, 245, 195); + colors[SECURE][TEXT] = SkColorSetRGB(0, 0, 0); + colors[SECURE][SELECTED_TEXT] = 0; // Unused + colors[NOT_SECURE][DEEMPHASIZED_TEXT] = + color_utils::AlphaBlend(colors[NOT_SECURE][TEXT], + colors[NOT_SECURE][BACKGROUND], 128); + colors[SECURE][DEEMPHASIZED_TEXT] = + color_utils::AlphaBlend(colors[SECURE][TEXT], + colors[SECURE][BACKGROUND], 128); + const SkColor kDarkNotSecureText = SkColorSetRGB(200, 0, 0); + const SkColor kLightNotSecureText = SkColorSetRGB(255, 55, 55); + colors[NOT_SECURE][SECURITY_TEXT] = + color_utils::PickMoreReadableColor(kDarkNotSecureText, + kLightNotSecureText, + colors[NOT_SECURE][BACKGROUND]); + colors[SECURE][SECURITY_TEXT] = SkColorSetRGB(0, 150, 20); +#if 0 // Info bubble background color is system theme window background color + colors[NOT_SECURE][SECURITY_INFO_BUBBLE_TEXT] = + colors[NOT_SECURE][SECURITY_TEXT]; + const SkColor kDarkSecureInfoBubbleText = SkColorSetRGB(0, 153, 51); + const SkColor kLightSecureInfoBubbleText = SkColorSetRGB(102, 255, 152); + colors[SECURE][SECURITY_INFO_BUBBLE_TEXT] = + color_utils::PickMoreReadableColor(kDarkSecureInfoBubbleText, + kLightSecureInfoBubbleText, + colors[NOT_SECURE][BACKGROUND]); +#else // Info bubble background color is white + colors[NOT_SECURE][SECURITY_INFO_BUBBLE_TEXT] = kDarkNotSecureText; + colors[SECURE][SECURITY_INFO_BUBBLE_TEXT] = SkColorSetRGB(0, 153, 51); +#endif + const SkColor kDarkSchemeStrikeout = SkColorSetRGB(210, 0, 0); + const SkColor kLightSchemeStrikeout = SkColorSetRGB(255, 45, 45); + colors[NOT_SECURE][SCHEME_STRIKEOUT] = + color_utils::PickMoreReadableColor(kDarkSchemeStrikeout, + kLightSchemeStrikeout, + colors[NOT_SECURE][BACKGROUND]); + colors[SECURE][SCHEME_STRIKEOUT] = 0; // Unused + initialized = true; + } + + return colors[is_secure ? SECURE : NOT_SECURE][kind]; +} + void LocationBarView::Update(const TabContents* tab_for_state_restoring) { SetSecurityIcon(model_->GetIcon()); RefreshPageActionViews(); @@ -282,8 +324,6 @@ void LocationBarView::Layout() { void LocationBarView::Paint(gfx::Canvas* canvas) { View::Paint(canvas); - SkColor bg = kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]; - const SkBitmap* background = popup_window_mode_ ? kPopupBackground : @@ -291,8 +331,10 @@ void LocationBarView::Paint(gfx::Canvas* canvas) { canvas->TileImageInt(*background, 0, 0, 0, 0, width(), height()); int top_margin = TopMargin(); - canvas->FillRectInt(bg, 0, top_margin, width(), - std::max(height() - top_margin - kVertMargin, 0)); + canvas->FillRectInt( + GetColor(model_->GetSchemeSecurityLevel() == ToolbarModel::SECURE, + BACKGROUND), + 0, top_margin, width(), std::max(height() - top_margin - kVertMargin, 0)); } void LocationBarView::VisibleBoundsInRootChanged() { @@ -675,7 +717,7 @@ void LocationBarView::SetInfoText(const std::wstring& text, info_label_.SetVisible(!text.empty()); info_label_.SetText(text); if (text_type == ToolbarModel::INFO_EV_TEXT) - info_label_.SetColor(SkColorSetRGB(0, 150, 20)); // Green. + info_label_.SetColor(GetColor(true, SECURITY_TEXT)); info_label_.SetTooltipText(tooltip_text); } @@ -1163,10 +1205,10 @@ bool LocationBarView::SecurityImageView::OnMousePressed( void LocationBarView::SecurityImageView::ShowInfoBubble() { std::wstring text; - SkColor text_color; - model_->GetIconHoverText(&text, &text_color); - - ShowInfoBubbleImpl(text, text_color); + model_->GetIconHoverText(&text); + ShowInfoBubbleImpl(text, GetColor( + model_->GetSecurityLevel() == ToolbarModel::SECURE, + SECURITY_INFO_BUBBLE_TEXT)); } // PageActionImageView---------------------------------------------------------- @@ -1329,8 +1371,11 @@ bool LocationBarView::PageActionImageView::OnMousePressed( } void LocationBarView::PageActionImageView::ShowInfoBubble() { - SkColor text_color = SK_ColorBLACK; - ShowInfoBubbleImpl(ASCIIToWide(tooltip_), text_color); +#if 0 // Info bubble background color is system theme window background color + ShowInfoBubbleImpl(ASCIIToWide(tooltip_), GetColor(false, TEXT)); +#else // Info bubble background color is white + ShowInfoBubbleImpl(ASCIIToWide(tooltip_), SK_ColorBLACK); +#endif } void LocationBarView::PageActionImageView::UpdateVisibility( diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h index dcc00da..919821f 100644 --- a/chrome/browser/views/location_bar_view.h +++ b/chrome/browser/views/location_bar_view.h @@ -56,6 +56,17 @@ class LocationBarView : public LocationBar, virtual void OnInputInProgress(bool in_progress) = 0; }; + enum ColorKind { + BACKGROUND = 0, + TEXT, + SELECTED_TEXT, + DEEMPHASIZED_TEXT, + SECURITY_TEXT, + SECURITY_INFO_BUBBLE_TEXT, + SCHEME_STRIKEOUT, + NUM_KINDS + }; + LocationBarView(Profile* profile, CommandUpdater* command_updater, ToolbarModel* model, @@ -70,6 +81,10 @@ class LocationBarView : public LocationBar, // only be called when the receiving instance is attached to a view container. bool IsInitialized() const; + // Returns the appropriate color for the desired kind, based on the user's + // system theme. + static SkColor GetColor(bool is_secure, ColorKind kind); + // Updates the location bar. We also reset the bar's permanent text and // security style, and, if |tab_for_state_restoring| is non-NULL, also restore // saved state that the tab holds. @@ -140,7 +155,6 @@ class LocationBarView : public LocationBar, virtual int PageActionVisibleCount(); static const int kVertMargin; - static const SkColor kBackgroundColorByLevel[]; protected: void Focus(); |