Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / views / toolbar / back_button.cc
blob73ae0411c64c06f374cbaab0be52536da6b57451
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/back_button.h"
7 #include "ui/gfx/geometry/insets.h"
8 #include "ui/views/animation/ink_drop_animation_controller.h"
9 #include "ui/views/controls/button/label_button_border.h"
10 #include "ui/views/painter.h"
12 BackButton::BackButton(views::ButtonListener* listener,
13 ui::MenuModel* model)
14 : ToolbarButton(listener, model),
15 margin_leading_(0) {}
17 BackButton::~BackButton() {}
19 void BackButton::SetLeadingMargin(int margin) {
20 margin_leading_ = margin;
22 UpdateThemedBorder();
24 // Similarly fiddle the focus border. Value consistent with LabelButton.
25 // TODO(gbillock): Refactor this magic number somewhere global to views,
26 // probably a FocusBorder constant.
27 const int kFocusRectInset = 3;
28 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets(
29 gfx::Insets(kFocusRectInset, kFocusRectInset + margin,
30 kFocusRectInset, kFocusRectInset)));
32 InvalidateLayout();
35 void BackButton::LayoutInkDrop() {
36 ink_drop_animation_controller()->SetInkDropBounds(
37 gfx::Rect(margin_leading_, 0, width() - margin_leading_, height()));
40 const char* BackButton::GetClassName() const {
41 return "BackButton";
44 scoped_ptr<views::LabelButtonBorder> BackButton::CreateDefaultBorder() const {
45 scoped_ptr<views::LabelButtonBorder> border =
46 ToolbarButton::CreateDefaultBorder();
48 // Adjust border insets to follow the margin change,
49 // which will be reflected in where the border is painted
50 // through |GetThemePaintRect|.
51 const gfx::Insets insets(border->GetInsets());
52 border->set_insets(gfx::Insets(insets.top(), insets.left() + margin_leading_,
53 insets.bottom(), insets.right()));
55 return border.Pass();
58 gfx::Rect BackButton::GetThemePaintRect() const {
59 gfx::Rect rect(LabelButton::GetThemePaintRect());
60 rect.Inset(margin_leading_, 0, 0, 0);
61 return rect;