Chromium Code Reviews| Index: chrome/browser/ui/views/location_bar/content_setting_image_view.cc |
| diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc |
| index e01c30feb2775f7ed30d0e515cb621dcfdad27b5..691bf61f57eb0004231705e7e9b441887b0caa21 100644 |
| --- a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc |
| +++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc |
| @@ -68,8 +68,11 @@ ContentSettingImageView::~ContentSettingImageView() { |
| } |
| } |
| -void ContentSettingImageView::UpdateFromWebContents(WebContents* web_contents) { |
| - content_setting_image_model_->UpdateFromWebContents(web_contents); |
| +void ContentSettingImageView::Update(TabContents* tab_contents) { |
| + if (tab_contents) { |
|
Bernhard Bauer
2012/07/31 23:31:18
Could we do an early-ish return if tab_content is
Greg Billock
2012/08/06 22:49:47
We could. That slightly changes the logic -- it'll
Bernhard Bauer
2012/08/07 00:08:37
Yeah... It's fine with me if you want to leave it
|
| + content_setting_image_model_->UpdateFromWebContents( |
| + tab_contents->web_contents()); |
| + } |
| if (!content_setting_image_model_->is_visible()) { |
| SetVisible(false); |
| return; |
| @@ -80,10 +83,9 @@ void ContentSettingImageView::UpdateFromWebContents(WebContents* web_contents) { |
| SetVisible(true); |
| TabSpecificContentSettings* content_settings = NULL; |
| - if (web_contents) { |
| - content_settings = |
| - TabContents::FromWebContents(web_contents)->content_settings(); |
| - } |
| + if (tab_contents) |
| + content_settings = tab_contents->content_settings(); |
| + |
| if (!content_settings || content_settings->IsBlockageIndicated( |
| content_setting_image_model_->get_content_settings_type())) |
| return; |
| @@ -167,6 +169,10 @@ void ContentSettingImageView::OnMouseReleased(const views::MouseEvent& event) { |
| if (!HitTest(event.location())) |
| return; |
| + OnClick(); |
| +} |
| + |
| +void ContentSettingImageView::OnClick() { |
| TabContents* tab_contents = parent_->GetTabContents(); |
| if (!tab_contents) |
| return; |
| @@ -233,7 +239,7 @@ void ContentSettingImageView::OnPaintBackground(gfx::Canvas* canvas) { |
| SkPaint paint; |
| paint.setShader(gfx::CreateGradientShader(kEdgeThickness, |
| height() - (2 * kEdgeThickness), |
| - kTopBoxColor, kBottomBoxColor)); |
| + gradient_top_color(), gradient_bottom_color())); |
| SkSafeUnref(paint.getShader()); |
| SkRect color_rect; |
| color_rect.iset(0, 0, width() - 1, height() - 1); |
| @@ -241,7 +247,7 @@ void ContentSettingImageView::OnPaintBackground(gfx::Canvas* canvas) { |
| kBoxCornerRadius, paint); |
| SkPaint outer_paint; |
| outer_paint.setStyle(SkPaint::kStroke_Style); |
| - outer_paint.setColor(kBorderColor); |
| + outer_paint.setColor(button_border_color()); |
| color_rect.inset(SkIntToScalar(kEdgeThickness), |
| SkIntToScalar(kEdgeThickness)); |
| canvas->sk_canvas()->drawRoundRect(color_rect, kBoxCornerRadius, |
| @@ -269,3 +275,14 @@ int ContentSettingImageView::GetBuiltInHorizontalPadding() const { |
| return GetBuiltInHorizontalPaddingImpl(); |
| } |
| +SkColor ContentSettingImageView::button_border_color() const { |
| + return kBorderColor; |
| +} |
| + |
| +SkColor ContentSettingImageView::gradient_top_color() const { |
| + return kTopBoxColor; |
| +} |
| + |
| +SkColor ContentSettingImageView::gradient_bottom_color() const { |
| + return kBottomBoxColor; |
| +} |