- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / browser / zoom_bubble_controller.h
1 // Copyright (c) 2013 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.
4
5 #ifndef CHROME_BROWSER_UI_COCOA_BROWSER_ZOOM_BUBBLE_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_BROWSER_ZOOM_BUBBLE_CONTROLLER_H_
7
8 #include "base/mac/scoped_block.h"
9 #include "base/mac/scoped_nsobject.h"
10 #include "chrome/browser/ui/cocoa/base_bubble_controller.h"
11 #import "ui/base/cocoa/tracking_area.h"
12
13 namespace content {
14 class WebContents;
15 }
16
17 // The ZoomBubbleController is used to display the current page zoom percent
18 // when not at the user's default. It is opened by the ZoomDecoration in the
19 // location bar.
20 @interface ZoomBubbleController : BaseBubbleController {
21  @private
22   // The contents for which the zoom percent is being displayed.
23   content::WebContents* contents_;
24
25   // Whether or not the bubble should automatically close itself after being
26   // opened.
27   BOOL autoClose_;
28
29   // A block that is run when the bubble is being closed. This allows any
30   // weak references to be niled.
31   base::mac::ScopedBlock<void(^)(ZoomBubbleController*)> closeObserver_;
32
33   // The text field that displays the current zoom percentage.
34   base::scoped_nsobject<NSTextField> zoomPercent_;
35
36   // Whether or not the mouse is over the bubble.
37   BOOL isMouseInside_;
38
39   // Used to prevent the bubble from auto-closing while the mouse is inside it.
40   ui::ScopedCrTrackingArea trackingArea_;
41 }
42
43 // Creates the bubble for a parent window but does not show it.
44 - (id)initWithParentWindow:(NSWindow*)parentWindow
45              closeObserver:(void(^)(ZoomBubbleController*))closeObserver;
46
47 // Shows the bubble for a given contents at an |anchorPoint| in window
48 // coordinates. If |autoClose| is YES, then the bubble was opened in response
49 // to a zoom change rather than a direct user action, and it will automatically
50 // dismiss itself after a few seconds.
51 - (void)showForWebContents:(content::WebContents*)contents
52                 anchoredAt:(NSPoint)anchorPoint
53                  autoClose:(BOOL)autoClose;
54
55 // Called by the ZoomDecoration when the zoom percentage changes.
56 - (void)onZoomChanged;
57
58 // Button action from the bubble that resets the zoom level to the default.
59 - (void)resetToDefault:(id)sender;
60
61 // Button action from the bubble that increases the zoom level.
62 - (void)zoomIn:(id)sender;
63
64 // Button action from the bubble that decreases the zoom level.
65 - (void)zoomOut:(id)sender;
66
67 // Closes the bubble synchronously, bypassing any animations.
68 - (void)closeWithoutAnimation;
69
70 @end
71
72 namespace chrome {
73
74 void SetZoomBubbleAutoCloseDelayForTesting(NSTimeInterval time_interval);
75
76 }  // namespace chrome
77
78 #endif  // CHROME_BROWSER_UI_COCOA_BROWSER_ZOOM_BUBBLE_CONTROLLER_H_