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

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

Issue 2668833003: DialogBrowserTest implementation to invoke Content settings bubble dialogs. (Closed)
Patch Set: Fixed Cocoa build Created 3 years, 10 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" 18 #include "ui/views/widget/widget_observer.h"
19 19
20 class ContentSettingImageModel; 20 class ContentSettingImageModel;
21 class LocationBarView; 21 class LocationBarView;
22 class ContentSettingBubbleDialogTest;
tapted 2017/02/03 00:35:40 nit: sort (but, also, since they share a namespac
kylix_rd 2017/02/03 18:55:04 Done.
22 23
23 namespace content { 24 namespace content {
24 class WebContents; 25 class WebContents;
25 } 26 }
26 27
27 namespace gfx { 28 namespace gfx {
28 class FontList; 29 class FontList;
29 } 30 }
30 31
31 namespace views { 32 namespace views {
32 class BubbleDialogDelegateView; 33 class BubbleDialogDelegateView;
33 } 34 }
34 35
35 // The ContentSettingImageView displays an icon and optional text label for 36 // The ContentSettingImageView displays an icon and optional text label for
36 // various content settings affordances in the location bar (i.e. plugin 37 // various content settings affordances in the location bar (i.e. plugin
37 // blocking, geolocation). 38 // blocking, geolocation).
38 class ContentSettingImageView : public IconLabelBubbleView, 39 class ContentSettingImageView : public IconLabelBubbleView,
39 public gfx::AnimationDelegate, 40 public gfx::AnimationDelegate,
40 public views::WidgetObserver { 41 public views::WidgetObserver {
41 public: 42 public:
42 ContentSettingImageView(std::unique_ptr<ContentSettingImageModel> image_model, 43 ContentSettingImageView(std::unique_ptr<ContentSettingImageModel> image_model,
43 LocationBarView* parent, 44 LocationBarView* parent,
44 const gfx::FontList& font_list); 45 const gfx::FontList& font_list);
45 ~ContentSettingImageView() override; 46 ~ContentSettingImageView() override;
46 47
47 // Updates the decoration from the shown WebContents. 48 // Updates the decoration from the shown WebContents.
48 void Update(content::WebContents* web_contents); 49 void Update(content::WebContents* web_contents);
49 50
51 // For testing. Return this view's ContentSettingImageModel.
52 ContentSettingImageModel* content_setting_image_model() {
53 return content_setting_image_model_.get();
54 }
55
50 private: 56 private:
57 friend class ContentSettingBubbleDialogTest;
58
51 // 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
52 // intervening "stay open" period. 60 // intervening "stay open" period.
53 static const int kAnimationDurationMS; 61 static const int kAnimationDurationMS;
54 62
55 // IconLabelBubbleView: 63 // IconLabelBubbleView:
56 const char* GetClassName() const override; 64 const char* GetClassName() const override;
57 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; 65 void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
58 bool OnMousePressed(const ui::MouseEvent& event) override; 66 bool OnMousePressed(const ui::MouseEvent& event) override;
59 void OnMouseReleased(const ui::MouseEvent& event) override; 67 void OnMouseReleased(const ui::MouseEvent& event) override;
60 void OnGestureEvent(ui::GestureEvent* event) override; 68 void OnGestureEvent(ui::GestureEvent* event) override;
(...skipping 12 matching lines...) Expand all
73 void AnimationProgressed(const gfx::Animation* animation) override; 81 void AnimationProgressed(const gfx::Animation* animation) override;
74 void AnimationCanceled(const gfx::Animation* animation) override; 82 void AnimationCanceled(const gfx::Animation* animation) override;
75 83
76 // views::WidgetObserver: 84 // views::WidgetObserver:
77 void OnWidgetDestroying(views::Widget* widget) override; 85 void OnWidgetDestroying(views::Widget* widget) override;
78 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; 86 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override;
79 87
80 // Updates the image and tooltip to match the current model state. 88 // Updates the image and tooltip to match the current model state.
81 void UpdateImage(); 89 void UpdateImage();
82 90
91 // Return the currently active bubble dialog. Used for testing.
92 views::BubbleDialogDelegateView* bubble_view() {
tapted 2017/02/03 00:35:40 This shouldn't be necessary here (a private access
kylix_rd 2017/02/03 18:55:04 I figured that with the inline method, it would co
tapted 2017/02/03 23:07:02 This violates https://chromium.googlesource.com/ch
93 return bubble_view_;
94 }
95
83 LocationBarView* parent_; // Weak, owns us. 96 LocationBarView* parent_; // Weak, owns us.
84 std::unique_ptr<ContentSettingImageModel> content_setting_image_model_; 97 std::unique_ptr<ContentSettingImageModel> content_setting_image_model_;
85 gfx::SlideAnimation slide_animator_; 98 gfx::SlideAnimation slide_animator_;
86 bool pause_animation_; 99 bool pause_animation_;
87 double pause_animation_state_; 100 double pause_animation_state_;
88 views::BubbleDialogDelegateView* bubble_view_; 101 views::BubbleDialogDelegateView* bubble_view_;
89 102
90 // This is used to check if the bubble was showing during the mouse pressed 103 // 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 104 // event. If this is true then the mouse released event is ignored to prevent
92 // the bubble from reshowing. 105 // the bubble from reshowing.
93 bool suppress_mouse_released_action_; 106 bool suppress_mouse_released_action_;
94 107
95 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView); 108 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView);
96 }; 109 };
97 110
98 #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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698