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 35a937686d01b8869a1014aec4cc6d9aa22340c9..fca5c538dd4af8eafb01f628f787415b562a86bf 100644 |
| --- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
| +++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
| @@ -17,6 +17,7 @@ |
| #include "chrome/browser/ui/passwords/password_dialog_prompts.h" |
| #include "chrome/browser/ui/passwords/passwords_model_delegate.h" |
| #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
| +#include "chrome/browser/ui/views/harmony/chrome_typography.h" |
| #include "chrome/browser/ui/views/passwords/credentials_item_view.h" |
| #include "chrome/browser/ui/views/passwords/credentials_selection_view.h" |
| #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" |
| @@ -39,7 +40,6 @@ |
| #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/layout/layout_constants.h" |
| #include "ui/views/widget/widget.h" |
| #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) |
| @@ -89,6 +89,8 @@ enum TextRowType { ROW_SINGLE, ROW_MULTILINE }; |
| void BuildColumnSet(views::GridLayout* layout, ColumnSetType type) { |
| views::ColumnSet* column_set = layout->AddColumnSet(type); |
| int full_width = ManagePasswordsBubbleView::kDesiredBubbleWidth; |
| + const int button_divider = ChromeLayoutProvider::Get()->GetDistanceMetric( |
| + views::DISTANCE_RELATED_BUTTON_HORIZONTAL); |
| switch (type) { |
| case SINGLE_VIEW_COLUMN_SET: |
| column_set->AddColumn(views::GridLayout::FILL, |
| @@ -105,7 +107,7 @@ void BuildColumnSet(views::GridLayout* layout, ColumnSetType type) { |
| views::GridLayout::USE_PREF, |
| 0, |
| 0); |
| - column_set->AddPaddingColumn(0, views::kRelatedButtonHSpacing); |
| + column_set->AddPaddingColumn(0, button_divider); |
| column_set->AddColumn(views::GridLayout::TRAILING, |
| views::GridLayout::CENTER, |
| 0, |
| @@ -120,7 +122,7 @@ void BuildColumnSet(views::GridLayout* layout, ColumnSetType type) { |
| views::GridLayout::USE_PREF, |
| 0, |
| 0); |
| - column_set->AddPaddingColumn(0, views::kRelatedButtonHSpacing); |
| + column_set->AddPaddingColumn(0, button_divider); |
| column_set->AddColumn(views::GridLayout::TRAILING, |
| views::GridLayout::CENTER, |
| 0, |
| @@ -143,14 +145,14 @@ void BuildColumnSet(views::GridLayout* layout, ColumnSetType type) { |
| views::GridLayout::USE_PREF, |
| 0, |
| 0); |
| - column_set->AddPaddingColumn(0, views::kRelatedButtonHSpacing); |
| + column_set->AddPaddingColumn(0, button_divider); |
| column_set->AddColumn(views::GridLayout::TRAILING, |
| views::GridLayout::CENTER, |
| 0, |
| views::GridLayout::USE_PREF, |
| 0, |
| 0); |
| - column_set->AddPaddingColumn(0, views::kRelatedButtonHSpacing); |
| + column_set->AddPaddingColumn(0, button_divider); |
| column_set->AddColumn(views::GridLayout::TRAILING, |
| views::GridLayout::CENTER, |
| 0, |
| @@ -179,13 +181,15 @@ void AddTitleRowWithLink(views::GridLayout* layout, |
| views::StyledLabel* title_label = |
| new views::StyledLabel(model->title(), listener); |
| - title_label->SetBaseFontList( |
| - ui::ResourceBundle::GetSharedInstance().GetFontList( |
| - ui::ResourceBundle::MediumFont)); |
| + title_label->SetBaseFontList(views::style::GetFont( |
| + views::style::CONTEXT_DIALOG_TITLE, views::style::STYLE_PRIMARY)); |
| title_label->AddStyleRange(model->title_brand_link_range(), GetLinkStyle()); |
| + title_label->AddStyleRange(gfx::Range(0, 3), GetLinkStyle()); |
|
tapted
2017/05/12 03:36:10
stray line?
Patti Lor
2017/05/15 01:53:48
Whoops, yep. Deleted :O
|
| layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| layout->AddView(title_label); |
| - layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); |
| + layout->AddPaddingRow(0, ChromeLayoutProvider::Get() |
| + ->GetInsetsMetric(views::INSETS_BUBBLE_CONTENTS) |
| + .top()); |
| } |
| } // namespace |
| @@ -338,7 +342,10 @@ ManagePasswordsBubbleView::PendingView::PendingView( |
| if (item) { |
| layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| layout->AddView(item); |
| - layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); |
| + layout->AddPaddingRow(0, |
| + ChromeLayoutProvider::Get() |
| + ->GetInsetsMetric(views::INSETS_BUBBLE_CONTENTS) |
| + .bottom()); |
| } |
| // Button row. |
| @@ -409,31 +416,26 @@ class ManagePasswordsBubbleView::ManageView : public views::View, |
| ManagePasswordsBubbleView::ManageView::ManageView( |
| ManagePasswordsBubbleView* parent) |
| : parent_(parent) { |
| + ChromeLayoutProvider* layout_provider = ChromeLayoutProvider::Get(); |
|
tapted
2017/05/12 03:36:10
nit: move closer to first use
Patti Lor
2017/05/15 01:53:48
Done.
|
| views::GridLayout* layout = new views::GridLayout(this); |
| layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
| SetLayoutManager(layout); |
| + BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
| + layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| // If we have a list of passwords to store for the current site, display |
| // them to the user for management. Otherwise, render a "No passwords for |
| // this site" message. |
| - BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
| if (!parent_->model()->local_credentials().empty()) { |
| ManagePasswordItemsView* item = new ManagePasswordItemsView( |
| parent_->model(), &parent_->model()->local_credentials()); |
| - layout->StartRowWithPadding(0, SINGLE_VIEW_COLUMN_SET, 0, |
| - views::kUnrelatedControlVerticalSpacing); |
| layout->AddView(item); |
| } else { |
| views::Label* empty_label = new views::Label( |
| - l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_NO_PASSWORDS)); |
| + l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_NO_PASSWORDS), |
| + CONTEXT_DEPRECATED_SMALL); |
| empty_label->SetMultiLine(true); |
| empty_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| - empty_label->SetFontList( |
| - ui::ResourceBundle::GetSharedInstance().GetFontList( |
| - ui::ResourceBundle::SmallFont)); |
| - |
| - layout->StartRowWithPadding(0, SINGLE_VIEW_COLUMN_SET, 0, |
| - views::kUnrelatedControlVerticalSpacing); |
| layout->AddView(empty_label); |
| } |
| @@ -446,9 +448,13 @@ ManagePasswordsBubbleView::ManageView::ManageView( |
| done_button_ = views::MdTextButton::CreateSecondaryUiButton( |
| this, l10n_util::GetStringUTF16(IDS_DONE)); |
| + layout->AddPaddingRow( |
| + 0, |
| + layout_provider->GetInsetsMetric(views::INSETS_BUBBLE_CONTENTS).bottom()); |
| BuildColumnSet(layout, LINK_BUTTON_COLUMN_SET); |
| - layout->StartRowWithPadding(0, LINK_BUTTON_COLUMN_SET, 0, |
| - views::kUnrelatedControlVerticalSpacing); |
| + layout->StartRowWithPadding( |
| + 0, LINK_BUTTON_COLUMN_SET, 0, |
| + layout_provider->GetInsetsMetric(views::INSETS_DIALOG_BUTTON).top()); |
| layout->AddView(manage_link_); |
| layout->AddView(done_button_); |
| @@ -503,17 +509,17 @@ class ManagePasswordsBubbleView::SaveConfirmationView |
| ManagePasswordsBubbleView::SaveConfirmationView::SaveConfirmationView( |
| ManagePasswordsBubbleView* parent) |
| : parent_(parent) { |
| + ChromeLayoutProvider* layout_provider = ChromeLayoutProvider::Get(); |
|
tapted
2017/05/12 03:36:10
nit: move closer to first use
Patti Lor
2017/05/15 01:53:48
Done.
|
| views::GridLayout* layout = new views::GridLayout(this); |
| layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
| SetLayoutManager(layout); |
| views::StyledLabel* confirmation = |
| new views::StyledLabel(parent_->model()->save_confirmation_text(), this); |
| - confirmation->SetBaseFontList( |
| - ui::ResourceBundle::GetSharedInstance().GetFontList( |
| - ui::ResourceBundle::SmallFont)); |
| - confirmation->AddStyleRange( |
| - parent_->model()->save_confirmation_link_range(), GetLinkStyle()); |
| + confirmation->SetBaseFontList(views::style::GetFont( |
| + CONTEXT_DEPRECATED_SMALL, views::style::STYLE_PRIMARY)); |
| + confirmation->AddStyleRange(parent_->model()->save_confirmation_link_range(), |
| + GetLinkStyle()); |
| BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
| layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| @@ -522,9 +528,14 @@ ManagePasswordsBubbleView::SaveConfirmationView::SaveConfirmationView( |
| ok_button_ = views::MdTextButton::CreateSecondaryUiButton( |
| this, l10n_util::GetStringUTF16(IDS_OK)); |
| + layout->AddPaddingRow( |
| + 0, |
| + layout_provider->GetInsetsMetric(views::INSETS_BUBBLE_CONTENTS).bottom()); |
| BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); |
| - layout->StartRowWithPadding( |
| - 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
| + gfx::Insets button_insets = |
| + layout_provider->GetInsetsMetric(views::INSETS_DIALOG_BUTTON); |
| + layout->StartRowWithPadding(0, SINGLE_BUTTON_COLUMN_SET, 0, |
| + button_insets.top()); |
| layout->AddView(ok_button_); |
| parent_->set_initially_focused_view(ok_button_); |
| @@ -644,6 +655,7 @@ class ManagePasswordsBubbleView::UpdatePendingView |
| ManagePasswordsBubbleView::UpdatePendingView::UpdatePendingView( |
| ManagePasswordsBubbleView* parent) |
| : parent_(parent), selection_view_(nullptr) { |
| + ChromeLayoutProvider* layout_provider = ChromeLayoutProvider::Get(); |
| views::GridLayout* layout = new views::GridLayout(this); |
| layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
| SetLayoutManager(layout); |
| @@ -670,11 +682,15 @@ ManagePasswordsBubbleView::UpdatePendingView::UpdatePendingView( |
| // Credential row. |
| layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| layout->AddView(item); |
| + layout->AddPaddingRow( |
| + 0, |
| + layout_provider->GetInsetsMetric(views::INSETS_BUBBLE_CONTENTS).bottom()); |
| // Button row. |
| BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); |
| - layout->StartRowWithPadding(0, DOUBLE_BUTTON_COLUMN_SET, 0, |
| - views::kUnrelatedControlVerticalSpacing); |
| + layout->StartRowWithPadding( |
| + 0, DOUBLE_BUTTON_COLUMN_SET, 0, |
| + layout_provider->GetInsetsMetric(views::INSETS_DIALOG_BUTTON).top()); |
| layout->AddView(update_button_); |
| layout->AddView(nope_button_); |