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> |
| 11 | 11 |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "chrome/browser/certificate_viewer.h" | 18 #include "chrome/browser/certificate_viewer.h" |
| 19 #include "chrome/browser/infobars/infobar_service.h" | 19 #include "chrome/browser/infobars/infobar_service.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/browser_dialogs.h" | 22 #include "chrome/browser/ui/browser_dialogs.h" |
| 23 #include "chrome/browser/ui/layout_constants.h" | 23 #include "chrome/browser/ui/layout_constants.h" |
| 24 #include "chrome/browser/ui/views/collected_cookies_views.h" | 24 #include "chrome/browser/ui/views/collected_cookies_views.h" |
| 25 #include "chrome/browser/ui/views/harmony/layout_delegate.h" | |
| 25 #include "chrome/browser/ui/views/website_settings/chosen_object_row.h" | 26 #include "chrome/browser/ui/views/website_settings/chosen_object_row.h" |
| 26 #include "chrome/browser/ui/views/website_settings/non_accessible_image_view.h" | 27 #include "chrome/browser/ui/views/website_settings/non_accessible_image_view.h" |
| 27 #include "chrome/browser/ui/views/website_settings/permission_selector_row.h" | 28 #include "chrome/browser/ui/views/website_settings/permission_selector_row.h" |
| 28 #include "chrome/browser/ui/website_settings/website_settings.h" | 29 #include "chrome/browser/ui/website_settings/website_settings.h" |
| 29 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 30 #include "chrome/grit/chromium_strings.h" | 31 #include "chrome/grit/chromium_strings.h" |
| 31 #include "chrome/grit/generated_resources.h" | 32 #include "chrome/grit/generated_resources.h" |
| 32 #include "chrome/grit/theme_resources.h" | 33 #include "chrome/grit/theme_resources.h" |
| 33 #include "components/content_settings/core/common/content_settings_types.h" | 34 #include "components/content_settings/core/common/content_settings_types.h" |
| 34 #include "components/strings/grit/components_chromium_strings.h" | 35 #include "components/strings/grit/components_chromium_strings.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 47 #include "ui/resources/grit/ui_resources.h" | 48 #include "ui/resources/grit/ui_resources.h" |
| 48 #include "ui/views/border.h" | 49 #include "ui/views/border.h" |
| 49 #include "ui/views/controls/button/image_button.h" | 50 #include "ui/views/controls/button/image_button.h" |
| 50 #include "ui/views/controls/button/md_text_button.h" | 51 #include "ui/views/controls/button/md_text_button.h" |
| 51 #include "ui/views/controls/image_view.h" | 52 #include "ui/views/controls/image_view.h" |
| 52 #include "ui/views/controls/label.h" | 53 #include "ui/views/controls/label.h" |
| 53 #include "ui/views/controls/link.h" | 54 #include "ui/views/controls/link.h" |
| 54 #include "ui/views/controls/styled_label.h" | 55 #include "ui/views/controls/styled_label.h" |
| 55 #include "ui/views/layout/box_layout.h" | 56 #include "ui/views/layout/box_layout.h" |
| 56 #include "ui/views/layout/grid_layout.h" | 57 #include "ui/views/layout/grid_layout.h" |
| 57 #include "ui/views/layout/layout_constants.h" | |
| 58 #include "ui/views/layout/layout_manager.h" | 58 #include "ui/views/layout/layout_manager.h" |
| 59 #include "ui/views/view.h" | 59 #include "ui/views/view.h" |
| 60 #include "ui/views/widget/widget.h" | 60 #include "ui/views/widget/widget.h" |
| 61 #include "url/gurl.h" | 61 #include "url/gurl.h" |
| 62 | 62 |
| 63 namespace { | 63 namespace { |
| 64 | 64 |
| 65 // NOTE(jdonnelly): This use of this process-wide variable assumes that there's | 65 // NOTE(jdonnelly): This use of this process-wide variable assumes that there's |
| 66 // never more than one website settings popup shown and that it's associated | 66 // never more than one website settings popup shown and that it's associated |
| 67 // with the current window. If this assumption fails in the future, we'll need | 67 // with the current window. If this assumption fails in the future, we'll need |
| 68 // to return a weak pointer from ShowPopup so callers can associate it with the | 68 // to return a weak pointer from ShowPopup so callers can associate it with the |
| 69 // current window (or other context) and check if the popup they care about is | 69 // current window (or other context) and check if the popup they care about is |
| 70 // showing. | 70 // showing. |
| 71 WebsiteSettingsPopupView::PopupType g_shown_popup_type = | 71 WebsiteSettingsPopupView::PopupType g_shown_popup_type = |
| 72 WebsiteSettingsPopupView::POPUP_NONE; | 72 WebsiteSettingsPopupView::POPUP_NONE; |
| 73 | 73 |
| 74 // General constants ----------------------------------------------------------- | 74 // General constants ----------------------------------------------------------- |
| 75 | 75 |
| 76 // Popup width constraints. | 76 // Popup width constraints. |
| 77 const int kMinPopupWidth = 320; | 77 const int kMinPopupWidth = 320; |
| 78 const int kMaxPopupWidth = 1000; | 78 const int kMaxPopupWidth = 1000; |
| 79 | 79 |
| 80 // Security Section (PopupHeaderView) ------------------------------------------ | 80 // Security Section (PopupHeaderView) ------------------------------------------ |
| 81 | 81 |
| 82 // Margin and padding values for the |PopupHeaderView|. | 82 // Margin and padding values for the |PopupHeaderView|. |
| 83 const int kHeaderMarginBottom = 10; | 83 const int kHeaderMarginBottom = 10; |
| 84 const int kHeaderPaddingBottom = views::kPanelVertMargin; | |
| 85 | 84 |
| 86 // Spacing between labels in the header. | 85 // Spacing between labels in the header. |
| 87 const int kHeaderLabelSpacing = 4; | 86 const int kHeaderLabelSpacing = 4; |
| 88 | 87 |
| 89 // Site Settings Section ------------------------------------------------------- | 88 // Site Settings Section ------------------------------------------------------- |
| 90 | 89 |
| 91 // Spacing above and below the cookies view. | 90 // Spacing above and below the cookies view. |
| 92 const int kCookiesViewVerticalPadding = 6; | 91 const int kCookiesViewVerticalPadding = 6; |
| 93 | 92 |
| 94 // Spacing between a permission image and the text. | 93 // Spacing between a permission image and the text. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 layout->AddView(details_label_, 1, 1, views::GridLayout::FILL, | 206 layout->AddView(details_label_, 1, 1, views::GridLayout::FILL, |
| 208 views::GridLayout::LEADING); | 207 views::GridLayout::LEADING); |
| 209 | 208 |
| 210 layout->StartRow(0, label_column_status); | 209 layout->StartRow(0, label_column_status); |
| 211 reset_decisions_label_container_ = new views::View(); | 210 reset_decisions_label_container_ = new views::View(); |
| 212 reset_decisions_label_container_->SetLayoutManager( | 211 reset_decisions_label_container_->SetLayoutManager( |
| 213 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 212 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
| 214 layout->AddView(reset_decisions_label_container_, 1, 1, | 213 layout->AddView(reset_decisions_label_container_, 1, 1, |
| 215 views::GridLayout::FILL, views::GridLayout::LEADING); | 214 views::GridLayout::FILL, views::GridLayout::LEADING); |
| 216 | 215 |
| 217 layout->AddPaddingRow(1, kHeaderPaddingBottom); | 216 layout->AddPaddingRow(1, |
|
tapted
2017/02/27 03:24:51
This may have been coincidence too.. I think we sh
Peter Kasting
2017/02/28 02:21:39
I don't have a strong opinion on this one. It see
Patti Lor
2017/03/03 08:24:39
Done.
Patti Lor
2017/03/03 08:24:39
Acknowledged.
| |
| 217 LayoutDelegate::Get()->GetMetric( | |
| 218 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN)); | |
| 218 } | 219 } |
| 219 | 220 |
| 220 PopupHeaderView::~PopupHeaderView() {} | 221 PopupHeaderView::~PopupHeaderView() {} |
| 221 | 222 |
| 222 void PopupHeaderView::SetDetails(const base::string16& details_text) { | 223 void PopupHeaderView::SetDetails(const base::string16& details_text) { |
| 223 std::vector<base::string16> subst; | 224 std::vector<base::string16> subst; |
| 224 subst.push_back(details_text); | 225 subst.push_back(details_text); |
| 225 subst.push_back(l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 226 subst.push_back(l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
| 226 | 227 |
| 227 std::vector<size_t> offsets; | 228 std::vector<size_t> offsets; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 layout->AddPaddingRow(1, kHeaderMarginBottom); | 433 layout->AddPaddingRow(1, kHeaderMarginBottom); |
| 433 layout->StartRow(1, content_column); | 434 layout->StartRow(1, content_column); |
| 434 | 435 |
| 435 site_settings_view_ = CreateSiteSettingsView(side_margin); | 436 site_settings_view_ = CreateSiteSettingsView(side_margin); |
| 436 layout->AddView(site_settings_view_); | 437 layout->AddView(site_settings_view_); |
| 437 | 438 |
| 438 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) { | 439 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
| 439 // In non-material, titles are inset from the dialog margin. Ensure the | 440 // In non-material, titles are inset from the dialog margin. Ensure the |
| 440 // horizontal insets match. | 441 // horizontal insets match. |
| 441 set_title_margins( | 442 set_title_margins( |
| 442 gfx::Insets(views::kPanelVertMargin, side_margin, 0, side_margin)); | 443 gfx::Insets(LayoutDelegate::Get()->GetMetric( |
| 444 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN), | |
|
tapted
2017/02/27 03:24:51
This only affects non-material, so I'm not sure it
Peter Kasting
2017/02/28 02:21:39
I'm fine with changing this anyway, because the go
Patti Lor
2017/03/03 08:24:39
Acknowledged, left as is.
| |
| 445 side_margin, 0, side_margin)); | |
| 443 } | 446 } |
| 444 views::BubbleDialogDelegateView::CreateBubble(this); | 447 views::BubbleDialogDelegateView::CreateBubble(this); |
| 445 | 448 |
| 446 presenter_.reset(new WebsiteSettings( | 449 presenter_.reset(new WebsiteSettings( |
| 447 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), | 450 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), |
| 448 web_contents, url, security_info)); | 451 web_contents, url, security_info)); |
| 449 } | 452 } |
| 450 | 453 |
| 451 void WebsiteSettingsPopupView::RenderFrameDeleted( | 454 void WebsiteSettingsPopupView::RenderFrameDeleted( |
| 452 content::RenderFrameHost* render_frame_host) { | 455 content::RenderFrameHost* render_frame_host) { |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); | 744 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); |
| 742 break; | 745 break; |
| 743 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: | 746 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: |
| 744 presenter_->OnRevokeSSLErrorBypassButtonPressed(); | 747 presenter_->OnRevokeSSLErrorBypassButtonPressed(); |
| 745 GetWidget()->Close(); | 748 GetWidget()->Close(); |
| 746 break; | 749 break; |
| 747 default: | 750 default: |
| 748 NOTREACHED(); | 751 NOTREACHED(); |
| 749 } | 752 } |
| 750 } | 753 } |
| OLD | NEW |