Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: chrome/browser/ui/views/options/managed_prefs_banner_view.cc

Issue 6670011: Options: Remove the GTK and Views native options code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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/options/managed_prefs_banner_view.h"
6
7 #include "grit/generated_resources.h"
8 #include "grit/theme_resources.h"
9 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/gfx/color_utils.h"
11 #include "views/controls/image_view.h"
12 #include "views/controls/label.h"
13 #include "views/layout/box_layout.h"
14 #include "views/layout/layout_constants.h"
15
16 // Spacing between the banner frame and its contents.
17 static const int kPrefsBannerPadding = 3;
18 // Width of the banner frame.
19 static const int kPrefsBannerBorderSize = 1;
20
21 ManagedPrefsBannerView::ManagedPrefsBannerView(PrefService* prefs,
22 OptionsPage page)
23 : policy::ManagedPrefsBannerBase(prefs, page) {
24 content_ = new views::View;
25 SkColor border_color = color_utils::GetSysSkColor(COLOR_3DSHADOW);
26 views::Border* border = views::Border::CreateSolidBorder(
27 kPrefsBannerBorderSize, border_color);
28 content_->set_border(border);
29
30 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
31 warning_image_ = new views::ImageView();
32 warning_image_->SetImage(rb.GetBitmapNamed(IDR_WARNING));
33 label_ = new views::Label(rb.GetLocalizedString(IDS_OPTIONS_MANAGED_PREFS));
34 }
35
36 void ManagedPrefsBannerView::Init() {
37 AddChildView(content_);
38 content_->SetLayoutManager(
39 new views::BoxLayout(views::BoxLayout::kHorizontal,
40 kPrefsBannerPadding,
41 kPrefsBannerPadding,
42 views::kRelatedControlSmallHorizontalSpacing));
43 content_->AddChildView(warning_image_);
44 content_->AddChildView(label_);
45 OnUpdateVisibility();
46 }
47
48 gfx::Size ManagedPrefsBannerView::GetPreferredSize() {
49 if (!IsVisible())
50 return gfx::Size();
51
52 // Add space below the banner.
53 gfx::Size size(content_->GetPreferredSize());
54 size.Enlarge(0, views::kRelatedControlVerticalSpacing);
55 return size;
56 }
57
58 void ManagedPrefsBannerView::Layout() {
59 content_->SetBounds(
60 0, 0, width(), height() - views::kRelatedControlVerticalSpacing);
61 }
62
63 void ManagedPrefsBannerView::ViewHierarchyChanged(bool is_add,
64 views::View* parent,
65 views::View* child) {
66 if (is_add && child == this)
67 Init();
68 }
69
70 void ManagedPrefsBannerView::OnUpdateVisibility() {
71 SetVisible(DetermineVisibility());
72 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/options/managed_prefs_banner_view.h ('k') | chrome/browser/ui/views/options/options_group_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698