Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: chrome/browser/ui/views/location_bar/content_setting_image_view.h

Issue 2720183002: [Views] Update ink drop for omnibox icons (Closed)
Patch Set: Removed CanProcessEventsWithinSubtree Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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,
40 public views::WidgetObserver {
41 public: 38 public:
42 ContentSettingImageView(std::unique_ptr<ContentSettingImageModel> image_model, 39 ContentSettingImageView(std::unique_ptr<ContentSettingImageModel> image_model,
43 LocationBarView* parent, 40 LocationBarView* parent,
44 const gfx::FontList& font_list); 41 const gfx::FontList& font_list);
45 ~ContentSettingImageView() override; 42 ~ContentSettingImageView() override;
46 43
47 // Updates the decoration from the shown WebContents. 44 // Updates the decoration from the shown WebContents.
48 void Update(content::WebContents* web_contents); 45 void Update(content::WebContents* web_contents);
49 46
50 private: 47 private:
51 // The total animation time, including open and close as well as an 48 // The total animation time, including open and close as well as an
52 // intervening "stay open" period. 49 // intervening "stay open" period.
53 static const int kAnimationDurationMS; 50 static const int kAnimationDurationMS;
54 51
55 // IconLabelBubbleView: 52 // IconLabelBubbleView:
56 const char* GetClassName() const override; 53 const char* GetClassName() const override;
57 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; 54 void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
58 bool OnMousePressed(const ui::MouseEvent& event) override;
59 void OnMouseReleased(const ui::MouseEvent& event) override;
60 void OnGestureEvent(ui::GestureEvent* event) override;
61 bool GetTooltipText(const gfx::Point& p, 55 bool GetTooltipText(const gfx::Point& p,
62 base::string16* tooltip) const override; 56 base::string16* tooltip) const override;
63 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override; 57 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override;
64 std::unique_ptr<views::InkDrop> CreateInkDrop() override;
65 SkColor GetTextColor() const override; 58 SkColor GetTextColor() const override;
66 bool ShouldShowLabel() const override; 59 bool ShouldShowLabel() const override;
67 double WidthMultiplier() const override; 60 double WidthMultiplier() const override;
68 bool IsShrinking() const override; 61 bool IsShrinking() const override;
69 bool OnActivate(const ui::Event& event) override; 62 bool ShowBubble(const ui::Event& event) override;
63 bool IsBubbleShowing() const override;
70 64
71 // gfx::AnimationDelegate: 65 // gfx::AnimationDelegate:
72 void AnimationEnded(const gfx::Animation* animation) override; 66 void AnimationEnded(const gfx::Animation* animation) override;
73 void AnimationProgressed(const gfx::Animation* animation) override; 67 void AnimationProgressed(const gfx::Animation* animation) override;
74 void AnimationCanceled(const gfx::Animation* animation) override; 68 void AnimationCanceled(const gfx::Animation* animation) override;
75 69
76 // views::WidgetObserver: 70 // views::WidgetObserver:
77 void OnWidgetDestroying(views::Widget* widget) override; 71 void OnWidgetDestroying(views::Widget* widget) override;
78 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; 72 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override;
79 73
80 // Updates the image and tooltip to match the current model state. 74 // Updates the image and tooltip to match the current model state.
81 void UpdateImage(); 75 void UpdateImage();
82 76
77 // Animates the view in and disables highlighting for hover and focus.
78 // TODO(bruthig): See crbug.com/669253. Since the ink drop highlight currently
79 // cannot handle host resizes, the highlight needs to be disabled when the
80 // animation is running.
81 void AnimateIn();
82
83 LocationBarView* parent_; // Weak, owns us. 83 LocationBarView* parent_; // Weak, owns us.
84 std::unique_ptr<ContentSettingImageModel> content_setting_image_model_; 84 std::unique_ptr<ContentSettingImageModel> content_setting_image_model_;
85 gfx::SlideAnimation slide_animator_; 85 gfx::SlideAnimation slide_animator_;
86 bool pause_animation_; 86 bool pause_animation_;
87 double pause_animation_state_; 87 double pause_animation_state_;
88 views::BubbleDialogDelegateView* bubble_view_; 88 views::BubbleDialogDelegateView* bubble_view_;
89 89
90 // 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
92 // the bubble from reshowing.
93 bool suppress_mouse_released_action_;
94
95 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView); 90 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView);
96 }; 91 };
97 92
98 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_ 93 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698