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

Side by Side Diff: chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Deleted LayoutDelegate and HarmonyLayoutDelegate. Created 3 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/media_galleries_dialog_views.h" 5 #include "chrome/browser/ui/views/extensions/media_galleries_dialog_views.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/ui/views/extensions/media_gallery_checkbox_view.h" 11 #include "chrome/browser/ui/views/extensions/media_gallery_checkbox_view.h"
12 #include "chrome/browser/ui/views/harmony/layout_delegate.h" 12 #include "chrome/browser/ui/views/harmony/chrome_views_layout_delegate.h"
13 #include "chrome/grit/generated_resources.h" 13 #include "chrome/grit/generated_resources.h"
14 #include "chrome/grit/locale_settings.h" 14 #include "chrome/grit/locale_settings.h"
15 #include "components/constrained_window/constrained_window_views.h" 15 #include "components/constrained_window/constrained_window_views.h"
16 #include "components/web_modal/web_contents_modal_dialog_manager.h" 16 #include "components/web_modal/web_contents_modal_dialog_manager.h"
17 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/native_theme/native_theme.h" 19 #include "ui/native_theme/native_theme.h"
20 #include "ui/views/border.h" 20 #include "ui/views/border.h"
21 #include "ui/views/controls/button/checkbox.h" 21 #include "ui/views/controls/button/checkbox.h"
22 #include "ui/views/controls/button/image_button.h" 22 #include "ui/views/controls/button/image_button.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 int column_set_id = 0; 104 int column_set_id = 0;
105 views::ColumnSet* columns = layout->AddColumnSet(column_set_id); 105 views::ColumnSet* columns = layout->AddColumnSet(column_set_id);
106 columns->AddColumn(views::GridLayout::LEADING, 106 columns->AddColumn(views::GridLayout::LEADING,
107 views::GridLayout::LEADING, 107 views::GridLayout::LEADING,
108 1, 108 1,
109 views::GridLayout::FIXED, 109 views::GridLayout::FIXED,
110 dialog_content_width, 110 dialog_content_width,
111 0); 111 0);
112 112
113 // Message text. 113 // Message text.
114 LayoutDelegate* layout_delegate = LayoutDelegate::Get(); 114 ChromeViewsLayoutDelegate* layout_delegate = ChromeViewsLayoutDelegate::Get();
115 const int vertical_padding = layout_delegate->GetMetric( 115 const int vertical_padding = layout_delegate->GetDistanceMetric(
116 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING); 116 ChromeDistanceMetric::RELATED_CONTROL_VERTICAL);
117 views::Label* subtext = new views::Label(controller_->GetSubtext()); 117 views::Label* subtext = new views::Label(controller_->GetSubtext());
118 subtext->SetMultiLine(true); 118 subtext->SetMultiLine(true);
119 subtext->SetHorizontalAlignment(gfx::ALIGN_LEFT); 119 subtext->SetHorizontalAlignment(gfx::ALIGN_LEFT);
120 layout->StartRow(0, column_set_id); 120 layout->StartRow(0, column_set_id);
121 layout->AddView( 121 layout->AddView(
122 subtext, 1, 1, 122 subtext, 1, 1,
123 views::GridLayout::FILL, views::GridLayout::LEADING, 123 views::GridLayout::FILL, views::GridLayout::LEADING,
124 dialog_content_width, subtext->GetHeightForWidth(dialog_content_width)); 124 dialog_content_width, subtext->GetHeightForWidth(dialog_content_width));
125 layout->AddPaddingRow(0, vertical_padding); 125 layout->AddPaddingRow(0, vertical_padding);
126 126
127 // Scrollable area for checkboxes. 127 // Scrollable area for checkboxes.
128 const int small_vertical_padding = LayoutDelegate::Get()->GetMetric( 128 const int small_vertical_padding = layout_delegate->GetDistanceMetric(
129 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING_SMALL); 129 ChromeDistanceMetric::RELATED_CONTROL_VERTICAL_SMALL);
130 ScrollableView* scroll_container = new ScrollableView(); 130 ScrollableView* scroll_container = new ScrollableView();
131 scroll_container->SetLayoutManager(new views::BoxLayout( 131 scroll_container->SetLayoutManager(new views::BoxLayout(
132 views::BoxLayout::kVertical, 0, 0, small_vertical_padding)); 132 views::BoxLayout::kVertical, 0, 0, small_vertical_padding));
133 scroll_container->SetBorder( 133 scroll_container->SetBorder(
134 views::CreateEmptyBorder(vertical_padding, 0, vertical_padding, 0)); 134 views::CreateEmptyBorder(vertical_padding, 0, vertical_padding, 0));
135 135
136 std::vector<base::string16> section_headers = 136 std::vector<base::string16> section_headers =
137 controller_->GetSectionHeaders(); 137 controller_->GetSectionHeaders();
138 for (size_t i = 0; i < section_headers.size(); i++) { 138 for (size_t i = 0; i < section_headers.size(); i++) {
139 MediaGalleriesDialogController::Entries entries = 139 MediaGalleriesDialogController::Entries entries =
140 controller_->GetSectionEntries(i); 140 controller_->GetSectionEntries(i);
141 141
142 // Header and separator line. 142 // Header and separator line.
143 if (!section_headers[i].empty() && !entries.empty()) { 143 if (!section_headers[i].empty() && !entries.empty()) {
144 views::Separator* separator = new views::Separator(); 144 views::Separator* separator = new views::Separator();
145 scroll_container->AddChildView(separator); 145 scroll_container->AddChildView(separator);
146 146
147 views::Label* header = new views::Label(section_headers[i]); 147 views::Label* header = new views::Label(section_headers[i]);
148 header->SetMultiLine(true); 148 header->SetMultiLine(true);
149 header->SetHorizontalAlignment(gfx::ALIGN_LEFT); 149 header->SetHorizontalAlignment(gfx::ALIGN_LEFT);
150 header->SetBorder(views::CreateEmptyBorder( 150 header->SetBorder(views::CreateEmptyBorder(
151 vertical_padding, 151 vertical_padding,
152 layout_delegate->GetMetric( 152 layout_delegate->GetDistanceMetric(
153 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN), 153 ChromeDistanceMetric::PANEL_CONTENT_MARGIN),
154 vertical_padding, 0)); 154 vertical_padding, 0));
155 scroll_container->AddChildView(header); 155 scroll_container->AddChildView(header);
156 } 156 }
157 157
158 // Checkboxes. 158 // Checkboxes.
159 MediaGalleriesDialogController::Entries::const_iterator iter; 159 MediaGalleriesDialogController::Entries::const_iterator iter;
160 for (iter = entries.begin(); iter != entries.end(); ++iter) { 160 for (iter = entries.begin(); iter != entries.end(); ++iter) {
161 int spacing = iter + 1 == entries.end() ? small_vertical_padding : 0; 161 int spacing = iter + 1 == entries.end() ? small_vertical_padding : 0;
162 AddOrUpdateGallery(*iter, scroll_container, spacing); 162 AddOrUpdateGallery(*iter, scroll_container, spacing);
163 } 163 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 context_menu_runner_.reset(); 322 context_menu_runner_.reset();
323 } 323 }
324 324
325 // MediaGalleriesDialogViewsController ----------------------------------------- 325 // MediaGalleriesDialogViewsController -----------------------------------------
326 326
327 // static 327 // static
328 MediaGalleriesDialog* MediaGalleriesDialog::Create( 328 MediaGalleriesDialog* MediaGalleriesDialog::Create(
329 MediaGalleriesDialogController* controller) { 329 MediaGalleriesDialogController* controller) {
330 return new MediaGalleriesDialogViews(controller); 330 return new MediaGalleriesDialogViews(controller);
331 } 331 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698