| 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/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 "ui/views/controls/image_view.h" | 12 #include "ui/views/controls/image_view.h" |
| 13 #include "ui/views/controls/label.h" | 13 #include "ui/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 SkColor color) | 24 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 image_->SetImage( | 28 image_->SetImage( |
| 29 ui::ResourceBundle::GetSharedInstance().GetBitmapNamed(contained_image)); | 29 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 30 contained_image)); |
| 30 AddChildView(image_); | 31 AddChildView(image_); |
| 31 | 32 |
| 32 label_ = new views::Label(); | 33 label_ = new views::Label(); |
| 33 label_->SetAutoColorReadabilityEnabled(false); | 34 label_->SetAutoColorReadabilityEnabled(false); |
| 34 label_->SetEnabledColor(color); | 35 label_->SetEnabledColor(color); |
| 35 AddChildView(label_); | 36 AddChildView(label_); |
| 36 } | 37 } |
| 37 | 38 |
| 38 IconLabelBubbleView::~IconLabelBubbleView() { | 39 IconLabelBubbleView::~IconLabelBubbleView() { |
| 39 } | 40 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 80 |
| 80 int IconLabelBubbleView::GetPreLabelWidth() const { | 81 int IconLabelBubbleView::GetPreLabelWidth() const { |
| 81 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 82 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 82 return kBubbleOuterPadding + rb.GetBitmapNamed(IDR_OMNIBOX_SEARCH)->width() + | 83 return kBubbleOuterPadding + rb.GetBitmapNamed(IDR_OMNIBOX_SEARCH)->width() + |
| 83 LocationBarView::kItemPadding; | 84 LocationBarView::kItemPadding; |
| 84 } | 85 } |
| 85 | 86 |
| 86 int IconLabelBubbleView::GetNonLabelWidth() const { | 87 int IconLabelBubbleView::GetNonLabelWidth() const { |
| 87 return GetPreLabelWidth() + kBubbleOuterPadding; | 88 return GetPreLabelWidth() + kBubbleOuterPadding; |
| 88 } | 89 } |
| OLD | NEW |