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

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

Issue 2734113006: "Bootstrap" a toolkit-views Typography spec. (Closed)
Patch Set: respond to comments Created 3 years, 9 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>
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
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
Peter Kasting 2017/03/17 20:59:39 Nit: No need for blank line here now
tapted 2017/03/20 07:33:35 Done.
239 views::Label* title_label =
240 new views::Label(bubble_content.title, title_context);
234 title_label->SetMultiLine(true); 241 title_label->SetMultiLine(true);
235 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 242 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); 243 layout->StartRow(0, kSingleColumnSetId);
242 layout->AddView(title_label); 244 layout->AddView(title_label);
243 bubble_content_empty = false; 245 bubble_content_empty = false;
244 } 246 }
245 247
246 if (!bubble_content.message.empty()) { 248 if (!bubble_content.message.empty()) {
247 views::Label* message_label = new views::Label(bubble_content.message); 249 views::Label* message_label = new views::Label(bubble_content.message);
248 layout->AddPaddingRow(0, unrelated_control_vertical_spacing); 250 layout->AddPaddingRow(0, unrelated_control_vertical_spacing);
249 message_label->SetMultiLine(true); 251 message_label->SetMultiLine(true);
250 message_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 252 message_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 combobox->SetSelectedIndex( 380 combobox->SetSelectedIndex(
379 model->GetDevices().empty() 381 model->GetDevices().empty()
380 ? 0 382 ? 0
381 : model->GetDeviceIndex(i->second.selected_device)); 383 : model->GetDeviceIndex(i->second.selected_device));
382 layout->AddView(combobox); 384 layout->AddView(combobox);
383 385
384 bubble_content_empty = false; 386 bubble_content_empty = false;
385 } 387 }
386 } 388 }
387 389
388 const gfx::FontList& domain_font =
389 ui::ResourceBundle::GetSharedInstance().GetFontList(
390 ui::ResourceBundle::BoldFont);
391 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i( 390 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i(
392 bubble_content.domain_lists.begin()); 391 bubble_content.domain_lists.begin());
393 i != bubble_content.domain_lists.end(); ++i) { 392 i != bubble_content.domain_lists.end(); ++i) {
394 layout->StartRow(0, kSingleColumnSetId); 393 layout->StartRow(0, kSingleColumnSetId);
395 views::Label* section_title = new views::Label(base::UTF8ToUTF16(i->title)); 394 views::Label* section_title = new views::Label(base::UTF8ToUTF16(i->title));
396 section_title->SetMultiLine(true); 395 section_title->SetMultiLine(true);
397 section_title->SetHorizontalAlignment(gfx::ALIGN_LEFT); 396 section_title->SetHorizontalAlignment(gfx::ALIGN_LEFT);
398 layout->AddView(section_title, 1, 1, GridLayout::FILL, GridLayout::LEADING); 397 layout->AddView(section_title, 1, 1, GridLayout::FILL, GridLayout::LEADING);
399 for (std::set<std::string>::const_iterator j = i->hosts.begin(); 398 for (std::set<std::string>::const_iterator j = i->hosts.begin();
400 j != i->hosts.end(); ++j) { 399 j != i->hosts.end(); ++j) {
401 layout->StartRow(0, indented_kSingleColumnSetId); 400 layout->StartRow(0, indented_kSingleColumnSetId);
402 layout->AddView(new views::Label(base::UTF8ToUTF16(*j), domain_font)); 401 // TODO(tapted): Verify this when we have a mock. http://crbug.com/700196.
402 layout->AddView(new views::Label(
403 base::UTF8ToUTF16(*j), CONTEXT_BODY_TEXT_LARGE, STYLE_EMPHASIZED));
403 } 404 }
404 bubble_content_empty = false; 405 bubble_content_empty = false;
405 } 406 }
406 407
407 if (!bubble_content.custom_link.empty()) { 408 if (!bubble_content.custom_link.empty()) {
408 custom_link_ = 409 custom_link_ =
409 new views::Link(base::UTF8ToUTF16(bubble_content.custom_link)); 410 new views::Link(base::UTF8ToUTF16(bubble_content.custom_link));
410 custom_link_->SetEnabled(bubble_content.custom_link_enabled); 411 custom_link_->SetEnabled(bubble_content.custom_link_enabled);
411 custom_link_->set_listener(this); 412 custom_link_->set_listener(this);
412 if (!bubble_content_empty) 413 if (!bubble_content_empty)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 DCHECK(i != list_item_links_.end()); 508 DCHECK(i != list_item_links_.end());
508 content_setting_bubble_model_->OnListItemClicked(i->second); 509 content_setting_bubble_model_->OnListItemClicked(i->second);
509 } 510 }
510 511
511 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { 512 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) {
512 MediaComboboxModel* model = 513 MediaComboboxModel* model =
513 static_cast<MediaComboboxModel*>(combobox->model()); 514 static_cast<MediaComboboxModel*>(combobox->model());
514 content_setting_bubble_model_->OnMediaMenuClicked( 515 content_setting_bubble_model_->OnMediaMenuClicked(
515 model->type(), model->GetDevices()[combobox->selected_index()].id); 516 model->type(), model->GetDevices()[combobox->selected_index()].id);
516 } 517 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698