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/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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 // Spacing above and below the cookies view. | 91 // Spacing above and below the cookies view. |
92 const int kCookiesViewVerticalPadding = 6; | 92 const int kCookiesViewVerticalPadding = 6; |
93 | 93 |
94 // Spacing between a permission image and the text. | 94 // Spacing between a permission image and the text. |
95 const int kPermissionImageSpacing = 6; | 95 const int kPermissionImageSpacing = 6; |
96 | 96 |
97 // Spacing between rows in the site settings section | 97 // Spacing between rows in the site settings section |
98 const int kPermissionsVerticalSpacing = 12; | 98 const int kPermissionsVerticalSpacing = 12; |
99 | 99 |
| 100 // Spacing between the label and the menu. |
| 101 const int kPermissionMenuSpacing = 16; |
| 102 |
100 // Button/styled label/link IDs ------------------------------------------------ | 103 // Button/styled label/link IDs ------------------------------------------------ |
101 const int BUTTON_CLOSE = 1337; | 104 const int BUTTON_CLOSE = 1337; |
102 const int STYLED_LABEL_SECURITY_DETAILS = 1338; | 105 const int STYLED_LABEL_SECURITY_DETAILS = 1338; |
103 const int STYLED_LABEL_RESET_CERTIFICATE_DECISIONS = 1339; | 106 const int STYLED_LABEL_RESET_CERTIFICATE_DECISIONS = 1339; |
104 const int LINK_COOKIE_DIALOG = 1340; | 107 const int LINK_COOKIE_DIALOG = 1340; |
105 const int LINK_SITE_SETTINGS = 1341; | 108 const int LINK_SITE_SETTINGS = 1341; |
106 | 109 |
107 // The default, ui::kTitleFontSizeDelta, is too large for the website settings | 110 // The default, ui::kTitleFontSizeDelta, is too large for the website settings |
108 // bubble (e.g. +3). Use +1 to obtain a smaller font. | 111 // bubble (e.g. +3). Use +1 to obtain a smaller font. |
109 constexpr int kSummaryFontSizeDelta = 1; | 112 constexpr int kSummaryFontSizeDelta = 1; |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 } | 458 } |
456 | 459 |
457 void WebsiteSettingsPopupView::WebContentsDestroyed() { | 460 void WebsiteSettingsPopupView::WebContentsDestroyed() { |
458 weak_factory_.InvalidateWeakPtrs(); | 461 weak_factory_.InvalidateWeakPtrs(); |
459 } | 462 } |
460 | 463 |
461 void WebsiteSettingsPopupView::OnPermissionChanged( | 464 void WebsiteSettingsPopupView::OnPermissionChanged( |
462 const WebsiteSettingsUI::PermissionInfo& permission) { | 465 const WebsiteSettingsUI::PermissionInfo& permission) { |
463 presenter_->OnSitePermissionChanged(permission.type, permission.setting); | 466 presenter_->OnSitePermissionChanged(permission.type, permission.setting); |
464 // The menu buttons for the permissions might have longer strings now, so we | 467 // The menu buttons for the permissions might have longer strings now, so we |
465 // need to size the whole bubble. | 468 // need to layout and size the whole bubble. |
| 469 Layout(); |
466 SizeToContents(); | 470 SizeToContents(); |
467 } | 471 } |
468 | 472 |
469 void WebsiteSettingsPopupView::OnChosenObjectDeleted( | 473 void WebsiteSettingsPopupView::OnChosenObjectDeleted( |
470 const WebsiteSettingsUI::ChosenObjectInfo& info) { | 474 const WebsiteSettingsUI::ChosenObjectInfo& info) { |
471 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); | 475 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); |
472 } | 476 } |
473 | 477 |
474 base::string16 WebsiteSettingsPopupView::GetWindowTitle() const { | 478 base::string16 WebsiteSettingsPopupView::GetWindowTitle() const { |
475 return summary_text_; | 479 return summary_text_; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 site_settings_view_->AddChildView(permissions_view_); | 622 site_settings_view_->AddChildView(permissions_view_); |
619 | 623 |
620 const int content_column = 0; | 624 const int content_column = 0; |
621 views::ColumnSet* column_set = layout->AddColumnSet(content_column); | 625 views::ColumnSet* column_set = layout->AddColumnSet(content_column); |
622 column_set->AddColumn(views::GridLayout::FILL, | 626 column_set->AddColumn(views::GridLayout::FILL, |
623 views::GridLayout::FILL, | 627 views::GridLayout::FILL, |
624 1, | 628 1, |
625 views::GridLayout::USE_PREF, | 629 views::GridLayout::USE_PREF, |
626 0, | 630 0, |
627 0); | 631 0); |
| 632 const int perms_column = 1; |
| 633 views::ColumnSet* perms_set = layout->AddColumnSet(perms_column); |
| 634 perms_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
| 635 views::GridLayout::FIXED, kPermissionIconColumnWidth, 0); |
| 636 perms_set->AddPaddingColumn(0, kPermissionIconMarginLeft); |
| 637 perms_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
| 638 views::GridLayout::USE_PREF, 0, 0); |
| 639 perms_set->AddPaddingColumn(1, kPermissionMenuSpacing); |
| 640 perms_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, 0, |
| 641 views::GridLayout::USE_PREF, 0, 0); |
628 for (const auto& permission : permission_info_list) { | 642 for (const auto& permission : permission_info_list) { |
629 layout->StartRow(1, content_column); | 643 layout->StartRow(1, perms_column); |
630 PermissionSelectorRow* selector = new PermissionSelectorRow( | 644 std::unique_ptr<PermissionSelectorRow> selector = |
631 profile_, | 645 base::MakeUnique<PermissionSelectorRow>( |
632 web_contents() ? web_contents()->GetVisibleURL() : GURL::EmptyGURL(), | 646 profile_, |
633 permission); | 647 web_contents() ? web_contents()->GetVisibleURL() |
| 648 : GURL::EmptyGURL(), |
| 649 permission, layout); |
634 selector->AddObserver(this); | 650 selector->AddObserver(this); |
635 layout->AddView(selector, 1, 1, views::GridLayout::FILL, | |
636 views::GridLayout::CENTER); | |
637 layout->AddPaddingRow(1, kPermissionsVerticalSpacing); | 651 layout->AddPaddingRow(1, kPermissionsVerticalSpacing); |
| 652 selector_rows_.push_back(std::move(selector)); |
638 } | 653 } |
639 | 654 |
640 for (auto& object : chosen_object_info_list) { | 655 for (auto& object : chosen_object_info_list) { |
641 layout->StartRow(1, content_column); | 656 layout->StartRow(1, content_column); |
642 // The view takes ownership of the object info. | 657 // The view takes ownership of the object info. |
643 auto* object_view = new ChosenObjectRow(std::move(object)); | 658 auto* object_view = new ChosenObjectRow(std::move(object)); |
644 object_view->AddObserver(this); | 659 object_view->AddObserver(this); |
645 layout->AddView(object_view, 1, 1, views::GridLayout::LEADING, | 660 layout->AddView(object_view, 1, 1, views::GridLayout::LEADING, |
646 views::GridLayout::CENTER); | 661 views::GridLayout::CENTER); |
647 layout->AddPaddingRow(1, kPermissionsVerticalSpacing); | 662 layout->AddPaddingRow(1, kPermissionsVerticalSpacing); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); | 756 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); |
742 break; | 757 break; |
743 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: | 758 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: |
744 presenter_->OnRevokeSSLErrorBypassButtonPressed(); | 759 presenter_->OnRevokeSSLErrorBypassButtonPressed(); |
745 GetWidget()->Close(); | 760 GetWidget()->Close(); |
746 break; | 761 break; |
747 default: | 762 default: |
748 NOTREACHED(); | 763 NOTREACHED(); |
749 } | 764 } |
750 } | 765 } |
OLD | NEW |