Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / views / toolbar / back_button.cc
blob54c6f2f988420906f69c52044461e5474815a742
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/controls/button/label_button_border.h"
9 #include "ui/views/painter.h"
11 BackButton::BackButton(views::ButtonListener* listener,
12 ui::MenuModel* model)
13 : ToolbarButton(listener, model),
14 margin_leading_(0) {}
16 BackButton::~BackButton() {}
18 void BackButton::SetLeadingMargin(int margin) {
19 margin_leading_ = margin;
21 UpdateThemedBorder();
23 // Similarly fiddle the focus border. Value consistent with LabelButton.
24 // TODO(gbillock): Refactor this magic number somewhere global to views,
25 // probably a FocusBorder constant.
26 const int kFocusRectInset = 3;
27 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets(
28 gfx::Insets(kFocusRectInset, kFocusRectInset + margin,
29 kFocusRectInset, kFocusRectInset)));
31 InvalidateLayout();
34 const char* BackButton::GetClassName() const {
35 return "BackButton";
38 scoped_ptr<views::LabelButtonBorder> BackButton::CreateDefaultBorder() const {
39 scoped_ptr<views::LabelButtonBorder> border =
40 ToolbarButton::CreateDefaultBorder();
42 // Adjust border insets to follow the margin change,
43 // which will be reflected in where the border is painted
44 // through |GetThemePaintRect|.
45 const gfx::Insets insets(border->GetInsets());
46 border->set_insets(gfx::Insets(insets.top(), insets.left() + margin_leading_,
47 insets.bottom(), insets.right()));
49 return border.Pass();
52 gfx::Rect BackButton::GetThemePaintRect() const {
53 gfx::Rect rect(LabelButton::GetThemePaintRect());
54 rect.Inset(margin_leading_, 0, 0, 0);
55 return rect;