blob: 34287ad421e53d3bfa14b3a1fd23a479d87632a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_
#include "base/basictypes.h"
#include "base/timer.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/text_button.h"
#include "ui/views/controls/label.h"
namespace content {
class WebContents;
}
// View used to display the zoom percentage when it has changed.
class ZoomBubbleView : public views::BubbleDelegateView,
public views::ButtonListener {
public:
// Shows the bubble and automatically closes it after a short time period if
// |auto_close| is true.
static void ShowBubble(views::View* anchor_view,
content::WebContents* web_contents,
bool auto_close);
// Closes the showing bubble (if one exists).
static void CloseBubble();
// Whether the zoom bubble is currently showing.
static bool IsShowing();
private:
ZoomBubbleView(views::View* anchor_view,
content::WebContents* web_contents,
bool auto_close);
virtual ~ZoomBubbleView();
// Refreshes the bubble by changing the zoom percentage appropriately and
// resetting the timer if necessary.
void Refresh();
void Close();
// Starts a timer which will close the bubble if |auto_close_| is true.
void StartTimerIfNecessary();
// Stops the auto-close timer.
void StopTimer();
// views::View method.
virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
// ui::EventHandler method.
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
// views::ButtonListener method.
virtual void ButtonPressed(views::Button* sender,
const ui::Event& event) OVERRIDE;
// views::BubbleDelegateView method.
virtual void Init() OVERRIDE;
virtual void WindowClosing() OVERRIDE;
// Singleton instance of the zoom bubble. The zoom bubble can only be shown on
// the active browser window, so there is no case in which it will be shown
// twice at the same time.
static ZoomBubbleView* zoom_bubble_;
// Timer used to close the bubble when |auto_close_| is true.
base::OneShotTimer<ZoomBubbleView> timer_;
// Label displaying the zoom percentage.
views::Label* label_;
// The WebContents for the page whose zoom has changed.
content::WebContents* web_contents_;
// Whether the currently displayed bubble will automatically close.
bool auto_close_;
DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView);
};
#endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_
|