Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / location_bar / zoom_decoration.h
blobd8b540fc3b4a3a7ae0a15716720b2ff6a05633ab
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;
16 class ZoomDecorationTest;
18 namespace ui_zoom {
19 class ZoomController;
22 // Zoom icon at the end of the omnibox (close to page actions) when at a
23 // non-standard zoom level.
24 class ZoomDecoration : public ImageDecoration,
25 public ZoomBubbleControllerDelegate {
26 public:
27 explicit ZoomDecoration(LocationBarViewMac* owner);
28 ~ZoomDecoration() override;
30 // Called when this decoration should show or hide itself in its most current
31 // state. Returns whether any updates were made.
32 bool UpdateIfNecessary(ui_zoom::ZoomController* zoom_controller,
33 bool default_zoom_changed);
35 // Shows the zoom bubble for this decoration. If |auto_close| is YES, then
36 // the bubble will automatically close after a fixed period of time.
37 // If a bubble is already showing, the |auto_close| timer is reset.
38 void ShowBubble(BOOL auto_close);
40 // Closes the zoom bubble.
41 void CloseBubble();
43 protected:
44 // Hides all UI associated with the zoom decoration.
45 // Virtual and protected for testing.
46 virtual void HideUI();
48 // Show and update UI associated with the zoom decoration.
49 // Virtual and protected for testing.
50 virtual void ShowAndUpdateUI(ui_zoom::ZoomController* zoom_controller,
51 NSString* tooltip_string);
53 private:
54 friend ZoomDecorationTest;
56 bool IsAtDefaultZoom() const;
58 // Virtual for testing.
59 virtual bool ShouldShowDecoration() const;
61 // LocationBarDecoration implementation.
62 bool AcceptsMousePress() override;
63 bool OnMousePressed(NSRect frame, NSPoint location) override;
64 NSString* GetToolTip() override;
65 NSPoint GetBubblePointInFrame(NSRect frame) override;
67 // ZoomBubbleControllerDelegate implementation.
68 content::WebContents* GetWebContents() override;
69 void OnClose() override;
71 // The control that owns this. Weak.
72 LocationBarViewMac* owner_;
74 // The bubble that this decoration shows. Weak, owns self.
75 ZoomBubbleController* bubble_;
77 // The string to show for a tooltip.
78 base::scoped_nsobject<NSString> tooltip_;
80 DISALLOW_COPY_AND_ASSIGN(ZoomDecoration);
83 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_ZOOM_DECORATION_H_