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 30 matching lines...) Expand all Loading... | |
| 41 #include "grit/theme_resources.h" | 41 #include "grit/theme_resources.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
| 43 #include "ui/base/material_design/material_design_controller.h" | 43 #include "ui/base/material_design/material_design_controller.h" |
| 44 #include "ui/base/models/simple_menu_model.h" | 44 #include "ui/base/models/simple_menu_model.h" |
| 45 #include "ui/base/resource/resource_bundle.h" | 45 #include "ui/base/resource/resource_bundle.h" |
| 46 #include "ui/gfx/canvas.h" | 46 #include "ui/gfx/canvas.h" |
| 47 #include "ui/gfx/font_list.h" | 47 #include "ui/gfx/font_list.h" |
| 48 #include "ui/gfx/geometry/insets.h" | 48 #include "ui/gfx/geometry/insets.h" |
| 49 #include "ui/gfx/image/image.h" | 49 #include "ui/gfx/image/image.h" |
| 50 #include "ui/resources/grit/ui_resources.h" | 50 #include "ui/resources/grit/ui_resources.h" |
| 51 #include "ui/views/border.h" | |
| 51 #include "ui/views/bubble/bubble_frame_view.h" | 52 #include "ui/views/bubble/bubble_frame_view.h" |
| 52 #include "ui/views/controls/button/image_button.h" | 53 #include "ui/views/controls/button/image_button.h" |
| 53 #include "ui/views/controls/button/md_text_button.h" | 54 #include "ui/views/controls/button/md_text_button.h" |
| 54 #include "ui/views/controls/image_view.h" | 55 #include "ui/views/controls/image_view.h" |
| 55 #include "ui/views/controls/label.h" | 56 #include "ui/views/controls/label.h" |
| 56 #include "ui/views/controls/link.h" | 57 #include "ui/views/controls/link.h" |
| 57 #include "ui/views/controls/styled_label.h" | 58 #include "ui/views/controls/styled_label.h" |
| 58 #include "ui/views/layout/box_layout.h" | 59 #include "ui/views/layout/box_layout.h" |
| 59 #include "ui/views/layout/grid_layout.h" | 60 #include "ui/views/layout/grid_layout.h" |
| 60 #include "ui/views/layout/layout_manager.h" | 61 #include "ui/views/layout/layout_manager.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 74 | 75 |
| 75 // Left icon margin. | 76 // Left icon margin. |
| 76 const int kIconMarginLeft = 6; | 77 const int kIconMarginLeft = 6; |
| 77 | 78 |
| 78 // Margin and padding values for the |PopupHeaderView|. | 79 // Margin and padding values for the |PopupHeaderView|. |
| 79 const int kHeaderMarginBottom = 10; | 80 const int kHeaderMarginBottom = 10; |
| 80 const int kHeaderPaddingBottom = 16; | 81 const int kHeaderPaddingBottom = 16; |
| 81 const int kHeaderPaddingLeft = 18; | 82 const int kHeaderPaddingLeft = 18; |
| 82 const int kHeaderPaddingRightForCloseButton = 8; | 83 const int kHeaderPaddingRightForCloseButton = 8; |
| 83 const int kHeaderPaddingRightForText = kHeaderPaddingLeft; | 84 const int kHeaderPaddingRightForText = kHeaderPaddingLeft; |
| 84 const int kHeaderPaddingTop = 12; | 85 const int kHeaderPaddingTop = 16; |
| 85 | 86 |
| 86 // Spacing between the site identity label and the site identity status text in | 87 // Spacing between the site identity label and the site identity status text in |
| 87 // the popup header. | 88 // the popup header. |
| 88 const int kHeaderRowSpacing = 4; | 89 const int kHeaderRowSpacing = 4; |
| 89 | 90 |
| 90 // The max possible width of the popup. | 91 // The max possible width of the popup. |
| 91 const int kMaxPopupWidth = 1000; | 92 const int kMaxPopupWidth = 1000; |
| 92 | 93 |
| 93 // The margins between the popup border and the popup content. | 94 // The margins between the popup border and the popup content. |
| 94 const int kPopupMarginTop = 4; | |
| 95 const int kPopupMarginLeft = 0; | |
| 96 const int kPopupMarginBottom = 14; | 95 const int kPopupMarginBottom = 14; |
| 97 const int kPopupMarginRight = 0; | |
| 98 | 96 |
| 99 // Padding values for sections on the site settings view. | 97 // Padding values for sections on the site settings view. |
| 100 const int kSiteSettingsViewContentMinWidth = 300; | 98 const int kSiteSettingsViewContentMinWidth = 300; |
| 101 const int kSiteSettingsViewPaddingBottom = 6; | 99 const int kSiteSettingsViewPaddingBottom = 6; |
| 102 const int kSiteSettingsViewPaddingLeft = 18; | 100 const int kSiteSettingsViewPaddingLeft = 18; |
| 103 const int kSiteSettingsViewPaddingRight = 18; | 101 const int kSiteSettingsViewPaddingRight = 18; |
| 104 const int kSiteSettingsViewPaddingTop = 4; | 102 const int kSiteSettingsViewPaddingTop = 4; |
| 105 | 103 |
| 106 // Space between the headline and the content of a section. | 104 // Space between the headline and the content of a section. |
| 107 const int kSiteSettingsViewHeadlineMarginBottom = 10; | 105 const int kSiteSettingsViewHeadlineMarginBottom = 10; |
| 108 // Spacing between rows in the "Permissions" and "Cookies and Site Data" | 106 // Spacing between rows in the "Permissions" and "Cookies and Site Data" |
| 109 // sections. | 107 // sections. |
| 110 const int kContentRowSpacing = 2; | 108 const int kContentRowSpacing = 2; |
| 111 | 109 |
| 112 const int kSiteDataIconColumnWidth = 20; | 110 const int kSiteDataIconColumnWidth = 20; |
| 113 | 111 |
| 114 const int BUTTON_RESET_CERTIFICATE_DECISIONS = 1337; | 112 const int BUTTON_RESET_CERTIFICATE_DECISIONS = 1337; |
| 115 | 113 |
| 116 } // namespace | 114 } // namespace |
| 117 | 115 |
| 118 // |PopupHeaderView| is the UI element (view) that represents the header of the | 116 // |PopupHeaderView| is the UI element (view) that represents the header of the |
| 119 // |WebsiteSettingsPopupView|. The header shows the status of the site's | 117 // |WebsiteSettingsPopupView|. The header shows the status of the site's |
| 120 // identity check and the name of the site's identity. | 118 // identity check and the name of the site's identity. |
| 121 class PopupHeaderView : public views::View { | 119 class PopupHeaderView : public views::View { |
| 122 public: | 120 public: |
| 123 explicit PopupHeaderView(views::ButtonListener* button_listener, | 121 explicit PopupHeaderView(views::ButtonListener* button_listener, |
| 124 views::StyledLabelListener* styled_label_listener); | 122 views::StyledLabelListener* styled_label_listener); |
| 125 ~PopupHeaderView() override; | 123 ~PopupHeaderView() override; |
| 126 | 124 |
| 127 // Sets the name of the site's identity. | 125 // Sets security summary. |
|
msw
2016/08/25 01:30:21
nit: // Sets the security summary for the current
lgarron
2016/08/25 03:26:58
Done.
| |
| 128 void SetIdentityName(const base::string16& name); | 126 void SetSummary(const base::string16& text); |
| 127 void SetSummaryColor(SkColor color); | |
| 129 | 128 |
| 130 // Sets the security summary text for the current page. | 129 // Sets the security details for the current page. |
| 131 void SetSecuritySummary(const base::string16& security_summary_text, | 130 void SetDetails(const base::string16& security_summary_text, |
|
msw
2016/08/25 01:30:22
nit: It's a little confusing that we support SetSu
lgarron
2016/08/25 03:26:58
I've changed the parameter to security_details_tex
| |
| 132 bool include_details_link); | 131 bool include_details_link); |
| 133 | 132 |
| 134 int GetPreferredNameWidth() const; | 133 int GetPreferredNameWidth() const; |
| 135 | 134 |
| 136 void AddResetDecisionsButton(); | 135 void AddResetDecisionsButton(); |
| 137 | 136 |
| 138 private: | 137 private: |
| 138 // The listener for the styled lables in this view. | |
|
msw
2016/08/25 01:30:22
nit: 'labels'
lgarron
2016/08/25 03:26:58
Done.
| |
| 139 views::StyledLabelListener* styled_label_listener_; | |
| 140 | |
| 139 // The label that displays the name of the site's identity. | 141 // The label that displays the name of the site's identity. |
|
msw
2016/08/25 01:30:22
nit: update comment.
lgarron
2016/08/25 03:26:57
Done.
| |
| 140 views::Label* name_; | 142 views::Label* summary_; |
| 143 | |
| 141 // The label that displays the status of the identity check for this site. | 144 // The label that displays the status of the identity check for this site. |
| 142 // Includes a link to open the DevTools Security panel. | 145 // Includes a link to open the DevTools Security panel. |
| 143 views::StyledLabel* status_; | 146 views::StyledLabel* status_; |
| 144 | 147 |
| 145 // The button listener attached to the buttons in this view. | |
| 146 views::ButtonListener* button_listener_; | |
| 147 | |
| 148 // A container for the button for resetting cert decisions. The button is only | 148 // A container for the button for resetting cert decisions. The button is only |
|
msw
2016/08/25 01:30:21
nit: update mentions of button, now it's a "styled
lgarron
2016/08/25 03:26:57
Done.
| |
| 149 // shown sometimes, so we use a container to keep track of where to place it | 149 // shown sometimes, so we use a container to keep track of where to place it |
| 150 // (if needed). | 150 // (if needed). |
| 151 views::View* reset_decisions_button_container_; | 151 views::View* reset_decisions_label_container_; |
| 152 views::StyledLabel* reset_decisions_label_; | |
| 152 | 153 |
| 153 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); | 154 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); |
| 154 }; | 155 }; |
| 155 | 156 |
| 156 // Website Settings are not supported for internal Chrome pages and extension | 157 // Website Settings are not supported for internal Chrome pages and extension |
| 157 // pages. Instead of the |WebsiteSettingsPopupView|, the | 158 // pages. Instead of the |WebsiteSettingsPopupView|, the |
| 158 // |InternalPageInfoPopupView| is displayed. | 159 // |InternalPageInfoPopupView| is displayed. |
| 159 class InternalPageInfoPopupView : public views::BubbleDialogDelegateView { | 160 class InternalPageInfoPopupView : public views::BubbleDialogDelegateView { |
| 160 public: | 161 public: |
| 161 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be | 162 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 177 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); | 178 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); |
| 178 }; | 179 }; |
| 179 | 180 |
| 180 //////////////////////////////////////////////////////////////////////////////// | 181 //////////////////////////////////////////////////////////////////////////////// |
| 181 // Popup Header | 182 // Popup Header |
| 182 //////////////////////////////////////////////////////////////////////////////// | 183 //////////////////////////////////////////////////////////////////////////////// |
| 183 | 184 |
| 184 PopupHeaderView::PopupHeaderView( | 185 PopupHeaderView::PopupHeaderView( |
| 185 views::ButtonListener* button_listener, | 186 views::ButtonListener* button_listener, |
| 186 views::StyledLabelListener* styled_label_listener) | 187 views::StyledLabelListener* styled_label_listener) |
| 187 : name_(nullptr), | 188 : styled_label_listener_(styled_label_listener), |
| 189 summary_(nullptr), | |
| 188 status_(nullptr), | 190 status_(nullptr), |
| 189 button_listener_(button_listener), | 191 reset_decisions_label_container_(nullptr) { |
|
msw
2016/08/25 01:30:21
nit: also init |reset_decisions_label_| to nullptr
lgarron
2016/08/25 03:26:57
Done.
| |
| 190 reset_decisions_button_container_(nullptr) { | |
| 191 views::GridLayout* layout = new views::GridLayout(this); | 192 views::GridLayout* layout = new views::GridLayout(this); |
| 192 SetLayoutManager(layout); | 193 SetLayoutManager(layout); |
| 193 | 194 |
| 194 const int label_column = 0; | 195 const int label_column = 0; |
| 195 views::ColumnSet* column_set = layout->AddColumnSet(label_column); | 196 views::ColumnSet* column_set = layout->AddColumnSet(label_column); |
| 196 column_set->AddPaddingColumn(0, kHeaderPaddingLeft); | 197 column_set->AddPaddingColumn(0, kHeaderPaddingLeft); |
| 197 column_set->AddColumn(views::GridLayout::FILL, | 198 column_set->AddColumn(views::GridLayout::FILL, |
| 198 views::GridLayout::FILL, | 199 views::GridLayout::FILL, |
| 199 1, | 200 1, |
| 200 views::GridLayout::USE_PREF, | 201 views::GridLayout::USE_PREF, |
| 201 0, | 202 0, |
| 202 0); | 203 0); |
| 203 column_set->AddPaddingColumn(1, 0); | 204 column_set->AddPaddingColumn(1, 0); |
| 204 column_set->AddColumn(views::GridLayout::FILL, | 205 column_set->AddColumn(views::GridLayout::FILL, |
| 205 views::GridLayout::FILL, | 206 views::GridLayout::FILL, |
| 206 1, | 207 1, |
| 207 views::GridLayout::USE_PREF, | 208 views::GridLayout::USE_PREF, |
| 208 0, | 209 0, |
| 209 0); | 210 0); |
| 210 column_set->AddPaddingColumn(0, kHeaderPaddingRightForCloseButton); | 211 column_set->AddPaddingColumn(0, kHeaderPaddingRightForCloseButton); |
| 211 | 212 |
| 212 layout->AddPaddingRow(0, kHeaderPaddingTop); | 213 // First we add the padding needed for the close button. |
| 214 // In order to move down the summary, we simulate additional padding by giving | |
| 215 // it an empty border on top later on. | |
| 216 layout->AddPaddingRow(0, kHeaderPaddingRightForCloseButton); | |
| 217 | |
| 218 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 213 | 219 |
| 214 layout->StartRow(0, label_column); | 220 layout->StartRow(0, label_column); |
| 215 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 221 const gfx::FontList& font_list = rb.GetFontListWithDelta(1); |
|
msw
2016/08/25 01:30:22
nit: do we really need this to be 1px bigger than
lgarron
2016/08/25 03:26:58
Yep, this is an explicit design design decision in
msw
2016/08/25 03:56:46
Acknowledged.
| |
| 216 name_ = new views::Label( | 222 summary_ = new views::Label(base::string16(), font_list); |
| 217 base::string16(), rb.GetFontList(ui::ResourceBundle::BoldFont)); | 223 summary_->SetBorder(views::Border::CreateEmptyBorder( |
| 218 layout->AddView(name_, 1, 1, views::GridLayout::LEADING, | 224 kHeaderPaddingTop - kHeaderPaddingRightForCloseButton, 0, 0, 0)); |
| 225 layout->AddView(summary_, 1, 1, views::GridLayout::LEADING, | |
| 219 views::GridLayout::TRAILING); | 226 views::GridLayout::TRAILING); |
| 220 views::ImageButton* close_button = new views::ImageButton(button_listener); | 227 views::ImageButton* close_button = new views::ImageButton(button_listener); |
|
msw
2016/08/25 01:30:22
aside: It'd be nice if this bubble simply used the
lgarron
2016/08/25 03:26:58
Bug filed: https://crbug.com/640851
| |
| 221 close_button->SetImage(views::CustomButton::STATE_NORMAL, | 228 close_button->SetImage(views::CustomButton::STATE_NORMAL, |
| 222 rb.GetImageNamed(IDR_CLOSE_2).ToImageSkia()); | 229 rb.GetImageNamed(IDR_CLOSE_2).ToImageSkia()); |
| 223 close_button->SetImage(views::CustomButton::STATE_HOVERED, | 230 close_button->SetImage(views::CustomButton::STATE_HOVERED, |
| 224 rb.GetImageNamed(IDR_CLOSE_2_H).ToImageSkia()); | 231 rb.GetImageNamed(IDR_CLOSE_2_H).ToImageSkia()); |
| 225 close_button->SetImage(views::CustomButton::STATE_PRESSED, | 232 close_button->SetImage(views::CustomButton::STATE_PRESSED, |
| 226 rb.GetImageNamed(IDR_CLOSE_2_P).ToImageSkia()); | 233 rb.GetImageNamed(IDR_CLOSE_2_P).ToImageSkia()); |
| 227 layout->AddView(close_button, 1, 1, views::GridLayout::TRAILING, | 234 layout->AddView(close_button, 1, 2, views::GridLayout::TRAILING, |
|
msw
2016/08/25 01:30:22
Is this now spanning two rows to vertically center
lgarron
2016/08/25 03:26:58
Good catch, this is a vestigial fix.
I was origin
| |
| 228 views::GridLayout::LEADING); | 235 views::GridLayout::LEADING); |
| 229 | 236 |
| 230 layout->AddPaddingRow(0, kHeaderRowSpacing); | 237 layout->AddPaddingRow(0, kHeaderRowSpacing); |
| 231 | 238 |
| 232 const int label_column_status = 1; | 239 const int label_column_status = 1; |
| 233 views::ColumnSet* column_set_status = | 240 views::ColumnSet* column_set_status = |
| 234 layout->AddColumnSet(label_column_status); | 241 layout->AddColumnSet(label_column_status); |
| 235 column_set_status->AddPaddingColumn(0, kHeaderPaddingLeft); | 242 column_set_status->AddPaddingColumn(0, kHeaderPaddingLeft); |
| 236 column_set_status->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, | 243 column_set_status->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, |
| 237 1, views::GridLayout::USE_PREF, 0, 0); | 244 1, views::GridLayout::USE_PREF, 0, 0); |
| 238 column_set_status->AddPaddingColumn(0, kHeaderPaddingRightForText); | 245 column_set_status->AddPaddingColumn(0, kHeaderPaddingRightForText); |
| 239 | 246 |
| 247 layout->AddPaddingRow(0, kHeaderRowSpacing); | |
| 248 | |
| 240 layout->StartRow(0, label_column_status); | 249 layout->StartRow(0, label_column_status); |
| 241 status_ = new views::StyledLabel(base::string16(), styled_label_listener); | 250 status_ = new views::StyledLabel(base::string16(), styled_label_listener); |
| 242 layout->AddView(status_, | 251 layout->AddView(status_, |
| 243 1, | 252 1, |
| 244 1, | 253 1, |
| 245 views::GridLayout::LEADING, | 254 views::GridLayout::LEADING, |
| 246 views::GridLayout::LEADING); | 255 views::GridLayout::LEADING); |
| 247 | 256 |
| 248 layout->StartRow(0, label_column_status); | 257 layout->StartRow(0, label_column_status); |
| 249 reset_decisions_button_container_ = new views::View(); | 258 reset_decisions_label_container_ = new views::View(); |
| 250 reset_decisions_button_container_->SetLayoutManager( | 259 reset_decisions_label_container_->SetLayoutManager( |
| 251 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 260 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
|
msw
2016/08/25 01:30:22
aside: perhaps this could be a FillLayout (but it'
lgarron
2016/08/25 03:26:58
Just tried, but that resizes the label to be the f
msw
2016/08/25 03:56:46
Acknowledged.
| |
| 252 layout->AddView(reset_decisions_button_container_, 1, 1, | 261 layout->AddView(reset_decisions_label_container_, 1, 1, |
| 253 views::GridLayout::LEADING, views::GridLayout::LEADING); | 262 views::GridLayout::LEADING, views::GridLayout::LEADING); |
| 254 | 263 |
| 255 layout->AddPaddingRow(1, kHeaderPaddingBottom); | 264 layout->AddPaddingRow(1, kHeaderPaddingBottom); |
| 256 } | 265 } |
| 257 | 266 |
| 258 PopupHeaderView::~PopupHeaderView() {} | 267 PopupHeaderView::~PopupHeaderView() {} |
| 259 | 268 |
| 260 int PopupHeaderView::GetPreferredNameWidth() const { | 269 int PopupHeaderView::GetPreferredNameWidth() const { |
| 261 return name_->GetPreferredSize().width(); | 270 return summary_->GetPreferredSize().width(); |
| 262 } | 271 } |
| 263 | 272 |
| 264 void PopupHeaderView::SetIdentityName(const base::string16& name) { | 273 void PopupHeaderView::SetSummary(const base::string16& text) { |
| 265 name_->SetText(name); | 274 summary_->SetText(text); |
| 266 } | 275 } |
| 267 | 276 |
| 268 void PopupHeaderView::SetSecuritySummary( | 277 void PopupHeaderView::SetSummaryColor(SkColor color) { |
| 269 const base::string16& security_summary_text, | 278 summary_->SetEnabledColor(color); |
| 270 bool include_details_link) { | 279 } |
| 280 | |
| 281 void PopupHeaderView::SetDetails(const base::string16& security_summary_text, | |
| 282 bool include_details_link) { | |
| 271 if (include_details_link) { | 283 if (include_details_link) { |
| 272 base::string16 details_string = | 284 base::string16 details_string = |
| 273 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_DETAILS_LINK); | 285 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_DETAILS_LINK); |
| 274 | 286 |
| 275 std::vector<base::string16> subst; | 287 std::vector<base::string16> subst; |
| 276 subst.push_back(security_summary_text); | 288 subst.push_back(security_summary_text); |
| 277 subst.push_back(details_string); | 289 subst.push_back(details_string); |
| 278 | 290 |
| 279 std::vector<size_t> offsets; | 291 std::vector<size_t> offsets; |
| 280 | 292 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 292 status_->AddStyleRange(details_range, link_style); | 304 status_->AddStyleRange(details_range, link_style); |
| 293 } else { | 305 } else { |
| 294 status_->SetText(security_summary_text); | 306 status_->SetText(security_summary_text); |
| 295 } | 307 } |
| 296 | 308 |
| 297 // Fit the styled label to occupy available width. | 309 // Fit the styled label to occupy available width. |
| 298 status_->SizeToFit(0); | 310 status_->SizeToFit(0); |
| 299 } | 311 } |
| 300 | 312 |
| 301 void PopupHeaderView::AddResetDecisionsButton() { | 313 void PopupHeaderView::AddResetDecisionsButton() { |
| 302 // TODO(estade): this looks pretty crazy as an MD button because the button | 314 std::vector<base::string16> subst; |
| 303 // text is very long. See crbug.com/512442 | 315 subst.push_back( |
| 304 views::LabelButton* reset_decisions_button = | 316 l10n_util::GetStringUTF16(IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION)); |
|
msw
2016/08/25 01:30:21
Please note CL dependencies in the CL description.
lgarron
2016/08/25 03:26:57
Hmm, I thought the convention was only to referenc
msw
2016/08/25 03:56:46
This is just to make reviewing easier. I was revie
lgarron
2016/08/25 04:10:14
Good point. Acknowledged. :-)
| |
| 305 views::MdTextButton::CreateSecondaryUiButton( | 317 subst.push_back(l10n_util::GetStringUTF16( |
| 306 button_listener_, | 318 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON)); |
| 307 l10n_util::GetStringUTF16( | |
| 308 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON)); | |
| 309 reset_decisions_button->set_id(BUTTON_RESET_CERTIFICATE_DECISIONS); | |
| 310 | 319 |
| 311 reset_decisions_button_container_->AddChildView(reset_decisions_button); | 320 std::vector<size_t> offsets; |
| 321 | |
| 322 base::string16 text = base::ReplaceStringPlaceholders( | |
| 323 base::ASCIIToUTF16("$1 $2"), subst, &offsets); | |
|
msw
2016/08/25 01:30:22
This is not the right way to combine localized str
lgarron
2016/08/25 03:26:58
Unfortunately, OSX needs to use separate strings f
msw
2016/08/25 03:56:46
Acknowledged.
| |
| 324 reset_decisions_label_ = new views::StyledLabel(text, styled_label_listener_); | |
| 325 gfx::Range link_range(offsets[1], text.length()); | |
| 326 | |
| 327 views::StyledLabel::RangeStyleInfo link_style = | |
| 328 views::StyledLabel::RangeStyleInfo::CreateForLink(); | |
| 329 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) | |
| 330 link_style.font_style |= gfx::Font::FontStyle::UNDERLINE; | |
| 331 link_style.disable_line_wrapping = false; | |
| 332 | |
| 333 reset_decisions_label_->AddStyleRange(link_range, link_style); | |
| 334 reset_decisions_label_->SizeToFit(0); | |
|
msw
2016/08/25 01:30:22
q: Is this needed?
lgarron
2016/08/25 03:26:57
Yes. I think we discussed it on a previous CL. The
msw
2016/08/25 03:56:46
Right... Can you add a similar comment:
// Fit the
lgarron
2016/08/25 04:10:14
Done.
| |
| 335 reset_decisions_label_container_->AddChildView(reset_decisions_label_); | |
| 312 | 336 |
| 313 // Now that it contains a button, the container needs padding at the top. | 337 // Now that it contains a button, the container needs padding at the top. |
|
msw
2016/08/25 01:30:22
nit: update mentions of button.
| |
| 314 reset_decisions_button_container_->SetBorder( | 338 reset_decisions_label_container_->SetBorder( |
| 315 views::Border::CreateEmptyBorder(8, 0, 0, 0)); | 339 views::Border::CreateEmptyBorder(8, 0, 0, 0)); |
| 316 | 340 |
| 317 InvalidateLayout(); | 341 InvalidateLayout(); |
| 318 } | 342 } |
| 319 | 343 |
| 320 //////////////////////////////////////////////////////////////////////////////// | 344 //////////////////////////////////////////////////////////////////////////////// |
| 321 // InternalPageInfoPopupView | 345 // InternalPageInfoPopupView |
| 322 //////////////////////////////////////////////////////////////////////////////// | 346 //////////////////////////////////////////////////////////////////////////////// |
| 323 | 347 |
| 324 InternalPageInfoPopupView::InternalPageInfoPopupView( | 348 InternalPageInfoPopupView::InternalPageInfoPopupView( |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 471 layout->StartRow(0, content_column); | 495 layout->StartRow(0, content_column); |
| 472 separator_ = new views::Separator(views::Separator::HORIZONTAL); | 496 separator_ = new views::Separator(views::Separator::HORIZONTAL); |
| 473 layout->AddView(separator_); | 497 layout->AddView(separator_); |
| 474 | 498 |
| 475 layout->AddPaddingRow(1, kHeaderMarginBottom); | 499 layout->AddPaddingRow(1, kHeaderMarginBottom); |
| 476 layout->StartRow(1, content_column); | 500 layout->StartRow(1, content_column); |
| 477 | 501 |
| 478 site_settings_view_ = CreateSiteSettingsView(); | 502 site_settings_view_ = CreateSiteSettingsView(); |
| 479 layout->AddView(site_settings_view_); | 503 layout->AddView(site_settings_view_); |
| 480 | 504 |
| 481 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, | 505 set_margins(gfx::Insets(0, 0, kPopupMarginBottom, |
| 482 kPopupMarginBottom, kPopupMarginRight)); | 506 0)); // Each section handles its own padding. |
|
msw
2016/08/25 01:30:22
nit: put the comment before the code and avoid wra
lgarron
2016/08/25 03:26:57
Done.
| |
| 483 | 507 |
| 484 views::BubbleDialogDelegateView::CreateBubble(this); | 508 views::BubbleDialogDelegateView::CreateBubble(this); |
| 485 | 509 |
| 486 presenter_.reset(new WebsiteSettings( | 510 presenter_.reset(new WebsiteSettings( |
| 487 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), | 511 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), |
| 488 web_contents, url, security_info, content::CertStore::GetInstance())); | 512 web_contents, url, security_info, content::CertStore::GetInstance())); |
| 489 } | 513 } |
| 490 | 514 |
| 491 void WebsiteSettingsPopupView::RenderFrameDeleted( | 515 void WebsiteSettingsPopupView::RenderFrameDeleted( |
| 492 content::RenderFrameHost* render_frame_host) { | 516 content::RenderFrameHost* render_frame_host) { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 // In addition, if a permission is set to the default setting, WebsiteSettings | 664 // In addition, if a permission is set to the default setting, WebsiteSettings |
| 641 // removes it from |permission_info_list|, but the button should remain. | 665 // removes it from |permission_info_list|, but the button should remain. |
| 642 if (permissions_content_) { | 666 if (permissions_content_) { |
| 643 base::STLDeleteContainerPointers(chosen_object_info_list.begin(), | 667 base::STLDeleteContainerPointers(chosen_object_info_list.begin(), |
| 644 chosen_object_info_list.end()); | 668 chosen_object_info_list.end()); |
| 645 return; | 669 return; |
| 646 } | 670 } |
| 647 | 671 |
| 648 permissions_content_ = new views::View(); | 672 permissions_content_ = new views::View(); |
| 649 views::GridLayout* layout = new views::GridLayout(permissions_content_); | 673 views::GridLayout* layout = new views::GridLayout(permissions_content_); |
| 674 layout->set_minimum_size(gfx::Size(300, 0)); | |
|
msw
2016/08/25 01:30:22
Why is this needed here? If it's needed, use kSite
lgarron
2016/08/25 03:26:57
Removed.
(I think this is a merge artifact.)
| |
| 650 permissions_content_->SetLayoutManager(layout); | 675 permissions_content_->SetLayoutManager(layout); |
| 651 | 676 |
| 652 base::string16 headline = | 677 base::string16 headline = |
| 653 permission_info_list.empty() | 678 permission_info_list.empty() |
| 654 ? base::string16() | 679 ? base::string16() |
| 655 : l10n_util::GetStringUTF16( | 680 : l10n_util::GetStringUTF16( |
| 656 IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS); | 681 IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS); |
| 657 views::View* permissions_section = | 682 views::View* permissions_section = |
| 658 CreateSection(headline, permissions_content_, nullptr); | 683 CreateSection(headline, permissions_content_, nullptr); |
| 659 site_settings_view_->AddChildView(permissions_section); | 684 site_settings_view_->AddChildView(permissions_section); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 702 new views::BoxLayout(views::BoxLayout::kHorizontal, | 727 new views::BoxLayout(views::BoxLayout::kHorizontal, |
| 703 kSiteSettingsViewPaddingLeft, kLinkMarginTop, 0)); | 728 kSiteSettingsViewPaddingLeft, kLinkMarginTop, 0)); |
| 704 link_section->AddChildView(site_settings_link_); | 729 link_section->AddChildView(site_settings_link_); |
| 705 site_settings_view_->AddChildView(link_section); | 730 site_settings_view_->AddChildView(link_section); |
| 706 | 731 |
| 707 SizeToContents(); | 732 SizeToContents(); |
| 708 } | 733 } |
| 709 | 734 |
| 710 void WebsiteSettingsPopupView::SetIdentityInfo( | 735 void WebsiteSettingsPopupView::SetIdentityInfo( |
| 711 const IdentityInfo& identity_info) { | 736 const IdentityInfo& identity_info) { |
| 712 base::string16 security_summary_text = identity_info.GetSecuritySummary(); | 737 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description = |
| 713 header_->SetIdentityName(base::UTF8ToUTF16(identity_info.site_identity)); | 738 identity_info.GetSecurityDescription(); |
| 739 | |
| 740 header_->SetSummary(security_description->summary); | |
| 741 if (security_description->summary_style & WebsiteSettingsUI::STYLE_COLOR) { | |
|
msw
2016/08/25 01:30:22
nit: curlies not needed.
lgarron
2016/08/25 03:26:57
*sheds tear and removes curlies*
| |
| 742 header_->SetSummaryColor(security_description->summary_color); | |
|
msw
2016/08/25 01:30:22
It would be nice if we passed around security leve
lgarron
2016/08/25 03:26:58
I strongly wanted to avoid hard-coding the colors
msw
2016/08/25 03:56:46
The right way to do is usually defining native the
lgarron
2016/08/25 04:10:14
In this case, the UI surface is not colored by the
msw
2016/08/25 04:44:57
Just tested; the bubble has a black background in
| |
| 743 } | |
| 714 | 744 |
| 715 if (identity_info.cert_id) { | 745 if (identity_info.cert_id) { |
| 716 cert_id_ = identity_info.cert_id; | 746 cert_id_ = identity_info.cert_id; |
| 717 | 747 |
| 718 if (identity_info.show_ssl_decision_revoke_button) | 748 if (identity_info.show_ssl_decision_revoke_button) |
| 719 header_->AddResetDecisionsButton(); | 749 header_->AddResetDecisionsButton(); |
| 720 } | 750 } |
| 721 | 751 |
| 722 bool include_details_link = | 752 bool include_details_link = |
| 723 !is_devtools_disabled_ || identity_info.cert_id != 0; | 753 !is_devtools_disabled_ || identity_info.cert_id != 0; |
| 724 | 754 |
| 725 header_->SetSecuritySummary(security_summary_text, include_details_link); | 755 header_->SetDetails(security_description->details, include_details_link); |
| 726 | 756 |
| 727 Layout(); | 757 Layout(); |
| 728 SizeToContents(); | 758 SizeToContents(); |
| 729 } | 759 } |
| 730 | 760 |
| 731 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) { | 761 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) { |
| 732 // TODO(lgarron): Remove this method. (https://crbug.com/571533) | 762 // TODO(lgarron): Remove this method. (https://crbug.com/571533) |
| 733 } | 763 } |
| 734 | 764 |
| 735 views::View* WebsiteSettingsPopupView::CreateSiteSettingsView() { | 765 views::View* WebsiteSettingsPopupView::CreateSiteSettingsView() { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 824 gfx::NativeWindow parent = | 854 gfx::NativeWindow parent = |
| 825 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr; | 855 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr; |
| 826 presenter_->RecordWebsiteSettingsAction( | 856 presenter_->RecordWebsiteSettingsAction( |
| 827 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED); | 857 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED); |
| 828 ShowCertificateViewerByID(web_contents_, parent, cert_id_); | 858 ShowCertificateViewerByID(web_contents_, parent, cert_id_); |
| 829 } else { | 859 } else { |
| 830 DevToolsWindow::OpenDevToolsWindow( | 860 DevToolsWindow::OpenDevToolsWindow( |
| 831 web_contents_, DevToolsToggleAction::ShowSecurityPanel()); | 861 web_contents_, DevToolsToggleAction::ShowSecurityPanel()); |
| 832 } | 862 } |
| 833 } | 863 } |
| OLD | NEW |