| 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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "components/content_settings/core/common/content_settings_types.h" | 9 #include "components/content_settings/core/common/content_settings_types.h" |
| 10 #include "ui/gfx/animation/animation_delegate.h" | 10 #include "ui/gfx/animation/animation_delegate.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // blocking, geolocation). | 34 // blocking, geolocation). |
| 35 class ContentSettingImageView : public gfx::AnimationDelegate, | 35 class ContentSettingImageView : public gfx::AnimationDelegate, |
| 36 public views::View, | 36 public views::View, |
| 37 public views::WidgetObserver { | 37 public views::WidgetObserver { |
| 38 public: | 38 public: |
| 39 ContentSettingImageView(ContentSettingsType content_type, | 39 ContentSettingImageView(ContentSettingsType content_type, |
| 40 LocationBarView* parent, | 40 LocationBarView* parent, |
| 41 const gfx::FontList& font_list, | 41 const gfx::FontList& font_list, |
| 42 SkColor text_color, | 42 SkColor text_color, |
| 43 SkColor parent_background_color); | 43 SkColor parent_background_color); |
| 44 virtual ~ContentSettingImageView(); | 44 ~ContentSettingImageView() override; |
| 45 | 45 |
| 46 // Updates the decoration from the shown WebContents. | 46 // Updates the decoration from the shown WebContents. |
| 47 void Update(content::WebContents* web_contents); | 47 void Update(content::WebContents* web_contents); |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 // Number of milliseconds spent animating open; also the time spent animating | 50 // Number of milliseconds spent animating open; also the time spent animating |
| 51 // closed. | 51 // closed. |
| 52 static const int kOpenTimeMS; | 52 static const int kOpenTimeMS; |
| 53 | 53 |
| 54 // The total animation time, including open and close as well as an | 54 // The total animation time, including open and close as well as an |
| 55 // intervening "stay open" period. | 55 // intervening "stay open" period. |
| 56 static const int kAnimationDurationMS; | 56 static const int kAnimationDurationMS; |
| 57 | 57 |
| 58 // Amount of padding at the edges of the bubble. If |by_icon| is true, this | 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 | 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 | 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 | 61 // "built in" to the icon in order to make the bubble appear to have |
| 62 // symmetrical padding.) | 62 // symmetrical padding.) |
| 63 static int GetBubbleOuterPadding(bool by_icon); | 63 static int GetBubbleOuterPadding(bool by_icon); |
| 64 | 64 |
| 65 // gfx::AnimationDelegate: | 65 // gfx::AnimationDelegate: |
| 66 virtual void AnimationEnded(const gfx::Animation* animation) override; | 66 void AnimationEnded(const gfx::Animation* animation) override; |
| 67 virtual void AnimationProgressed(const gfx::Animation* animation) override; | 67 void AnimationProgressed(const gfx::Animation* animation) override; |
| 68 virtual void AnimationCanceled(const gfx::Animation* animation) override; | 68 void AnimationCanceled(const gfx::Animation* animation) override; |
| 69 | 69 |
| 70 // views::View: | 70 // views::View: |
| 71 virtual gfx::Size GetPreferredSize() const override; | 71 gfx::Size GetPreferredSize() const override; |
| 72 virtual void Layout() override; | 72 void Layout() override; |
| 73 virtual bool OnMousePressed(const ui::MouseEvent& event) override; | 73 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 74 virtual void OnMouseReleased(const ui::MouseEvent& event) override; | 74 void OnMouseReleased(const ui::MouseEvent& event) override; |
| 75 virtual void OnGestureEvent(ui::GestureEvent* event) override; | 75 void OnGestureEvent(ui::GestureEvent* event) override; |
| 76 virtual void OnPaintBackground(gfx::Canvas* canvas) override; | 76 void OnPaintBackground(gfx::Canvas* canvas) override; |
| 77 | 77 |
| 78 // views::WidgetObserver: | 78 // views::WidgetObserver: |
| 79 virtual void OnWidgetDestroying(views::Widget* widget) override; | 79 void OnWidgetDestroying(views::Widget* widget) override; |
| 80 | 80 |
| 81 bool background_showing() const { | 81 bool background_showing() const { |
| 82 return slide_animator_.is_animating() || pause_animation_; | 82 return slide_animator_.is_animating() || pause_animation_; |
| 83 } | 83 } |
| 84 | 84 |
| 85 int GetTotalSpacingWhileAnimating() const; | 85 int GetTotalSpacingWhileAnimating() const; |
| 86 void OnClick(); | 86 void OnClick(); |
| 87 | 87 |
| 88 LocationBarView* parent_; // Weak, owns us. | 88 LocationBarView* parent_; // Weak, owns us. |
| 89 scoped_ptr<ContentSettingImageModel> content_setting_image_model_; | 89 scoped_ptr<ContentSettingImageModel> content_setting_image_model_; |
| 90 scoped_ptr<views::Painter> background_painter_; | 90 scoped_ptr<views::Painter> background_painter_; |
| 91 views::ImageView* icon_; | 91 views::ImageView* icon_; |
| 92 views::Label* text_label_; | 92 views::Label* text_label_; |
| 93 gfx::SlideAnimation slide_animator_; | 93 gfx::SlideAnimation slide_animator_; |
| 94 bool pause_animation_; | 94 bool pause_animation_; |
| 95 double pause_animation_state_; | 95 double pause_animation_state_; |
| 96 views::Widget* bubble_widget_; | 96 views::Widget* bubble_widget_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView); | 98 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_ | 101 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_ |
| OLD | NEW |