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.
5 #ifndef CHROME_BROWSER_UI_COCOA_BROWSER_ZOOM_BUBBLE_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_BROWSER_ZOOM_BUBBLE_CONTROLLER_H_
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"
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
20 @interface ZoomBubbleController : BaseBubbleController {
22 // The contents for which the zoom percent is being displayed.
23 content::WebContents* contents_;
25 // Whether or not the bubble should automatically close itself after being
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_;
33 // The text field that displays the current zoom percentage.
34 base::scoped_nsobject<NSTextField> zoomPercent_;
36 // Whether or not the mouse is over the bubble.
39 // Used to prevent the bubble from auto-closing while the mouse is inside it.
40 ui::ScopedCrTrackingArea trackingArea_;
43 // Creates the bubble for a parent window but does not show it.
44 - (id)initWithParentWindow:(NSWindow*)parentWindow
45 closeObserver:(void(^)(ZoomBubbleController*))closeObserver;
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;
55 // Called by the ZoomDecoration when the zoom percentage changes.
56 - (void)onZoomChanged;
58 // Button action from the bubble that resets the zoom level to the default.
59 - (void)resetToDefault:(id)sender;
61 // Button action from the bubble that increases the zoom level.
62 - (void)zoomIn:(id)sender;
64 // Button action from the bubble that decreases the zoom level.
65 - (void)zoomOut:(id)sender;
67 // Closes the bubble synchronously, bypassing any animations.
68 - (void)closeWithoutAnimation;
74 void SetZoomBubbleAutoCloseDelayForTesting(NSTimeInterval time_interval);
78 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_ZOOM_BUBBLE_CONTROLLER_H_