Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 GridLayout::USE_PREF, 0, 0); | 223 GridLayout::USE_PREF, 0, 0); |
| 224 column_set->AddPaddingColumn(0, related_control_horizontal_spacing); | 224 column_set->AddPaddingColumn(0, related_control_horizontal_spacing); |
| 225 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, | 225 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, |
| 226 GridLayout::USE_PREF, 0, 0); | 226 GridLayout::USE_PREF, 0, 0); |
| 227 | 227 |
| 228 const ContentSettingBubbleModel::BubbleContent& bubble_content = | 228 const ContentSettingBubbleModel::BubbleContent& bubble_content = |
| 229 content_setting_bubble_model_->bubble_content(); | 229 content_setting_bubble_model_->bubble_content(); |
| 230 bool bubble_content_empty = true; | 230 bool bubble_content_empty = true; |
| 231 | 231 |
| 232 if (!bubble_content.title.empty()) { | 232 if (!bubble_content.title.empty()) { |
| 233 views::Label* title_label = new views::Label(bubble_content.title); | 233 const views::TextContext kTitleContext = |
| 234 layout_delegate->IsHarmonyMode() | |
| 235 ? views::TextContext::DIALOG_TITLE | |
| 236 : views::TextContext::DIALOG_TEXT_SMALL; | |
|
Peter Kasting
2017/03/14 23:53:33
Nit: It would be nice to just use DIALOG_TITLE unc
tapted
2017/03/15 08:26:24
The difference between these two fonts is signific
Peter Kasting
2017/03/15 10:01:48
Honestly I'd be fine with this if we shortened the
| |
| 237 views::Label* title_label = | |
| 238 new views::Label(bubble_content.title, kTitleContext); | |
| 234 title_label->SetMultiLine(true); | 239 title_label->SetMultiLine(true); |
| 235 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 240 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 236 if (layout_delegate->IsHarmonyMode()) { | |
| 237 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 238 title_label->SetFontList( | |
| 239 rb.GetFontListWithDelta(ui::kTitleFontSizeDelta)); | |
| 240 } | |
| 241 layout->StartRow(0, kSingleColumnSetId); | 241 layout->StartRow(0, kSingleColumnSetId); |
| 242 layout->AddView(title_label); | 242 layout->AddView(title_label); |
| 243 bubble_content_empty = false; | 243 bubble_content_empty = false; |
| 244 } | 244 } |
| 245 | 245 |
| 246 if (!bubble_content.message.empty()) { | 246 if (!bubble_content.message.empty()) { |
| 247 views::Label* message_label = new views::Label(bubble_content.message); | 247 views::Label* message_label = new views::Label(bubble_content.message); |
| 248 layout->AddPaddingRow(0, unrelated_control_vertical_spacing); | 248 layout->AddPaddingRow(0, unrelated_control_vertical_spacing); |
| 249 message_label->SetMultiLine(true); | 249 message_label->SetMultiLine(true); |
| 250 message_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 250 message_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 combobox->SetSelectedIndex( | 378 combobox->SetSelectedIndex( |
| 379 model->GetDevices().empty() | 379 model->GetDevices().empty() |
| 380 ? 0 | 380 ? 0 |
| 381 : model->GetDeviceIndex(i->second.selected_device)); | 381 : model->GetDeviceIndex(i->second.selected_device)); |
| 382 layout->AddView(combobox); | 382 layout->AddView(combobox); |
| 383 | 383 |
| 384 bubble_content_empty = false; | 384 bubble_content_empty = false; |
| 385 } | 385 } |
| 386 } | 386 } |
| 387 | 387 |
| 388 const gfx::FontList& domain_font = | |
| 389 ui::ResourceBundle::GetSharedInstance().GetFontList( | |
| 390 ui::ResourceBundle::BoldFont); | |
| 391 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i( | 388 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i( |
| 392 bubble_content.domain_lists.begin()); | 389 bubble_content.domain_lists.begin()); |
| 393 i != bubble_content.domain_lists.end(); ++i) { | 390 i != bubble_content.domain_lists.end(); ++i) { |
| 394 layout->StartRow(0, kSingleColumnSetId); | 391 layout->StartRow(0, kSingleColumnSetId); |
| 395 views::Label* section_title = new views::Label(base::UTF8ToUTF16(i->title)); | 392 views::Label* section_title = new views::Label(base::UTF8ToUTF16(i->title)); |
| 396 section_title->SetMultiLine(true); | 393 section_title->SetMultiLine(true); |
| 397 section_title->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 394 section_title->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 398 layout->AddView(section_title, 1, 1, GridLayout::FILL, GridLayout::LEADING); | 395 layout->AddView(section_title, 1, 1, GridLayout::FILL, GridLayout::LEADING); |
| 399 for (std::set<std::string>::const_iterator j = i->hosts.begin(); | 396 for (std::set<std::string>::const_iterator j = i->hosts.begin(); |
| 400 j != i->hosts.end(); ++j) { | 397 j != i->hosts.end(); ++j) { |
| 401 layout->StartRow(0, indented_kSingleColumnSetId); | 398 layout->StartRow(0, indented_kSingleColumnSetId); |
| 402 layout->AddView(new views::Label(base::UTF8ToUTF16(*j), domain_font)); | 399 // TODO(tapted): Verify this when we have a mock. http://crbug.com/700196. |
| 400 layout->AddView(new views::Label(base::UTF8ToUTF16(*j), | |
| 401 views::TextContext::DIALOG_MESSAGE, | |
| 402 views::TextStyle::WEB_DOMAIN)); | |
| 403 } | 403 } |
| 404 bubble_content_empty = false; | 404 bubble_content_empty = false; |
| 405 } | 405 } |
| 406 | 406 |
| 407 if (!bubble_content.custom_link.empty()) { | 407 if (!bubble_content.custom_link.empty()) { |
| 408 custom_link_ = | 408 custom_link_ = |
| 409 new views::Link(base::UTF8ToUTF16(bubble_content.custom_link)); | 409 new views::Link(base::UTF8ToUTF16(bubble_content.custom_link)); |
| 410 custom_link_->SetEnabled(bubble_content.custom_link_enabled); | 410 custom_link_->SetEnabled(bubble_content.custom_link_enabled); |
| 411 custom_link_->set_listener(this); | 411 custom_link_->set_listener(this); |
| 412 if (!bubble_content_empty) | 412 if (!bubble_content_empty) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 507 DCHECK(i != list_item_links_.end()); | 507 DCHECK(i != list_item_links_.end()); |
| 508 content_setting_bubble_model_->OnListItemClicked(i->second); | 508 content_setting_bubble_model_->OnListItemClicked(i->second); |
| 509 } | 509 } |
| 510 | 510 |
| 511 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { | 511 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { |
| 512 MediaComboboxModel* model = | 512 MediaComboboxModel* model = |
| 513 static_cast<MediaComboboxModel*>(combobox->model()); | 513 static_cast<MediaComboboxModel*>(combobox->model()); |
| 514 content_setting_bubble_model_->OnMediaMenuClicked( | 514 content_setting_bubble_model_->OnMediaMenuClicked( |
| 515 model->type(), model->GetDevices()[combobox->selected_index()].id); | 515 model->type(), model->GetDevices()[combobox->selected_index()].id); |
| 516 } | 516 } |
| OLD | NEW |