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

Side by Side Diff: chrome/browser/ui/views/content_setting_bubble_contents.cc

Issue 2663013003: Rename various LayoutDelegate types/functions for brevity and consistency. (Closed)
Patch Set: Created 3 years, 10 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/content_setting_bubble_contents.h" 5 #include "chrome/browser/ui/views/content_setting_bubble_contents.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 ContentSettingBubbleContents::~ContentSettingBubbleContents() { 180 ContentSettingBubbleContents::~ContentSettingBubbleContents() {
181 // Must remove the children here so the comboboxes get destroyed before 181 // Must remove the children here so the comboboxes get destroyed before
182 // their associated models. 182 // their associated models.
183 RemoveAllChildViews(true); 183 RemoveAllChildViews(true);
184 } 184 }
185 185
186 gfx::Size ContentSettingBubbleContents::GetPreferredSize() const { 186 gfx::Size ContentSettingBubbleContents::GetPreferredSize() const {
187 gfx::Size preferred_size(views::View::GetPreferredSize()); 187 gfx::Size preferred_size(views::View::GetPreferredSize());
188 int preferred_width = LayoutDelegate::Get()->GetDialogPreferredWidth( 188 int preferred_width = LayoutDelegate::Get()->GetDialogPreferredWidth(
189 LayoutDelegate::DialogWidthType::SMALL); 189 LayoutDelegate::DialogWidth::SMALL);
190 if (!preferred_width) 190 if (!preferred_width)
191 preferred_width = (!content_setting_bubble_model_->bubble_content() 191 preferred_width = (!content_setting_bubble_model_->bubble_content()
192 .domain_lists.empty() && 192 .domain_lists.empty() &&
193 (kMinMultiLineContentsWidth > preferred_size.width())) 193 (kMinMultiLineContentsWidth > preferred_size.width()))
194 ? kMinMultiLineContentsWidth 194 ? kMinMultiLineContentsWidth
195 : preferred_size.width(); 195 : preferred_size.width();
196 else 196 else
197 preferred_width -= margins().width(); 197 preferred_width -= margins().width();
198 if (content_setting_bubble_model_->AsSubresourceFilterBubbleModel()) { 198 if (content_setting_bubble_model_->AsSubresourceFilterBubbleModel()) {
199 preferred_size.set_width(std::min(preferred_width, 199 preferred_size.set_width(std::min(preferred_width,
200 kMaxDefaultContentsWidth)); 200 kMaxDefaultContentsWidth));
201 } else { 201 } else {
202 preferred_size.set_width(std::min(preferred_width, kMaxContentsWidth)); 202 preferred_size.set_width(std::min(preferred_width, kMaxContentsWidth));
203 } 203 }
204 return preferred_size; 204 return preferred_size;
205 } 205 }
206 206
207 void ContentSettingBubbleContents::Init() { 207 void ContentSettingBubbleContents::Init() {
208 using views::GridLayout; 208 using views::GridLayout;
209 209
210 GridLayout* layout = new views::GridLayout(this); 210 GridLayout* layout = new views::GridLayout(this);
211 SetLayoutManager(layout); 211 SetLayoutManager(layout);
212 const LayoutDelegate* layout_delegate = LayoutDelegate::Get(); 212 const LayoutDelegate* layout_delegate = LayoutDelegate::Get();
213 const int related_control_horizontal_spacing = 213 const int related_control_horizontal_spacing = layout_delegate->GetMetric(
214 layout_delegate->GetLayoutDistance( 214 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING);
215 LayoutDelegate::LayoutDistanceType:: 215 const int related_control_vertical_spacing = layout_delegate->GetMetric(
216 RELATED_CONTROL_HORIZONTAL_SPACING); 216 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING);
217 const int related_control_vertical_spacing = 217 const int unrelated_control_vertical_spacing = layout_delegate->GetMetric(
218 layout_delegate->GetLayoutDistance( 218 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING);
219 LayoutDelegate::LayoutDistanceType::RELATED_CONTROL_VERTICAL_SPACING);
220 const int unrelated_control_vertical_spacing =
221 layout_delegate->GetLayoutDistance(
222 LayoutDelegate::LayoutDistanceType::
223 UNRELATED_CONTROL_VERTICAL_SPACING);
224 219
225 const int kSingleColumnSetId = 0; 220 const int kSingleColumnSetId = 0;
226 views::ColumnSet* column_set = layout->AddColumnSet(kSingleColumnSetId); 221 views::ColumnSet* column_set = layout->AddColumnSet(kSingleColumnSetId);
227 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 222 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
228 GridLayout::USE_PREF, 0, 0); 223 GridLayout::USE_PREF, 0, 0);
229 column_set->AddPaddingColumn(0, related_control_horizontal_spacing); 224 column_set->AddPaddingColumn(0, related_control_horizontal_spacing);
230 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 225 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
231 GridLayout::USE_PREF, 0, 0); 226 GridLayout::USE_PREF, 0, 0);
232 227
233 const ContentSettingBubbleModel::BubbleContent& bubble_content = 228 const ContentSettingBubbleModel::BubbleContent& bubble_content =
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 row++; 296 row++;
302 bubble_content_empty = false; 297 bubble_content_empty = false;
303 } 298 }
304 } 299 }
305 300
306 const int indented_kSingleColumnSetId = 3; 301 const int indented_kSingleColumnSetId = 3;
307 // Insert a column set with greater indent. 302 // Insert a column set with greater indent.
308 views::ColumnSet* indented_single_column_set = 303 views::ColumnSet* indented_single_column_set =
309 layout->AddColumnSet(indented_kSingleColumnSetId); 304 layout->AddColumnSet(indented_kSingleColumnSetId);
310 indented_single_column_set->AddPaddingColumn( 305 indented_single_column_set->AddPaddingColumn(
311 0, layout_delegate->GetLayoutDistance( 306 0,
312 LayoutDelegate::LayoutDistanceType::SUBSECTION_HORIZONTAL_INDENT)); 307 layout_delegate->GetMetric(
308 LayoutDelegate::Metric::SUBSECTION_HORIZONTAL_INDENT));
313 indented_single_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 309 indented_single_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL,
314 1, GridLayout::USE_PREF, 0, 0); 310 1, GridLayout::USE_PREF, 0, 0);
315 311
316 const ContentSettingBubbleModel::RadioGroup& radio_group = 312 const ContentSettingBubbleModel::RadioGroup& radio_group =
317 bubble_content.radio_group; 313 bubble_content.radio_group;
318 if (!radio_group.radio_items.empty()) { 314 if (!radio_group.radio_items.empty()) {
319 if (!bubble_content_empty) 315 if (!bubble_content_empty)
320 layout->AddPaddingRow(0, related_control_vertical_spacing); 316 layout->AddPaddingRow(0, related_control_vertical_spacing);
321 for (ContentSettingBubbleModel::RadioItems::const_iterator i( 317 for (ContentSettingBubbleModel::RadioItems::const_iterator i(
322 radio_group.radio_items.begin()); 318 radio_group.radio_items.begin());
(...skipping 21 matching lines...) Expand all
344 radio_group_[radio_group.default_item]->SetChecked(true); 340 radio_group_[radio_group.default_item]->SetChecked(true);
345 } 341 }
346 342
347 // Layout code for the media device menus. 343 // Layout code for the media device menus.
348 if (content_setting_bubble_model_->AsMediaStreamBubbleModel()) { 344 if (content_setting_bubble_model_->AsMediaStreamBubbleModel()) {
349 const int kMediaMenuColumnSetId = 4; 345 const int kMediaMenuColumnSetId = 4;
350 views::ColumnSet* menu_column_set = 346 views::ColumnSet* menu_column_set =
351 layout->AddColumnSet(kMediaMenuColumnSetId); 347 layout->AddColumnSet(kMediaMenuColumnSetId);
352 menu_column_set->AddPaddingColumn( 348 menu_column_set->AddPaddingColumn(
353 0, 349 0,
354 layout_delegate->GetLayoutDistance( 350 layout_delegate->GetMetric(
355 LayoutDelegate::LayoutDistanceType::SUBSECTION_HORIZONTAL_INDENT)); 351 LayoutDelegate::Metric::SUBSECTION_HORIZONTAL_INDENT));
356 menu_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0, 352 menu_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0,
357 GridLayout::USE_PREF, 0, 0); 353 GridLayout::USE_PREF, 0, 0);
358 menu_column_set->AddPaddingColumn(0, related_control_horizontal_spacing); 354 menu_column_set->AddPaddingColumn(0, related_control_horizontal_spacing);
359 menu_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 355 menu_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
360 GridLayout::USE_PREF, 0, 0); 356 GridLayout::USE_PREF, 0, 0);
361 357
362 for (ContentSettingBubbleModel::MediaMenuMap::const_iterator i( 358 for (ContentSettingBubbleModel::MediaMenuMap::const_iterator i(
363 bubble_content.media_menus.begin()); 359 bubble_content.media_menus.begin());
364 i != bubble_content.media_menus.end(); ++i) { 360 i != bubble_content.media_menus.end(); ++i) {
365 if (!bubble_content_empty) 361 if (!bubble_content_empty)
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 DCHECK(i != list_item_links_.end()); 507 DCHECK(i != list_item_links_.end());
512 content_setting_bubble_model_->OnListItemClicked(i->second); 508 content_setting_bubble_model_->OnListItemClicked(i->second);
513 } 509 }
514 510
515 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { 511 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) {
516 MediaComboboxModel* model = 512 MediaComboboxModel* model =
517 static_cast<MediaComboboxModel*>(combobox->model()); 513 static_cast<MediaComboboxModel*>(combobox->model());
518 content_setting_bubble_model_->OnMediaMenuClicked( 514 content_setting_bubble_model_->OnMediaMenuClicked(
519 model->type(), model->GetDevices()[combobox->selected_index()].id); 515 model->type(), model->GetDevices()[combobox->selected_index()].id);
520 } 516 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698