[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / location_bar / button_decoration.h
blob3306721077e34aa911a94c65ab97c09e799c1005
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_BUTTON_DECORATION_H_
6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_BUTTON_DECORATION_H_
8 #import "base/mac/scoped_nsobject.h"
9 #include "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h"
10 #import "ui/base/cocoa/appkit_utils.h"
12 // |LocationBarDecoration| which looks and acts like a button. It has a
13 // nine-part image as the background, and an icon that is rendered in the center
14 // of the nine-part image.
16 class ButtonDecoration : public LocationBarDecoration {
17 public:
18 enum ButtonState {
19 kButtonStateNormal,
20 kButtonStateHover,
21 kButtonStatePressed
24 // Constructs the ButtonDecoration with the specified background 9-part images
25 // and icons for the three button states. Also takes the maximum number of
26 // pixels of inner horizontal padding to be used between the left/right 9-part
27 // images and the icon.
28 ButtonDecoration(ui::NinePartImageIds normal_image_ids,
29 int normal_icon_id,
30 ui::NinePartImageIds hover_image_ids,
31 int hover_icon_id,
32 ui::NinePartImageIds pressed_image_ids,
33 int pressed_icon_id,
34 CGFloat max_inner_padding);
36 virtual ~ButtonDecoration();
38 void SetButtonState(ButtonState state);
39 ButtonState GetButtonState() const;
41 // Whether a click on this decoration should prevent focusing of the omnibox
42 // or not.
43 virtual bool PreventFocus(NSPoint location) const;
45 // Changes the icon for the specified button state only.
46 void SetIcon(ButtonState state, int icon_id);
48 // Changes the icon for all button states.
49 void SetIcon(int icon_id);
51 // Changes the background image for all button states.
52 void SetBackgroundImageIds(ui::NinePartImageIds normal_image_ids,
53 ui::NinePartImageIds hover_image_ids,
54 ui::NinePartImageIds pressed_image_ids);
56 ui::NinePartImageIds GetBackgroundImageIds() const;
57 NSImage* GetIconImage() const;
59 // Implement |LocationBarDecoration|.
60 virtual CGFloat GetWidthForSpace(CGFloat width) OVERRIDE;
61 virtual void DrawInFrame(NSRect frame, NSView* control_view) OVERRIDE;
62 virtual bool AcceptsMousePress() OVERRIDE;
63 virtual bool IsDraggable() OVERRIDE;
64 virtual bool OnMousePressed(NSRect frame, NSPoint location) OVERRIDE;
65 virtual ButtonDecoration* AsButtonDecoration() OVERRIDE;
67 private:
68 ui::NinePartImageIds normal_image_ids_;
69 ui::NinePartImageIds hover_image_ids_;
70 ui::NinePartImageIds pressed_image_ids_;
71 int normal_icon_id_;
72 int hover_icon_id_;
73 int pressed_icon_id_;
74 ButtonState state_;
75 CGFloat max_inner_padding_;
77 DISALLOW_COPY_AND_ASSIGN(ButtonDecoration);
80 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_BUTTON_DECORATION_H_