Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / views / style / platform_style.cc
blob520ececb549a22bf780c8f313808b4ec5b40ba85
1 // Copyright 2015 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 "ui/views/style/platform_style.h"
7 #include "ui/base/resource/material_design/material_design_controller.h"
8 #include "ui/views/controls/button/label_button.h"
9 #include "ui/views/controls/button/label_button_border.h"
11 namespace views {
13 #if defined(OS_CHROMEOS)
14 // static
15 scoped_ptr<LabelButtonBorder> PlatformStyle::CreateLabelButtonBorder(
16 Button::ButtonStyle style) {
17 if (!ui::MaterialDesignController::IsModeMaterial() ||
18 style != Button::STYLE_TEXTBUTTON) {
19 return make_scoped_ptr(new LabelButtonAssetBorder(style));
22 // The material design spec for Chrome OS includes no visual effects for
23 // button states, so a non-asset border with insets is used.
24 scoped_ptr<LabelButtonBorder> border(new views::LabelButtonBorder());
25 border->set_insets(views::LabelButtonAssetBorder::GetDefaultInsetsForStyle(
26 Button::STYLE_TEXTBUTTON));
27 return border.Pass();
29 #elif !defined(OS_MACOSX)
30 // static
31 scoped_ptr<LabelButtonBorder> PlatformStyle::CreateLabelButtonBorder(
32 Button::ButtonStyle style) {
33 scoped_ptr<LabelButtonAssetBorder> border(new LabelButtonAssetBorder(style));
34 // The material design spec does not include a visual effect for the
35 // STATE_HOVERED button state so we have to remove the default one added by
36 // LabelButtonAssetBorder.
37 if (ui::MaterialDesignController::IsModeMaterial())
38 border->SetPainter(false, Button::STATE_HOVERED, nullptr);
39 return border.Pass();
41 #endif
43 #if !defined(OS_LINUX) || defined(OS_CHROMEOS)
44 // static
45 scoped_ptr<Border> PlatformStyle::CreateThemedLabelButtonBorder(
46 LabelButton* button) {
47 return button->CreateDefaultBorder();
49 #endif
51 } // namespace views