| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 9 #include "grit/theme_resources.h" | 9 #include "grit/theme_resources.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| 11 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
| 12 #include "views/controls/image_view.h" | 12 #include "views/controls/image_view.h" |
| 13 #include "views/controls/label.h" | 13 #include "views/controls/label.h" |
| 14 | 14 |
| 15 // Amount of padding at the edges of the bubble. | 15 // Amount of padding at the edges of the bubble. |
| 16 static const int kBubbleOuterPadding = LocationBarView::kEdgeItemPadding - | 16 static const int kBubbleOuterPadding = LocationBarView::kEdgeItemPadding - |
| 17 LocationBarView::kBubbleHorizontalPadding; | 17 LocationBarView::kBubbleHorizontalPadding; |
| 18 | 18 |
| 19 // Amount of padding after the label. | 19 // Amount of padding after the label. |
| 20 static const int kLabelPadding = 5; | 20 static const int kLabelPadding = 5; |
| 21 | 21 |
| 22 IconLabelBubbleView::IconLabelBubbleView(const int background_images[], | 22 IconLabelBubbleView::IconLabelBubbleView(const int background_images[], |
| 23 int contained_image, | 23 int contained_image, |
| 24 const SkColor& color) | 24 const SkColor& color) |
| 25 : background_painter_(background_images), | 25 : background_painter_(background_images), |
| 26 is_extension_icon_(false) { | 26 is_extension_icon_(false) { |
| 27 image_ = new views::ImageView(); | 27 image_ = new views::ImageView(); |
| 28 AddChildView(image_); | |
| 29 image_->SetImage( | 28 image_->SetImage( |
| 30 ResourceBundle::GetSharedInstance().GetBitmapNamed(contained_image)); | 29 ResourceBundle::GetSharedInstance().GetBitmapNamed(contained_image)); |
| 30 AddChildView(image_); |
| 31 |
| 31 label_ = new views::Label(); | 32 label_ = new views::Label(); |
| 33 label_->SetAutoColorReadabilityEnabled(false); |
| 34 label_->SetEnabledColor(color); |
| 32 AddChildView(label_); | 35 AddChildView(label_); |
| 33 label_->SetColor(color); | |
| 34 } | 36 } |
| 35 | 37 |
| 36 IconLabelBubbleView::~IconLabelBubbleView() { | 38 IconLabelBubbleView::~IconLabelBubbleView() { |
| 37 } | 39 } |
| 38 | 40 |
| 39 void IconLabelBubbleView::SetFont(const gfx::Font& font) { | 41 void IconLabelBubbleView::SetFont(const gfx::Font& font) { |
| 40 label_->SetFont(font); | 42 label_->SetFont(font); |
| 41 } | 43 } |
| 42 | 44 |
| 43 void IconLabelBubbleView::SetLabel(const string16& label) { | 45 void IconLabelBubbleView::SetLabel(const string16& label) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 79 |
| 78 int IconLabelBubbleView::GetPreLabelWidth() const { | 80 int IconLabelBubbleView::GetPreLabelWidth() const { |
| 79 return kBubbleOuterPadding + ResourceBundle::GetSharedInstance(). | 81 return kBubbleOuterPadding + ResourceBundle::GetSharedInstance(). |
| 80 GetBitmapNamed(IDR_OMNIBOX_SEARCH)->width() + | 82 GetBitmapNamed(IDR_OMNIBOX_SEARCH)->width() + |
| 81 LocationBarView::kItemPadding; | 83 LocationBarView::kItemPadding; |
| 82 } | 84 } |
| 83 | 85 |
| 84 int IconLabelBubbleView::GetNonLabelWidth() const { | 86 int IconLabelBubbleView::GetNonLabelWidth() const { |
| 85 return GetPreLabelWidth() + kBubbleOuterPadding; | 87 return GetPreLabelWidth() + kBubbleOuterPadding; |
| 86 } | 88 } |
| OLD | NEW |