Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(747)

Unified Diff: chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc

Issue 2907983002: Allow dialogs to use a custom View as their title. (Closed)
Patch Set: pass strings by reference Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..11debd9c186003333e219ca0c50d10aa7106292e 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
@@ -833,6 +778,16 @@ void ManagePasswordsBubbleView::CloseBubble() {
LocationBarBubbleDelegateView::CloseBubble();
}
+views::View* ManagePasswordsBubbleView::CreateTitleView(
+ const base::string16& title_text) {
+ title_view_ = new views::StyledLabel(title_text, this);
+ title_view_->SetBaseFontList(views::style::GetFont(
+ views::style::CONTEXT_DIALOG_TITLE, views::style::STYLE_PRIMARY));
+ if (!model_.title_brand_link_range().is_empty())
+ title_view_->AddStyleRange(model_.title_brand_link_range(), GetLinkStyle());
+ return title_view_;
+}
+
base::string16 ManagePasswordsBubbleView::GetWindowTitle() const {
return model_.title();
}
@@ -848,13 +803,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 +813,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(range, model_.title_brand_link_range());
Peter Kasting 2017/06/17 01:16:20 Nit: (expected, actual)
Bret 2017/06/21 22:37:54 Done.
+ model_.OnBrandLinkClicked();
+}
+
void ManagePasswordsBubbleView::Refresh() {
RemoveAllChildViews(true);
initially_focused_view_ = NULL;
@@ -872,7 +828,7 @@ void ManagePasswordsBubbleView::Refresh() {
// Show/hide the close button.
GetWidget()->non_client_view()->ResetWindowControls();
GetWidget()->UpdateWindowIcon();
- GetWidget()->UpdateWindowTitle();
+ SetupTitleView();
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();

Powered by Google App Engine
This is Rietveld 408576698