Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / gtk / zoom_bubble_gtk.h
blob355109ffcf7356617939d8cfc8501134e36aff4c
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_GTK_ZOOM_BUBBLE_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_ZOOM_BUBBLE_GTK_H_
8 #include <gtk/gtk.h>
10 #include "base/basictypes.h"
11 #include "base/timer/timer.h"
12 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
15 #include "ui/base/gtk/gtk_signal.h"
17 typedef struct _GtkWidget GtkWidget;
19 class FullscreenController;
21 namespace content {
22 class NotificationDetails;
23 class NotificationSource;
24 class WebContents;
27 class ZoomBubbleGtk : public content::NotificationObserver {
28 public:
29 // Shows the zoom bubble below |anchor_widget| with an arrow pointing at
30 // |anchor_widget|. If |anchor_widget| is a toplevel window, the bubble will
31 // fixed positioned in the top right of corner of the widget with no arrow.
32 static void ShowBubble(content::WebContents* web_contents,
33 bool auto_close);
35 // Whether the zoom bubble is currently showing.
36 static bool IsShowing();
38 // Closes the zoom bubble (if there is one).
39 static void CloseBubble();
41 private:
42 ZoomBubbleGtk(GtkWidget* anchor,
43 content::WebContents* web_contents,
44 bool auto_close,
45 FullscreenController* fullscreen_controller);
47 virtual ~ZoomBubbleGtk();
49 // content::NotificationObserver:
50 virtual void Observe(int type,
51 const content::NotificationSource& source,
52 const content::NotificationDetails& details) OVERRIDE;
54 // Convenience method to start |timer_| if |auto_close_| is true.
55 void StartTimerIfNecessary();
57 // Stops any close timer if |timer_| is currently running.
58 void StopTimerIfNecessary();
60 // Refreshes the bubble by changing the zoom percentage appropriately and
61 // resetting the timer if necessary.
62 void Refresh();
64 // Closes the zoom bubble.
65 void Close();
67 // Notified when the bubble is destroyed so this instance can be deleted.
68 CHROMEGTK_CALLBACK_0(ZoomBubbleGtk, void, OnDestroy);
70 // Fired when the reset link is clicked.
71 CHROMEGTK_CALLBACK_0(ZoomBubbleGtk, void, OnSetDefaultLinkClick);
73 // Fired when the mouse enters or leaves the widget.
74 CHROMEGTK_CALLBACK_1(ZoomBubbleGtk, gboolean, OnMouseEnter,
75 GdkEventCrossing*);
76 CHROMEGTK_CALLBACK_1(ZoomBubbleGtk, gboolean, OnMouseLeave,
77 GdkEventCrossing*);
79 // Whether the currently displayed bubble will automatically close.
80 bool auto_close_;
82 // Whether the mouse is currently inside the bubble.
83 bool mouse_inside_;
85 // Timer used to close the bubble when |auto_close_| is true.
86 base::OneShotTimer<ZoomBubbleGtk> timer_;
88 // The WebContents for the page whose zoom has changed.
89 content::WebContents* web_contents_;
91 // An event box that wraps the content of the bubble.
92 GtkWidget* event_box_;
94 // Label showing zoom percentage.
95 GtkWidget* label_;
97 // The BubbleGtk object containing the zoom bubble's content.
98 BubbleGtk* bubble_;
100 // Used to register for fullscreen change notifications.
101 content::NotificationRegistrar registrar_;
103 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleGtk);
106 #endif // CHROME_BROWSER_UI_GTK_ZOOM_BUBBLE_GTK_H_