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

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

Powered by Google App Engine
This is Rietveld 408576698