[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / views / toolbar / wrench_toolbar_button.cc
blobc3c5d7dbadcfd1f634906ba0fbcbb8eb26add41c
1 // Copyright 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 #include "chrome/browser/ui/views/toolbar/wrench_toolbar_button.h"
7 #include "grit/theme_resources.h"
8 #include "ui/base/resource/resource_bundle.h"
9 #include "ui/base/theme_provider.h"
11 WrenchToolbarButton::WrenchToolbarButton(views::MenuButtonListener* listener)
12 : views::MenuButton(NULL, base::string16(), listener, false) {
13 wrench_icon_painter_.reset(new WrenchIconPainter(this));
15 // Used for sizing only.
16 ui::ResourceBundle& rb = ResourceBundle::GetSharedInstance();
17 SetIcon(*rb.GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER));
20 WrenchToolbarButton::~WrenchToolbarButton() {
23 void WrenchToolbarButton::SetSeverity(WrenchIconPainter::Severity severity,
24 bool animate) {
25 wrench_icon_painter_->SetSeverity(severity, animate);
28 void WrenchToolbarButton::OnPaint(gfx::Canvas* canvas) {
29 wrench_icon_painter_->Paint(
30 canvas, GetThemeProvider(), gfx::Rect(size()), GetCurrentBezelType());
31 views::Painter::PaintFocusPainter(this, canvas, focus_painter());
34 void WrenchToolbarButton::ScheduleWrenchIconPaint() {
35 SchedulePaint();
38 WrenchIconPainter::BezelType WrenchToolbarButton::GetCurrentBezelType() const {
39 switch (state()) {
40 case STATE_HOVERED:
41 return WrenchIconPainter::BEZEL_HOVER;
42 case STATE_PRESSED:
43 return WrenchIconPainter::BEZEL_PRESSED;
44 default:
45 return WrenchIconPainter::BEZEL_NONE;