Chromium Code Reviews| 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(); | |
|
sky
2017/03/07 22:03:40
How come you Layout() here?
Elly Fong-Jones
2017/03/08 18:41:09
If we don't, the sizes of the individual permissio
sky
2017/03/08 18:50:35
Are you sure you don't want the Layout() after the
| |
| 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 permissions_column = 1; | |
| 633 views::ColumnSet* permissions_set = layout->AddColumnSet(permissions_column); | |
| 634 permissions_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, | |
| 635 0, views::GridLayout::FIXED, | |
| 636 kPermissionIconColumnWidth, 0); | |
| 637 permissions_set->AddPaddingColumn(0, kPermissionIconMarginLeft); | |
| 638 permissions_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, | |
| 639 0, views::GridLayout::USE_PREF, 0, 0); | |
| 640 permissions_set->AddPaddingColumn(1, kPermissionMenuSpacing); | |
| 641 permissions_set->AddColumn(views::GridLayout::TRAILING, | |
| 642 views::GridLayout::FILL, 0, | |
| 643 views::GridLayout::USE_PREF, 0, 0); | |
| 628 for (const auto& permission : permission_info_list) { | 644 for (const auto& permission : permission_info_list) { |
| 629 layout->StartRow(1, content_column); | 645 layout->StartRow(1, permissions_column); |
| 630 PermissionSelectorRow* selector = new PermissionSelectorRow( | 646 std::unique_ptr<PermissionSelectorRow> selector = |
| 631 profile_, | 647 base::MakeUnique<PermissionSelectorRow>( |
| 632 web_contents() ? web_contents()->GetVisibleURL() : GURL::EmptyGURL(), | 648 profile_, |
| 633 permission); | 649 web_contents() ? web_contents()->GetVisibleURL() |
| 650 : GURL::EmptyGURL(), | |
| 651 permission, layout); | |
| 634 selector->AddObserver(this); | 652 selector->AddObserver(this); |
| 635 layout->AddView(selector, 1, 1, views::GridLayout::FILL, | |
| 636 views::GridLayout::CENTER); | |
| 637 layout->AddPaddingRow(1, kPermissionsVerticalSpacing); | 653 layout->AddPaddingRow(1, kPermissionsVerticalSpacing); |
| 654 selector_rows_.push_back(std::move(selector)); | |
| 638 } | 655 } |
| 639 | 656 |
| 640 for (auto& object : chosen_object_info_list) { | 657 for (auto& object : chosen_object_info_list) { |
| 641 layout->StartRow(1, content_column); | 658 layout->StartRow(1, content_column); |
| 642 // The view takes ownership of the object info. | 659 // The view takes ownership of the object info. |
| 643 auto* object_view = new ChosenObjectRow(std::move(object)); | 660 auto* object_view = new ChosenObjectRow(std::move(object)); |
| 644 object_view->AddObserver(this); | 661 object_view->AddObserver(this); |
| 645 layout->AddView(object_view, 1, 1, views::GridLayout::LEADING, | 662 layout->AddView(object_view, 1, 1, views::GridLayout::LEADING, |
| 646 views::GridLayout::CENTER); | 663 views::GridLayout::CENTER); |
| 647 layout->AddPaddingRow(1, kPermissionsVerticalSpacing); | 664 layout->AddPaddingRow(1, kPermissionsVerticalSpacing); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); | 758 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); |
| 742 break; | 759 break; |
| 743 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: | 760 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: |
| 744 presenter_->OnRevokeSSLErrorBypassButtonPressed(); | 761 presenter_->OnRevokeSSLErrorBypassButtonPressed(); |
| 745 GetWidget()->Close(); | 762 GetWidget()->Close(); |
| 746 break; | 763 break; |
| 747 default: | 764 default: |
| 748 NOTREACHED(); | 765 NOTREACHED(); |
| 749 } | 766 } |
| 750 } | 767 } |
| OLD | NEW |