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

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

Issue 301733006: Zoom Extension API (chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add event manager for manual zoom events. Created 6 years, 6 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 | Annotate | Revision Log
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/timer/timer.h" 9 #include "base/timer/timer.h"
10 #include "chrome/browser/extensions/extension_icon_image.h"
10 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 11 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
11 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
13 #include "ui/views/bubble/bubble_delegate.h" 14 #include "ui/views/bubble/bubble_delegate.h"
14 #include "ui/views/controls/button/button.h" 15 #include "ui/views/controls/button/button.h"
16 #include "ui/views/controls/button/image_button.h"
Devlin 2014/06/16 19:04:49 Why do you need the full include?
wjmaclean 2014/06/18 19:03:54 Done.
15 #include "ui/views/controls/label.h" 17 #include "ui/views/controls/label.h"
16 18
17 class FullscreenController; 19 class FullscreenController;
18 20
19 namespace content { 21 namespace content {
20 class NotificationDetails; 22 class NotificationDetails;
21 class NotificationSource; 23 class NotificationSource;
22 class WebContents; 24 class WebContents;
23 } 25 }
24 26
25 // View used to display the zoom percentage when it has changed. 27 // View used to display the zoom percentage when it has changed.
26 class ZoomBubbleView : public views::BubbleDelegateView, 28 class ZoomBubbleView : public views::BubbleDelegateView,
27 public views::ButtonListener, 29 public views::ButtonListener,
28 public content::NotificationObserver, 30 public content::NotificationObserver,
29 public ImmersiveModeController::Observer { 31 public ImmersiveModeController::Observer,
32 public extensions::IconImage::Observer {
30 public: 33 public:
31 // Shows the bubble and automatically closes it after a short time period if 34 // Shows the bubble and automatically closes it after a short time period if
32 // |auto_close| is true. 35 // |auto_close| is true.
33 static void ShowBubble(content::WebContents* web_contents, 36 static void ShowBubble(content::WebContents* web_contents,
34 bool auto_close); 37 bool auto_close);
35 38
36 // Closes the showing bubble (if one exists). 39 // Closes the showing bubble (if one exists).
37 static void CloseBubble(); 40 static void CloseBubble();
38 41
39 // Whether the zoom bubble is currently showing. 42 // Whether the zoom bubble is currently showing.
(...skipping 16 matching lines...) Expand all
56 // browser window. Because the positioning is based on the size of the 59 // browser window. Because the positioning is based on the size of the
57 // bubble, this must be called after the bubble is created. 60 // bubble, this must be called after the bubble is created.
58 void AdjustForFullscreen(const gfx::Rect& screen_bounds); 61 void AdjustForFullscreen(const gfx::Rect& screen_bounds);
59 62
60 // Refreshes the bubble by changing the zoom percentage appropriately and 63 // Refreshes the bubble by changing the zoom percentage appropriately and
61 // resetting the timer if necessary. 64 // resetting the timer if necessary.
62 void Refresh(); 65 void Refresh();
63 66
64 void Close(); 67 void Close();
65 68
69 // Sets information about the extension that initiated the zoom change.
70 // Calling this method asserts that the extension |extension| did initiate
71 // the zoom change.
72 void SetExtensionInfo(const extensions::Extension* extension);
73
66 // Starts a timer which will close the bubble if |auto_close_| is true. 74 // Starts a timer which will close the bubble if |auto_close_| is true.
67 void StartTimerIfNecessary(); 75 void StartTimerIfNecessary();
68 76
69 // Stops the auto-close timer. 77 // Stops the auto-close timer.
70 void StopTimer(); 78 void StopTimer();
71 79
80 // extensions::IconImage::Observer overrides:
81 virtual void OnExtensionIconImageChanged(
82 extensions::IconImage* image) OVERRIDE;
83
72 // views::View methods. 84 // views::View methods.
73 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; 85 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
74 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; 86 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
75 87
76 // ui::EventHandler method. 88 // ui::EventHandler method.
77 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; 89 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
78 90
79 // views::ButtonListener method. 91 // views::ButtonListener method.
80 virtual void ButtonPressed(views::Button* sender, 92 virtual void ButtonPressed(views::Button* sender,
81 const ui::Event& event) OVERRIDE; 93 const ui::Event& event) OVERRIDE;
82 94
83 // views::BubbleDelegateView method. 95 // views::BubbleDelegateView method.
84 virtual void Init() OVERRIDE; 96 virtual void Init() OVERRIDE;
85 virtual void WindowClosing() OVERRIDE; 97 virtual void WindowClosing() OVERRIDE;
86 98
87 // content::NotificationObserver method. 99 // content::NotificationObserver method.
88 virtual void Observe(int type, 100 virtual void Observe(int type,
89 const content::NotificationSource& source, 101 const content::NotificationSource& source,
90 const content::NotificationDetails& details) OVERRIDE; 102 const content::NotificationDetails& details) OVERRIDE;
91 103
92 // ImmersiveModeController::Observer methods. 104 // ImmersiveModeController::Observer methods.
93 virtual void OnImmersiveRevealStarted() OVERRIDE; 105 virtual void OnImmersiveRevealStarted() OVERRIDE;
94 virtual void OnImmersiveModeControllerDestroyed() OVERRIDE; 106 virtual void OnImmersiveModeControllerDestroyed() OVERRIDE;
95 107
108 // Stores information about the extension that initiated the zoom change, if
109 // any.
110 struct ExtensionInfo {
Devlin 2014/06/16 19:04:49 Appropriate name, but please don't add another Ext
wjmaclean 2014/06/18 19:03:54 Done. Let me know if the new name, "ZoomBubbleExt
111 ExtensionInfo();
112 ~ExtensionInfo();
113
114 // The unique id of the extension, which is used to find the correct
115 // extension after clicking on the image button in the zoom bubble.
116 std::string id;
117
118 // The name of the extension, which appears in the tooltip of the image
119 // button in the zoom bubble.
120 std::string name;
121
122 // An image of the extension's icon, which appears in the zoom bubble as an
123 // image button.
124 scoped_ptr<const extensions::IconImage> icon_image;
125 } extension_info_;
Devlin 2014/06/16 19:04:49 We don't usually do struct declarations like this.
wjmaclean 2014/06/18 19:03:54 Done.
126
96 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on 127 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on
97 // the active browser window, so there is no case in which it will be shown 128 // the active browser window, so there is no case in which it will be shown
98 // twice at the same time. 129 // twice at the same time.
99 static ZoomBubbleView* zoom_bubble_; 130 static ZoomBubbleView* zoom_bubble_;
100 131
101 // Timer used to close the bubble when |auto_close_| is true. 132 // Timer used to close the bubble when |auto_close_| is true.
102 base::OneShotTimer<ZoomBubbleView> timer_; 133 base::OneShotTimer<ZoomBubbleView> timer_;
103 134
135 // Image button in the zoom bubble that will show the |extension_icon_| image
136 // if an extension initiated the zoom change, and links to that extension at
137 // "chrome://extensions".
138 views::ImageButton* image_button_;
139
104 // Label displaying the zoom percentage. 140 // Label displaying the zoom percentage.
105 views::Label* label_; 141 views::Label* label_;
106 142
107 // The WebContents for the page whose zoom has changed. 143 // The WebContents for the page whose zoom has changed.
108 content::WebContents* web_contents_; 144 content::WebContents* web_contents_;
109 145
110 // Whether the currently displayed bubble will automatically close. 146 // Whether the currently displayed bubble will automatically close.
111 bool auto_close_; 147 bool auto_close_;
112 148
113 // The immersive mode controller for the BrowserView containing 149 // The immersive mode controller for the BrowserView containing
114 // |web_contents_|. 150 // |web_contents_|.
115 // Not owned. 151 // Not owned.
116 ImmersiveModeController* immersive_mode_controller_; 152 ImmersiveModeController* immersive_mode_controller_;
117 153
118 // Used to register for fullscreen change notifications. 154 // Used to register for fullscreen change notifications.
119 content::NotificationRegistrar registrar_; 155 content::NotificationRegistrar registrar_;
120 156
121 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); 157 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView);
122 }; 158 };
123 159
124 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ 160 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698