| 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 "chrome/common/content_settings_types.h" | 9 #include "chrome/common/content_settings_types.h" |
| 10 #include "ui/base/animation/animation_delegate.h" | 10 #include "ui/gfx/animation/animation_delegate.h" |
| 11 #include "ui/base/animation/slide_animation.h" | 11 #include "ui/gfx/animation/slide_animation.h" |
| 12 #include "ui/gfx/font.h" | 12 #include "ui/gfx/font.h" |
| 13 #include "ui/views/painter.h" | 13 #include "ui/views/painter.h" |
| 14 #include "ui/views/view.h" | 14 #include "ui/views/view.h" |
| 15 #include "ui/views/widget/widget_observer.h" | 15 #include "ui/views/widget/widget_observer.h" |
| 16 | 16 |
| 17 class ContentSettingImageModel; | 17 class ContentSettingImageModel; |
| 18 class LocationBarView; | 18 class LocationBarView; |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 class WebContents; | 21 class WebContents; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace views { | 24 namespace views { |
| 25 class ImageView; | 25 class ImageView; |
| 26 class Label; | 26 class Label; |
| 27 } | 27 } |
| 28 | 28 |
| 29 // The ContentSettingImageView displays an icon and optional text label for | 29 // The ContentSettingImageView displays an icon and optional text label for |
| 30 // various content settings affordances in the location bar (i.e. plugin | 30 // various content settings affordances in the location bar (i.e. plugin |
| 31 // blocking, geolocation). | 31 // blocking, geolocation). |
| 32 class ContentSettingImageView : public ui::AnimationDelegate, | 32 class ContentSettingImageView : public gfx::AnimationDelegate, |
| 33 public views::View, | 33 public views::View, |
| 34 public views::WidgetObserver { | 34 public views::WidgetObserver { |
| 35 public: | 35 public: |
| 36 ContentSettingImageView(ContentSettingsType content_type, | 36 ContentSettingImageView(ContentSettingsType content_type, |
| 37 LocationBarView* parent, | 37 LocationBarView* parent, |
| 38 const gfx::Font& font, | 38 const gfx::Font& font, |
| 39 int font_y_offset, | 39 int font_y_offset, |
| 40 SkColor text_color, | 40 SkColor text_color, |
| 41 SkColor parent_background_color); | 41 SkColor parent_background_color); |
| 42 virtual ~ContentSettingImageView(); | 42 virtual ~ContentSettingImageView(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 57 // intervening "stay open" period. | 57 // intervening "stay open" period. |
| 58 static const int kAnimationDurationMS; | 58 static const int kAnimationDurationMS; |
| 59 | 59 |
| 60 // Amount of padding at the edges of the bubble. If |by_icon| is true, this | 60 // Amount of padding at the edges of the bubble. If |by_icon| is true, this |
| 61 // is the padding next to the icon; otherwise it's the padding next to the | 61 // is the padding next to the icon; otherwise it's the padding next to the |
| 62 // label. (We increase padding next to the label by the amount of padding | 62 // label. (We increase padding next to the label by the amount of padding |
| 63 // "built in" to the icon in order to make the bubble appear to have | 63 // "built in" to the icon in order to make the bubble appear to have |
| 64 // symmetrical padding.) | 64 // symmetrical padding.) |
| 65 static int GetBubbleOuterPadding(bool by_icon); | 65 static int GetBubbleOuterPadding(bool by_icon); |
| 66 | 66 |
| 67 // ui::AnimationDelegate: | 67 // gfx::AnimationDelegate: |
| 68 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 68 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
| 69 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 69 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 70 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE; | 70 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE; |
| 71 | 71 |
| 72 // views::View: | 72 // views::View: |
| 73 virtual gfx::Size GetPreferredSize() OVERRIDE; | 73 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 74 virtual void Layout() OVERRIDE; | 74 virtual void Layout() OVERRIDE; |
| 75 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 75 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
| 76 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 76 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
| 77 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 77 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 78 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; | 78 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; |
| 79 | 79 |
| 80 // views::WidgetObserver: | 80 // views::WidgetObserver: |
| 81 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; | 81 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; |
| 82 | 82 |
| 83 bool background_showing() const { | 83 bool background_showing() const { |
| 84 return slide_animator_.is_animating() || pause_animation_; | 84 return slide_animator_.is_animating() || pause_animation_; |
| 85 } | 85 } |
| 86 | 86 |
| 87 int GetTotalSpacingWhileAnimating() const; | 87 int GetTotalSpacingWhileAnimating() const; |
| 88 void OnClick(); | 88 void OnClick(); |
| 89 void CreateBubble(content::WebContents* web_contents); | 89 void CreateBubble(content::WebContents* web_contents); |
| 90 | 90 |
| 91 LocationBarView* parent_; // Weak, owns us. | 91 LocationBarView* parent_; // Weak, owns us. |
| 92 scoped_ptr<ContentSettingImageModel> content_setting_image_model_; | 92 scoped_ptr<ContentSettingImageModel> content_setting_image_model_; |
| 93 scoped_ptr<views::Painter> background_painter_; | 93 scoped_ptr<views::Painter> background_painter_; |
| 94 views::ImageView* icon_; | 94 views::ImageView* icon_; |
| 95 views::Label* text_label_; | 95 views::Label* text_label_; |
| 96 ui::SlideAnimation slide_animator_; | 96 gfx::SlideAnimation slide_animator_; |
| 97 bool pause_animation_; | 97 bool pause_animation_; |
| 98 double pause_animation_state_; | 98 double pause_animation_state_; |
| 99 views::Widget* bubble_widget_; | 99 views::Widget* bubble_widget_; |
| 100 | 100 |
| 101 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView); | 101 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView); |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_ | 104 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_ |
| OLD | NEW |