| 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() ? views::TextContext::DIALOG_TITLE |
| 235 : ChromeTextContext::DIALOG_TEXT_SMALL; |
| 236 views::Label* title_label = |
| 237 new views::Label(bubble_content.title, kTitleContext); |
| 234 title_label->SetMultiLine(true); | 238 title_label->SetMultiLine(true); |
| 235 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 239 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); | 240 layout->StartRow(0, kSingleColumnSetId); |
| 242 layout->AddView(title_label); | 241 layout->AddView(title_label); |
| 243 bubble_content_empty = false; | 242 bubble_content_empty = false; |
| 244 } | 243 } |
| 245 | 244 |
| 246 if (!bubble_content.message.empty()) { | 245 if (!bubble_content.message.empty()) { |
| 247 views::Label* message_label = new views::Label(bubble_content.message); | 246 views::Label* message_label = new views::Label(bubble_content.message); |
| 248 layout->AddPaddingRow(0, unrelated_control_vertical_spacing); | 247 layout->AddPaddingRow(0, unrelated_control_vertical_spacing); |
| 249 message_label->SetMultiLine(true); | 248 message_label->SetMultiLine(true); |
| 250 message_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 249 message_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 combobox->SetSelectedIndex( | 377 combobox->SetSelectedIndex( |
| 379 model->GetDevices().empty() | 378 model->GetDevices().empty() |
| 380 ? 0 | 379 ? 0 |
| 381 : model->GetDeviceIndex(i->second.selected_device)); | 380 : model->GetDeviceIndex(i->second.selected_device)); |
| 382 layout->AddView(combobox); | 381 layout->AddView(combobox); |
| 383 | 382 |
| 384 bubble_content_empty = false; | 383 bubble_content_empty = false; |
| 385 } | 384 } |
| 386 } | 385 } |
| 387 | 386 |
| 388 const gfx::FontList& domain_font = | |
| 389 ui::ResourceBundle::GetSharedInstance().GetFontList( | |
| 390 ui::ResourceBundle::BoldFont); | |
| 391 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i( | 387 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i( |
| 392 bubble_content.domain_lists.begin()); | 388 bubble_content.domain_lists.begin()); |
| 393 i != bubble_content.domain_lists.end(); ++i) { | 389 i != bubble_content.domain_lists.end(); ++i) { |
| 394 layout->StartRow(0, kSingleColumnSetId); | 390 layout->StartRow(0, kSingleColumnSetId); |
| 395 views::Label* section_title = new views::Label(base::UTF8ToUTF16(i->title)); | 391 views::Label* section_title = new views::Label(base::UTF8ToUTF16(i->title)); |
| 396 section_title->SetMultiLine(true); | 392 section_title->SetMultiLine(true); |
| 397 section_title->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 393 section_title->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 398 layout->AddView(section_title, 1, 1, GridLayout::FILL, GridLayout::LEADING); | 394 layout->AddView(section_title, 1, 1, GridLayout::FILL, GridLayout::LEADING); |
| 399 for (std::set<std::string>::const_iterator j = i->hosts.begin(); | 395 for (std::set<std::string>::const_iterator j = i->hosts.begin(); |
| 400 j != i->hosts.end(); ++j) { | 396 j != i->hosts.end(); ++j) { |
| 401 layout->StartRow(0, indented_kSingleColumnSetId); | 397 layout->StartRow(0, indented_kSingleColumnSetId); |
| 402 layout->AddView(new views::Label(base::UTF8ToUTF16(*j), domain_font)); | 398 // TODO(tapted): Verify this when we have a mock. http://crbug.com/700196. |
| 399 layout->AddView(new views::Label(base::UTF8ToUTF16(*j), |
| 400 views::TextContext::DIALOG_MESSAGE, |
| 401 views::TextStyle::WEB_DOMAIN)); |
| 403 } | 402 } |
| 404 bubble_content_empty = false; | 403 bubble_content_empty = false; |
| 405 } | 404 } |
| 406 | 405 |
| 407 if (!bubble_content.custom_link.empty()) { | 406 if (!bubble_content.custom_link.empty()) { |
| 408 custom_link_ = | 407 custom_link_ = |
| 409 new views::Link(base::UTF8ToUTF16(bubble_content.custom_link)); | 408 new views::Link(base::UTF8ToUTF16(bubble_content.custom_link)); |
| 410 custom_link_->SetEnabled(bubble_content.custom_link_enabled); | 409 custom_link_->SetEnabled(bubble_content.custom_link_enabled); |
| 411 custom_link_->set_listener(this); | 410 custom_link_->set_listener(this); |
| 412 if (!bubble_content_empty) | 411 if (!bubble_content_empty) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 DCHECK(i != list_item_links_.end()); | 506 DCHECK(i != list_item_links_.end()); |
| 508 content_setting_bubble_model_->OnListItemClicked(i->second); | 507 content_setting_bubble_model_->OnListItemClicked(i->second); |
| 509 } | 508 } |
| 510 | 509 |
| 511 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { | 510 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { |
| 512 MediaComboboxModel* model = | 511 MediaComboboxModel* model = |
| 513 static_cast<MediaComboboxModel*>(combobox->model()); | 512 static_cast<MediaComboboxModel*>(combobox->model()); |
| 514 content_setting_bubble_model_->OnMediaMenuClicked( | 513 content_setting_bubble_model_->OnMediaMenuClicked( |
| 515 model->type(), model->GetDevices()[combobox->selected_index()].id); | 514 model->type(), model->GetDevices()[combobox->selected_index()].id); |
| 516 } | 515 } |
| OLD | NEW |