| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 } | 460 } |
| 458 | 461 |
| 459 void WebsiteSettingsPopupView::WebContentsDestroyed() { | 462 void WebsiteSettingsPopupView::WebContentsDestroyed() { |
| 460 weak_factory_.InvalidateWeakPtrs(); | 463 weak_factory_.InvalidateWeakPtrs(); |
| 461 } | 464 } |
| 462 | 465 |
| 463 void WebsiteSettingsPopupView::OnPermissionChanged( | 466 void WebsiteSettingsPopupView::OnPermissionChanged( |
| 464 const WebsiteSettingsUI::PermissionInfo& permission) { | 467 const WebsiteSettingsUI::PermissionInfo& permission) { |
| 465 presenter_->OnSitePermissionChanged(permission.type, permission.setting); | 468 presenter_->OnSitePermissionChanged(permission.type, permission.setting); |
| 466 // The menu buttons for the permissions might have longer strings now, so we | 469 // The menu buttons for the permissions might have longer strings now, so we |
| 467 // need to size the whole bubble. | 470 // need to layout and size the whole bubble. |
| 471 Layout(); |
| 468 SizeToContents(); | 472 SizeToContents(); |
| 469 } | 473 } |
| 470 | 474 |
| 471 void WebsiteSettingsPopupView::OnChosenObjectDeleted( | 475 void WebsiteSettingsPopupView::OnChosenObjectDeleted( |
| 472 const WebsiteSettingsUI::ChosenObjectInfo& info) { | 476 const WebsiteSettingsUI::ChosenObjectInfo& info) { |
| 473 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); | 477 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); |
| 474 } | 478 } |
| 475 | 479 |
| 476 base::string16 WebsiteSettingsPopupView::GetWindowTitle() const { | 480 base::string16 WebsiteSettingsPopupView::GetWindowTitle() const { |
| 477 return summary_text_; | 481 return summary_text_; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 site_settings_view_->AddChildView(permissions_view_); | 624 site_settings_view_->AddChildView(permissions_view_); |
| 621 | 625 |
| 622 const int content_column = 0; | 626 const int content_column = 0; |
| 623 views::ColumnSet* column_set = layout->AddColumnSet(content_column); | 627 views::ColumnSet* column_set = layout->AddColumnSet(content_column); |
| 624 column_set->AddColumn(views::GridLayout::FILL, | 628 column_set->AddColumn(views::GridLayout::FILL, |
| 625 views::GridLayout::FILL, | 629 views::GridLayout::FILL, |
| 626 1, | 630 1, |
| 627 views::GridLayout::USE_PREF, | 631 views::GridLayout::USE_PREF, |
| 628 0, | 632 0, |
| 629 0); | 633 0); |
| 634 const int permissions_column = 1; |
| 635 views::ColumnSet* permissions_set = layout->AddColumnSet(permissions_column); |
| 636 permissions_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, |
| 637 0, views::GridLayout::FIXED, |
| 638 kPermissionIconColumnWidth, 0); |
| 639 permissions_set->AddPaddingColumn(0, kPermissionIconMarginLeft); |
| 640 permissions_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, |
| 641 0, views::GridLayout::USE_PREF, 0, 0); |
| 642 permissions_set->AddPaddingColumn(1, kPermissionMenuSpacing); |
| 643 permissions_set->AddColumn(views::GridLayout::TRAILING, |
| 644 views::GridLayout::FILL, 0, |
| 645 views::GridLayout::USE_PREF, 0, 0); |
| 630 for (const auto& permission : permission_info_list) { | 646 for (const auto& permission : permission_info_list) { |
| 631 layout->StartRow(1, content_column); | 647 layout->StartRow(1, permissions_column); |
| 632 PermissionSelectorRow* selector = new PermissionSelectorRow( | 648 std::unique_ptr<PermissionSelectorRow> selector = |
| 633 profile_, | 649 base::MakeUnique<PermissionSelectorRow>( |
| 634 web_contents() ? web_contents()->GetVisibleURL() : GURL::EmptyGURL(), | 650 profile_, |
| 635 permission); | 651 web_contents() ? web_contents()->GetVisibleURL() |
| 652 : GURL::EmptyGURL(), |
| 653 permission, layout); |
| 636 selector->AddObserver(this); | 654 selector->AddObserver(this); |
| 637 layout->AddView(selector, 1, 1, views::GridLayout::FILL, | |
| 638 views::GridLayout::CENTER); | |
| 639 layout->AddPaddingRow(1, kPermissionsVerticalSpacing); | 655 layout->AddPaddingRow(1, kPermissionsVerticalSpacing); |
| 656 selector_rows_.push_back(std::move(selector)); |
| 640 } | 657 } |
| 641 | 658 |
| 642 for (auto& object : chosen_object_info_list) { | 659 for (auto& object : chosen_object_info_list) { |
| 643 layout->StartRow(1, content_column); | 660 layout->StartRow(1, content_column); |
| 644 // The view takes ownership of the object info. | 661 // The view takes ownership of the object info. |
| 645 auto* object_view = new ChosenObjectRow(std::move(object)); | 662 auto* object_view = new ChosenObjectRow(std::move(object)); |
| 646 object_view->AddObserver(this); | 663 object_view->AddObserver(this); |
| 647 layout->AddView(object_view, 1, 1, views::GridLayout::LEADING, | 664 layout->AddView(object_view, 1, 1, views::GridLayout::LEADING, |
| 648 views::GridLayout::CENTER); | 665 views::GridLayout::CENTER); |
| 649 layout->AddPaddingRow(1, kPermissionsVerticalSpacing); | 666 layout->AddPaddingRow(1, kPermissionsVerticalSpacing); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); | 760 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); |
| 744 break; | 761 break; |
| 745 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: | 762 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: |
| 746 presenter_->OnRevokeSSLErrorBypassButtonPressed(); | 763 presenter_->OnRevokeSSLErrorBypassButtonPressed(); |
| 747 GetWidget()->Close(); | 764 GetWidget()->Close(); |
| 748 break; | 765 break; |
| 749 default: | 766 default: |
| 750 NOTREACHED(); | 767 NOTREACHED(); |
| 751 } | 768 } |
| 752 } | 769 } |
| OLD | NEW |