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

Side by Side Diff: chrome/browser/ui/views/website_settings/website_settings_popup_view.cc

Issue 2306673003: Material Page Info (Views, 3/3): Update site settings section. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pointers. Created 4 years, 3 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/website_settings/website_settings_popup_view.h " 5 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h "
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 namespace { 65 namespace {
66 66
67 // NOTE(jdonnelly): This use of this process-wide variable assumes that there's 67 // NOTE(jdonnelly): This use of this process-wide variable assumes that there's
68 // never more than one website settings popup shown and that it's associated 68 // never more than one website settings popup shown and that it's associated
69 // with the current window. If this assumption fails in the future, we'll need 69 // with the current window. If this assumption fails in the future, we'll need
70 // to return a weak pointer from ShowPopup so callers can associate it with the 70 // to return a weak pointer from ShowPopup so callers can associate it with the
71 // current window (or other context) and check if the popup they care about is 71 // current window (or other context) and check if the popup they care about is
72 // showing. 72 // showing.
73 bool is_popup_showing = false; 73 bool is_popup_showing = false;
74 74
75 // Left icon margin. 75 /**************** General constants ****************/
lgarron 2016/09/23 02:07:45 I've updated the structure and variable names in t
msw 2016/09/26 20:47:56 nit: consider a more common chrome/* comment headi
lgarron 2016/09/28 21:11:47 Done. Thanks for letting me know the convention; I
76 const int kIconMarginLeft = 6; 76
77 // Popup width constraints.
78 const int kMinPopupWidth = 320;
79 const int kMaxPopupWidth = 1000;
80
81 // Margin and padding values shared by all sections.
82 const int kSectionPaddingHorizontal = 16;
msw 2016/09/26 20:47:56 nit: try to use a views constant, like kUnrelatedC
lgarron 2016/09/28 21:11:46 This is the outside padding for each section, whic
msw 2016/09/30 00:37:04 Sadly, there's no one-size-fits-all answer to that
lgarron 2016/09/30 05:05:55 Yeah, I wish translating specs to code didn't requ
msw 2016/09/30 17:18:26 That line dates back to initial commit, or perhaps
83
84 // Margin and padding values shared by all sections.
85 const int kPopupMarginBottom = 16;
86
87 /**************** Security Section (PopupHeaderView) ****************/
77 88
78 // Margin and padding values for the |PopupHeaderView|. 89 // Margin and padding values for the |PopupHeaderView|.
79 const int kHeaderMarginBottom = 10; 90 const int kHeaderMarginBottom = 10;
80 const int kHeaderPaddingBottom = 16; 91 const int kHeaderPaddingBottom = 16;
81 const int kHeaderPaddingLeft = 18;
82 const int kHeaderPaddingRightForText = kHeaderPaddingLeft;
83 const int kHeaderPaddingTop = 16; 92 const int kHeaderPaddingTop = 16;
84 const int kHeaderPaddingForCloseButton = 8; 93 const int kHeaderPaddingForCloseButton = 8;
85 94
86 // Spacing between labels in the header. 95 // Spacing between labels in the header.
87 const int kHeaderLabelSpacing = 4; 96 const int kHeaderLabelSpacing = 4;
88 97
89 // The max possible width of the popup. 98 /**************** Site Settings Section ****************/
90 const int kMaxPopupWidth = 1000;
91 99
92 // The margins between the popup border and the popup content. 100 // Spacing before and after the cookies view.
93 const int kPopupMarginBottom = 14; 101 const int kCookiesViewVerticalPadding = 6;
94 102
95 // Padding values for sections on the site settings view. 103 // Square size of the permission images.
96 const int kSiteSettingsViewContentMinWidth = 300; 104 const int kPermissionImageSize = 16;
msw 2016/09/26 20:47:55 Does this only apply to vector icons or are image
lgarron 2016/09/28 21:11:46 All image resources are 16px (default_100_percent)
97 const int kSiteSettingsViewPaddingBottom = 6;
98 const int kSiteSettingsViewPaddingLeft = 18;
99 const int kSiteSettingsViewPaddingRight = 18;
100 const int kSiteSettingsViewPaddingTop = 4;
101 105
102 // Space between the headline and the content of a section. 106 // Spacing between a permission image and the text.
103 const int kSiteSettingsViewHeadlineMarginBottom = 10; 107 const int kPermissionImageSpacing = 6;
104 // Spacing between rows in the "Permissions" and "Cookies and Site Data"
105 // sections.
106 const int kContentRowSpacing = 2;
107 108
108 const int kSiteDataIconColumnWidth = 20; 109 // Spacing between rows in the site settings section
110 const int kPermissionsVerticalSpacing = 12;
111
112 /**************** Button IDs ****************/
109 113
110 const int BUTTON_RESET_CERTIFICATE_DECISIONS = 1337; 114 const int BUTTON_RESET_CERTIFICATE_DECISIONS = 1337;
115 const int BUTTON_SITE_SETTINGS = 1338;
111 116
112 } // namespace 117 } // namespace
113 118
114 // |PopupHeaderView| is the UI element (view) that represents the header of the 119 // |PopupHeaderView| is the UI element (view) that represents the header of the
115 // |WebsiteSettingsPopupView|. The header shows the status of the site's 120 // |WebsiteSettingsPopupView|. The header shows the status of the site's
116 // identity check and the name of the site's identity. 121 // identity check and the name of the site's identity.
117 class PopupHeaderView : public views::View { 122 class PopupHeaderView : public views::View {
118 public: 123 public:
119 explicit PopupHeaderView(views::ButtonListener* button_listener, 124 explicit PopupHeaderView(views::ButtonListener* button_listener,
120 views::StyledLabelListener* styled_label_listener); 125 views::StyledLabelListener* styled_label_listener);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 : styled_label_listener_(styled_label_listener), 190 : styled_label_listener_(styled_label_listener),
186 summary_label_(nullptr), 191 summary_label_(nullptr),
187 details_label_(nullptr), 192 details_label_(nullptr),
188 reset_decisions_label_container_(nullptr), 193 reset_decisions_label_container_(nullptr),
189 reset_decisions_label_(nullptr) { 194 reset_decisions_label_(nullptr) {
190 views::GridLayout* layout = new views::GridLayout(this); 195 views::GridLayout* layout = new views::GridLayout(this);
191 SetLayoutManager(layout); 196 SetLayoutManager(layout);
192 197
193 const int label_column = 0; 198 const int label_column = 0;
194 views::ColumnSet* column_set = layout->AddColumnSet(label_column); 199 views::ColumnSet* column_set = layout->AddColumnSet(label_column);
195 column_set->AddPaddingColumn(0, kHeaderPaddingLeft); 200 column_set->AddPaddingColumn(0, kSectionPaddingHorizontal);
196 column_set->AddColumn(views::GridLayout::FILL, 201 column_set->AddColumn(views::GridLayout::FILL,
197 views::GridLayout::FILL, 202 views::GridLayout::FILL,
198 1, 203 1,
199 views::GridLayout::USE_PREF, 204 views::GridLayout::USE_PREF,
200 0, 205 0,
201 0); 206 0);
202 column_set->AddPaddingColumn(1, 0); 207 column_set->AddPaddingColumn(1, 0);
203 column_set->AddColumn(views::GridLayout::FILL, 208 column_set->AddColumn(views::GridLayout::FILL,
204 views::GridLayout::FILL, 209 views::GridLayout::FILL,
205 1, 210 1,
(...skipping 24 matching lines...) Expand all
230 close_button->SetImage(views::CustomButton::STATE_PRESSED, 235 close_button->SetImage(views::CustomButton::STATE_PRESSED,
231 rb.GetImageNamed(IDR_CLOSE_2_P).ToImageSkia()); 236 rb.GetImageNamed(IDR_CLOSE_2_P).ToImageSkia());
232 layout->AddView(close_button, 1, 1, views::GridLayout::TRAILING, 237 layout->AddView(close_button, 1, 1, views::GridLayout::TRAILING,
233 views::GridLayout::LEADING); 238 views::GridLayout::LEADING);
234 239
235 layout->AddPaddingRow(0, kHeaderLabelSpacing); 240 layout->AddPaddingRow(0, kHeaderLabelSpacing);
236 241
237 const int label_column_status = 1; 242 const int label_column_status = 1;
238 views::ColumnSet* column_set_status = 243 views::ColumnSet* column_set_status =
239 layout->AddColumnSet(label_column_status); 244 layout->AddColumnSet(label_column_status);
240 column_set_status->AddPaddingColumn(0, kHeaderPaddingLeft); 245 column_set_status->AddPaddingColumn(0, kSectionPaddingHorizontal);
241 column_set_status->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 246 column_set_status->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
242 1, views::GridLayout::USE_PREF, 0, 0); 247 1, views::GridLayout::USE_PREF, 0, 0);
243 column_set_status->AddPaddingColumn(0, kHeaderPaddingRightForText); 248 column_set_status->AddPaddingColumn(0, kSectionPaddingHorizontal);
244 249
245 layout->AddPaddingRow(0, kHeaderLabelSpacing); 250 layout->AddPaddingRow(0, kHeaderLabelSpacing);
246 251
247 layout->StartRow(0, label_column_status); 252 layout->StartRow(0, label_column_status);
248 details_label_ = 253 details_label_ =
249 new views::StyledLabel(base::string16(), styled_label_listener); 254 new views::StyledLabel(base::string16(), styled_label_listener);
250 layout->AddView(details_label_, 1, 1, views::GridLayout::LEADING, 255 layout->AddView(details_label_, 1, 1, views::GridLayout::LEADING,
251 views::GridLayout::LEADING); 256 views::GridLayout::LEADING);
252 257
253 layout->StartRow(0, label_column_status); 258 layout->StartRow(0, label_column_status);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 gfx::NativeView parent_window, 452 gfx::NativeView parent_window,
448 Profile* profile, 453 Profile* profile,
449 content::WebContents* web_contents, 454 content::WebContents* web_contents,
450 const GURL& url, 455 const GURL& url,
451 const security_state::SecurityStateModel::SecurityInfo& security_info) 456 const security_state::SecurityStateModel::SecurityInfo& security_info)
452 : content::WebContentsObserver(web_contents), 457 : content::WebContentsObserver(web_contents),
453 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), 458 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
454 header_(nullptr), 459 header_(nullptr),
455 separator_(nullptr), 460 separator_(nullptr),
456 site_settings_view_(nullptr), 461 site_settings_view_(nullptr),
457 site_data_content_(nullptr), 462 cookies_view_(nullptr),
458 cookie_dialog_link_(nullptr), 463 cookie_dialog_link_(nullptr),
459 permissions_content_(nullptr), 464 permissions_view_(nullptr),
460 site_settings_link_(nullptr), 465 site_settings_button_(nullptr),
461 weak_factory_(this) { 466 weak_factory_(this) {
462 set_parent_window(parent_window); 467 set_parent_window(parent_window);
463 468
464 is_devtools_disabled_ = 469 is_devtools_disabled_ =
465 profile->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); 470 profile->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled);
466 471
467 // Compensate for built-in vertical padding in the anchor view's image. 472 // Compensate for built-in vertical padding in the anchor view's image.
468 set_anchor_view_insets(gfx::Insets( 473 set_anchor_view_insets(gfx::Insets(
469 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); 474 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0));
470 475
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 is_popup_showing = false; 532 is_popup_showing = false;
528 presenter_->OnUIClosing(); 533 presenter_->OnUIClosing();
529 } 534 }
530 535
531 int WebsiteSettingsPopupView::GetDialogButtons() const { 536 int WebsiteSettingsPopupView::GetDialogButtons() const {
532 return ui::DIALOG_BUTTON_NONE; 537 return ui::DIALOG_BUTTON_NONE;
533 } 538 }
534 539
535 void WebsiteSettingsPopupView::ButtonPressed(views::Button* button, 540 void WebsiteSettingsPopupView::ButtonPressed(views::Button* button,
536 const ui::Event& event) { 541 const ui::Event& event) {
537 if (button->id() == BUTTON_RESET_CERTIFICATE_DECISIONS) 542 switch (button->id()) {
538 presenter_->OnRevokeSSLErrorBypassButtonPressed(); 543 case BUTTON_RESET_CERTIFICATE_DECISIONS:
539 GetWidget()->Close(); 544 presenter_->OnRevokeSSLErrorBypassButtonPressed();
545 GetWidget()->Close();
546 break;
547 case BUTTON_SITE_SETTINGS:
548 // TODO(palmer): This opens the general Content Settings pane, which is OK
549 // for now. But on Android, it opens a page specific to a given origin
550 // that
msw 2016/09/26 20:47:56 Fix line wrapping.
lgarron 2016/09/28 21:11:46 Done.
551 // shows all of the settings for that origin. If/when that's available on
552 // desktop we should link to that here, too.
553 web_contents()->OpenURL(content::OpenURLParams(
554 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(),
555 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK,
556 false));
557 presenter_->RecordWebsiteSettingsAction(
558 WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED);
559 break;
560 default:
561 NOTREACHED();
562 }
540 } 563 }
541 564
542 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, 565 void WebsiteSettingsPopupView::LinkClicked(views::Link* source,
543 int event_flags) { 566 int event_flags) {
544 // The popup closes automatically when the collected cookies dialog or the 567 // The popup closes automatically when the collected cookies dialog or the
545 // certificate viewer opens. So delay handling of the link clicked to avoid 568 // certificate viewer opens. So delay handling of the link clicked to avoid
546 // a crash in the base class which needs to complete the mouse event handling. 569 // a crash in the base class which needs to complete the mouse event handling.
547 content::BrowserThread::PostTask( 570 content::BrowserThread::PostTask(
548 content::BrowserThread::UI, FROM_HERE, 571 content::BrowserThread::UI, FROM_HERE,
549 base::Bind(&WebsiteSettingsPopupView::HandleLinkClickedAsync, 572 base::Bind(&WebsiteSettingsPopupView::HandleLinkClickedAsync,
550 weak_factory_.GetWeakPtr(), source)); 573 weak_factory_.GetWeakPtr(), source));
551 } 574 }
552 575
553 gfx::Size WebsiteSettingsPopupView::GetPreferredSize() const { 576 gfx::Size WebsiteSettingsPopupView::GetPreferredSize() const {
554 if (header_ == nullptr && site_settings_view_ == nullptr) 577 if (header_ == nullptr && site_settings_view_ == nullptr)
555 return views::View::GetPreferredSize(); 578 return views::View::GetPreferredSize();
556 579
557 int height = 0; 580 int height = 0;
558 if (header_) 581 if (header_)
559 height += header_->GetPreferredSize().height() + kHeaderMarginBottom; 582 height += header_->GetPreferredSize().height() + kHeaderMarginBottom;
560 if (separator_) 583 if (separator_)
561 height += separator_->GetPreferredSize().height(); 584 height += separator_->GetPreferredSize().height();
562 585
563 if (site_settings_view_) 586 if (site_settings_view_)
564 height += site_settings_view_->GetPreferredSize().height(); 587 height += site_settings_view_->GetPreferredSize().height();
565 588
566 int width = kSiteSettingsViewContentMinWidth; 589 int width = kMinPopupWidth;
567 if (site_data_content_)
568 width = std::max(width, site_data_content_->GetPreferredSize().width());
569 if (permissions_content_)
570 width = std::max(width, permissions_content_->GetPreferredSize().width());
571 if (header_) 590 if (header_)
572 width = std::max(width, header_->GetPreferredNameWidth()); 591 width = std::max(width, header_->GetPreferredNameWidth());
msw 2016/09/26 20:47:56 Did this rely on the addition of padding values?
lgarron 2016/09/28 21:11:46 Indeed, yes. But now that you've prompted me to lo
573 width += kSiteSettingsViewPaddingLeft + kSiteSettingsViewPaddingRight; 592 if (site_settings_view_)
593 width = std::max(width, site_settings_view_->GetPreferredSize().width());
574 width = std::min(width, kMaxPopupWidth); 594 width = std::min(width, kMaxPopupWidth);
575 return gfx::Size(width, height); 595 return gfx::Size(width, height);
576 } 596 }
577 597
578 void WebsiteSettingsPopupView::SetCookieInfo( 598 void WebsiteSettingsPopupView::SetCookieInfo(
579 const CookieInfoList& cookie_info_list) { 599 const CookieInfoList& cookie_info_list) {
580 // |cookie_info_list| should only ever have 2 items: first- and third-party 600 // |cookie_info_list| should only ever have 2 items: first- and third-party
581 // cookies. 601 // cookies.
582 DCHECK_EQ(cookie_info_list.size(), 2u); 602 DCHECK_EQ(cookie_info_list.size(), 2u);
583 base::string16 first_party_label_text; 603 base::string16 label_text;
584 base::string16 third_party_label_text; 604 int total_allowed = 0;
msw 2016/09/26 20:47:56 nit: can you just do something like: int allowed
lgarron 2016/09/28 21:11:47 I could, but that would be inconsistent with the (
msw 2016/09/30 00:37:04 This is fine as-is
585 for (const auto& i : cookie_info_list) { 605 for (const auto& i : cookie_info_list) {
msw 2016/09/26 20:47:56 nit: curlies not needed; s/i/cookie/
lgarron 2016/09/28 21:11:46 Done.
586 if (i.is_first_party) { 606 total_allowed += i.allowed;
587 first_party_label_text = l10n_util::GetPluralStringFUTF16(
588 IDS_WEBSITE_SETTINGS_FIRST_PARTY_SITE_DATA, i.allowed);
msw 2016/09/26 20:47:55 Remove string resources that are no longer used.
lgarron 2016/09/28 21:11:46 Done.
589 } else {
590 third_party_label_text = l10n_util::GetPluralStringFUTF16(
591 IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA, i.allowed);
msw 2016/09/26 20:47:56 Remove string resources that are no longer used.
lgarron 2016/09/28 21:11:47 Done.
592 }
593 } 607 }
608 label_text = l10n_util::GetPluralStringFUTF16(
msw 2016/09/26 20:47:56 nit: combine the declaration and assignment of |la
lgarron 2016/09/28 21:11:46 Done.
609 IDS_WEBSITE_SETTINGS_NUM_COOKIES, total_allowed);
594 610
595 if (!cookie_dialog_link_) { 611 if (!cookie_dialog_link_) {
596 cookie_dialog_link_ = new views::Link(first_party_label_text); 612 cookie_dialog_link_ = new views::Link(label_text);
597 cookie_dialog_link_->set_listener(this); 613 cookie_dialog_link_->set_listener(this);
598 } else { 614 } else {
599 cookie_dialog_link_->SetText(first_party_label_text); 615 cookie_dialog_link_->SetText(label_text);
600 } 616 }
601 617
602 views::GridLayout* layout = 618 views::GridLayout* layout =
603 static_cast<views::GridLayout*>(site_data_content_->GetLayoutManager()); 619 static_cast<views::GridLayout*>(cookies_view_->GetLayoutManager());
604 if (!layout) { 620 if (!layout) {
605 layout = new views::GridLayout(site_data_content_); 621 layout = new views::GridLayout(cookies_view_);
606 site_data_content_->SetLayoutManager(layout); 622 cookies_view_->SetLayoutManager(layout);
607 623
608 const int site_data_content_column = 0; 624 const int cookies_view_column = 0;
609 views::ColumnSet* column_set = 625 views::ColumnSet* column_set = layout->AddColumnSet(cookies_view_column);
610 layout->AddColumnSet(site_data_content_column); 626 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
611 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, 627 views::GridLayout::FIXED, kPermissionImageSize, 0);
612 views::GridLayout::FIXED, kSiteDataIconColumnWidth, 628 column_set->AddPaddingColumn(0, kPermissionImageSpacing);
613 0); 629 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL,
614 column_set->AddPaddingColumn(0, kIconMarginLeft); 630 0, views::GridLayout::USE_PREF, 0, 0);
615 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
616 views::GridLayout::USE_PREF, 0, 0);
617 // No padding. This third column is for |third_party_label_text| (see
618 // below),
619 // and the text needs to flow naturally from the |first_party_label_text|
620 // link.
621 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
622 views::GridLayout::USE_PREF, 0, 0);
623 631
624 layout->AddPaddingRow(1, 5); 632 layout->AddPaddingRow(0, kCookiesViewVerticalPadding);
625 633
626 layout->StartRow(1, site_data_content_column); 634 layout->StartRow(1, cookies_view_column);
627 WebsiteSettingsUI::PermissionInfo info; 635 WebsiteSettingsUI::PermissionInfo info;
628 info.type = CONTENT_SETTINGS_TYPE_COOKIES; 636 info.type = CONTENT_SETTINGS_TYPE_COOKIES;
629 info.setting = CONTENT_SETTING_ALLOW; 637 info.setting = CONTENT_SETTING_ALLOW;
630 info.is_incognito = 638 info.is_incognito =
631 Profile::FromBrowserContext(web_contents()->GetBrowserContext()) 639 Profile::FromBrowserContext(web_contents()->GetBrowserContext())
632 ->IsOffTheRecord(); 640 ->IsOffTheRecord();
633 views::ImageView* icon = new views::ImageView(); 641 views::ImageView* icon = new views::ImageView();
634 const gfx::Image& image = WebsiteSettingsUI::GetPermissionIcon(info); 642 const gfx::Image& image = WebsiteSettingsUI::GetPermissionIcon(info);
635 icon->SetImage(image.ToImageSkia()); 643 icon->SetImage(image.ToImageSkia());
636 layout->AddView(icon, 1, 1, views::GridLayout::CENTER, 644 layout->AddView(
637 views::GridLayout::CENTER); 645 icon, 1, 2, views::GridLayout::FILL,
638 layout->AddView(cookie_dialog_link_, 1, 1, views::GridLayout::CENTER, 646 // TODO: The vertical alignment may change to CENTER once Harmony is
639 views::GridLayout::CENTER); 647 // implemented. See https://crbug.com/512442#c48
640 base::string16 comma = base::ASCIIToUTF16(", "); 648 views::GridLayout::LEADING);
641 649
642 layout->AddView(new views::Label(comma + third_party_label_text), 1, 1, 650 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
643 views::GridLayout::LEADING, views::GridLayout::CENTER); 651 const gfx::FontList& font_list = rb.GetFontListWithDelta(1);
msw 2016/09/26 20:47:55 Ditto
652 views::Label* cookies_label = new views::Label(
653 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA),
654 font_list);
655 layout->AddView(cookies_label);
656 layout->StartRow(1, cookies_view_column);
657 layout->SkipColumns(1);
644 658
645 layout->AddPaddingRow(1, 6); 659 layout->AddView(cookie_dialog_link_);
660
661 layout->AddPaddingRow(0, kCookiesViewVerticalPadding);
646 } 662 }
647 663
648 layout->Layout(site_data_content_); 664 layout->Layout(cookies_view_);
649 SizeToContents(); 665 SizeToContents();
650 } 666 }
651 667
652 void WebsiteSettingsPopupView::SetPermissionInfo( 668 void WebsiteSettingsPopupView::SetPermissionInfo(
653 const PermissionInfoList& permission_info_list, 669 const PermissionInfoList& permission_info_list,
654 const ChosenObjectInfoList& chosen_object_info_list) { 670 const ChosenObjectInfoList& chosen_object_info_list) {
655 // When a permission is changed, WebsiteSettings::OnSitePermissionChanged() 671 // When a permission is changed, WebsiteSettings::OnSitePermissionChanged()
656 // calls this method with updated permissions. However, PermissionSelectorRow 672 // calls this method with updated permissions. However, PermissionSelectorRow
657 // will have already updated its state, so it's already reflected in the UI. 673 // will have already updated its state, so it's already reflected in the UI.
658 // In addition, if a permission is set to the default setting, WebsiteSettings 674 // In addition, if a permission is set to the default setting, WebsiteSettings
659 // removes it from |permission_info_list|, but the button should remain. 675 // removes it from |permission_info_list|, but the button should remain.
660 if (permissions_content_) { 676 if (permissions_view_) {
661 base::STLDeleteContainerPointers(chosen_object_info_list.begin(), 677 base::STLDeleteContainerPointers(chosen_object_info_list.begin(),
662 chosen_object_info_list.end()); 678 chosen_object_info_list.end());
663 return; 679 return;
664 } 680 }
665 681
666 permissions_content_ = new views::View(); 682 permissions_view_ = new views::View();
667 views::GridLayout* layout = new views::GridLayout(permissions_content_); 683 views::GridLayout* layout = new views::GridLayout(permissions_view_);
668 permissions_content_->SetLayoutManager(layout); 684 permissions_view_->SetLayoutManager(layout);
685 site_settings_view_->AddChildView(permissions_view_);
669 686
670 base::string16 headline = 687 const int column_set_id = 0;
671 permission_info_list.empty() 688 views::ColumnSet* column_set = layout->AddColumnSet(column_set_id);
672 ? base::string16() 689 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
673 : l10n_util::GetStringUTF16( 690 views::GridLayout::FIXED, kPermissionImageSize, 0);
674 IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS); 691 column_set->AddPaddingColumn(0, kPermissionImageSpacing);
675 views::View* permissions_section = 692 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
676 CreateSection(headline, permissions_content_, nullptr); 693 views::GridLayout::USE_PREF, 0, 0);
677 site_settings_view_->AddChildView(permissions_section);
678 694
679 const int content_column = 0;
680 views::ColumnSet* column_set = layout->AddColumnSet(content_column);
681 column_set->AddColumn(views::GridLayout::FILL,
682 views::GridLayout::FILL,
683 1,
684 views::GridLayout::USE_PREF,
685 0,
686 0);
687 for (const auto& permission : permission_info_list) { 695 for (const auto& permission : permission_info_list) {
688 layout->StartRow(1, content_column); 696 layout->StartRow(1, column_set_id);
689 PermissionSelectorRow* selector = new PermissionSelectorRow( 697 PermissionSelectorRow* selector = new PermissionSelectorRow(
690 web_contents() ? web_contents()->GetVisibleURL() : GURL::EmptyGURL(), 698 web_contents() ? web_contents()->GetVisibleURL() : GURL::EmptyGURL(),
691 permission); 699 permission, layout);
692 selector->AddObserver(this); 700 selector->AddObserver(this);
693 layout->AddView(selector, 701 layout->AddPaddingRow(1, kPermissionsVerticalSpacing);
694 1,
695 1,
696 views::GridLayout::LEADING,
697 views::GridLayout::CENTER);
698 layout->AddPaddingRow(1, kContentRowSpacing);
699 } 702 }
700 703
701 for (auto* object : chosen_object_info_list) { 704 if (chosen_object_info_list.size() > 0) {
msw 2016/09/26 20:47:55 nit: This seems unnecessary, given the loop below;
lgarron 2016/09/28 21:11:46 Hmm, this seems to be from an old version of the c
702 layout->StartRow(1, content_column); 705 for (auto* object : chosen_object_info_list) {
703 // The view takes ownership of the object info. 706 layout->StartRow(1, column_set_id);
704 auto* object_view = new ChosenObjectRow(base::WrapUnique(object)); 707 // layout->SkipColumns(1);
msw 2016/09/26 20:47:56 Remove commented-out code; please do a close self-
lgarron 2016/09/28 21:11:47 Done, sorry about that (I actually did several pas
705 object_view->AddObserver(this); 708 // The view takes ownership of the object info.
706 layout->AddView(object_view, 1, 1, views::GridLayout::LEADING, 709 auto object_view = new ChosenObjectRow(base::WrapUnique(object), layout);
707 views::GridLayout::CENTER); 710 object_view->AddObserver(this);
708 layout->AddPaddingRow(1, kContentRowSpacing); 711 // layout->AddView(object_view, 1, 2, views::GridLayout::LEADING,
msw 2016/09/26 20:47:56 Remove commented-out code; please do a close self-
lgarron 2016/09/28 21:11:47 Done.
712 // views::GridLayout::CENTER);
713 layout->AddPaddingRow(1, kPermissionsVerticalSpacing);
714 }
709 } 715 }
710 716
711 layout->Layout(permissions_content_); 717 layout->Layout(permissions_view_);
712 718
713 // Add site settings link. 719 // Add site settings link.
714 site_settings_link_ = new views::Link( 720 views::LabelButton* site_settings_button_ =
msw 2016/09/26 20:47:56 Does this conflict with a member identifier? Don't
lgarron 2016/09/28 21:11:46 It used to be a member, but should not be anymore.
715 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_SETTINGS_LINK)); 721 views::MdTextButton::CreateSecondaryUiButton(
716 site_settings_link_->set_listener(this); 722 this, l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_SETTINGS_LINK));
717 views::View* link_section = new views::View(); 723 site_settings_button_->set_id(BUTTON_SITE_SETTINGS);
718 const int kLinkMarginTop = 4; 724 views::View* button_wrapper = new views::View();
719 link_section->SetLayoutManager( 725 views::BoxLayout* box_layout =
720 new views::BoxLayout(views::BoxLayout::kHorizontal, 726 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
721 kSiteSettingsViewPaddingLeft, kLinkMarginTop, 0)); 727 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
msw 2016/09/26 20:47:55 nit: box_layout->set_main_axis_alignment(ui::Mater
lgarron 2016/09/28 21:11:47 Done.
722 link_section->AddChildView(site_settings_link_); 728 box_layout->set_main_axis_alignment(
723 site_settings_view_->AddChildView(link_section); 729 views::BoxLayout::MAIN_AXIS_ALIGNMENT_END);
730 } else {
731 box_layout->set_main_axis_alignment(
732 views::BoxLayout::MAIN_AXIS_ALIGNMENT_START);
733 }
734 button_wrapper->SetLayoutManager(box_layout);
735 button_wrapper->AddChildView(site_settings_button_);
736 site_settings_view_->AddChildView(button_wrapper);
724 737
725 SizeToContents(); 738 SizeToContents();
726 } 739 }
727 740
728 void WebsiteSettingsPopupView::SetIdentityInfo( 741 void WebsiteSettingsPopupView::SetIdentityInfo(
729 const IdentityInfo& identity_info) { 742 const IdentityInfo& identity_info) {
730 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description = 743 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description =
731 identity_info.GetSecurityDescription(); 744 identity_info.GetSecurityDescription();
732 745
733 header_->SetSummary(security_description->summary); 746 header_->SetSummary(security_description->summary);
(...skipping 11 matching lines...) Expand all
745 758
746 Layout(); 759 Layout();
747 SizeToContents(); 760 SizeToContents();
748 } 761 }
749 762
750 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) { 763 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) {
751 // TODO(lgarron): Remove this method. (https://crbug.com/571533) 764 // TODO(lgarron): Remove this method. (https://crbug.com/571533)
752 } 765 }
753 766
754 views::View* WebsiteSettingsPopupView::CreateSiteSettingsView() { 767 views::View* WebsiteSettingsPopupView::CreateSiteSettingsView() {
755 views::View* pane = new views::View(); 768 views::View* site_settings_view = new views::View();
756 pane->SetLayoutManager( 769 views::BoxLayout* box_layout =
757 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1)); 770 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0);
771 site_settings_view->SetLayoutManager(box_layout);
772 box_layout->set_cross_axis_alignment(
773 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH);
758 774
759 // Add cookies and site data section. 775 // Add cookies view.
760 site_data_content_ = new views::View(); 776 cookies_view_ = new views::View();
761 views::View* site_data_section = CreateSection( 777 box_layout->set_inside_border_insets(
msw 2016/09/26 20:47:56 nit: move above with the other |box_layout| init (
lgarron 2016/09/28 21:11:46 Done.
762 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA), 778 gfx::Insets(0, kSectionPaddingHorizontal));
763 site_data_content_, nullptr); 779 site_settings_view->AddChildView(cookies_view_);
764 pane->AddChildView(site_data_section);
765 780
766 return pane; 781 return site_settings_view;
767 } 782 }
768 views::View* WebsiteSettingsPopupView::CreateSection(
769 const base::string16& headline_text,
770 views::View* content,
771 views::Link* link) {
772 views::View* container = new views::View();
773 views::GridLayout* layout = new views::GridLayout(container);
774 container->SetLayoutManager(layout);
775 const int content_column = 0;
776 views::ColumnSet* column_set = layout->AddColumnSet(content_column);
777 column_set->AddPaddingColumn(0, kSiteSettingsViewPaddingLeft);
778 column_set->AddColumn(views::GridLayout::FILL,
779 views::GridLayout::FILL,
780 1,
781 views::GridLayout::USE_PREF,
782 0,
783 0);
784
785 if (headline_text.length() > 0) {
786 layout->AddPaddingRow(1, kSiteSettingsViewPaddingTop);
787 layout->StartRow(1, content_column);
788 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
789 views::Label* headline = new views::Label(
790 headline_text, rb.GetFontList(ui::ResourceBundle::BoldFont));
791 layout->AddView(headline, 1, 1, views::GridLayout::LEADING,
792 views::GridLayout::CENTER);
793 }
794
795 layout->AddPaddingRow(1, kSiteSettingsViewHeadlineMarginBottom);
796 layout->StartRow(1, content_column);
797 layout->AddView(content, 1, 1, views::GridLayout::LEADING,
798 views::GridLayout::CENTER);
799
800 if (link) {
801 layout->AddPaddingRow(1, 4);
802 layout->StartRow(1, content_column);
803 layout->AddView(link, 1, 1, views::GridLayout::LEADING,
804 views::GridLayout::CENTER);
805 }
806
807 layout->AddPaddingRow(1, kSiteSettingsViewPaddingBottom);
808 return container;
809 }
810
811 783
812 void WebsiteSettingsPopupView::HandleLinkClickedAsync(views::Link* source) { 784 void WebsiteSettingsPopupView::HandleLinkClickedAsync(views::Link* source) {
813 if (web_contents() == nullptr || web_contents()->IsBeingDestroyed()) 785 if (web_contents() == nullptr || web_contents()->IsBeingDestroyed())
814 return; 786 return;
815 787 DCHECK_EQ(source, cookie_dialog_link_);
816 if (source == cookie_dialog_link_) { 788 // Count how often the Collected Cookies dialog is opened.
817 // Count how often the Collected Cookies dialog is opened. 789 presenter_->RecordWebsiteSettingsAction(
818 presenter_->RecordWebsiteSettingsAction( 790 WebsiteSettings::WEBSITE_SETTINGS_COOKIES_DIALOG_OPENED);
819 WebsiteSettings::WEBSITE_SETTINGS_COOKIES_DIALOG_OPENED); 791 new CollectedCookiesViews(web_contents());
820
821 new CollectedCookiesViews(web_contents());
822 } else if (source == site_settings_link_) {
823 // TODO(palmer): This opens the general Content Settings pane, which is OK
824 // for now. But on Android, it opens a page specific to a given origin that
825 // shows all of the settings for that origin. If/when that's available on
826 // desktop we should link to that here, too.
827 web_contents()->OpenURL(content::OpenURLParams(
828 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(),
829 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK,
830 false));
831 presenter_->RecordWebsiteSettingsAction(
832 WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED);
833 } else {
834 NOTREACHED();
835 }
836 } 792 }
837 793
838 void WebsiteSettingsPopupView::StyledLabelLinkClicked(views::StyledLabel* label, 794 void WebsiteSettingsPopupView::StyledLabelLinkClicked(views::StyledLabel* label,
839 const gfx::Range& range, 795 const gfx::Range& range,
840 int event_flags) { 796 int event_flags) {
841 presenter_->RecordWebsiteSettingsAction( 797 presenter_->RecordWebsiteSettingsAction(
842 WebsiteSettings::WEBSITE_SETTINGS_SECURITY_DETAILS_OPENED); 798 WebsiteSettings::WEBSITE_SETTINGS_SECURITY_DETAILS_OPENED);
843 799
844 if (is_devtools_disabled_) { 800 if (is_devtools_disabled_) {
845 DCHECK(certificate_); 801 DCHECK(certificate_);
846 gfx::NativeWindow parent = 802 gfx::NativeWindow parent =
847 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr; 803 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr;
848 presenter_->RecordWebsiteSettingsAction( 804 presenter_->RecordWebsiteSettingsAction(
849 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED); 805 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED);
850 ShowCertificateViewer(web_contents(), parent, certificate_.get()); 806 ShowCertificateViewer(web_contents(), parent, certificate_.get());
851 } else { 807 } else {
852 DevToolsWindow::OpenDevToolsWindow( 808 DevToolsWindow::OpenDevToolsWindow(
853 web_contents(), DevToolsToggleAction::ShowSecurityPanel()); 809 web_contents(), DevToolsToggleAction::ShowSecurityPanel());
854 } 810 }
855 } 811 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698