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

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

Issue 795053003: [Password Manager] Close the bubble when fullscreen state gets change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses Peter's review comments. Created 6 years 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_ZOOM_BUBBLE_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/gtest_prod_util.h" 9 #include "base/gtest_prod_util.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
11 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 11 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
12 #include "chrome/browser/ui/views/managed_full_screen_bubble_delegate_view.h"
12 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
14 #include "extensions/browser/extension_icon_image.h" 15 #include "extensions/browser/extension_icon_image.h"
15 #include "ui/views/bubble/bubble_delegate.h" 16 #include "ui/views/bubble/bubble_delegate.h"
16 #include "ui/views/controls/button/button.h" 17 #include "ui/views/controls/button/button.h"
17 #include "ui/views/controls/label.h" 18 #include "ui/views/controls/label.h"
18 19
19 class FullscreenController; 20 class FullscreenController;
20 21
21 namespace content { 22 namespace content {
22 class NotificationDetails; 23 class NotificationDetails;
23 class NotificationSource; 24 class NotificationSource;
24 class WebContents; 25 class WebContents;
25 } 26 }
26 27
27 namespace views { 28 namespace views {
28 class ImageButton; 29 class ImageButton;
29 } // namespace views 30 } // namespace views
30 31
31 // View used to display the zoom percentage when it has changed. 32 // View used to display the zoom percentage when it has changed.
32 class ZoomBubbleView : public views::BubbleDelegateView, 33 class ZoomBubbleView : public ManagedFullScreenBubbleDelegateView,
33 public views::ButtonListener, 34 public views::ButtonListener,
34 public content::NotificationObserver,
35 public ImmersiveModeController::Observer, 35 public ImmersiveModeController::Observer,
36 public extensions::IconImage::Observer { 36 public extensions::IconImage::Observer {
37 public: 37 public:
38 // Shows the bubble and automatically closes it after a short time period if 38 // Shows the bubble and automatically closes it after a short time period if
39 // |auto_close| is true. 39 // |auto_close| is true.
40 static void ShowBubble(content::WebContents* web_contents, 40 static void ShowBubble(content::WebContents* web_contents,
41 bool auto_close); 41 bool auto_close);
42 42
43 // Closes the showing bubble (if one exists). 43 // Closes the showing bubble (if one exists).
44 static void CloseBubble(); 44 static void CloseBubble();
45 45
46 // Whether the zoom bubble is currently showing. 46 // Whether the zoom bubble is currently showing.
47 static bool IsShowing(); 47 static bool IsShowing();
48 48
49 // Returns the zoom bubble if the zoom bubble is showing. Returns NULL 49 // Returns the zoom bubble if the zoom bubble is showing. Returns NULL
50 // otherwise. 50 // otherwise.
51 static const ZoomBubbleView* GetZoomBubbleForTest(); 51 static const ZoomBubbleView* GetZoomBubbleForTest();
52 52
53 private: 53 private:
54 FRIEND_TEST_ALL_PREFIXES(ZoomBubbleBrowserTest, ImmersiveFullscreen); 54 FRIEND_TEST_ALL_PREFIXES(ZoomBubbleBrowserTest, ImmersiveFullscreen);
55 55
56 // Stores information about the extension that initiated the zoom change, if
57 // any.
58 struct ZoomBubbleExtensionInfo {
59 ZoomBubbleExtensionInfo();
60 ~ZoomBubbleExtensionInfo();
61
62 // The unique id of the extension, which is used to find the correct
63 // extension after clicking on the image button in the zoom bubble.
64 std::string id;
65
66 // The name of the extension, which appears in the tooltip of the image
67 // button in the zoom bubble.
68 std::string name;
69
70 // An image of the extension's icon, which appears in the zoom bubble as an
71 // image button.
72 scoped_ptr<const extensions::IconImage> icon_image;
73 };
74
75 ZoomBubbleView(views::View* anchor_view, 56 ZoomBubbleView(views::View* anchor_view,
76 content::WebContents* web_contents, 57 content::WebContents* web_contents,
77 bool auto_close, 58 bool auto_close,
78 ImmersiveModeController* immersive_mode_controller, 59 ImmersiveModeController* immersive_mode_controller,
79 FullscreenController* fullscreen_controller); 60 FullscreenController* fullscreen_controller);
80 ~ZoomBubbleView() override; 61 ~ZoomBubbleView() override;
81 62
82 // If the bubble is not anchored to a view, places the bubble in the top 63 // views::View methods.
Peter Kasting 2014/12/23 00:49:02 Since you're trying to clean this stuff up anyway,
Pritam Nikam 2014/12/23 06:22:29 Done.
83 // right (left in RTL) of the |screen_bounds| that contain |web_contents_|'s 64 void OnMouseEntered(const ui::MouseEvent& event) override;
84 // browser window. Because the positioning is based on the size of the 65 void OnMouseExited(const ui::MouseEvent& event) override;
85 // bubble, this must be called after the bubble is created. 66
86 void AdjustForFullscreen(const gfx::Rect& screen_bounds); 67 // views::BubbleDelegateView method.
68 void Init() override;
69 void WindowClosing() override;
70
71 // ManagedFullScreenBubbleDelegateView:
72 using ManagedFullScreenBubbleDelegateView::AdjustForFullscreen;
Peter Kasting 2014/12/23 00:49:02 Don't do this, just make the method public in the
Pritam Nikam 2014/12/23 06:22:29 Done.
73 void Close() override;
74
75 // ui::EventHandler method.
76 void OnGestureEvent(ui::GestureEvent* event) override;
77
78 // views::ButtonListener method.
79 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
80
81 // ImmersiveModeController::Observer methods.
82 void OnImmersiveRevealStarted() override;
83 void OnImmersiveModeControllerDestroyed() override;
84
85 // extensions::IconImage::Observer overrides:
86 void OnExtensionIconImageChanged(extensions::IconImage* /* image */) override;
87 87
88 // Refreshes the bubble by changing the zoom percentage appropriately and 88 // Refreshes the bubble by changing the zoom percentage appropriately and
89 // resetting the timer if necessary. 89 // resetting the timer if necessary.
90 void Refresh(); 90 void Refresh();
91 91
92 void Close();
93
94 // Sets information about the extension that initiated the zoom change. 92 // Sets information about the extension that initiated the zoom change.
95 // Calling this method asserts that the extension |extension| did initiate 93 // Calling this method asserts that the extension |extension| did initiate
96 // the zoom change. 94 // the zoom change.
97 void SetExtensionInfo(const extensions::Extension* extension); 95 void SetExtensionInfo(const extensions::Extension* extension);
98 96
99 // Starts a timer which will close the bubble if |auto_close_| is true. 97 // Starts a timer which will close the bubble if |auto_close_| is true.
100 void StartTimerIfNecessary(); 98 void StartTimerIfNecessary();
101 99
102 // Stops the auto-close timer. 100 // Stops the auto-close timer.
103 void StopTimer(); 101 void StopTimer();
104 102
105 // extensions::IconImage::Observer overrides: 103 // Stores information about the extension that initiated the zoom change, if
106 void OnExtensionIconImageChanged(extensions::IconImage* /* image */) override; 104 // any.
105 struct ZoomBubbleExtensionInfo {
Peter Kasting 2014/12/23 00:49:02 Member structs/classes should probably go above me
Pritam Nikam 2014/12/23 06:22:29 Done.
106 ZoomBubbleExtensionInfo();
107 ~ZoomBubbleExtensionInfo();
107 108
108 // views::View methods. 109 // The unique id of the extension, which is used to find the correct
109 void OnMouseEntered(const ui::MouseEvent& event) override; 110 // extension after clicking on the image button in the zoom bubble.
110 void OnMouseExited(const ui::MouseEvent& event) override; 111 std::string id;
111 112
112 // ui::EventHandler method. 113 // The name of the extension, which appears in the tooltip of the image
113 void OnGestureEvent(ui::GestureEvent* event) override; 114 // button in the zoom bubble.
115 std::string name;
114 116
115 // views::ButtonListener method. 117 // An image of the extension's icon, which appears in the zoom bubble as an
116 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 118 // image button.
117 119 scoped_ptr<const extensions::IconImage> icon_image;
118 // views::BubbleDelegateView method. 120 };
119 void Init() override;
120 void WindowClosing() override;
121
122 // content::NotificationObserver method.
123 void Observe(int type,
124 const content::NotificationSource& source,
125 const content::NotificationDetails& details) override;
126
127 // ImmersiveModeController::Observer methods.
128 void OnImmersiveRevealStarted() override;
129 void OnImmersiveModeControllerDestroyed() override;
130 121
131 ZoomBubbleExtensionInfo extension_info_; 122 ZoomBubbleExtensionInfo extension_info_;
132 123
133 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on 124 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on
134 // the active browser window, so there is no case in which it will be shown 125 // the active browser window, so there is no case in which it will be shown
135 // twice at the same time. 126 // twice at the same time.
136 static ZoomBubbleView* zoom_bubble_; 127 static ZoomBubbleView* zoom_bubble_;
137 128
138 // Timer used to close the bubble when |auto_close_| is true. 129 // Timer used to close the bubble when |auto_close_| is true.
139 base::OneShotTimer<ZoomBubbleView> timer_; 130 base::OneShotTimer<ZoomBubbleView> timer_;
(...skipping 10 matching lines...) Expand all
150 content::WebContents* web_contents_; 141 content::WebContents* web_contents_;
151 142
152 // Whether the currently displayed bubble will automatically close. 143 // Whether the currently displayed bubble will automatically close.
153 bool auto_close_; 144 bool auto_close_;
154 145
155 // The immersive mode controller for the BrowserView containing 146 // The immersive mode controller for the BrowserView containing
156 // |web_contents_|. 147 // |web_contents_|.
157 // Not owned. 148 // Not owned.
158 ImmersiveModeController* immersive_mode_controller_; 149 ImmersiveModeController* immersive_mode_controller_;
159 150
160 // Used to register for fullscreen change notifications.
161 content::NotificationRegistrar registrar_;
162
163 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); 151 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView);
164 }; 152 };
165 153
166 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ 154 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698