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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" | 16 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
17 #include "chrome/browser/plugins/plugin_finder.h" | 17 #include "chrome/browser/plugins/plugin_finder.h" |
18 #include "chrome/browser/plugins/plugin_metadata.h" | 18 #include "chrome/browser/plugins/plugin_metadata.h" |
19 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 19 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
20 #include "chrome/browser/ui/layout_constants.h" | 20 #include "chrome/browser/ui/layout_constants.h" |
| 21 #include "chrome/browser/ui/views/harmony/chrome_typography.h" |
21 #include "chrome/browser/ui/views/harmony/layout_delegate.h" | 22 #include "chrome/browser/ui/views/harmony/layout_delegate.h" |
22 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
23 #include "components/content_settings/core/browser/host_content_settings_map.h" | 24 #include "components/content_settings/core/browser/host_content_settings_map.h" |
24 #include "components/strings/grit/components_strings.h" | 25 #include "components/strings/grit/components_strings.h" |
25 #include "content/public/browser/navigation_handle.h" | 26 #include "content/public/browser/navigation_handle.h" |
26 #include "content/public/browser/plugin_service.h" | 27 #include "content/public/browser/plugin_service.h" |
27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
28 #include "ui/base/cursor/cursor.h" | 29 #include "ui/base/cursor/cursor.h" |
29 #include "ui/base/default_style.h" | 30 #include "ui/base/default_style.h" |
30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 GridLayout::USE_PREF, 0, 0); | 224 GridLayout::USE_PREF, 0, 0); |
224 column_set->AddPaddingColumn(0, related_control_horizontal_spacing); | 225 column_set->AddPaddingColumn(0, related_control_horizontal_spacing); |
225 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, | 226 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, |
226 GridLayout::USE_PREF, 0, 0); | 227 GridLayout::USE_PREF, 0, 0); |
227 | 228 |
228 const ContentSettingBubbleModel::BubbleContent& bubble_content = | 229 const ContentSettingBubbleModel::BubbleContent& bubble_content = |
229 content_setting_bubble_model_->bubble_content(); | 230 content_setting_bubble_model_->bubble_content(); |
230 bool bubble_content_empty = true; | 231 bool bubble_content_empty = true; |
231 | 232 |
232 if (!bubble_content.title.empty()) { | 233 if (!bubble_content.title.empty()) { |
233 views::Label* title_label = new views::Label(bubble_content.title); | 234 const int title_context = |
| 235 layout_delegate->IsHarmonyMode() |
| 236 ? static_cast<int>(views::style::CONTEXT_DIALOG_TITLE) |
| 237 : CONTEXT_BODY_TEXT_SMALL; |
| 238 views::Label* title_label = |
| 239 new views::Label(bubble_content.title, title_context); |
234 title_label->SetMultiLine(true); | 240 title_label->SetMultiLine(true); |
235 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 241 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); | 242 layout->StartRow(0, kSingleColumnSetId); |
242 layout->AddView(title_label); | 243 layout->AddView(title_label); |
243 bubble_content_empty = false; | 244 bubble_content_empty = false; |
244 } | 245 } |
245 | 246 |
246 if (!bubble_content.message.empty()) { | 247 if (!bubble_content.message.empty()) { |
247 views::Label* message_label = new views::Label(bubble_content.message); | 248 views::Label* message_label = new views::Label(bubble_content.message); |
248 layout->AddPaddingRow(0, unrelated_control_vertical_spacing); | 249 layout->AddPaddingRow(0, unrelated_control_vertical_spacing); |
249 message_label->SetMultiLine(true); | 250 message_label->SetMultiLine(true); |
250 message_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 251 message_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 combobox->SetSelectedIndex( | 379 combobox->SetSelectedIndex( |
379 model->GetDevices().empty() | 380 model->GetDevices().empty() |
380 ? 0 | 381 ? 0 |
381 : model->GetDeviceIndex(i->second.selected_device)); | 382 : model->GetDeviceIndex(i->second.selected_device)); |
382 layout->AddView(combobox); | 383 layout->AddView(combobox); |
383 | 384 |
384 bubble_content_empty = false; | 385 bubble_content_empty = false; |
385 } | 386 } |
386 } | 387 } |
387 | 388 |
388 const gfx::FontList& domain_font = | |
389 ui::ResourceBundle::GetSharedInstance().GetFontList( | |
390 ui::ResourceBundle::BoldFont); | |
391 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i( | 389 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i( |
392 bubble_content.domain_lists.begin()); | 390 bubble_content.domain_lists.begin()); |
393 i != bubble_content.domain_lists.end(); ++i) { | 391 i != bubble_content.domain_lists.end(); ++i) { |
394 layout->StartRow(0, kSingleColumnSetId); | 392 layout->StartRow(0, kSingleColumnSetId); |
395 views::Label* section_title = new views::Label(base::UTF8ToUTF16(i->title)); | 393 views::Label* section_title = new views::Label(base::UTF8ToUTF16(i->title)); |
396 section_title->SetMultiLine(true); | 394 section_title->SetMultiLine(true); |
397 section_title->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 395 section_title->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
398 layout->AddView(section_title, 1, 1, GridLayout::FILL, GridLayout::LEADING); | 396 layout->AddView(section_title, 1, 1, GridLayout::FILL, GridLayout::LEADING); |
399 for (std::set<std::string>::const_iterator j = i->hosts.begin(); | 397 for (std::set<std::string>::const_iterator j = i->hosts.begin(); |
400 j != i->hosts.end(); ++j) { | 398 j != i->hosts.end(); ++j) { |
401 layout->StartRow(0, indented_kSingleColumnSetId); | 399 layout->StartRow(0, indented_kSingleColumnSetId); |
402 layout->AddView(new views::Label(base::UTF8ToUTF16(*j), domain_font)); | 400 // TODO(tapted): Verify this when we have a mock. http://crbug.com/700196. |
| 401 layout->AddView(new views::Label( |
| 402 base::UTF8ToUTF16(*j), CONTEXT_BODY_TEXT_LARGE, STYLE_EMPHASIZED)); |
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 |