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

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

Issue 2717613003: Views Page Info: Implement expanding all permissions (Closed)
Patch Set: gco default-mac 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
« no previous file with comments | « chrome/browser/ui/views/website_settings/website_settings_popup_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 // Spacing between rows in the site settings section 98 // Spacing between rows in the site settings section
99 const int kPermissionsVerticalSpacing = 12; 99 const int kPermissionsVerticalSpacing = 12;
100 100
101 // Button/styled label/link IDs ------------------------------------------------ 101 // Button/styled label/link IDs ------------------------------------------------
102 const int BUTTON_CLOSE = 1337; 102 const int BUTTON_CLOSE = 1337;
103 const int STYLED_LABEL_SECURITY_DETAILS = 1338; 103 const int STYLED_LABEL_SECURITY_DETAILS = 1338;
104 const int STYLED_LABEL_RESET_CERTIFICATE_DECISIONS = 1339; 104 const int STYLED_LABEL_RESET_CERTIFICATE_DECISIONS = 1339;
105 const int LINK_COOKIE_DIALOG = 1340; 105 const int LINK_COOKIE_DIALOG = 1340;
106 const int LINK_SITE_SETTINGS = 1341; 106 const int LINK_SITE_SETTINGS = 1341;
107 const int LINK_SHOW_ALL_PERMISSIONS = 1342;
107 108
108 // The default, ui::kTitleFontSizeDelta, is too large for the website settings 109 // The default, ui::kTitleFontSizeDelta, is too large for the website settings
109 // bubble (e.g. +3). Use +1 to obtain a smaller font. 110 // bubble (e.g. +3). Use +1 to obtain a smaller font.
110 constexpr int kSummaryFontSizeDelta = 1; 111 constexpr int kSummaryFontSizeDelta = 1;
111 112
112 // Adds a ColumnSet on |layout| with a single View column and padding columns 113 // Adds a ColumnSet on |layout| with a single View column and padding columns
113 // on either side of it with |margin| width. 114 // on either side of it with |margin| width.
114 void AddColumnWithSideMargin(views::GridLayout* layout, int margin, int id) { 115 void AddColumnWithSideMargin(views::GridLayout* layout, int margin, int id) {
115 views::ColumnSet* column_set = layout->AddColumnSet(id); 116 views::ColumnSet* column_set = layout->AddColumnSet(id);
116 column_set->AddPaddingColumn(0, margin); 117 column_set->AddPaddingColumn(0, margin);
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 const security_state::SecurityInfo& security_info) 396 const security_state::SecurityInfo& security_info)
396 : content::WebContentsObserver(web_contents), 397 : content::WebContentsObserver(web_contents),
397 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), 398 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
398 profile_(profile), 399 profile_(profile),
399 header_(nullptr), 400 header_(nullptr),
400 separator_(nullptr), 401 separator_(nullptr),
401 site_settings_view_(nullptr), 402 site_settings_view_(nullptr),
402 cookies_view_(nullptr), 403 cookies_view_(nullptr),
403 cookie_dialog_link_(nullptr), 404 cookie_dialog_link_(nullptr),
404 permissions_view_(nullptr), 405 permissions_view_(nullptr),
406 permission_link_(nullptr),
405 weak_factory_(this) { 407 weak_factory_(this) {
406 g_shown_popup_type = POPUP_WEBSITE_SETTINGS; 408 g_shown_popup_type = POPUP_WEBSITE_SETTINGS;
407 set_parent_window(parent_window); 409 set_parent_window(parent_window);
408 410
409 // Compensate for built-in vertical padding in the anchor view's image. 411 // Compensate for built-in vertical padding in the anchor view's image.
410 set_anchor_view_insets(gfx::Insets( 412 set_anchor_view_insets(gfx::Insets(
411 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); 413 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0));
412 414
413 // Capture the default bubble margin, and move it to the Layout classes. This 415 // Capture the default bubble margin, and move it to the Layout classes. This
414 // is necessary so that the views::Separator can extend the full width of the 416 // is necessary so that the views::Separator can extend the full width of the
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 layout->AddPaddingRow(0, kCookiesViewVerticalPadding); 611 layout->AddPaddingRow(0, kCookiesViewVerticalPadding);
610 } 612 }
611 613
612 layout->Layout(cookies_view_); 614 layout->Layout(cookies_view_);
613 SizeToContents(); 615 SizeToContents();
614 } 616 }
615 617
616 void WebsiteSettingsPopupView::SetPermissionInfo( 618 void WebsiteSettingsPopupView::SetPermissionInfo(
617 const PermissionInfoList& permission_info_list, 619 const PermissionInfoList& permission_info_list,
618 ChosenObjectInfoList chosen_object_info_list) { 620 ChosenObjectInfoList chosen_object_info_list) {
619 // When a permission is changed, WebsiteSettings::OnSitePermissionChanged() 621 // Recreate the permissions view from the new info.
620 // calls this method with updated permissions. However, PermissionSelectorRow 622 permissions_view_->RemoveAllChildViews(true);
621 // will have already updated its state, so it's already reflected in the UI.
622 // In addition, if a permission is set to the default setting, WebsiteSettings
623 // removes it from |permission_info_list|, but the button should remain.
624 if (permissions_view_)
625 return;
626 623
627 permissions_view_ = new views::View();
628 views::GridLayout* layout = new views::GridLayout(permissions_view_); 624 views::GridLayout* layout = new views::GridLayout(permissions_view_);
629 permissions_view_->SetLayoutManager(layout); 625 permissions_view_->SetLayoutManager(layout);
630 626
631 site_settings_view_->AddChildView(permissions_view_);
632
633 const int content_column = 0; 627 const int content_column = 0;
634 views::ColumnSet* column_set = layout->AddColumnSet(content_column); 628 views::ColumnSet* column_set = layout->AddColumnSet(content_column);
635 column_set->AddColumn(views::GridLayout::FILL, 629 column_set->AddColumn(views::GridLayout::FILL,
636 views::GridLayout::FILL, 630 views::GridLayout::FILL,
637 1, 631 1,
638 views::GridLayout::USE_PREF, 632 views::GridLayout::USE_PREF,
639 0, 633 0,
640 0); 634 0);
641 for (const auto& permission : permission_info_list) { 635 for (const auto& permission : permission_info_list) {
642 layout->StartRow(1, content_column); 636 layout->StartRow(1, content_column);
(...skipping 11 matching lines...) Expand all
654 layout->StartRow(1, content_column); 648 layout->StartRow(1, content_column);
655 // The view takes ownership of the object info. 649 // The view takes ownership of the object info.
656 auto* object_view = new ChosenObjectRow(std::move(object)); 650 auto* object_view = new ChosenObjectRow(std::move(object));
657 object_view->AddObserver(this); 651 object_view->AddObserver(this);
658 layout->AddView(object_view, 1, 1, views::GridLayout::LEADING, 652 layout->AddView(object_view, 1, 1, views::GridLayout::LEADING,
659 views::GridLayout::CENTER); 653 views::GridLayout::CENTER);
660 layout->AddPaddingRow(1, kPermissionsVerticalSpacing); 654 layout->AddPaddingRow(1, kPermissionsVerticalSpacing);
661 } 655 }
662 656
663 layout->Layout(permissions_view_); 657 layout->Layout(permissions_view_);
664
665 // Add site settings link.
666 views::Link* site_settings_link = new views::Link(
667 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_SETTINGS_LINK));
668 site_settings_link->set_id(LINK_SITE_SETTINGS);
669 site_settings_link->set_listener(this);
670 views::View* link_section = new views::View();
671 const int kLinkMarginTop = 4;
672 link_section->SetLayoutManager(new views::BoxLayout(
673 views::BoxLayout::kHorizontal, 0, kLinkMarginTop, 0));
674 link_section->AddChildView(site_settings_link);
675 site_settings_view_->AddChildView(link_section);
676
677 SizeToContents(); 658 SizeToContents();
678 } 659 }
679 660
680 void WebsiteSettingsPopupView::UpdatePermissionButton( 661 void WebsiteSettingsPopupView::UpdatePermissionButton(
681 WebsiteSettingsUI::VisiblePermissions visible_permissions) { 662 WebsiteSettingsUI::VisiblePermissions visible_permissions) {
682 // TODO(crbug.com/657267) 663 permission_link_->SetText(GetPermissionButtonString(visible_permissions));
664 permission_link_->set_id(visible_permissions ==
665 WebsiteSettingsUI::VISIBLE_PERMISSIONS_ALL
666 ? LINK_SITE_SETTINGS
667 : LINK_SHOW_ALL_PERMISSIONS);
668 SizeToContents();
683 } 669 }
684 670
685 void WebsiteSettingsPopupView::SetIdentityInfo( 671 void WebsiteSettingsPopupView::SetIdentityInfo(
686 const IdentityInfo& identity_info) { 672 const IdentityInfo& identity_info) {
687 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description = 673 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description =
688 identity_info.GetSecurityDescription(); 674 identity_info.GetSecurityDescription();
689 675
690 summary_text_ = security_description->summary; 676 summary_text_ = security_description->summary;
691 GetWidget()->UpdateWindowTitle(); 677 GetWidget()->UpdateWindowTitle();
692 678
(...skipping 15 matching lines...) Expand all
708 views::BoxLayout* box_layout = 694 views::BoxLayout* box_layout =
709 new views::BoxLayout(views::BoxLayout::kVertical, side_margin, 0, 0); 695 new views::BoxLayout(views::BoxLayout::kVertical, side_margin, 0, 0);
710 site_settings_view->SetLayoutManager(box_layout); 696 site_settings_view->SetLayoutManager(box_layout);
711 box_layout->set_cross_axis_alignment( 697 box_layout->set_cross_axis_alignment(
712 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); 698 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH);
713 699
714 // Add cookies view. 700 // Add cookies view.
715 cookies_view_ = new views::View(); 701 cookies_view_ = new views::View();
716 site_settings_view->AddChildView(cookies_view_); 702 site_settings_view->AddChildView(cookies_view_);
717 703
704 permissions_view_ = new views::View();
705 site_settings_view->AddChildView(permissions_view_);
706
707 // Create permission link with wrapper, and keep a member reference to the
708 // link itself so we can change the title/behaviour later.
709 base::string16 permission_link_default_string =
710 GetPermissionButtonString(WebsiteSettingsUI::VISIBLE_PERMISSIONS_ALL);
711 permission_link_ = new views::Link(permission_link_default_string);
712 permission_link_->set_id(LINK_SITE_SETTINGS);
713 permission_link_->set_listener(this);
714 const int kLinkMarginTop = 4;
715 views::View* permission_link_wrapper = new views::View();
716 permission_link_wrapper->SetLayoutManager(new views::BoxLayout(
717 views::BoxLayout::kHorizontal, 0, kLinkMarginTop, 0));
718 permission_link_wrapper->AddChildView(permission_link_);
719 site_settings_view->AddChildView(permission_link_wrapper);
720
718 return site_settings_view; 721 return site_settings_view;
719 } 722 }
720 723
721 void WebsiteSettingsPopupView::HandleLinkClickedAsync(views::Link* source) { 724 void WebsiteSettingsPopupView::HandleLinkClickedAsync(views::Link* source) {
722 // Both switch cases require accessing web_contents(), so we check it here. 725 // Both switch cases require accessing web_contents(), so we check it here.
723 if (web_contents() == nullptr || web_contents()->IsBeingDestroyed()) 726 if (web_contents() == nullptr || web_contents()->IsBeingDestroyed())
724 return; 727 return;
725 switch (source->id()) { 728 switch (source->id()) {
729 case LINK_SHOW_ALL_PERMISSIONS:
730 // TODO(crbug.com/695670): Place this code in a cross-platform location.
731 DCHECK(presenter_);
732 presenter_->PresentAllSitePermissions();
733 presenter_->RecordWebsiteSettingsAction(
734 WebsiteSettings::WEBSITE_SETTINGS_SHOW_ALL_PERMISSIONS_PRESSED);
735 break;
726 case LINK_SITE_SETTINGS: 736 case LINK_SITE_SETTINGS:
727 // TODO(crbug.com/655876): This opens the general Content Settings pane, 737 // TODO(crbug.com/655876): This opens the general Content Settings pane,
728 // which is OK for now. But on Android, it opens a page specific to a 738 // which is OK for now. But on Android, it opens a page specific to a
729 // given origin that shows all of the settings for that origin. If/when 739 // given origin that shows all of the settings for that origin. If/when
730 // that's available on desktop we should link to that here, too. 740 // that's available on desktop we should link to that here, too.
731 web_contents()->OpenURL(content::OpenURLParams( 741 web_contents()->OpenURL(content::OpenURLParams(
732 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), 742 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(),
733 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, 743 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK,
734 false)); 744 false));
735 presenter_->RecordWebsiteSettingsAction( 745 presenter_->RecordWebsiteSettingsAction(
(...skipping 23 matching lines...) Expand all
759 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); 769 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED);
760 break; 770 break;
761 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: 771 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS:
762 presenter_->OnRevokeSSLErrorBypassButtonPressed(); 772 presenter_->OnRevokeSSLErrorBypassButtonPressed();
763 GetWidget()->Close(); 773 GetWidget()->Close();
764 break; 774 break;
765 default: 775 default:
766 NOTREACHED(); 776 NOTREACHED();
767 } 777 }
768 } 778 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/website_settings/website_settings_popup_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698