NaCl docs: add sanitizers to GSoC ideas
[chromium-blink-merge.git] / chrome / browser / ui / views / location_bar / content_setting_image_view.h
blobe53de627589d5a62c49006062f2fab022343e1e4
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_CONTENT_SETTING_IMAGE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "components/content_settings/core/common/content_settings_types.h"
10 #include "ui/gfx/animation/animation_delegate.h"
11 #include "ui/gfx/animation/slide_animation.h"
12 #include "ui/views/painter.h"
13 #include "ui/views/view.h"
14 #include "ui/views/widget/widget_observer.h"
16 class ContentSettingImageModel;
17 class LocationBarView;
19 namespace content {
20 class WebContents;
23 namespace gfx {
24 class FontList;
27 namespace views {
28 class ImageView;
29 class Label;
32 // The ContentSettingImageView displays an icon and optional text label for
33 // various content settings affordances in the location bar (i.e. plugin
34 // blocking, geolocation).
35 class ContentSettingImageView : public gfx::AnimationDelegate,
36 public views::View,
37 public views::WidgetObserver {
38 public:
39 ContentSettingImageView(ContentSettingsType content_type,
40 LocationBarView* parent,
41 const gfx::FontList& font_list,
42 SkColor text_color,
43 SkColor parent_background_color);
44 ~ContentSettingImageView() override;
46 // Updates the decoration from the shown WebContents.
47 void Update(content::WebContents* web_contents);
49 private:
50 // Number of milliseconds spent animating open; also the time spent animating
51 // closed.
52 static const int kOpenTimeMS;
54 // The total animation time, including open and close as well as an
55 // intervening "stay open" period.
56 static const int kAnimationDurationMS;
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 // gfx::AnimationDelegate:
66 void AnimationEnded(const gfx::Animation* animation) override;
67 void AnimationProgressed(const gfx::Animation* animation) override;
68 void AnimationCanceled(const gfx::Animation* animation) override;
70 // views::View:
71 gfx::Size GetPreferredSize() const override;
72 void Layout() override;
73 const char* GetClassName() const override;
74 bool OnMousePressed(const ui::MouseEvent& event) override;
75 void OnMouseReleased(const ui::MouseEvent& event) override;
76 void OnGestureEvent(ui::GestureEvent* event) override;
77 void OnPaintBackground(gfx::Canvas* canvas) override;
79 // views::WidgetObserver:
80 void OnWidgetDestroying(views::Widget* widget) override;
82 bool background_showing() const {
83 return slide_animator_.is_animating() || pause_animation_;
86 int GetTotalSpacingWhileAnimating() const;
87 void OnClick();
89 LocationBarView* parent_; // Weak, owns us.
90 scoped_ptr<ContentSettingImageModel> content_setting_image_model_;
91 scoped_ptr<views::Painter> background_painter_;
92 views::ImageView* icon_;
93 views::Label* text_label_;
94 gfx::SlideAnimation slide_animator_;
95 bool pause_animation_;
96 double pause_animation_state_;
97 views::Widget* bubble_widget_;
99 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView);
102 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_