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

Side by Side Diff: chrome/browser/ui/views/website_settings/chosen_object_row.cc

Issue 2306673003: Material Page Info (Views, 3/3): Update site settings section. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pointers. Created 4 years, 2 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/website_settings/chosen_object_row.h" 5 #include "chrome/browser/ui/views/website_settings/chosen_object_row.h"
6 6
7 #include "chrome/browser/ui/views/website_settings/chosen_object_row_observer.h" 7 #include "chrome/browser/ui/views/website_settings/chosen_object_row_observer.h"
8 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h " 8 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h "
9 #include "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/gfx/font_list.h"
11 #include "ui/resources/grit/ui_resources.h" 12 #include "ui/resources/grit/ui_resources.h"
12 #include "ui/views/controls/button/image_button.h" 13 #include "ui/views/controls/button/image_button.h"
13 #include "ui/views/controls/image_view.h" 14 #include "ui/views/controls/image_view.h"
14 #include "ui/views/controls/label.h" 15 #include "ui/views/controls/label.h"
16 #include "ui/views/layout/box_layout.h"
15 #include "ui/views/layout/grid_layout.h" 17 #include "ui/views/layout/grid_layout.h"
16 18
17 ChosenObjectRow::ChosenObjectRow( 19 ChosenObjectRow::ChosenObjectRow(
18 std::unique_ptr<WebsiteSettingsUI::ChosenObjectInfo> info) 20 std::unique_ptr<WebsiteSettingsUI::ChosenObjectInfo> info,
21 views::GridLayout* layout)
19 : info_(std::move(info)) { 22 : info_(std::move(info)) {
20 views::GridLayout* layout = new views::GridLayout(this);
21 SetLayoutManager(layout);
22 const int column_set_id = 0;
23 views::ColumnSet* column_set = layout->AddColumnSet(column_set_id);
24 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
25 views::GridLayout::FIXED, kPermissionIconColumnWidth,
26 0);
27 column_set->AddPaddingColumn(0, kPermissionIconMarginLeft);
28 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
29 views::GridLayout::USE_PREF, 0, 0);
30 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
31 views::GridLayout::USE_PREF, 0, 0);
32
33 layout->StartRow(1, column_set_id);
34 // Create the permission icon. 23 // Create the permission icon.
35 icon_ = new views::ImageView(); 24 icon_ = new views::ImageView();
36 const gfx::Image& image = 25 const gfx::Image& image =
37 WebsiteSettingsUI::GetChosenObjectIcon(*info_, false); 26 WebsiteSettingsUI::GetChosenObjectIcon(*info_, false);
38 icon_->SetImage(image.ToImageSkia()); 27 icon_->SetImage(image.ToImageSkia());
39 layout->AddView(icon_, 1, 1, views::GridLayout::CENTER, 28 layout->AddView(icon_);
40 views::GridLayout::CENTER); 29
30 label_with_delete_ = new views::View();
msw 2016/09/26 20:47:55 Why create a view to contain the label and the del
lgarron 2016/09/28 21:11:45 They could be added directly, but then I'd need to
msw 2016/09/30 00:37:04 It'd be nice to avoid unnecessary containers, but
lgarron 2016/09/30 05:05:55 Acknowledged.
31 views::BoxLayout* box_layout =
32 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 5);
msw 2016/09/26 20:47:55 optional nit: use a views layout constant (kRelate
lgarron 2016/09/28 21:11:45 Thanks for the tip; I've changed to views::kRelate
33 box_layout->set_cross_axis_alignment(
34 views::BoxLayout::CROSS_AXIS_ALIGNMENT_END);
35 label_with_delete_->SetLayoutManager(box_layout);
36
41 // Create the label that displays the permission type. 37 // Create the label that displays the permission type.
42 views::Label* label = new views::Label(l10n_util::GetStringFUTF16( 38 const gfx::FontList& font_list =
43 info_->ui_info.label_string_id, 39 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(1);
msw 2016/09/26 20:47:55 I find it odd to just toss around 1px taller fonts
lgarron 2016/09/28 21:11:45 Brought it up with Max (designer) and Emily (PM) a
44 WebsiteSettingsUI::ChosenObjectToUIString(*info_))); 40 views::Label* label =
45 layout->AddView(label, 1, 1, views::GridLayout::LEADING, 41 new views::Label(l10n_util::GetStringFUTF16(
46 views::GridLayout::CENTER); 42 info_->ui_info.label_string_id,
43 WebsiteSettingsUI::ChosenObjectToUIString(*info_)),
44 font_list);
45 label_with_delete_->AddChildView(label);
46
47 // Create the delete button. 47 // Create the delete button.
48 delete_button_ = new views::ImageButton(this); 48 delete_button_ = new views::ImageButton(this);
49 delete_button_->SetFocusForPlatform(); 49 delete_button_->SetFocusForPlatform();
50 delete_button_->set_request_focus_on_press(true); 50 delete_button_->set_request_focus_on_press(true);
51 delete_button_->SetTooltipText( 51 delete_button_->SetTooltipText(
52 l10n_util::GetStringUTF16(info_->ui_info.delete_tooltip_string_id)); 52 l10n_util::GetStringUTF16(info_->ui_info.delete_tooltip_string_id));
53 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 53 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
54 delete_button_->SetImage(views::ImageButton::STATE_NORMAL, 54 delete_button_->SetImage(views::ImageButton::STATE_NORMAL,
55 rb.GetImageSkiaNamed(IDR_CLOSE_2)); 55 rb.GetImageSkiaNamed(IDR_CLOSE_2));
56 delete_button_->SetImage(views::ImageButton::STATE_HOVERED, 56 delete_button_->SetImage(views::ImageButton::STATE_HOVERED,
57 rb.GetImageSkiaNamed(IDR_CLOSE_2_H)); 57 rb.GetImageSkiaNamed(IDR_CLOSE_2_H));
58 delete_button_->SetImage(views::ImageButton::STATE_PRESSED, 58 delete_button_->SetImage(views::ImageButton::STATE_PRESSED,
59 rb.GetImageSkiaNamed(IDR_CLOSE_2_P)); 59 rb.GetImageSkiaNamed(IDR_CLOSE_2_P));
60 layout->AddView(delete_button_, 1, 1, views::GridLayout::LEADING, 60 label_with_delete_->AddChildView(delete_button_);
61 views::GridLayout::CENTER); 61 layout->AddView(label_with_delete_);
62 } 62 }
63 63
64 void ChosenObjectRow::AddObserver(ChosenObjectRowObserver* observer) { 64 void ChosenObjectRow::AddObserver(ChosenObjectRowObserver* observer) {
65 observer_list_.AddObserver(observer); 65 observer_list_.AddObserver(observer);
66 } 66 }
67 67
68 ChosenObjectRow::~ChosenObjectRow() {} 68 ChosenObjectRow::~ChosenObjectRow() {}
69 69
70 void ChosenObjectRow::ButtonPressed(views::Button* sender, 70 void ChosenObjectRow::ButtonPressed(views::Button* sender,
71 const ui::Event& event) { 71 const ui::Event& event) {
72 // Change the icon to reflect the selected setting. 72 // Change the icon to reflect the selected setting.
73 const gfx::Image& image = 73 const gfx::Image& image =
74 WebsiteSettingsUI::GetChosenObjectIcon(*info_, true); 74 WebsiteSettingsUI::GetChosenObjectIcon(*info_, true);
75 icon_->SetImage(image.ToImageSkia()); 75 icon_->SetImage(image.ToImageSkia());
76 76
77 RemoveChildView(delete_button_); 77 label_with_delete_->RemoveChildView(delete_button_);
78 delete delete_button_; 78 delete delete_button_;
79 delete_button_ = nullptr; 79 delete_button_ = nullptr;
80 80
81 FOR_EACH_OBSERVER(ChosenObjectRowObserver, observer_list_, 81 FOR_EACH_OBSERVER(ChosenObjectRowObserver, observer_list_,
82 OnChosenObjectDeleted(*info_)); 82 OnChosenObjectDeleted(*info_));
83 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698