Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / views / location_bar / icon_label_bubble_view.h
blobac06a74444478e986fd631caf4a5763ea129082a
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/geometry/size.h"
12 #include "ui/views/controls/label.h"
13 #include "ui/views/view.h"
15 namespace gfx {
16 class Canvas;
17 class FontList;
18 class ImageSkia;
21 namespace views {
22 class ImageView;
23 class Label;
24 class Painter;
27 // View used to draw a bubble to the left of the address, containing an icon and
28 // a label. We use this as a base for the classes that handle the EV bubble and
29 // tab-to-search UI.
30 class IconLabelBubbleView : public views::View {
31 public:
32 // |hover_background_images| is an optional set of images to be used in place
33 // of |background_images| during mouse hover.
34 IconLabelBubbleView(const int background_images[],
35 const int hover_background_images[],
36 int contained_image,
37 const gfx::FontList& font_list,
38 SkColor text_color,
39 SkColor parent_background_color,
40 bool elide_in_middle);
41 ~IconLabelBubbleView() override;
43 void SetLabel(const base::string16& label);
44 void SetImage(const gfx::ImageSkia& image);
45 void set_is_extension_icon(bool is_extension_icon) {
46 is_extension_icon_ = is_extension_icon;
49 protected:
50 // views::View:
51 gfx::Size GetPreferredSize() const override;
52 void Layout() override;
53 void OnMouseEntered(const ui::MouseEvent& event) override;
54 void OnMouseExited(const ui::MouseEvent& event) override;
56 const gfx::FontList& font_list() const { return label_->font_list(); }
58 gfx::Size GetSizeForLabelWidth(int width) const;
60 private:
61 // Amount of padding at the edges of the bubble. If |by_icon| is true, this
62 // is the padding next to the icon; otherwise it's the padding next to the
63 // label. (We increase padding next to the label by the amount of padding
64 // "built in" to the icon in order to make the bubble appear to have
65 // symmetrical padding.)
66 static int GetBubbleOuterPadding(bool by_icon);
68 // views::View:
69 const char* GetClassName() const override;
70 void OnPaint(gfx::Canvas* canvas) override;
72 int GetPreLabelWidth() const;
74 // For painting the background.
75 scoped_ptr<views::Painter> background_painter_;
76 scoped_ptr<views::Painter> hover_background_painter_;
78 // The contents of the bubble.
79 views::ImageView* image_;
80 views::Label* label_;
82 bool is_extension_icon_;
83 bool in_hover_;
85 DISALLOW_COPY_AND_ASSIGN(IconLabelBubbleView);
88 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_