Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / views / location_bar / icon_label_bubble_view.h
blobe844d41c3de7f70c0653816e835d714007d98227
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_
8 #include <string>
10 #include "base/strings/string16.h"
11 #include "ui/gfx/size.h"
12 #include "ui/views/view.h"
14 namespace gfx {
15 class Canvas;
16 class FontList;
17 class ImageSkia;
20 namespace views {
21 class ImageView;
22 class Label;
23 class Painter;
26 // View used to draw a bubble to the left of the address, containing an icon and
27 // a label. We use this as a base for the classes that handle the EV bubble and
28 // tab-to-search UI.
29 class IconLabelBubbleView : public views::View {
30 public:
31 // |hover_background_images| is an optional set of images to be used in place
32 // of |background_images| during mouse hover.
33 IconLabelBubbleView(const int background_images[],
34 const int hover_background_images[],
35 int contained_image,
36 const gfx::FontList& font_list,
37 SkColor text_color,
38 SkColor parent_background_color,
39 bool elide_in_middle);
40 virtual ~IconLabelBubbleView();
42 void SetLabel(const base::string16& label);
43 void SetImage(const gfx::ImageSkia& image);
44 void set_is_extension_icon(bool is_extension_icon) {
45 is_extension_icon_ = is_extension_icon;
48 protected:
49 // views::View:
50 virtual gfx::Size GetPreferredSize() OVERRIDE;
51 virtual void Layout() OVERRIDE;
52 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
53 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
55 gfx::Size GetSizeForLabelWidth(int width) const;
57 private:
58 // Amount of padding at the edges of the bubble. If |by_icon| is true, this
59 // is the padding next to the icon; otherwise it's the padding next to the
60 // label. (We increase padding next to the label by the amount of padding
61 // "built in" to the icon in order to make the bubble appear to have
62 // symmetrical padding.)
63 static int GetBubbleOuterPadding(bool by_icon);
65 // views::View:
66 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
68 int GetPreLabelWidth() const;
70 // For painting the background.
71 scoped_ptr<views::Painter> background_painter_;
72 scoped_ptr<views::Painter> hover_background_painter_;
74 // The contents of the bubble.
75 views::ImageView* image_;
76 views::Label* label_;
78 bool is_extension_icon_;
79 bool in_hover_;
81 DISALLOW_COPY_AND_ASSIGN(IconLabelBubbleView);
84 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_