| 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 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_ | 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_ | 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 11 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
| 12 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" | 12 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" |
| 13 #include "components/content_settings/core/common/content_settings_types.h" | 13 #include "components/content_settings/core/common/content_settings_types.h" |
| 14 #include "ui/gfx/animation/animation_delegate.h" | 14 #include "ui/gfx/animation/animation_delegate.h" |
| 15 #include "ui/gfx/animation/slide_animation.h" | 15 #include "ui/gfx/animation/slide_animation.h" |
| 16 #include "ui/views/painter.h" | 16 #include "ui/views/painter.h" |
| 17 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
| 18 #include "ui/views/widget/widget_observer.h" | |
| 19 | 18 |
| 20 class ContentSettingImageModel; | 19 class ContentSettingImageModel; |
| 21 class LocationBarView; | 20 class LocationBarView; |
| 22 | 21 |
| 23 namespace content { | 22 namespace content { |
| 24 class WebContents; | 23 class WebContents; |
| 25 } | 24 } |
| 26 | 25 |
| 27 namespace gfx { | 26 namespace gfx { |
| 28 class FontList; | 27 class FontList; |
| 29 } | 28 } |
| 30 | 29 |
| 31 namespace views { | 30 namespace views { |
| 32 class BubbleDialogDelegateView; | 31 class BubbleDialogDelegateView; |
| 33 } | 32 } |
| 34 | 33 |
| 35 // The ContentSettingImageView displays an icon and optional text label for | 34 // The ContentSettingImageView displays an icon and optional text label for |
| 36 // various content settings affordances in the location bar (i.e. plugin | 35 // various content settings affordances in the location bar (i.e. plugin |
| 37 // blocking, geolocation). | 36 // blocking, geolocation). |
| 38 class ContentSettingImageView : public IconLabelBubbleView, | 37 class ContentSettingImageView : public IconLabelBubbleView, |
| 39 public gfx::AnimationDelegate, | 38 public gfx::AnimationDelegate { |
| 40 public views::WidgetObserver { | |
| 41 public: | 39 public: |
| 42 ContentSettingImageView(std::unique_ptr<ContentSettingImageModel> image_model, | 40 ContentSettingImageView(std::unique_ptr<ContentSettingImageModel> image_model, |
| 43 LocationBarView* parent, | 41 LocationBarView* parent, |
| 44 const gfx::FontList& font_list); | 42 const gfx::FontList& font_list); |
| 45 ~ContentSettingImageView() override; | 43 ~ContentSettingImageView() override; |
| 46 | 44 |
| 47 // Updates the decoration from the shown WebContents. | 45 // Updates the decoration from the shown WebContents. |
| 48 void Update(content::WebContents* web_contents); | 46 void Update(content::WebContents* web_contents); |
| 49 | 47 |
| 50 private: | 48 private: |
| 51 // The total animation time, including open and close as well as an | 49 // The total animation time, including open and close as well as an |
| 52 // intervening "stay open" period. | 50 // intervening "stay open" period. |
| 53 static const int kAnimationDurationMS; | 51 static const int kAnimationDurationMS; |
| 54 | 52 |
| 55 // IconLabelBubbleView: | 53 // IconLabelBubbleView: |
| 56 const char* GetClassName() const override; | 54 const char* GetClassName() const override; |
| 55 bool IsInkDropEnabled() const override; |
| 57 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | 56 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
| 58 bool OnMousePressed(const ui::MouseEvent& event) override; | 57 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 59 void OnMouseReleased(const ui::MouseEvent& event) override; | 58 void OnMouseReleased(const ui::MouseEvent& event) override; |
| 60 void OnGestureEvent(ui::GestureEvent* event) override; | 59 void OnGestureEvent(ui::GestureEvent* event) override; |
| 61 bool GetTooltipText(const gfx::Point& p, | 60 bool GetTooltipText(const gfx::Point& p, |
| 62 base::string16* tooltip) const override; | 61 base::string16* tooltip) const override; |
| 63 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override; | 62 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override; |
| 64 std::unique_ptr<views::InkDrop> CreateInkDrop() override; | |
| 65 SkColor GetTextColor() const override; | 63 SkColor GetTextColor() const override; |
| 66 bool ShouldShowLabel() const override; | 64 bool ShouldShowLabel() const override; |
| 67 double WidthMultiplier() const override; | 65 double WidthMultiplier() const override; |
| 68 bool IsShrinking() const override; | 66 bool IsShrinking() const override; |
| 69 bool OnActivate(const ui::Event& event) override; | 67 bool OnActivate(const ui::Event& event) override; |
| 70 | 68 |
| 71 // gfx::AnimationDelegate: | 69 // gfx::AnimationDelegate: |
| 72 void AnimationEnded(const gfx::Animation* animation) override; | 70 void AnimationEnded(const gfx::Animation* animation) override; |
| 73 void AnimationProgressed(const gfx::Animation* animation) override; | 71 void AnimationProgressed(const gfx::Animation* animation) override; |
| 74 void AnimationCanceled(const gfx::Animation* animation) override; | 72 void AnimationCanceled(const gfx::Animation* animation) override; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 89 | 87 |
| 90 // This is used to check if the bubble was showing during the mouse pressed | 88 // This is used to check if the bubble was showing during the mouse pressed |
| 91 // event. If this is true then the mouse released event is ignored to prevent | 89 // event. If this is true then the mouse released event is ignored to prevent |
| 92 // the bubble from reshowing. | 90 // the bubble from reshowing. |
| 93 bool suppress_mouse_released_action_; | 91 bool suppress_mouse_released_action_; |
| 94 | 92 |
| 95 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView); | 93 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView); |
| 96 }; | 94 }; |
| 97 | 95 |
| 98 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_ | 96 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_ |
| OLD | NEW |