Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / views / toolbar / wrench_toolbar_button.cc
blob4271129c99599da9cb9e395673f1bc8cc6240617
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 // Badge linux aura builds so they're quickly identifiable.
30 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
31 wrench_icon_painter_->set_badge(
32 *GetThemeProvider()->GetImageSkiaNamed(IDR_TOOLS_BADGE_AURA));
33 #endif
35 wrench_icon_painter_->Paint(
36 canvas, GetThemeProvider(), gfx::Rect(size()), GetCurrentBezelType());
37 views::Painter::PaintFocusPainter(this, canvas, focus_painter());
40 void WrenchToolbarButton::ScheduleWrenchIconPaint() {
41 SchedulePaint();
44 WrenchIconPainter::BezelType WrenchToolbarButton::GetCurrentBezelType() const {
45 switch (state()) {
46 case STATE_HOVERED:
47 return WrenchIconPainter::BEZEL_HOVER;
48 case STATE_PRESSED:
49 return WrenchIconPainter::BEZEL_PRESSED;
50 default:
51 return WrenchIconPainter::BEZEL_NONE;