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 29 matching lines...) Expand all Loading... | |
| 40 #include "extensions/common/constants.h" | 40 #include "extensions/common/constants.h" |
| 41 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
| 42 #include "ui/base/material_design/material_design_controller.h" | 42 #include "ui/base/material_design/material_design_controller.h" |
| 43 #include "ui/base/models/simple_menu_model.h" | 43 #include "ui/base/models/simple_menu_model.h" |
| 44 #include "ui/base/resource/resource_bundle.h" | 44 #include "ui/base/resource/resource_bundle.h" |
| 45 #include "ui/gfx/canvas.h" | 45 #include "ui/gfx/canvas.h" |
| 46 #include "ui/gfx/font_list.h" | 46 #include "ui/gfx/font_list.h" |
| 47 #include "ui/gfx/geometry/insets.h" | 47 #include "ui/gfx/geometry/insets.h" |
| 48 #include "ui/gfx/image/image.h" | 48 #include "ui/gfx/image/image.h" |
| 49 #include "ui/resources/grit/ui_resources.h" | 49 #include "ui/resources/grit/ui_resources.h" |
| 50 #include "ui/views/border.h" | |
| 50 #include "ui/views/bubble/bubble_frame_view.h" | 51 #include "ui/views/bubble/bubble_frame_view.h" |
| 51 #include "ui/views/controls/button/image_button.h" | 52 #include "ui/views/controls/button/image_button.h" |
| 52 #include "ui/views/controls/button/md_text_button.h" | 53 #include "ui/views/controls/button/md_text_button.h" |
| 53 #include "ui/views/controls/image_view.h" | 54 #include "ui/views/controls/image_view.h" |
| 54 #include "ui/views/controls/label.h" | 55 #include "ui/views/controls/label.h" |
| 55 #include "ui/views/controls/link.h" | 56 #include "ui/views/controls/link.h" |
| 56 #include "ui/views/controls/styled_label.h" | 57 #include "ui/views/controls/styled_label.h" |
| 57 #include "ui/views/layout/box_layout.h" | 58 #include "ui/views/layout/box_layout.h" |
| 58 #include "ui/views/layout/grid_layout.h" | 59 #include "ui/views/layout/grid_layout.h" |
| 59 #include "ui/views/layout/layout_manager.h" | 60 #include "ui/views/layout/layout_manager.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 73 | 74 |
| 74 // Left icon margin. | 75 // Left icon margin. |
| 75 const int kIconMarginLeft = 6; | 76 const int kIconMarginLeft = 6; |
| 76 | 77 |
| 77 // Margin and padding values for the |PopupHeaderView|. | 78 // Margin and padding values for the |PopupHeaderView|. |
| 78 const int kHeaderMarginBottom = 10; | 79 const int kHeaderMarginBottom = 10; |
| 79 const int kHeaderPaddingBottom = 16; | 80 const int kHeaderPaddingBottom = 16; |
| 80 const int kHeaderPaddingLeft = 18; | 81 const int kHeaderPaddingLeft = 18; |
| 81 const int kHeaderPaddingRightForCloseButton = 8; | 82 const int kHeaderPaddingRightForCloseButton = 8; |
| 82 const int kHeaderPaddingRightForText = kHeaderPaddingLeft; | 83 const int kHeaderPaddingRightForText = kHeaderPaddingLeft; |
| 83 const int kHeaderPaddingTop = 12; | 84 const int kHeaderPaddingTop = 16; |
| 84 | 85 |
| 85 // Spacing between the site identity label and the site identity status text in | 86 // Spacing between labels in the header. |
| 86 // the popup header. | 87 const int kHeaderLabelSpacing = 4; |
| 87 const int kHeaderRowSpacing = 4; | |
| 88 | 88 |
| 89 // The max possible width of the popup. | 89 // The max possible width of the popup. |
| 90 const int kMaxPopupWidth = 1000; | 90 const int kMaxPopupWidth = 1000; |
| 91 | 91 |
| 92 // The margins between the popup border and the popup content. | 92 // The margins between the popup border and the popup content. |
| 93 const int kPopupMarginTop = 4; | |
| 94 const int kPopupMarginLeft = 0; | |
| 95 const int kPopupMarginBottom = 14; | 93 const int kPopupMarginBottom = 14; |
| 96 const int kPopupMarginRight = 0; | |
| 97 | 94 |
| 98 // Padding values for sections on the site settings view. | 95 // Padding values for sections on the site settings view. |
| 99 const int kSiteSettingsViewContentMinWidth = 300; | 96 const int kSiteSettingsViewContentMinWidth = 300; |
| 100 const int kSiteSettingsViewPaddingBottom = 6; | 97 const int kSiteSettingsViewPaddingBottom = 6; |
| 101 const int kSiteSettingsViewPaddingLeft = 18; | 98 const int kSiteSettingsViewPaddingLeft = 18; |
| 102 const int kSiteSettingsViewPaddingRight = 18; | 99 const int kSiteSettingsViewPaddingRight = 18; |
| 103 const int kSiteSettingsViewPaddingTop = 4; | 100 const int kSiteSettingsViewPaddingTop = 4; |
| 104 | 101 |
| 105 // Space between the headline and the content of a section. | 102 // Space between the headline and the content of a section. |
| 106 const int kSiteSettingsViewHeadlineMarginBottom = 10; | 103 const int kSiteSettingsViewHeadlineMarginBottom = 10; |
| 107 // Spacing between rows in the "Permissions" and "Cookies and Site Data" | 104 // Spacing between rows in the "Permissions" and "Cookies and Site Data" |
| 108 // sections. | 105 // sections. |
| 109 const int kContentRowSpacing = 2; | 106 const int kContentRowSpacing = 2; |
| 110 | 107 |
| 111 const int kSiteDataIconColumnWidth = 20; | 108 const int kSiteDataIconColumnWidth = 20; |
| 112 | 109 |
| 113 const int BUTTON_RESET_CERTIFICATE_DECISIONS = 1337; | 110 const int BUTTON_RESET_CERTIFICATE_DECISIONS = 1337; |
| 114 | 111 |
| 115 } // namespace | 112 } // namespace |
| 116 | 113 |
| 117 // |PopupHeaderView| is the UI element (view) that represents the header of the | 114 // |PopupHeaderView| is the UI element (view) that represents the header of the |
| 118 // |WebsiteSettingsPopupView|. The header shows the status of the site's | 115 // |WebsiteSettingsPopupView|. The header shows the status of the site's |
| 119 // identity check and the name of the site's identity. | 116 // identity check and the name of the site's identity. |
| 120 class PopupHeaderView : public views::View { | 117 class PopupHeaderView : public views::View { |
| 121 public: | 118 public: |
| 122 explicit PopupHeaderView(views::ButtonListener* button_listener, | 119 explicit PopupHeaderView(views::ButtonListener* button_listener, |
| 123 views::StyledLabelListener* styled_label_listener); | 120 views::StyledLabelListener* styled_label_listener); |
| 124 ~PopupHeaderView() override; | 121 ~PopupHeaderView() override; |
| 125 | 122 |
| 126 // Sets the name of the site's identity. | 123 // Sets the security summary for the current page. |
| 127 void SetIdentityName(const base::string16& name); | 124 void SetSummary(const base::string16& summary_text); |
| 128 | 125 |
| 129 // Sets the security summary text for the current page. | 126 // Sets the security details for the current page. |
| 130 void SetSecuritySummary(const base::string16& security_summary_text, | 127 void SetDetails(const base::string16& details_text, |
| 131 bool include_details_link); | 128 bool include_details_link); |
| 132 | 129 |
| 133 int GetPreferredNameWidth() const; | 130 int GetPreferredNameWidth() const; |
| 134 | 131 |
| 135 void AddResetDecisionsButton(); | 132 void AddResetDecisionsLabel(); |
| 136 | 133 |
| 137 private: | 134 private: |
| 138 // The label that displays the name of the site's identity. | 135 // The listener for the styled labels in this view. |
| 139 views::Label* name_; | 136 views::StyledLabelListener* styled_label_listener_; |
| 137 | |
| 138 // The label that displays security summary for the current page. | |
| 139 views::Label* summary_label_; | |
| 140 | |
| 140 // The label that displays the status of the identity check for this site. | 141 // The label that displays the status of the identity check for this site. |
| 141 // Includes a link to open the DevTools Security panel. | 142 // Includes a link to open the DevTools Security panel. |
| 142 views::StyledLabel* status_; | 143 views::StyledLabel* details_label_; |
| 143 | 144 |
| 144 // The button listener attached to the buttons in this view. | 145 // A container for the styled label with link for resetting cert decisions. |
|
msw
2016/09/10 01:51:26
nit: "a link"
lgarron
2016/09/10 02:08:10
Done.
| |
| 145 views::ButtonListener* button_listener_; | 146 // This is only shown sometimes, so we use a container to keep track of |
| 146 | 147 // where to place it (if needed). |
| 147 // A container for the button for resetting cert decisions. The button is only | 148 views::View* reset_decisions_label_container_; |
| 148 // shown sometimes, so we use a container to keep track of where to place it | 149 views::StyledLabel* reset_decisions_label_; |
| 149 // (if needed). | |
| 150 views::View* reset_decisions_button_container_; | |
| 151 | 150 |
| 152 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); | 151 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); |
| 153 }; | 152 }; |
| 154 | 153 |
| 155 // Website Settings are not supported for internal Chrome pages and extension | 154 // Website Settings are not supported for internal Chrome pages and extension |
| 156 // pages. Instead of the |WebsiteSettingsPopupView|, the | 155 // pages. Instead of the |WebsiteSettingsPopupView|, the |
| 157 // |InternalPageInfoPopupView| is displayed. | 156 // |InternalPageInfoPopupView| is displayed. |
| 158 class InternalPageInfoPopupView : public views::BubbleDialogDelegateView { | 157 class InternalPageInfoPopupView : public views::BubbleDialogDelegateView { |
| 159 public: | 158 public: |
| 160 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be | 159 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be |
| 161 // provided to ensure this bubble is closed when the parent closes. | 160 // provided to ensure this bubble is closed when the parent closes. |
| 162 InternalPageInfoPopupView(views::View* anchor_view, | 161 InternalPageInfoPopupView(views::View* anchor_view, |
| 163 gfx::NativeView parent_window, | 162 gfx::NativeView parent_window, |
| 164 const GURL& url); | 163 const GURL& url); |
| 165 ~InternalPageInfoPopupView() override; | 164 ~InternalPageInfoPopupView() override; |
| 166 | 165 |
| 167 // views::BubbleDialogDelegateView: | 166 // views::BubbleDialogDelegateView: |
| 168 views::NonClientFrameView* CreateNonClientFrameView( | 167 views::NonClientFrameView* CreateNonClientFrameView( |
| 169 views::Widget* widget) override; | 168 views::Widget* widget) override; |
| 170 void OnWidgetDestroying(views::Widget* widget) override; | 169 void OnWidgetDestroying(views::Widget* widget) override; |
| 171 int GetDialogButtons() const override; | |
| 172 | 170 |
| 173 private: | 171 private: |
| 174 friend class WebsiteSettingsPopupView; | 172 friend class WebsiteSettingsPopupView; |
| 175 | 173 |
| 176 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); | 174 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); |
| 177 }; | 175 }; |
| 178 | 176 |
| 179 //////////////////////////////////////////////////////////////////////////////// | 177 //////////////////////////////////////////////////////////////////////////////// |
| 180 // Popup Header | 178 // Popup Header |
| 181 //////////////////////////////////////////////////////////////////////////////// | 179 //////////////////////////////////////////////////////////////////////////////// |
| 182 | 180 |
| 183 PopupHeaderView::PopupHeaderView( | 181 PopupHeaderView::PopupHeaderView( |
| 184 views::ButtonListener* button_listener, | 182 views::ButtonListener* button_listener, |
| 185 views::StyledLabelListener* styled_label_listener) | 183 views::StyledLabelListener* styled_label_listener) |
| 186 : name_(nullptr), | 184 : styled_label_listener_(styled_label_listener), |
| 187 status_(nullptr), | 185 summary_label_(nullptr), |
| 188 button_listener_(button_listener), | 186 details_label_(nullptr), |
| 189 reset_decisions_button_container_(nullptr) { | 187 reset_decisions_label_container_(nullptr), |
| 188 reset_decisions_label_(nullptr) { | |
| 190 views::GridLayout* layout = new views::GridLayout(this); | 189 views::GridLayout* layout = new views::GridLayout(this); |
| 191 SetLayoutManager(layout); | 190 SetLayoutManager(layout); |
| 192 | 191 |
| 193 const int label_column = 0; | 192 const int label_column = 0; |
| 194 views::ColumnSet* column_set = layout->AddColumnSet(label_column); | 193 views::ColumnSet* column_set = layout->AddColumnSet(label_column); |
| 195 column_set->AddPaddingColumn(0, kHeaderPaddingLeft); | 194 column_set->AddPaddingColumn(0, kHeaderPaddingLeft); |
| 196 column_set->AddColumn(views::GridLayout::FILL, | 195 column_set->AddColumn(views::GridLayout::FILL, |
| 197 views::GridLayout::FILL, | 196 views::GridLayout::FILL, |
| 198 1, | 197 1, |
| 199 views::GridLayout::USE_PREF, | 198 views::GridLayout::USE_PREF, |
| 200 0, | 199 0, |
| 201 0); | 200 0); |
| 202 column_set->AddPaddingColumn(1, 0); | 201 column_set->AddPaddingColumn(1, 0); |
| 203 column_set->AddColumn(views::GridLayout::FILL, | 202 column_set->AddColumn(views::GridLayout::FILL, |
| 204 views::GridLayout::FILL, | 203 views::GridLayout::FILL, |
| 205 1, | 204 1, |
| 206 views::GridLayout::USE_PREF, | 205 views::GridLayout::USE_PREF, |
| 207 0, | 206 0, |
| 208 0); | 207 0); |
| 209 column_set->AddPaddingColumn(0, kHeaderPaddingRightForCloseButton); | 208 column_set->AddPaddingColumn(0, kHeaderPaddingRightForCloseButton); |
| 210 | 209 |
| 211 layout->AddPaddingRow(0, kHeaderPaddingTop); | 210 // First we add the padding needed for the close button. |
| 211 // In order to move down the summary, we simulate additional padding by giving | |
| 212 // it an empty border on top later on. | |
| 213 layout->AddPaddingRow(0, kHeaderPaddingRightForCloseButton); | |
|
msw
2016/09/10 01:51:26
nit: If the value is a height, using kHeaderPaddin
lgarron
2016/09/10 02:08:10
Changed to kHeaderPaddingForCloseButton.
| |
| 214 | |
| 215 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 212 | 216 |
| 213 layout->StartRow(0, label_column); | 217 layout->StartRow(0, label_column); |
| 214 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 218 const gfx::FontList& font_list = rb.GetFontListWithDelta(1); |
|
msw
2016/09/10 01:51:26
nit: I still think it's odd to increase this font
lgarron
2016/09/10 02:08:10
This is based off these mocks [1], this comment [2
| |
| 215 name_ = new views::Label( | 219 summary_label_ = new views::Label(base::string16(), font_list); |
| 216 base::string16(), rb.GetFontList(ui::ResourceBundle::BoldFont)); | 220 summary_label_->SetBorder(views::Border::CreateEmptyBorder( |
| 217 layout->AddView(name_, 1, 1, views::GridLayout::LEADING, | 221 kHeaderPaddingTop - kHeaderPaddingRightForCloseButton, 0, 0, 0)); |
|
msw
2016/09/10 01:51:26
ditto nit: it seems weird to subtract 'Top' and 'R
lgarron
2016/09/10 02:08:10
[see above]
| |
| 222 layout->AddView(summary_label_, 1, 1, views::GridLayout::LEADING, | |
| 218 views::GridLayout::TRAILING); | 223 views::GridLayout::TRAILING); |
| 219 views::ImageButton* close_button = new views::ImageButton(button_listener); | 224 views::ImageButton* close_button = new views::ImageButton(button_listener); |
| 220 close_button->SetImage(views::CustomButton::STATE_NORMAL, | 225 close_button->SetImage(views::CustomButton::STATE_NORMAL, |
| 221 rb.GetImageNamed(IDR_CLOSE_2).ToImageSkia()); | 226 rb.GetImageNamed(IDR_CLOSE_2).ToImageSkia()); |
| 222 close_button->SetImage(views::CustomButton::STATE_HOVERED, | 227 close_button->SetImage(views::CustomButton::STATE_HOVERED, |
| 223 rb.GetImageNamed(IDR_CLOSE_2_H).ToImageSkia()); | 228 rb.GetImageNamed(IDR_CLOSE_2_H).ToImageSkia()); |
| 224 close_button->SetImage(views::CustomButton::STATE_PRESSED, | 229 close_button->SetImage(views::CustomButton::STATE_PRESSED, |
| 225 rb.GetImageNamed(IDR_CLOSE_2_P).ToImageSkia()); | 230 rb.GetImageNamed(IDR_CLOSE_2_P).ToImageSkia()); |
| 226 layout->AddView(close_button, 1, 1, views::GridLayout::TRAILING, | 231 layout->AddView(close_button, 1, 1, views::GridLayout::TRAILING, |
| 227 views::GridLayout::LEADING); | 232 views::GridLayout::LEADING); |
| 228 | 233 |
| 229 layout->AddPaddingRow(0, kHeaderRowSpacing); | 234 layout->AddPaddingRow(0, kHeaderLabelSpacing); |
| 230 | 235 |
| 231 const int label_column_status = 1; | 236 const int label_column_status = 1; |
| 232 views::ColumnSet* column_set_status = | 237 views::ColumnSet* column_set_status = |
| 233 layout->AddColumnSet(label_column_status); | 238 layout->AddColumnSet(label_column_status); |
| 234 column_set_status->AddPaddingColumn(0, kHeaderPaddingLeft); | 239 column_set_status->AddPaddingColumn(0, kHeaderPaddingLeft); |
| 235 column_set_status->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, | 240 column_set_status->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, |
| 236 1, views::GridLayout::USE_PREF, 0, 0); | 241 1, views::GridLayout::USE_PREF, 0, 0); |
| 237 column_set_status->AddPaddingColumn(0, kHeaderPaddingRightForText); | 242 column_set_status->AddPaddingColumn(0, kHeaderPaddingRightForText); |
| 238 | 243 |
| 244 layout->AddPaddingRow(0, kHeaderLabelSpacing); | |
| 245 | |
| 239 layout->StartRow(0, label_column_status); | 246 layout->StartRow(0, label_column_status); |
| 240 status_ = new views::StyledLabel(base::string16(), styled_label_listener); | 247 details_label_ = |
| 241 layout->AddView(status_, | 248 new views::StyledLabel(base::string16(), styled_label_listener); |
| 242 1, | 249 layout->AddView(details_label_, 1, 1, views::GridLayout::LEADING, |
| 243 1, | |
| 244 views::GridLayout::LEADING, | |
| 245 views::GridLayout::LEADING); | 250 views::GridLayout::LEADING); |
| 246 | 251 |
| 247 layout->StartRow(0, label_column_status); | 252 layout->StartRow(0, label_column_status); |
| 248 reset_decisions_button_container_ = new views::View(); | 253 reset_decisions_label_container_ = new views::View(); |
| 249 reset_decisions_button_container_->SetLayoutManager( | 254 reset_decisions_label_container_->SetLayoutManager( |
| 250 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 255 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
| 251 layout->AddView(reset_decisions_button_container_, 1, 1, | 256 layout->AddView(reset_decisions_label_container_, 1, 1, |
| 252 views::GridLayout::LEADING, views::GridLayout::LEADING); | 257 views::GridLayout::LEADING, views::GridLayout::LEADING); |
| 253 | 258 |
| 254 layout->AddPaddingRow(1, kHeaderPaddingBottom); | 259 layout->AddPaddingRow(1, kHeaderPaddingBottom); |
| 255 } | 260 } |
| 256 | 261 |
| 257 PopupHeaderView::~PopupHeaderView() {} | 262 PopupHeaderView::~PopupHeaderView() {} |
| 258 | 263 |
| 259 int PopupHeaderView::GetPreferredNameWidth() const { | 264 int PopupHeaderView::GetPreferredNameWidth() const { |
| 260 return name_->GetPreferredSize().width(); | 265 return summary_label_->GetPreferredSize().width(); |
| 261 } | 266 } |
| 262 | 267 |
| 263 void PopupHeaderView::SetIdentityName(const base::string16& name) { | 268 void PopupHeaderView::SetSummary(const base::string16& summary_text) { |
| 264 name_->SetText(name); | 269 summary_label_->SetText(summary_text); |
| 265 } | 270 } |
| 266 | 271 |
| 267 void PopupHeaderView::SetSecuritySummary( | 272 void PopupHeaderView::SetDetails(const base::string16& details_text, |
| 268 const base::string16& security_summary_text, | 273 bool include_details_label_link) { |
| 269 bool include_details_link) { | 274 if (include_details_label_link) { |
| 270 if (include_details_link) { | 275 base::string16 details_link_text = |
| 271 base::string16 details_string = | |
| 272 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_DETAILS_LINK); | 276 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_DETAILS_LINK); |
| 273 | 277 |
| 274 std::vector<base::string16> subst; | 278 std::vector<base::string16> subst; |
| 275 subst.push_back(security_summary_text); | 279 subst.push_back(details_text); |
| 276 subst.push_back(details_string); | 280 subst.push_back(details_link_text); |
| 277 | 281 |
| 278 std::vector<size_t> offsets; | 282 std::vector<size_t> offsets; |
| 279 | 283 |
| 280 base::string16 text = base::ReplaceStringPlaceholders( | 284 base::string16 text = base::ReplaceStringPlaceholders( |
| 281 base::ASCIIToUTF16("$1 $2"), subst, &offsets); | 285 base::ASCIIToUTF16("$1 $2"), subst, &offsets); |
| 282 status_->SetText(text); | 286 details_label_->SetText(text); |
| 283 gfx::Range details_range(offsets[1], text.length()); | 287 gfx::Range details_range(offsets[1], text.length()); |
| 284 | 288 |
| 285 views::StyledLabel::RangeStyleInfo link_style = | 289 views::StyledLabel::RangeStyleInfo link_style = |
| 286 views::StyledLabel::RangeStyleInfo::CreateForLink(); | 290 views::StyledLabel::RangeStyleInfo::CreateForLink(); |
| 287 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) | 291 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) |
| 288 link_style.font_style |= gfx::Font::FontStyle::UNDERLINE; | 292 link_style.font_style |= gfx::Font::FontStyle::UNDERLINE; |
| 289 link_style.disable_line_wrapping = false; | 293 link_style.disable_line_wrapping = false; |
| 290 | 294 |
| 291 status_->AddStyleRange(details_range, link_style); | 295 details_label_->AddStyleRange(details_range, link_style); |
| 292 } else { | 296 } else { |
| 293 status_->SetText(security_summary_text); | 297 details_label_->SetText(details_text); |
| 294 } | 298 } |
| 295 | 299 |
| 296 // Fit the styled label to occupy available width. | 300 // Fit the styled label to occupy available width. |
| 297 status_->SizeToFit(0); | 301 details_label_->SizeToFit(0); |
| 298 } | 302 } |
| 299 | 303 |
| 300 void PopupHeaderView::AddResetDecisionsButton() { | 304 void PopupHeaderView::AddResetDecisionsLabel() { |
| 301 // TODO(estade): this looks pretty crazy as an MD button because the button | 305 std::vector<base::string16> subst; |
| 302 // text is very long. See crbug.com/512442 | 306 subst.push_back( |
| 303 views::LabelButton* reset_decisions_button = | 307 l10n_util::GetStringUTF16(IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION)); |
| 304 views::MdTextButton::CreateSecondaryUiButton( | 308 subst.push_back(l10n_util::GetStringUTF16( |
| 305 button_listener_, | 309 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON)); |
| 306 l10n_util::GetStringUTF16( | |
| 307 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON)); | |
| 308 reset_decisions_button->set_id(BUTTON_RESET_CERTIFICATE_DECISIONS); | |
| 309 | 310 |
| 310 reset_decisions_button_container_->AddChildView(reset_decisions_button); | 311 std::vector<size_t> offsets; |
| 311 | 312 |
| 312 // Now that it contains a button, the container needs padding at the top. | 313 base::string16 text = base::ReplaceStringPlaceholders( |
| 313 reset_decisions_button_container_->SetBorder( | 314 base::ASCIIToUTF16("$1 $2"), subst, &offsets); |
| 315 reset_decisions_label_ = new views::StyledLabel(text, styled_label_listener_); | |
| 316 gfx::Range link_range(offsets[1], text.length()); | |
| 317 | |
| 318 views::StyledLabel::RangeStyleInfo link_style = | |
| 319 views::StyledLabel::RangeStyleInfo::CreateForLink(); | |
| 320 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) | |
| 321 link_style.font_style |= gfx::Font::FontStyle::UNDERLINE; | |
| 322 link_style.disable_line_wrapping = false; | |
| 323 | |
| 324 reset_decisions_label_->AddStyleRange(link_range, link_style); | |
| 325 // Fit the styled label to occupy available width. | |
| 326 reset_decisions_label_->SizeToFit(0); | |
| 327 reset_decisions_label_container_->AddChildView(reset_decisions_label_); | |
| 328 | |
| 329 // Now that it contains a label, the container needs padding at the top. | |
| 330 reset_decisions_label_container_->SetBorder( | |
| 314 views::Border::CreateEmptyBorder(8, 0, 0, 0)); | 331 views::Border::CreateEmptyBorder(8, 0, 0, 0)); |
| 315 | 332 |
| 316 InvalidateLayout(); | 333 InvalidateLayout(); |
| 317 } | 334 } |
| 318 | 335 |
| 319 //////////////////////////////////////////////////////////////////////////////// | 336 //////////////////////////////////////////////////////////////////////////////// |
| 320 // InternalPageInfoPopupView | 337 // InternalPageInfoPopupView |
| 321 //////////////////////////////////////////////////////////////////////////////// | 338 //////////////////////////////////////////////////////////////////////////////// |
| 322 | 339 |
| 323 InternalPageInfoPopupView::InternalPageInfoPopupView( | 340 InternalPageInfoPopupView::InternalPageInfoPopupView( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 // 16px padding + half of icon width comes out to 24px. | 389 // 16px padding + half of icon width comes out to 24px. |
| 373 frame->bubble_border()->set_arrow_offset( | 390 frame->bubble_border()->set_arrow_offset( |
| 374 24 + frame->bubble_border()->GetBorderThickness()); | 391 24 + frame->bubble_border()->GetBorderThickness()); |
| 375 return frame; | 392 return frame; |
| 376 } | 393 } |
| 377 | 394 |
| 378 void InternalPageInfoPopupView::OnWidgetDestroying(views::Widget* widget) { | 395 void InternalPageInfoPopupView::OnWidgetDestroying(views::Widget* widget) { |
| 379 is_popup_showing = false; | 396 is_popup_showing = false; |
| 380 } | 397 } |
| 381 | 398 |
| 382 int InternalPageInfoPopupView::GetDialogButtons() const { | |
| 383 return ui::DIALOG_BUTTON_NONE; | |
| 384 } | |
| 385 | |
| 386 //////////////////////////////////////////////////////////////////////////////// | 399 //////////////////////////////////////////////////////////////////////////////// |
| 387 // WebsiteSettingsPopupView | 400 // WebsiteSettingsPopupView |
| 388 //////////////////////////////////////////////////////////////////////////////// | 401 //////////////////////////////////////////////////////////////////////////////// |
| 389 | 402 |
| 390 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { | 403 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { |
| 391 } | 404 } |
| 392 | 405 |
| 393 // static | 406 // static |
| 394 void WebsiteSettingsPopupView::ShowPopup( | 407 void WebsiteSettingsPopupView::ShowPopup( |
| 395 views::View* anchor_view, | 408 views::View* anchor_view, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 layout->StartRow(0, content_column); | 481 layout->StartRow(0, content_column); |
| 469 separator_ = new views::Separator(views::Separator::HORIZONTAL); | 482 separator_ = new views::Separator(views::Separator::HORIZONTAL); |
| 470 layout->AddView(separator_); | 483 layout->AddView(separator_); |
| 471 | 484 |
| 472 layout->AddPaddingRow(1, kHeaderMarginBottom); | 485 layout->AddPaddingRow(1, kHeaderMarginBottom); |
| 473 layout->StartRow(1, content_column); | 486 layout->StartRow(1, content_column); |
| 474 | 487 |
| 475 site_settings_view_ = CreateSiteSettingsView(); | 488 site_settings_view_ = CreateSiteSettingsView(); |
| 476 layout->AddView(site_settings_view_); | 489 layout->AddView(site_settings_view_); |
| 477 | 490 |
| 478 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, | 491 // Each section handles its own padding. |
| 479 kPopupMarginBottom, kPopupMarginRight)); | 492 set_margins(gfx::Insets(0, 0, kPopupMarginBottom, 0)); |
| 480 | 493 |
| 481 views::BubbleDialogDelegateView::CreateBubble(this); | 494 views::BubbleDialogDelegateView::CreateBubble(this); |
| 482 | 495 |
| 483 presenter_.reset(new WebsiteSettings( | 496 presenter_.reset(new WebsiteSettings( |
| 484 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), | 497 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), |
| 485 web_contents, url, security_info)); | 498 web_contents, url, security_info)); |
| 486 } | 499 } |
| 487 | 500 |
| 488 void WebsiteSettingsPopupView::RenderFrameDeleted( | 501 void WebsiteSettingsPopupView::RenderFrameDeleted( |
| 489 content::RenderFrameHost* render_frame_host) { | 502 content::RenderFrameHost* render_frame_host) { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 702 new views::BoxLayout(views::BoxLayout::kHorizontal, | 715 new views::BoxLayout(views::BoxLayout::kHorizontal, |
| 703 kSiteSettingsViewPaddingLeft, kLinkMarginTop, 0)); | 716 kSiteSettingsViewPaddingLeft, kLinkMarginTop, 0)); |
| 704 link_section->AddChildView(site_settings_link_); | 717 link_section->AddChildView(site_settings_link_); |
| 705 site_settings_view_->AddChildView(link_section); | 718 site_settings_view_->AddChildView(link_section); |
| 706 | 719 |
| 707 SizeToContents(); | 720 SizeToContents(); |
| 708 } | 721 } |
| 709 | 722 |
| 710 void WebsiteSettingsPopupView::SetIdentityInfo( | 723 void WebsiteSettingsPopupView::SetIdentityInfo( |
| 711 const IdentityInfo& identity_info) { | 724 const IdentityInfo& identity_info) { |
| 712 base::string16 security_summary_text = identity_info.GetSecuritySummary(); | 725 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description = |
| 713 header_->SetIdentityName(base::UTF8ToUTF16(identity_info.site_identity)); | 726 identity_info.GetSecurityDescription(); |
| 727 | |
| 728 header_->SetSummary(security_description->summary); | |
| 714 | 729 |
| 715 if (identity_info.certificate) { | 730 if (identity_info.certificate) { |
| 716 certificate_ = identity_info.certificate; | 731 certificate_ = identity_info.certificate; |
| 717 | 732 |
| 718 if (identity_info.show_ssl_decision_revoke_button) | 733 if (identity_info.show_ssl_decision_revoke_button) |
| 719 header_->AddResetDecisionsButton(); | 734 header_->AddResetDecisionsLabel(); |
| 720 } | 735 } |
| 721 | 736 |
| 722 bool include_details_link = !is_devtools_disabled_ || certificate_; | 737 bool include_details_link = !is_devtools_disabled_ || certificate_; |
| 723 | 738 |
| 724 header_->SetSecuritySummary(security_summary_text, include_details_link); | 739 header_->SetDetails(security_description->details, include_details_link); |
| 725 | 740 |
| 726 Layout(); | 741 Layout(); |
| 727 SizeToContents(); | 742 SizeToContents(); |
| 728 } | 743 } |
| 729 | 744 |
| 730 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) { | 745 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) { |
| 731 // TODO(lgarron): Remove this method. (https://crbug.com/571533) | 746 // TODO(lgarron): Remove this method. (https://crbug.com/571533) |
| 732 } | 747 } |
| 733 | 748 |
| 734 views::View* WebsiteSettingsPopupView::CreateSiteSettingsView() { | 749 views::View* WebsiteSettingsPopupView::CreateSiteSettingsView() { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 826 gfx::NativeWindow parent = | 841 gfx::NativeWindow parent = |
| 827 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr; | 842 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr; |
| 828 presenter_->RecordWebsiteSettingsAction( | 843 presenter_->RecordWebsiteSettingsAction( |
| 829 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED); | 844 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED); |
| 830 ShowCertificateViewer(web_contents(), parent, certificate_.get()); | 845 ShowCertificateViewer(web_contents(), parent, certificate_.get()); |
| 831 } else { | 846 } else { |
| 832 DevToolsWindow::OpenDevToolsWindow( | 847 DevToolsWindow::OpenDevToolsWindow( |
| 833 web_contents(), DevToolsToggleAction::ShowSecurityPanel()); | 848 web_contents(), DevToolsToggleAction::ShowSecurityPanel()); |
| 834 } | 849 } |
| 835 } | 850 } |
| OLD | NEW |