Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/passwords/manage_passwords_bubble_view.h" | 5 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/metrics/user_metrics.h" | 8 #include "base/metrics/user_metrics.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
| 11 #include "chrome/browser/platform_util.h" | 11 #include "chrome/browser/platform_util.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_finder.h" | 14 #include "chrome/browser/ui/browser_finder.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 16 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
| 17 #include "chrome/browser/ui/passwords/password_dialog_prompts.h" | 17 #include "chrome/browser/ui/passwords/password_dialog_prompts.h" |
| 18 #include "chrome/browser/ui/passwords/passwords_model_delegate.h" | 18 #include "chrome/browser/ui/passwords/passwords_model_delegate.h" |
| 19 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" | 19 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
| 20 #include "chrome/browser/ui/views/harmony/chrome_typography.h" | |
| 20 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" | 21 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" |
| 21 #include "chrome/browser/ui/views/passwords/credentials_selection_view.h" | 22 #include "chrome/browser/ui/views/passwords/credentials_selection_view.h" |
| 22 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" | 23 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" |
| 23 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" | 24 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" |
| 24 #include "chrome/grit/generated_resources.h" | 25 #include "chrome/grit/generated_resources.h" |
| 25 #include "components/strings/grit/components_strings.h" | 26 #include "components/strings/grit/components_strings.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/base/material_design/material_design_controller.h" | 28 #include "ui/base/material_design/material_design_controller.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
| 29 #include "ui/base/ui_features.h" | 30 #include "ui/base/ui_features.h" |
| 30 #include "ui/gfx/color_palette.h" | 31 #include "ui/gfx/color_palette.h" |
| 31 #include "ui/gfx/image/image_skia.h" | 32 #include "ui/gfx/image/image_skia.h" |
| 32 #include "ui/native_theme/native_theme.h" | 33 #include "ui/native_theme/native_theme.h" |
| 33 #include "ui/views/controls/button/blue_button.h" | 34 #include "ui/views/controls/button/blue_button.h" |
| 34 #include "ui/views/controls/button/md_text_button.h" | 35 #include "ui/views/controls/button/md_text_button.h" |
| 35 #include "ui/views/controls/link.h" | 36 #include "ui/views/controls/link.h" |
| 36 #include "ui/views/controls/link_listener.h" | 37 #include "ui/views/controls/link_listener.h" |
| 37 #include "ui/views/controls/separator.h" | 38 #include "ui/views/controls/separator.h" |
| 38 #include "ui/views/controls/styled_label.h" | 39 #include "ui/views/controls/styled_label.h" |
| 39 #include "ui/views/controls/styled_label_listener.h" | 40 #include "ui/views/controls/styled_label_listener.h" |
| 40 #include "ui/views/layout/fill_layout.h" | 41 #include "ui/views/layout/fill_layout.h" |
| 41 #include "ui/views/layout/grid_layout.h" | 42 #include "ui/views/layout/grid_layout.h" |
| 42 #include "ui/views/layout/layout_constants.h" | |
| 43 #include "ui/views/widget/widget.h" | 43 #include "ui/views/widget/widget.h" |
| 44 | 44 |
| 45 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) | 45 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) |
| 46 #include "chrome/browser/ui/views/frame/browser_view.h" | 46 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
| 50 #include "chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bu bble_view.h" | 50 #include "chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bu bble_view.h" |
| 51 #endif | 51 #endif |
| 52 | 52 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 82 TRIPLE_BUTTON_COLUMN_SET, | 82 TRIPLE_BUTTON_COLUMN_SET, |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 enum TextRowType { ROW_SINGLE, ROW_MULTILINE }; | 85 enum TextRowType { ROW_SINGLE, ROW_MULTILINE }; |
| 86 | 86 |
| 87 // Construct an appropriate ColumnSet for the given |type|, and add it | 87 // Construct an appropriate ColumnSet for the given |type|, and add it |
| 88 // to |layout|. | 88 // to |layout|. |
| 89 void BuildColumnSet(views::GridLayout* layout, ColumnSetType type) { | 89 void BuildColumnSet(views::GridLayout* layout, ColumnSetType type) { |
| 90 views::ColumnSet* column_set = layout->AddColumnSet(type); | 90 views::ColumnSet* column_set = layout->AddColumnSet(type); |
| 91 int full_width = ManagePasswordsBubbleView::kDesiredBubbleWidth; | 91 int full_width = ManagePasswordsBubbleView::kDesiredBubbleWidth; |
| 92 const int button_divider = ChromeLayoutProvider::Get()->GetDistanceMetric( | |
| 93 views::DISTANCE_RELATED_BUTTON_HORIZONTAL); | |
| 92 switch (type) { | 94 switch (type) { |
| 93 case SINGLE_VIEW_COLUMN_SET: | 95 case SINGLE_VIEW_COLUMN_SET: |
| 94 column_set->AddColumn(views::GridLayout::FILL, | 96 column_set->AddColumn(views::GridLayout::FILL, |
| 95 views::GridLayout::FILL, | 97 views::GridLayout::FILL, |
| 96 0, | 98 0, |
| 97 views::GridLayout::FIXED, | 99 views::GridLayout::FIXED, |
| 98 full_width, | 100 full_width, |
| 99 0); | 101 0); |
| 100 break; | 102 break; |
| 101 case DOUBLE_BUTTON_COLUMN_SET: | 103 case DOUBLE_BUTTON_COLUMN_SET: |
| 102 column_set->AddColumn(views::GridLayout::TRAILING, | 104 column_set->AddColumn(views::GridLayout::TRAILING, |
| 103 views::GridLayout::CENTER, | 105 views::GridLayout::CENTER, |
| 104 1, | 106 1, |
| 105 views::GridLayout::USE_PREF, | 107 views::GridLayout::USE_PREF, |
| 106 0, | 108 0, |
| 107 0); | 109 0); |
| 108 column_set->AddPaddingColumn(0, views::kRelatedButtonHSpacing); | 110 column_set->AddPaddingColumn(0, button_divider); |
| 109 column_set->AddColumn(views::GridLayout::TRAILING, | 111 column_set->AddColumn(views::GridLayout::TRAILING, |
| 110 views::GridLayout::CENTER, | 112 views::GridLayout::CENTER, |
| 111 0, | 113 0, |
| 112 views::GridLayout::USE_PREF, | 114 views::GridLayout::USE_PREF, |
| 113 0, | 115 0, |
| 114 0); | 116 0); |
| 115 break; | 117 break; |
| 116 case LINK_BUTTON_COLUMN_SET: | 118 case LINK_BUTTON_COLUMN_SET: |
| 117 column_set->AddColumn(views::GridLayout::LEADING, | 119 column_set->AddColumn(views::GridLayout::LEADING, |
| 118 views::GridLayout::CENTER, | 120 views::GridLayout::CENTER, |
| 119 1, | 121 1, |
| 120 views::GridLayout::USE_PREF, | 122 views::GridLayout::USE_PREF, |
| 121 0, | 123 0, |
| 122 0); | 124 0); |
| 123 column_set->AddPaddingColumn(0, views::kRelatedButtonHSpacing); | 125 column_set->AddPaddingColumn(0, button_divider); |
| 124 column_set->AddColumn(views::GridLayout::TRAILING, | 126 column_set->AddColumn(views::GridLayout::TRAILING, |
| 125 views::GridLayout::CENTER, | 127 views::GridLayout::CENTER, |
| 126 0, | 128 0, |
| 127 views::GridLayout::USE_PREF, | 129 views::GridLayout::USE_PREF, |
| 128 0, | 130 0, |
| 129 0); | 131 0); |
| 130 break; | 132 break; |
| 131 case SINGLE_BUTTON_COLUMN_SET: | 133 case SINGLE_BUTTON_COLUMN_SET: |
| 132 column_set->AddColumn(views::GridLayout::TRAILING, | 134 column_set->AddColumn(views::GridLayout::TRAILING, |
| 133 views::GridLayout::CENTER, | 135 views::GridLayout::CENTER, |
| 134 1, | 136 1, |
| 135 views::GridLayout::USE_PREF, | 137 views::GridLayout::USE_PREF, |
| 136 0, | 138 0, |
| 137 0); | 139 0); |
| 138 break; | 140 break; |
| 139 case TRIPLE_BUTTON_COLUMN_SET: | 141 case TRIPLE_BUTTON_COLUMN_SET: |
| 140 column_set->AddColumn(views::GridLayout::LEADING, | 142 column_set->AddColumn(views::GridLayout::LEADING, |
| 141 views::GridLayout::CENTER, | 143 views::GridLayout::CENTER, |
| 142 1, | 144 1, |
| 143 views::GridLayout::USE_PREF, | 145 views::GridLayout::USE_PREF, |
| 144 0, | 146 0, |
| 145 0); | 147 0); |
| 146 column_set->AddPaddingColumn(0, views::kRelatedButtonHSpacing); | 148 column_set->AddPaddingColumn(0, button_divider); |
| 147 column_set->AddColumn(views::GridLayout::TRAILING, | 149 column_set->AddColumn(views::GridLayout::TRAILING, |
| 148 views::GridLayout::CENTER, | 150 views::GridLayout::CENTER, |
| 149 0, | 151 0, |
| 150 views::GridLayout::USE_PREF, | 152 views::GridLayout::USE_PREF, |
| 151 0, | 153 0, |
| 152 0); | 154 0); |
| 153 column_set->AddPaddingColumn(0, views::kRelatedButtonHSpacing); | 155 column_set->AddPaddingColumn(0, button_divider); |
| 154 column_set->AddColumn(views::GridLayout::TRAILING, | 156 column_set->AddColumn(views::GridLayout::TRAILING, |
| 155 views::GridLayout::CENTER, | 157 views::GridLayout::CENTER, |
| 156 0, | 158 0, |
| 157 views::GridLayout::USE_PREF, | 159 views::GridLayout::USE_PREF, |
| 158 0, | 160 0, |
| 159 0); | 161 0); |
| 160 break; | 162 break; |
| 161 } | 163 } |
| 162 } | 164 } |
| 163 | 165 |
| 164 views::StyledLabel::RangeStyleInfo GetLinkStyle() { | 166 views::StyledLabel::RangeStyleInfo GetLinkStyle() { |
| 165 auto result = views::StyledLabel::RangeStyleInfo::CreateForLink(); | 167 auto result = views::StyledLabel::RangeStyleInfo::CreateForLink(); |
| 166 result.disable_line_wrapping = false; | 168 result.disable_line_wrapping = false; |
| 167 return result; | 169 return result; |
| 168 } | 170 } |
| 169 | 171 |
| 170 // If a special title is required (i.e. one that contains links), creates a | 172 // If a special title is required (i.e. one that contains links), creates a |
| 171 // title view and a row for it in |layout|. | 173 // title view and a row for it in |layout|. |
| 172 // TODO(estade): this should be removed and a replaced by a normal title (via | 174 // TODO(estade): this should be removed and a replaced by a normal title (via |
| 173 // GetWindowTitle). | 175 // GetWindowTitle). |
| 174 void AddTitleRowWithLink(views::GridLayout* layout, | 176 void AddTitleRowWithLink(views::GridLayout* layout, |
| 175 ManagePasswordsBubbleModel* model, | 177 ManagePasswordsBubbleModel* model, |
| 176 views::StyledLabelListener* listener) { | 178 views::StyledLabelListener* listener) { |
| 177 if (model->title_brand_link_range().is_empty()) | 179 if (model->title_brand_link_range().is_empty()) |
| 178 return; | 180 return; |
| 179 | 181 |
| 180 views::StyledLabel* title_label = | 182 views::StyledLabel* title_label = |
| 181 new views::StyledLabel(model->title(), listener); | 183 new views::StyledLabel(model->title(), listener); |
| 182 title_label->SetBaseFontList( | 184 title_label->SetBaseFontList(views::style::GetFont( |
| 183 ui::ResourceBundle::GetSharedInstance().GetFontList( | 185 views::style::CONTEXT_DIALOG_TITLE, views::style::STYLE_PRIMARY)); |
| 184 ui::ResourceBundle::MediumFont)); | |
| 185 title_label->AddStyleRange(model->title_brand_link_range(), GetLinkStyle()); | 186 title_label->AddStyleRange(model->title_brand_link_range(), GetLinkStyle()); |
| 187 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
| |
| 186 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 188 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| 187 layout->AddView(title_label); | 189 layout->AddView(title_label); |
| 188 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); | 190 layout->AddPaddingRow(0, ChromeLayoutProvider::Get() |
| 191 ->GetInsetsMetric(views::INSETS_BUBBLE_CONTENTS) | |
| 192 .top()); | |
| 189 } | 193 } |
| 190 | 194 |
| 191 } // namespace | 195 } // namespace |
| 192 | 196 |
| 193 // ManagePasswordsBubbleView::AutoSigninView ---------------------------------- | 197 // ManagePasswordsBubbleView::AutoSigninView ---------------------------------- |
| 194 | 198 |
| 195 // A view containing just one credential that was used for for automatic signing | 199 // A view containing just one credential that was used for for automatic signing |
| 196 // in. | 200 // in. |
| 197 class ManagePasswordsBubbleView::AutoSigninView | 201 class ManagePasswordsBubbleView::AutoSigninView |
| 198 : public views::View, | 202 : public views::View, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BUBBLE_BLACKLIST_BUTTON)); | 335 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BUBBLE_BLACKLIST_BUTTON)); |
| 332 | 336 |
| 333 // Title row. | 337 // Title row. |
| 334 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 338 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
| 335 AddTitleRowWithLink(layout, parent_->model(), this); | 339 AddTitleRowWithLink(layout, parent_->model(), this); |
| 336 | 340 |
| 337 // Credential row. | 341 // Credential row. |
| 338 if (item) { | 342 if (item) { |
| 339 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 343 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| 340 layout->AddView(item); | 344 layout->AddView(item); |
| 341 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); | 345 layout->AddPaddingRow(0, |
| 346 ChromeLayoutProvider::Get() | |
| 347 ->GetInsetsMetric(views::INSETS_BUBBLE_CONTENTS) | |
| 348 .bottom()); | |
| 342 } | 349 } |
| 343 | 350 |
| 344 // Button row. | 351 // Button row. |
| 345 BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); | 352 BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); |
| 346 layout->StartRow(0, DOUBLE_BUTTON_COLUMN_SET); | 353 layout->StartRow(0, DOUBLE_BUTTON_COLUMN_SET); |
| 347 layout->AddView(save_button_); | 354 layout->AddView(save_button_); |
| 348 layout->AddView(never_button_); | 355 layout->AddView(never_button_); |
| 349 | 356 |
| 350 parent_->set_initially_focused_view(save_button_); | 357 parent_->set_initially_focused_view(save_button_); |
| 351 } | 358 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 | 409 |
| 403 views::Link* manage_link_; | 410 views::Link* manage_link_; |
| 404 views::Button* done_button_; | 411 views::Button* done_button_; |
| 405 | 412 |
| 406 DISALLOW_COPY_AND_ASSIGN(ManageView); | 413 DISALLOW_COPY_AND_ASSIGN(ManageView); |
| 407 }; | 414 }; |
| 408 | 415 |
| 409 ManagePasswordsBubbleView::ManageView::ManageView( | 416 ManagePasswordsBubbleView::ManageView::ManageView( |
| 410 ManagePasswordsBubbleView* parent) | 417 ManagePasswordsBubbleView* parent) |
| 411 : parent_(parent) { | 418 : parent_(parent) { |
| 419 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.
| |
| 412 views::GridLayout* layout = new views::GridLayout(this); | 420 views::GridLayout* layout = new views::GridLayout(this); |
| 413 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 421 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
| 414 SetLayoutManager(layout); | 422 SetLayoutManager(layout); |
| 423 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | |
| 424 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | |
| 415 | 425 |
| 416 // If we have a list of passwords to store for the current site, display | 426 // If we have a list of passwords to store for the current site, display |
| 417 // them to the user for management. Otherwise, render a "No passwords for | 427 // them to the user for management. Otherwise, render a "No passwords for |
| 418 // this site" message. | 428 // this site" message. |
| 419 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | |
| 420 if (!parent_->model()->local_credentials().empty()) { | 429 if (!parent_->model()->local_credentials().empty()) { |
| 421 ManagePasswordItemsView* item = new ManagePasswordItemsView( | 430 ManagePasswordItemsView* item = new ManagePasswordItemsView( |
| 422 parent_->model(), &parent_->model()->local_credentials()); | 431 parent_->model(), &parent_->model()->local_credentials()); |
| 423 layout->StartRowWithPadding(0, SINGLE_VIEW_COLUMN_SET, 0, | |
| 424 views::kUnrelatedControlVerticalSpacing); | |
| 425 layout->AddView(item); | 432 layout->AddView(item); |
| 426 } else { | 433 } else { |
| 427 views::Label* empty_label = new views::Label( | 434 views::Label* empty_label = new views::Label( |
| 428 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_NO_PASSWORDS)); | 435 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_NO_PASSWORDS), |
| 436 CONTEXT_DEPRECATED_SMALL); | |
| 429 empty_label->SetMultiLine(true); | 437 empty_label->SetMultiLine(true); |
| 430 empty_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 438 empty_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 431 empty_label->SetFontList( | |
| 432 ui::ResourceBundle::GetSharedInstance().GetFontList( | |
| 433 ui::ResourceBundle::SmallFont)); | |
| 434 | |
| 435 layout->StartRowWithPadding(0, SINGLE_VIEW_COLUMN_SET, 0, | |
| 436 views::kUnrelatedControlVerticalSpacing); | |
| 437 layout->AddView(empty_label); | 439 layout->AddView(empty_label); |
| 438 } | 440 } |
| 439 | 441 |
| 440 // Then add the "manage passwords" link and "Done" button. | 442 // Then add the "manage passwords" link and "Done" button. |
| 441 manage_link_ = new views::Link(parent_->model()->manage_link()); | 443 manage_link_ = new views::Link(parent_->model()->manage_link()); |
| 442 manage_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 444 manage_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 443 manage_link_->SetUnderline(false); | 445 manage_link_->SetUnderline(false); |
| 444 manage_link_->set_listener(this); | 446 manage_link_->set_listener(this); |
| 445 | 447 |
| 446 done_button_ = views::MdTextButton::CreateSecondaryUiButton( | 448 done_button_ = views::MdTextButton::CreateSecondaryUiButton( |
| 447 this, l10n_util::GetStringUTF16(IDS_DONE)); | 449 this, l10n_util::GetStringUTF16(IDS_DONE)); |
| 448 | 450 |
| 451 layout->AddPaddingRow( | |
| 452 0, | |
| 453 layout_provider->GetInsetsMetric(views::INSETS_BUBBLE_CONTENTS).bottom()); | |
| 449 BuildColumnSet(layout, LINK_BUTTON_COLUMN_SET); | 454 BuildColumnSet(layout, LINK_BUTTON_COLUMN_SET); |
| 450 layout->StartRowWithPadding(0, LINK_BUTTON_COLUMN_SET, 0, | 455 layout->StartRowWithPadding( |
| 451 views::kUnrelatedControlVerticalSpacing); | 456 0, LINK_BUTTON_COLUMN_SET, 0, |
| 457 layout_provider->GetInsetsMetric(views::INSETS_DIALOG_BUTTON).top()); | |
| 452 layout->AddView(manage_link_); | 458 layout->AddView(manage_link_); |
| 453 layout->AddView(done_button_); | 459 layout->AddView(done_button_); |
| 454 | 460 |
| 455 parent_->set_initially_focused_view(done_button_); | 461 parent_->set_initially_focused_view(done_button_); |
| 456 } | 462 } |
| 457 | 463 |
| 458 ManagePasswordsBubbleView::ManageView::~ManageView() { | 464 ManagePasswordsBubbleView::ManageView::~ManageView() { |
| 459 } | 465 } |
| 460 | 466 |
| 461 void ManagePasswordsBubbleView::ManageView::ButtonPressed( | 467 void ManagePasswordsBubbleView::ManageView::ButtonPressed( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 | 502 |
| 497 ManagePasswordsBubbleView* parent_; | 503 ManagePasswordsBubbleView* parent_; |
| 498 views::Button* ok_button_; | 504 views::Button* ok_button_; |
| 499 | 505 |
| 500 DISALLOW_COPY_AND_ASSIGN(SaveConfirmationView); | 506 DISALLOW_COPY_AND_ASSIGN(SaveConfirmationView); |
| 501 }; | 507 }; |
| 502 | 508 |
| 503 ManagePasswordsBubbleView::SaveConfirmationView::SaveConfirmationView( | 509 ManagePasswordsBubbleView::SaveConfirmationView::SaveConfirmationView( |
| 504 ManagePasswordsBubbleView* parent) | 510 ManagePasswordsBubbleView* parent) |
| 505 : parent_(parent) { | 511 : parent_(parent) { |
| 512 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.
| |
| 506 views::GridLayout* layout = new views::GridLayout(this); | 513 views::GridLayout* layout = new views::GridLayout(this); |
| 507 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 514 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
| 508 SetLayoutManager(layout); | 515 SetLayoutManager(layout); |
| 509 | 516 |
| 510 views::StyledLabel* confirmation = | 517 views::StyledLabel* confirmation = |
| 511 new views::StyledLabel(parent_->model()->save_confirmation_text(), this); | 518 new views::StyledLabel(parent_->model()->save_confirmation_text(), this); |
| 512 confirmation->SetBaseFontList( | 519 confirmation->SetBaseFontList(views::style::GetFont( |
| 513 ui::ResourceBundle::GetSharedInstance().GetFontList( | 520 CONTEXT_DEPRECATED_SMALL, views::style::STYLE_PRIMARY)); |
| 514 ui::ResourceBundle::SmallFont)); | 521 confirmation->AddStyleRange(parent_->model()->save_confirmation_link_range(), |
| 515 confirmation->AddStyleRange( | 522 GetLinkStyle()); |
| 516 parent_->model()->save_confirmation_link_range(), GetLinkStyle()); | |
| 517 | 523 |
| 518 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 524 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
| 519 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 525 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| 520 layout->AddView(confirmation); | 526 layout->AddView(confirmation); |
| 521 | 527 |
| 522 ok_button_ = views::MdTextButton::CreateSecondaryUiButton( | 528 ok_button_ = views::MdTextButton::CreateSecondaryUiButton( |
| 523 this, l10n_util::GetStringUTF16(IDS_OK)); | 529 this, l10n_util::GetStringUTF16(IDS_OK)); |
| 524 | 530 |
| 531 layout->AddPaddingRow( | |
| 532 0, | |
| 533 layout_provider->GetInsetsMetric(views::INSETS_BUBBLE_CONTENTS).bottom()); | |
| 525 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); | 534 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); |
| 526 layout->StartRowWithPadding( | 535 gfx::Insets button_insets = |
| 527 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); | 536 layout_provider->GetInsetsMetric(views::INSETS_DIALOG_BUTTON); |
| 537 layout->StartRowWithPadding(0, SINGLE_BUTTON_COLUMN_SET, 0, | |
| 538 button_insets.top()); | |
| 528 layout->AddView(ok_button_); | 539 layout->AddView(ok_button_); |
| 529 | 540 |
| 530 parent_->set_initially_focused_view(ok_button_); | 541 parent_->set_initially_focused_view(ok_button_); |
| 531 } | 542 } |
| 532 | 543 |
| 533 ManagePasswordsBubbleView::SaveConfirmationView::~SaveConfirmationView() { | 544 ManagePasswordsBubbleView::SaveConfirmationView::~SaveConfirmationView() { |
| 534 } | 545 } |
| 535 | 546 |
| 536 void ManagePasswordsBubbleView::SaveConfirmationView::StyledLabelLinkClicked( | 547 void ManagePasswordsBubbleView::SaveConfirmationView::StyledLabelLinkClicked( |
| 537 views::StyledLabel* label, | 548 views::StyledLabel* label, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 637 | 648 |
| 638 views::Button* update_button_; | 649 views::Button* update_button_; |
| 639 views::Button* nope_button_; | 650 views::Button* nope_button_; |
| 640 | 651 |
| 641 DISALLOW_COPY_AND_ASSIGN(UpdatePendingView); | 652 DISALLOW_COPY_AND_ASSIGN(UpdatePendingView); |
| 642 }; | 653 }; |
| 643 | 654 |
| 644 ManagePasswordsBubbleView::UpdatePendingView::UpdatePendingView( | 655 ManagePasswordsBubbleView::UpdatePendingView::UpdatePendingView( |
| 645 ManagePasswordsBubbleView* parent) | 656 ManagePasswordsBubbleView* parent) |
| 646 : parent_(parent), selection_view_(nullptr) { | 657 : parent_(parent), selection_view_(nullptr) { |
| 658 ChromeLayoutProvider* layout_provider = ChromeLayoutProvider::Get(); | |
| 647 views::GridLayout* layout = new views::GridLayout(this); | 659 views::GridLayout* layout = new views::GridLayout(this); |
| 648 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 660 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
| 649 SetLayoutManager(layout); | 661 SetLayoutManager(layout); |
| 650 | 662 |
| 651 // Create the pending credential item, update button. | 663 // Create the pending credential item, update button. |
| 652 View* item = nullptr; | 664 View* item = nullptr; |
| 653 if (parent->model()->ShouldShowMultipleAccountUpdateUI()) { | 665 if (parent->model()->ShouldShowMultipleAccountUpdateUI()) { |
| 654 selection_view_ = new CredentialsSelectionView(parent->model()); | 666 selection_view_ = new CredentialsSelectionView(parent->model()); |
| 655 item = selection_view_; | 667 item = selection_view_; |
| 656 } else { | 668 } else { |
| 657 item = new ManagePasswordItemsView(parent_->model(), | 669 item = new ManagePasswordItemsView(parent_->model(), |
| 658 &parent->model()->pending_password()); | 670 &parent->model()->pending_password()); |
| 659 } | 671 } |
| 660 nope_button_ = views::MdTextButton::CreateSecondaryUiButton( | 672 nope_button_ = views::MdTextButton::CreateSecondaryUiButton( |
| 661 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON)); | 673 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON)); |
| 662 | 674 |
| 663 update_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( | 675 update_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( |
| 664 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UPDATE_BUTTON)); | 676 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UPDATE_BUTTON)); |
| 665 | 677 |
| 666 // Title row. | 678 // Title row. |
| 667 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 679 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
| 668 AddTitleRowWithLink(layout, parent_->model(), this); | 680 AddTitleRowWithLink(layout, parent_->model(), this); |
| 669 | 681 |
| 670 // Credential row. | 682 // Credential row. |
| 671 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 683 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| 672 layout->AddView(item); | 684 layout->AddView(item); |
| 685 layout->AddPaddingRow( | |
| 686 0, | |
| 687 layout_provider->GetInsetsMetric(views::INSETS_BUBBLE_CONTENTS).bottom()); | |
| 673 | 688 |
| 674 // Button row. | 689 // Button row. |
| 675 BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); | 690 BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); |
| 676 layout->StartRowWithPadding(0, DOUBLE_BUTTON_COLUMN_SET, 0, | 691 layout->StartRowWithPadding( |
| 677 views::kUnrelatedControlVerticalSpacing); | 692 0, DOUBLE_BUTTON_COLUMN_SET, 0, |
| 693 layout_provider->GetInsetsMetric(views::INSETS_DIALOG_BUTTON).top()); | |
| 678 layout->AddView(update_button_); | 694 layout->AddView(update_button_); |
| 679 layout->AddView(nope_button_); | 695 layout->AddView(nope_button_); |
| 680 | 696 |
| 681 parent_->set_initially_focused_view(update_button_); | 697 parent_->set_initially_focused_view(update_button_); |
| 682 } | 698 } |
| 683 | 699 |
| 684 ManagePasswordsBubbleView::UpdatePendingView::~UpdatePendingView() {} | 700 ManagePasswordsBubbleView::UpdatePendingView::~UpdatePendingView() {} |
| 685 | 701 |
| 686 void ManagePasswordsBubbleView::UpdatePendingView::ButtonPressed( | 702 void ManagePasswordsBubbleView::UpdatePendingView::ButtonPressed( |
| 687 views::Button* sender, | 703 views::Button* sender, |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 880 } else if (model_.state() == | 896 } else if (model_.state() == |
| 881 password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE) { | 897 password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE) { |
| 882 AddChildView(new DesktopIOSPromotionBubbleView( | 898 AddChildView(new DesktopIOSPromotionBubbleView( |
| 883 model_.GetProfile(), | 899 model_.GetProfile(), |
| 884 desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE)); | 900 desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE)); |
| 885 #endif | 901 #endif |
| 886 } else { | 902 } else { |
| 887 AddChildView(new ManageView(this)); | 903 AddChildView(new ManageView(this)); |
| 888 } | 904 } |
| 889 } | 905 } |
| OLD | NEW |