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/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 private: | 54 private: |
55 // Number of milliseconds spent animating open; also the time spent animating | 55 // Number of milliseconds spent animating open; also the time spent animating |
56 // closed. | 56 // closed. |
57 static const int kOpenTimeMS; | 57 static const int kOpenTimeMS; |
58 | 58 |
59 // The total animation time, including open and close as well as an | 59 // The total animation time, including open and close as well as an |
60 // intervening "stay open" period. | 60 // intervening "stay open" period. |
61 static const int kAnimationDurationMS; | 61 static const int kAnimationDurationMS; |
62 | 62 |
63 // IconLabelBubbleView: | 63 // IconLabelBubbleView: |
| 64 const char* GetClassName() const override; |
| 65 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
| 66 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 67 void OnMouseReleased(const ui::MouseEvent& event) override; |
| 68 bool OnKeyPressed(const ui::KeyEvent& event) override; |
| 69 void OnGestureEvent(ui::GestureEvent* event) override; |
| 70 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override; |
64 SkColor GetTextColor() const override; | 71 SkColor GetTextColor() const override; |
65 SkColor GetBorderColor() const override; | 72 SkColor GetBorderColor() const override; |
66 bool ShouldShowBackground() const override; | 73 bool ShouldShowBackground() const override; |
67 double WidthMultiplier() const override; | 74 double WidthMultiplier() const override; |
68 bool IsShrinking() const override; | 75 bool IsShrinking() const override; |
69 | 76 |
70 // gfx::AnimationDelegate: | 77 // gfx::AnimationDelegate: |
71 void AnimationEnded(const gfx::Animation* animation) override; | 78 void AnimationEnded(const gfx::Animation* animation) override; |
72 void AnimationProgressed(const gfx::Animation* animation) override; | 79 void AnimationProgressed(const gfx::Animation* animation) override; |
73 void AnimationCanceled(const gfx::Animation* animation) override; | 80 void AnimationCanceled(const gfx::Animation* animation) override; |
74 | 81 |
75 // views::View: | |
76 const char* GetClassName() const override; | |
77 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | |
78 bool OnMousePressed(const ui::MouseEvent& event) override; | |
79 void OnMouseReleased(const ui::MouseEvent& event) override; | |
80 bool OnKeyPressed(const ui::KeyEvent& event) override; | |
81 void OnGestureEvent(ui::GestureEvent* event) override; | |
82 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override; | |
83 | |
84 // views::WidgetObserver: | 82 // views::WidgetObserver: |
85 void OnWidgetDestroying(views::Widget* widget) override; | 83 void OnWidgetDestroying(views::Widget* widget) override; |
86 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; | 84 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; |
87 | 85 |
| 86 // Called when the user clicks the view; this freezes the animation or snaps |
| 87 // it to its end state as necessary and then opens a content setting bubble. |
88 void OnClick(); | 88 void OnClick(); |
89 | 89 |
| 90 // Updates the image and tooltip to match the current model state. |
90 void UpdateImage(); | 91 void UpdateImage(); |
91 | 92 |
92 // Returns true if a related bubble is showing. | |
93 bool IsBubbleShowing() const; | |
94 | |
95 LocationBarView* parent_; // Weak, owns us. | 93 LocationBarView* parent_; // Weak, owns us. |
96 scoped_ptr<ContentSettingImageModel> content_setting_image_model_; | 94 scoped_ptr<ContentSettingImageModel> content_setting_image_model_; |
97 gfx::SlideAnimation slide_animator_; | 95 gfx::SlideAnimation slide_animator_; |
98 bool pause_animation_; | 96 bool pause_animation_; |
99 double pause_animation_state_; | 97 double pause_animation_state_; |
100 views::BubbleDelegateView* bubble_view_; | 98 views::BubbleDelegateView* bubble_view_; |
101 | 99 |
102 // This is used to check if the bubble was showing during the mouse pressed | 100 // This is used to check if the bubble was showing during the mouse pressed |
103 // event. If this is true then the mouse released event is ignored to prevent | 101 // event. If this is true then the mouse released event is ignored to prevent |
104 // the bubble from reshowing. | 102 // the bubble from reshowing. |
105 bool suppress_mouse_released_action_; | 103 bool suppress_mouse_released_action_; |
106 | 104 |
107 // Animation delegate for the ink drop ripple effect. | 105 // Animation delegate for the ink drop ripple effect. |
108 scoped_ptr<views::InkDropDelegate> ink_drop_delegate_; | 106 scoped_ptr<views::InkDropDelegate> ink_drop_delegate_; |
109 | 107 |
110 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView); | 108 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView); |
111 }; | 109 }; |
112 | 110 |
113 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_ | 111 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_ |
OLD | NEW |