Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / views / apps / app_info_dialog / app_info_panel.cc
blob4302a9664a079eba1fbaa99e0e04fc6925ee2642
1 // Copyright 2014 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/apps/app_info_dialog/app_info_panel.h"
7 #include "chrome/browser/ui/browser_navigator.h"
8 #include "ui/base/resource/resource_bundle.h"
9 #include "ui/views/controls/label.h"
10 #include "ui/views/layout/box_layout.h"
11 #include "ui/views/layout/layout_constants.h"
12 #include "ui/views/widget/widget.h"
13 #include "url/gurl.h"
15 namespace {
17 // The spacing between the key and the value labels in the Details section.
18 const int kSpacingBetweenKeyAndStartOfValue = 3;
21 AppInfoPanel::AppInfoPanel(Profile* profile, const extensions::Extension* app)
22 : profile_(profile), app_(app) {
25 AppInfoPanel::~AppInfoPanel() {
28 void AppInfoPanel::Close() {
29 GetWidget()->Close();
32 void AppInfoPanel::OpenLink(const GURL& url) {
33 DCHECK(!url.is_empty());
34 chrome::NavigateParams params(profile_, url, ui::PAGE_TRANSITION_LINK);
35 chrome::Navigate(&params);
38 views::Label* AppInfoPanel::CreateHeading(const base::string16& text) const {
39 views::Label* label = new views::Label(text);
40 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
41 label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
42 ui::ResourceBundle::MediumFont));
43 return label;
46 views::View* AppInfoPanel::CreateVerticalStack(int child_spacing) const {
47 views::View* vertically_stacked_view = new views::View();
48 vertically_stacked_view->SetLayoutManager(
49 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, child_spacing));
50 return vertically_stacked_view;
53 views::View* AppInfoPanel::CreateVerticalStack() const {
54 return CreateVerticalStack(views::kRelatedControlVerticalSpacing);
57 views::View* AppInfoPanel::CreateHorizontalStack(int child_spacing) const {
58 views::View* vertically_stacked_view = new views::View();
59 vertically_stacked_view->SetLayoutManager(
60 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, child_spacing));
61 return vertically_stacked_view;
64 views::View* AppInfoPanel::CreateKeyValueField(views::View* key,
65 views::View* value) const {
66 views::View* horizontal_stack =
67 CreateHorizontalStack(kSpacingBetweenKeyAndStartOfValue);
68 horizontal_stack->AddChildView(key);
69 horizontal_stack->AddChildView(value);
70 return horizontal_stack;