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.
4
5#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_panel.h"
6
7#include "ui/base/resource/resource_bundle.h"
8#include "ui/views/controls/label.h"
9#include "ui/views/layout/box_layout.h"
10#include "ui/views/layout/layout_constants.h"
11
12namespace {
13
14// The spacing between the key and the value labels in the Details section.
15const int kSpacingBetweenKeyAndStartOfValue = 3;
16}
17
18AppInfoPanel::AppInfoPanel(Profile* profile, const extensions::Extension* app)
19    : profile_(profile), app_(app) {
20}
21
22AppInfoPanel::~AppInfoPanel() {
23}
24
25views::Label* AppInfoPanel::CreateHeading(const base::string16& text) const {
26  views::Label* label = new views::Label(text);
27  label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
28  label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
29      ui::ResourceBundle::MediumFont));
30  return label;
31}
32
33views::View* AppInfoPanel::CreateVerticalStack(int child_spacing) const {
34  views::View* vertically_stacked_view = new views::View();
35  vertically_stacked_view->SetLayoutManager(
36      new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, child_spacing));
37  return vertically_stacked_view;
38}
39
40views::View* AppInfoPanel::CreateVerticalStack() const {
41  return CreateVerticalStack(views::kRelatedControlVerticalSpacing);
42}
43
44views::View* AppInfoPanel::CreateHorizontalStack(int child_spacing) const {
45  views::View* vertically_stacked_view = new views::View();
46  vertically_stacked_view->SetLayoutManager(
47      new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, child_spacing));
48  return vertically_stacked_view;
49}
50
51views::View* AppInfoPanel::CreateHorizontalStack() const {
52  return CreateVerticalStack(views::kRelatedControlHorizontalSpacing);
53}
54
55views::View* AppInfoPanel::CreateKeyValueField(views::View* key,
56                                               views::View* value) const {
57  views::View* horizontal_stack =
58      CreateHorizontalStack(kSpacingBetweenKeyAndStartOfValue);
59  horizontal_stack->AddChildView(key);
60  horizontal_stack->AddChildView(value);
61  return horizontal_stack;
62}
63