| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" | 5 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/views/layout_constants.h" | 8 #include "chrome/browser/ui/views/layout_constants.h" |
| 9 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" | 9 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" |
| 10 #include "ui/base/resource/material_design/material_design_controller.h" | 10 #include "ui/base/resource/material_design/material_design_controller.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 width() - pre_label_width - GetBubbleOuterPadding(false), | 109 width() - pre_label_width - GetBubbleOuterPadding(false), |
| 110 height()); | 110 height()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void IconLabelBubbleView::OnNativeThemeChanged( | 113 void IconLabelBubbleView::OnNativeThemeChanged( |
| 114 const ui::NativeTheme* native_theme) { | 114 const ui::NativeTheme* native_theme) { |
| 115 if (!ui::MaterialDesignController::IsModeMaterial()) | 115 if (!ui::MaterialDesignController::IsModeMaterial()) |
| 116 return; | 116 return; |
| 117 | 117 |
| 118 label_->SetEnabledColor(GetTextColor()); | 118 label_->SetEnabledColor(GetTextColor()); |
| 119 SkColor border_color = GetBorderColor(); | 119 |
| 120 SkColor background_color = SkColorSetA(border_color, 0x13); | 120 bool inverted = |
| 121 color_utils::GetLuminanceForColor(parent_background_color_) < 128; |
| 122 SkColor border_color = inverted ? SK_ColorWHITE : GetBorderColor(); |
| 123 SkColor background_color = |
| 124 inverted ? SK_ColorWHITE : SkColorSetA(border_color, 0x13); |
| 121 set_background( | 125 set_background( |
| 122 new BackgroundWith1PxBorder(background_color, border_color, false)); | 126 new BackgroundWith1PxBorder(background_color, border_color, false)); |
| 123 SetLabelBackgroundColor(background_color); | 127 SetLabelBackgroundColor(background_color); |
| 124 } | 128 } |
| 125 | 129 |
| 126 gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const { | 130 gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const { |
| 127 gfx::Size size(image_->GetPreferredSize()); | 131 gfx::Size size(image_->GetPreferredSize()); |
| 128 if (ShouldShowBackground()) { | 132 if (ShouldShowBackground()) { |
| 129 const int image_width = image_->GetPreferredSize().width(); | 133 const int image_width = image_->GetPreferredSize().width(); |
| 130 const int padding = GetLayoutConstant(ICON_LABEL_VIEW_INTERNAL_PADDING); | 134 const int padding = GetLayoutConstant(ICON_LABEL_VIEW_INTERNAL_PADDING); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 } | 181 } |
| 178 | 182 |
| 179 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { | 183 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { |
| 180 if (!ShouldShowBackground()) | 184 if (!ShouldShowBackground()) |
| 181 return; | 185 return; |
| 182 if (background_painter_) | 186 if (background_painter_) |
| 183 background_painter_->Paint(canvas, size()); | 187 background_painter_->Paint(canvas, size()); |
| 184 if (background()) | 188 if (background()) |
| 185 background()->Paint(canvas, this); | 189 background()->Paint(canvas, this); |
| 186 } | 190 } |
| OLD | NEW |