Commit 37240b4f authored by tapted's avatar tapted Committed by Commit bot

PageInfo bubble: Use the non-client view's window title and close button.

Currently it sets a custom close button which is different to the other
Harmony dialogs.

To keep items aligned, use the standard panel margins from
ui/views/layout_constants.h. (13px rather than 16px). This makes the
panel slightly more narrow.

BUG=640851, 674269

Review-Url: https://codereview.chromium.org/2581493002
Cr-Commit-Position: refs/heads/master@{#442779}
parent e00ffecc
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include "ui/views/controls/styled_label.h" #include "ui/views/controls/styled_label.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
#include "ui/views/layout/grid_layout.h" #include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
#include "ui/views/layout/layout_manager.h" #include "ui/views/layout/layout_manager.h"
#include "ui/views/view.h" #include "ui/views/view.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
...@@ -78,18 +79,16 @@ const int kMinPopupWidth = 320; ...@@ -78,18 +79,16 @@ const int kMinPopupWidth = 320;
const int kMaxPopupWidth = 1000; const int kMaxPopupWidth = 1000;
// Margin and padding values shared by all sections. // Margin and padding values shared by all sections.
const int kSectionPaddingHorizontal = 16; const int kSectionPaddingHorizontal = views::kPanelHorizMargin;
// Padding for the bottom of the bubble. // Padding for the bottom of the bubble.
const int kPopupMarginBottom = 16; const int kPopupMarginBottom = views::kPanelVertMargin;
// Security Section (PopupHeaderView) ------------------------------------------ // Security Section (PopupHeaderView) ------------------------------------------
// Margin and padding values for the |PopupHeaderView|. // Margin and padding values for the |PopupHeaderView|.
const int kHeaderMarginBottom = 10; const int kHeaderMarginBottom = 10;
const int kHeaderPaddingBottom = 16; const int kHeaderPaddingBottom = views::kPanelVertMargin;
const int kHeaderPaddingTop = 16;
const int kHeaderPaddingForCloseButton = 8;
// Spacing between labels in the header. // Spacing between labels in the header.
const int kHeaderLabelSpacing = 4; const int kHeaderLabelSpacing = 4;
...@@ -112,6 +111,10 @@ const int STYLED_LABEL_RESET_CERTIFICATE_DECISIONS = 1339; ...@@ -112,6 +111,10 @@ const int STYLED_LABEL_RESET_CERTIFICATE_DECISIONS = 1339;
const int LINK_COOKIE_DIALOG = 1340; const int LINK_COOKIE_DIALOG = 1340;
const int LINK_SITE_SETTINGS = 1341; const int LINK_SITE_SETTINGS = 1341;
// The default, ui::kTitleFontSizeDelta, is too large for the website settings
// bubble (e.g. +3). Use +1 to obtain a smaller font.
constexpr int kSummaryFontSizeDelta = 1;
} // namespace } // namespace
// |PopupHeaderView| is the UI element (view) that represents the header of the // |PopupHeaderView| is the UI element (view) that represents the header of the
...@@ -135,9 +138,6 @@ class PopupHeaderView : public views::View { ...@@ -135,9 +138,6 @@ class PopupHeaderView : public views::View {
// The listener for the styled labels in this view. // The listener for the styled labels in this view.
views::StyledLabelListener* styled_label_listener_; views::StyledLabelListener* styled_label_listener_;
// The label that displays security summary for the current page.
views::Label* summary_label_;
// The label that displays the status of the identity check for this site. // The label that displays the status of the identity check for this site.
// Includes a link to open the Chrome Help Center article about connection // Includes a link to open the Chrome Help Center article about connection
// security. // security.
...@@ -187,59 +187,12 @@ PopupHeaderView::PopupHeaderView( ...@@ -187,59 +187,12 @@ PopupHeaderView::PopupHeaderView(
views::ButtonListener* button_listener, views::ButtonListener* button_listener,
views::StyledLabelListener* styled_label_listener) views::StyledLabelListener* styled_label_listener)
: styled_label_listener_(styled_label_listener), : styled_label_listener_(styled_label_listener),
summary_label_(nullptr),
details_label_(nullptr), details_label_(nullptr),
reset_decisions_label_container_(nullptr), reset_decisions_label_container_(nullptr),
reset_decisions_label_(nullptr) { reset_decisions_label_(nullptr) {
views::GridLayout* layout = new views::GridLayout(this); views::GridLayout* layout = new views::GridLayout(this);
SetLayoutManager(layout); SetLayoutManager(layout);
const int label_column = 0;
views::ColumnSet* column_set = layout->AddColumnSet(label_column);
column_set->AddPaddingColumn(0, kSectionPaddingHorizontal);
column_set->AddColumn(views::GridLayout::FILL,
views::GridLayout::FILL,
1,
views::GridLayout::USE_PREF,
0,
0);
column_set->AddPaddingColumn(1, 0);
column_set->AddColumn(views::GridLayout::FILL,
views::GridLayout::FILL,
1,
views::GridLayout::USE_PREF,
0,
0);
column_set->AddPaddingColumn(0, kHeaderPaddingForCloseButton);
// First we add the padding needed for the close button.
// In order to move down the summary, we simulate additional padding by giving
// it an empty border on top later on.
layout->AddPaddingRow(0, kHeaderPaddingForCloseButton);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
layout->StartRow(0, label_column);
const gfx::FontList& font_list = rb.GetFontListWithDelta(1);
summary_label_ = new views::Label(base::string16(), font_list);
summary_label_->SetMultiLine(true);
summary_label_->SetBorder(views::CreateEmptyBorder(
kHeaderPaddingTop - kHeaderPaddingForCloseButton, 0, 0, 0));
layout->AddView(summary_label_, 1, 1, views::GridLayout::LEADING,
views::GridLayout::TRAILING);
views::ImageButton* close_button = new views::ImageButton(button_listener);
close_button->set_id(BUTTON_CLOSE);
close_button->SetImage(views::CustomButton::STATE_NORMAL,
rb.GetImageNamed(IDR_CLOSE_2).ToImageSkia());
close_button->SetImage(views::CustomButton::STATE_HOVERED,
rb.GetImageNamed(IDR_CLOSE_2_H).ToImageSkia());
close_button->SetImage(views::CustomButton::STATE_PRESSED,
rb.GetImageNamed(IDR_CLOSE_2_P).ToImageSkia());
layout->AddView(close_button, 1, 1, views::GridLayout::TRAILING,
views::GridLayout::LEADING);
layout->AddPaddingRow(0, kHeaderLabelSpacing);
const int label_column_status = 1; const int label_column_status = 1;
views::ColumnSet* column_set_status = views::ColumnSet* column_set_status =
layout->AddColumnSet(label_column_status); layout->AddColumnSet(label_column_status);
...@@ -269,10 +222,6 @@ PopupHeaderView::PopupHeaderView( ...@@ -269,10 +222,6 @@ PopupHeaderView::PopupHeaderView(
PopupHeaderView::~PopupHeaderView() {} PopupHeaderView::~PopupHeaderView() {}
void PopupHeaderView::SetSummary(const base::string16& summary_text) {
summary_label_->SetText(summary_text);
}
void PopupHeaderView::SetDetails(const base::string16& details_text) { void PopupHeaderView::SetDetails(const base::string16& details_text) {
std::vector<base::string16> subst; std::vector<base::string16> subst;
subst.push_back(details_text); subst.push_back(details_text);
...@@ -488,7 +437,6 @@ WebsiteSettingsPopupView::WebsiteSettingsPopupView( ...@@ -488,7 +437,6 @@ WebsiteSettingsPopupView::WebsiteSettingsPopupView(
// Each section handles its own padding. // Each section handles its own padding.
set_margins(gfx::Insets(0, 0, kPopupMarginBottom, 0)); set_margins(gfx::Insets(0, 0, kPopupMarginBottom, 0));
views::BubbleDialogDelegateView::CreateBubble(this); views::BubbleDialogDelegateView::CreateBubble(this);
presenter_.reset(new WebsiteSettings( presenter_.reset(new WebsiteSettings(
...@@ -519,6 +467,14 @@ void WebsiteSettingsPopupView::OnChosenObjectDeleted( ...@@ -519,6 +467,14 @@ void WebsiteSettingsPopupView::OnChosenObjectDeleted(
presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object);
} }
base::string16 WebsiteSettingsPopupView::GetWindowTitle() const {
return summary_text_;
}
bool WebsiteSettingsPopupView::ShouldShowCloseButton() const {
return true;
}
void WebsiteSettingsPopupView::OnWidgetDestroying(views::Widget* widget) { void WebsiteSettingsPopupView::OnWidgetDestroying(views::Widget* widget) {
g_shown_popup_type = POPUP_NONE; g_shown_popup_type = POPUP_NONE;
presenter_->OnUIClosing(); presenter_->OnUIClosing();
...@@ -528,6 +484,11 @@ int WebsiteSettingsPopupView::GetDialogButtons() const { ...@@ -528,6 +484,11 @@ int WebsiteSettingsPopupView::GetDialogButtons() const {
return ui::DIALOG_BUTTON_NONE; return ui::DIALOG_BUTTON_NONE;
} }
const gfx::FontList& WebsiteSettingsPopupView::GetTitleFontList() const {
return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
kSummaryFontSizeDelta);
}
void WebsiteSettingsPopupView::ButtonPressed(views::Button* button, void WebsiteSettingsPopupView::ButtonPressed(views::Button* button,
const ui::Event& event) { const ui::Event& event) {
DCHECK_EQ(BUTTON_CLOSE, button->id()); DCHECK_EQ(BUTTON_CLOSE, button->id());
...@@ -704,7 +665,8 @@ void WebsiteSettingsPopupView::SetIdentityInfo( ...@@ -704,7 +665,8 @@ void WebsiteSettingsPopupView::SetIdentityInfo(
std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description = std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description =
identity_info.GetSecurityDescription(); identity_info.GetSecurityDescription();
header_->SetSummary(security_description->summary); summary_text_ = security_description->summary;
GetWidget()->UpdateWindowTitle();
if (identity_info.certificate) { if (identity_info.certificate) {
certificate_ = identity_info.certificate; certificate_ = identity_info.certificate;
......
...@@ -107,8 +107,11 @@ class WebsiteSettingsPopupView : public content::WebContentsObserver, ...@@ -107,8 +107,11 @@ class WebsiteSettingsPopupView : public content::WebContentsObserver,
const WebsiteSettingsUI::ChosenObjectInfo& info) override; const WebsiteSettingsUI::ChosenObjectInfo& info) override;
// views::BubbleDialogDelegateView implementation. // views::BubbleDialogDelegateView implementation.
base::string16 GetWindowTitle() const override;
bool ShouldShowCloseButton() const override;
void OnWidgetDestroying(views::Widget* widget) override; void OnWidgetDestroying(views::Widget* widget) override;
int GetDialogButtons() const override; int GetDialogButtons() const override;
const gfx::FontList& GetTitleFontList() const override;
// views::ButtonListener implementation. // views::ButtonListener implementation.
void ButtonPressed(views::Button* button, const ui::Event& event) override; void ButtonPressed(views::Button* button, const ui::Event& event) override;
...@@ -150,6 +153,9 @@ class WebsiteSettingsPopupView : public content::WebContentsObserver, ...@@ -150,6 +153,9 @@ class WebsiteSettingsPopupView : public content::WebContentsObserver,
// The header section (containing security-related information). // The header section (containing security-related information).
PopupHeaderView* header_; PopupHeaderView* header_;
// The security summary for the current page.
base::string16 summary_text_;
// The separator between the header and the site settings view. // The separator between the header and the site settings view.
views::Separator* separator_; views::Separator* separator_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment