Chromium Code Reviews| Index: chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
| diff --git a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
| index 89a651df2e9d0c7abf027460c90248b3ea5f029a..a2a26b3b14e1521813f05c9efeb1194a1c46a03b 100644 |
| --- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
| +++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
| @@ -32,13 +32,13 @@ |
| #include "ui/gfx/color_palette.h" |
| #include "ui/gfx/image/image_skia.h" |
| #include "ui/native_theme/native_theme.h" |
| +#include "ui/views/bubble/bubble_frame_view.h" |
| #include "ui/views/controls/button/blue_button.h" |
| #include "ui/views/controls/button/md_text_button.h" |
| #include "ui/views/controls/link.h" |
| #include "ui/views/controls/link_listener.h" |
| #include "ui/views/controls/separator.h" |
| #include "ui/views/controls/styled_label.h" |
| -#include "ui/views/controls/styled_label_listener.h" |
| #include "ui/views/layout/fill_layout.h" |
| #include "ui/views/layout/grid_layout.h" |
| #include "ui/views/widget/widget.h" |
| @@ -170,28 +170,6 @@ views::StyledLabel::RangeStyleInfo GetLinkStyle() { |
| return result; |
| } |
| -// If a special title is required (i.e. one that contains links), creates a |
| -// title view and a row for it in |layout|. |
| -// TODO(estade): this should be removed and a replaced by a normal title (via |
| -// GetWindowTitle). |
| -void AddTitleRowWithLink(views::GridLayout* layout, |
| - ManagePasswordsBubbleModel* model, |
| - views::StyledLabelListener* listener) { |
| - if (model->title_brand_link_range().is_empty()) |
| - return; |
| - |
| - views::StyledLabel* title_label = |
| - new views::StyledLabel(model->title(), listener); |
| - title_label->SetBaseFontList(views::style::GetFont( |
| - views::style::CONTEXT_DIALOG_TITLE, views::style::STYLE_PRIMARY)); |
| - title_label->AddStyleRange(model->title_brand_link_range(), GetLinkStyle()); |
| - layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| - layout->AddView(title_label); |
| - layout->AddPaddingRow(0, ChromeLayoutProvider::Get() |
| - ->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS) |
| - .top()); |
| -} |
| - |
| } // namespace |
| // ManagePasswordsBubbleView::AutoSigninView ---------------------------------- |
| @@ -290,10 +268,8 @@ void ManagePasswordsBubbleView::AutoSigninView::OnTimer() { |
| // A view offering the user the ability to save credentials. Contains a |
| // single ManagePasswordItemsView, along with a "Save Passwords" button |
| // and a "Never" button. |
| -class ManagePasswordsBubbleView::PendingView |
| - : public views::View, |
| - public views::ButtonListener, |
| - public views::StyledLabelListener { |
| +class ManagePasswordsBubbleView::PendingView : public views::View, |
| + public views::ButtonListener { |
| public: |
| explicit PendingView(ManagePasswordsBubbleView* parent); |
| ~PendingView() override; |
| @@ -302,11 +278,6 @@ class ManagePasswordsBubbleView::PendingView |
| // views::ButtonListener: |
| void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| - // views::StyledLabelListener: |
| - void StyledLabelLinkClicked(views::StyledLabel* label, |
| - const gfx::Range& range, |
| - int event_flags) override; |
| - |
| ManagePasswordsBubbleView* parent_; |
| views::Button* save_button_; |
| @@ -334,9 +305,7 @@ ManagePasswordsBubbleView::PendingView::PendingView( |
| this, |
| l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BUBBLE_BLACKLIST_BUTTON)); |
| - // Title row. |
| BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
| - AddTitleRowWithLink(layout, parent_->model(), this); |
| // Credential row. |
| if (item) { |
| @@ -378,14 +347,6 @@ void ManagePasswordsBubbleView::PendingView::ButtonPressed( |
| parent_->CloseBubble(); |
| } |
| -void ManagePasswordsBubbleView::PendingView::StyledLabelLinkClicked( |
| - views::StyledLabel* label, |
| - const gfx::Range& range, |
| - int event_flags) { |
| - DCHECK_EQ(range, parent_->model()->title_brand_link_range()); |
| - parent_->model()->OnBrandLinkClicked(); |
| -} |
| - |
| // ManagePasswordsBubbleView::ManageView -------------------------------------- |
| // A view offering the user a list of their currently saved credentials |
| @@ -626,8 +587,7 @@ void ManagePasswordsBubbleView::SignInPromoView::ButtonPressed( |
| // and a rejection button. |
| class ManagePasswordsBubbleView::UpdatePendingView |
| : public views::View, |
| - public views::ButtonListener, |
| - public views::StyledLabelListener { |
| + public views::ButtonListener { |
| public: |
| explicit UpdatePendingView(ManagePasswordsBubbleView* parent); |
| ~UpdatePendingView() override; |
| @@ -636,11 +596,6 @@ class ManagePasswordsBubbleView::UpdatePendingView |
| // views::ButtonListener: |
| void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| - // views::StyledLabelListener: |
| - void StyledLabelLinkClicked(views::StyledLabel* label, |
| - const gfx::Range& range, |
| - int event_flags) override; |
| - |
| ManagePasswordsBubbleView* parent_; |
| CredentialsSelectionView* selection_view_; |
| @@ -674,9 +629,7 @@ ManagePasswordsBubbleView::UpdatePendingView::UpdatePendingView( |
| update_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( |
| this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UPDATE_BUTTON)); |
| - // Title row. |
| BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
| - AddTitleRowWithLink(layout, parent_->model(), this); |
| // Credential row. |
| layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| @@ -716,14 +669,6 @@ void ManagePasswordsBubbleView::UpdatePendingView::ButtonPressed( |
| parent_->CloseBubble(); |
| } |
| -void ManagePasswordsBubbleView::UpdatePendingView::StyledLabelLinkClicked( |
| - views::StyledLabel* label, |
| - const gfx::Range& range, |
| - int event_flags) { |
| - DCHECK_EQ(range, parent_->model()->title_brand_link_range()); |
| - parent_->model()->OnBrandLinkClicked(); |
| -} |
| - |
| // ManagePasswordsBubbleView -------------------------------------------------- |
| // static |
| @@ -802,7 +747,8 @@ ManagePasswordsBubbleView::ManagePasswordsBubbleView( |
| model_(PasswordsModelDelegateFromWebContents(web_contents), |
| reason == AUTOMATIC ? ManagePasswordsBubbleModel::AUTOMATIC |
| : ManagePasswordsBubbleModel::USER_ACTION), |
| - initially_focused_view_(nullptr) { |
| + initially_focused_view_(nullptr), |
| + title_view_(nullptr) { |
| mouse_handler_.reset(new WebContentMouseHandler(this, this->web_contents())); |
| manage_passwords_bubble_ = this; |
| chrome::RecordDialogCreation(chrome::DialogIdentifier::MANAGE_PASSWORDS); |
| @@ -833,6 +779,20 @@ void ManagePasswordsBubbleView::CloseBubble() { |
| LocationBarBubbleDelegateView::CloseBubble(); |
| } |
| +void ManagePasswordsBubbleView::AddedToWidget() { |
| + title_view_ = new views::StyledLabel(base::string16(), this); |
| + title_view_->SetBaseFontList(views::style::GetFont( |
| + views::style::CONTEXT_DIALOG_TITLE, views::style::STYLE_PRIMARY)); |
| + UpdateTitleText(); |
| + GetBubbleFrameView()->SetTitleView(title_view_); |
| +} |
| + |
| +void ManagePasswordsBubbleView::UpdateTitleText() { |
| + title_view_->SetText(GetWindowTitle()); |
|
Peter Kasting
2017/06/23 06:00:09
Same comment applies as in ManagePasswordsBubbleVi
Bret
2017/06/24 01:12:33
Done.
|
| + if (!model_.title_brand_link_range().is_empty()) |
| + title_view_->AddStyleRange(model_.title_brand_link_range(), GetLinkStyle()); |
| +} |
| + |
| base::string16 ManagePasswordsBubbleView::GetWindowTitle() const { |
| return model_.title(); |
| } |
| @@ -848,13 +808,6 @@ gfx::ImageSkia ManagePasswordsBubbleView::GetWindowIcon() { |
| return gfx::ImageSkia(); |
| } |
| -bool ManagePasswordsBubbleView::ShouldShowWindowTitle() const { |
| - // Since bubble titles don't support links, fall back to a custom title view |
| - // if we need to show a link. Only use the normal title path if there's no |
| - // link. |
| - return model_.title_brand_link_range().is_empty(); |
| -} |
| - |
| bool ManagePasswordsBubbleView::ShouldShowWindowIcon() const { |
| return model_.state() == password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE; |
| } |
| @@ -865,6 +818,14 @@ bool ManagePasswordsBubbleView::ShouldShowCloseButton() const { |
| model_.state() == password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE; |
| } |
| +void ManagePasswordsBubbleView::StyledLabelLinkClicked( |
| + views::StyledLabel* label, |
| + const gfx::Range& range, |
| + int event_flags) { |
| + DCHECK_EQ(model_.title_brand_link_range(), range); |
| + model_.OnBrandLinkClicked(); |
| +} |
| + |
| void ManagePasswordsBubbleView::Refresh() { |
| RemoveAllChildViews(true); |
| initially_focused_view_ = NULL; |
| @@ -872,7 +833,7 @@ void ManagePasswordsBubbleView::Refresh() { |
| // Show/hide the close button. |
| GetWidget()->non_client_view()->ResetWindowControls(); |
| GetWidget()->UpdateWindowIcon(); |
| - GetWidget()->UpdateWindowTitle(); |
| + UpdateTitleText(); |
| if (model_.state() == password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE) { |
| // Update the height and keep the existing width. |
| gfx::Rect bubble_bounds = GetWidget()->GetWindowBoundsInScreen(); |