Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / views / location_bar / content_setting_image_view.h
blobf68232fc2c1baa58401f3d208a7db741f4b6e24e
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 "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h"
10 #include "components/content_settings/core/common/content_settings_types.h"
11 #include "ui/gfx/animation/animation_delegate.h"
12 #include "ui/gfx/animation/slide_animation.h"
13 #include "ui/views/painter.h"
14 #include "ui/views/view.h"
15 #include "ui/views/widget/widget_observer.h"
17 class ContentSettingImageModel;
18 class LocationBarView;
20 namespace content {
21 class WebContents;
24 namespace gfx {
25 class FontList;
28 namespace views {
29 class ImageView;
30 class Label;
33 // The ContentSettingImageView displays an icon and optional text label for
34 // various content settings affordances in the location bar (i.e. plugin
35 // blocking, geolocation).
36 class ContentSettingImageView : public IconLabelBubbleView,
37 public gfx::AnimationDelegate,
38 public views::WidgetObserver {
39 public:
40 ContentSettingImageView(ContentSettingsType content_type,
41 LocationBarView* parent,
42 const gfx::FontList& font_list,
43 SkColor text_color,
44 SkColor parent_background_color);
45 ~ContentSettingImageView() override;
47 // Updates the decoration from the shown WebContents.
48 void Update(content::WebContents* web_contents);
50 private:
51 // Number of milliseconds spent animating open; also the time spent animating
52 // closed.
53 static const int kOpenTimeMS;
55 // The total animation time, including open and close as well as an
56 // intervening "stay open" period.
57 static const int kAnimationDurationMS;
59 // IconLabelBubbleView::
60 bool ShouldShowBackground() const override;
61 double WidthMultiplier() const override;
63 // gfx::AnimationDelegate:
64 void AnimationEnded(const gfx::Animation* animation) override;
65 void AnimationProgressed(const gfx::Animation* animation) override;
66 void AnimationCanceled(const gfx::Animation* animation) override;
68 // views::View:
69 const char* GetClassName() const override;
70 bool OnMousePressed(const ui::MouseEvent& event) override;
71 void OnMouseReleased(const ui::MouseEvent& event) override;
72 void OnGestureEvent(ui::GestureEvent* event) override;
74 // views::WidgetObserver:
75 void OnWidgetDestroying(views::Widget* widget) override;
77 void OnClick();
79 LocationBarView* parent_; // Weak, owns us.
80 scoped_ptr<ContentSettingImageModel> content_setting_image_model_;
81 gfx::SlideAnimation slide_animator_;
82 bool pause_animation_;
83 double pause_animation_state_;
84 views::Widget* bubble_widget_;
86 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView);
89 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_