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_COCOA_LOCATION_BAR_ZOOM_DECORATION_H_
6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_ZOOM_DECORATION_H_
8 #import <Cocoa/Cocoa.h>
10 #include "base/basictypes.h"
11 #import "chrome/browser/ui/cocoa/browser/zoom_bubble_controller.h"
12 #include "chrome/browser/ui/cocoa/location_bar/image_decoration.h"
14 class LocationBarViewMac
;
15 @
class ZoomBubbleController
;
17 class ZoomDecorationTest
;
19 // Zoom icon at the end of the omnibox (close to page actions) when at a
20 // non-standard zoom level.
21 class ZoomDecoration
: public ImageDecoration
,
22 public ZoomBubbleControllerDelegate
{
24 explicit ZoomDecoration(LocationBarViewMac
* owner
);
25 virtual ~ZoomDecoration();
27 // Called when this decoration should show or hide itself in its most current
29 void Update(ZoomController
* zoom_controller
);
31 // Shows the zoom bubble for this decoration. If |auto_close| is YES, then
32 // the bubble will automatically close after a fixed period of time.
33 void ShowBubble(BOOL auto_close
);
35 // Closes the zoom bubble.
39 friend ZoomDecorationTest
;
41 NSPoint
GetBubblePointInFrame(NSRect frame
);
42 bool IsAtDefaultZoom() const;
43 bool ShouldShowDecoration() const;
45 // LocationBarDecoration implementation.
46 virtual bool AcceptsMousePress() OVERRIDE
;
47 virtual bool OnMousePressed(NSRect frame
) OVERRIDE
;
48 virtual NSString
* GetToolTip() OVERRIDE
;
50 // ZoomBubbleControllerDelegate implementation.
51 virtual content::WebContents
* GetWebContents() OVERRIDE
;
52 virtual void OnClose() OVERRIDE
;
54 // The control that owns this. Weak.
55 LocationBarViewMac
* owner_
;
57 // The bubble that this decoration shows. Weak, owns self.
58 ZoomBubbleController
* bubble_
;
60 // The string to show for a tooltip.
61 base::scoped_nsobject
<NSString
> tooltip_
;
63 DISALLOW_COPY_AND_ASSIGN(ZoomDecoration
);
66 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_ZOOM_DECORATION_H_