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/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
13 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 13 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
14 #include "chrome/browser/ui/views/frame/browser_view.h" | 14 #include "chrome/browser/ui/views/frame/browser_view.h" |
15 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" | 15 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" |
16 #include "chrome/browser/ui/views/passwords/credentials_selection_view.h" | 16 #include "chrome/browser/ui/views/passwords/credentials_selection_view.h" |
17 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" | 17 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" |
18 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" | 18 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" |
19 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
20 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
21 #include "grit/components_strings.h" | 21 #include "grit/components_strings.h" |
22 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/base/material_design/material_design_controller.h" |
23 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
24 #include "ui/views/controls/button/blue_button.h" | 25 #include "ui/views/controls/button/blue_button.h" |
25 #include "ui/views/controls/button/label_button.h" | 26 #include "ui/views/controls/button/md_text_button.h" |
26 #include "ui/views/controls/link.h" | 27 #include "ui/views/controls/link.h" |
27 #include "ui/views/controls/link_listener.h" | 28 #include "ui/views/controls/link_listener.h" |
28 #include "ui/views/controls/separator.h" | 29 #include "ui/views/controls/separator.h" |
29 #include "ui/views/controls/styled_label.h" | 30 #include "ui/views/controls/styled_label.h" |
30 #include "ui/views/controls/styled_label_listener.h" | 31 #include "ui/views/controls/styled_label_listener.h" |
31 #include "ui/views/event_monitor.h" | 32 #include "ui/views/event_monitor.h" |
32 #include "ui/views/layout/fill_layout.h" | 33 #include "ui/views/layout/fill_layout.h" |
33 #include "ui/views/layout/grid_layout.h" | 34 #include "ui/views/layout/grid_layout.h" |
34 #include "ui/views/layout/layout_constants.h" | 35 #include "ui/views/layout/layout_constants.h" |
35 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 new views::StyledLabel(model->title(), listener); | 169 new views::StyledLabel(model->title(), listener); |
169 title_label->SetBaseFontList( | 170 title_label->SetBaseFontList( |
170 ui::ResourceBundle::GetSharedInstance().GetFontList( | 171 ui::ResourceBundle::GetSharedInstance().GetFontList( |
171 ui::ResourceBundle::MediumFont)); | 172 ui::ResourceBundle::MediumFont)); |
172 title_label->AddStyleRange(model->title_brand_link_range(), GetLinkStyle()); | 173 title_label->AddStyleRange(model->title_brand_link_range(), GetLinkStyle()); |
173 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 174 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
174 layout->AddView(title_label); | 175 layout->AddView(title_label); |
175 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); | 176 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); |
176 } | 177 } |
177 | 178 |
178 std::unique_ptr<views::LabelButton> GenerateButton( | |
179 views::ButtonListener* listener, | |
180 const base::string16& text) { | |
181 std::unique_ptr<views::LabelButton> button( | |
182 new views::LabelButton(listener, text)); | |
183 button->SetStyle(views::Button::STYLE_BUTTON); | |
184 return button; | |
185 } | |
186 | |
187 } // namespace | 179 } // namespace |
188 | 180 |
189 // ManagePasswordsBubbleView::AutoSigninView ---------------------------------- | 181 // ManagePasswordsBubbleView::AutoSigninView ---------------------------------- |
190 | 182 |
191 // A view containing just one credential that was used for for automatic signing | 183 // A view containing just one credential that was used for for automatic signing |
192 // in. | 184 // in. |
193 class ManagePasswordsBubbleView::AutoSigninView | 185 class ManagePasswordsBubbleView::AutoSigninView |
194 : public views::View, | 186 : public views::View, |
195 public views::ButtonListener, | 187 public views::ButtonListener, |
196 public views::WidgetObserver { | 188 public views::WidgetObserver { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 298 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
307 SetLayoutManager(layout); | 299 SetLayoutManager(layout); |
308 | 300 |
309 // Create the pending credential item, save button and refusal combobox. | 301 // Create the pending credential item, save button and refusal combobox. |
310 ManagePasswordItemsView* item = nullptr; | 302 ManagePasswordItemsView* item = nullptr; |
311 if (!parent->model()->pending_password().username_value.empty()) { | 303 if (!parent->model()->pending_password().username_value.empty()) { |
312 std::vector<const autofill::PasswordForm*> credentials( | 304 std::vector<const autofill::PasswordForm*> credentials( |
313 1, &parent->model()->pending_password()); | 305 1, &parent->model()->pending_password()); |
314 item = new ManagePasswordItemsView(parent_->model(), credentials); | 306 item = new ManagePasswordItemsView(parent_->model(), credentials); |
315 } | 307 } |
316 save_button_ = new views::BlueButton( | 308 save_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( |
317 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); | 309 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); |
318 never_button_ = GenerateButton( | 310 never_button_ = views::MdTextButton::CreateSecondaryUiButton( |
319 this, | 311 this, |
320 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BUBBLE_BLACKLIST_BUTTON)) | 312 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BUBBLE_BLACKLIST_BUTTON)); |
321 .release(); | |
322 | 313 |
323 // Title row. | 314 // Title row. |
324 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 315 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
325 AddTitleRowWithLink(layout, parent_->model(), this); | 316 AddTitleRowWithLink(layout, parent_->model(), this); |
326 | 317 |
327 // Credential row. | 318 // Credential row. |
328 if (item) { | 319 if (item) { |
329 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 320 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
330 layout->AddView(item); | 321 layout->AddView(item); |
331 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); | 322 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 views::kUnrelatedControlVerticalSpacing); | 435 views::kUnrelatedControlVerticalSpacing); |
445 layout->AddView(empty_label); | 436 layout->AddView(empty_label); |
446 } | 437 } |
447 | 438 |
448 // Then add the "manage passwords" link and "Done" button. | 439 // Then add the "manage passwords" link and "Done" button. |
449 manage_link_ = new views::Link(parent_->model()->manage_link()); | 440 manage_link_ = new views::Link(parent_->model()->manage_link()); |
450 manage_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 441 manage_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
451 manage_link_->SetUnderline(false); | 442 manage_link_->SetUnderline(false); |
452 manage_link_->set_listener(this); | 443 manage_link_->set_listener(this); |
453 | 444 |
454 done_button_ = | 445 done_button_ = views::MdTextButton::CreateSecondaryUiButton( |
455 GenerateButton(this, l10n_util::GetStringUTF16(IDS_DONE)).release(); | 446 this, l10n_util::GetStringUTF16(IDS_DONE)); |
456 | 447 |
457 BuildColumnSet(layout, LINK_BUTTON_COLUMN_SET); | 448 BuildColumnSet(layout, LINK_BUTTON_COLUMN_SET); |
458 layout->StartRowWithPadding(0, LINK_BUTTON_COLUMN_SET, 0, | 449 layout->StartRowWithPadding(0, LINK_BUTTON_COLUMN_SET, 0, |
459 views::kUnrelatedControlVerticalSpacing); | 450 views::kUnrelatedControlVerticalSpacing); |
460 layout->AddView(manage_link_); | 451 layout->AddView(manage_link_); |
461 layout->AddView(done_button_); | 452 layout->AddView(done_button_); |
462 | 453 |
463 parent_->set_initially_focused_view(done_button_); | 454 parent_->set_initially_focused_view(done_button_); |
464 } | 455 } |
465 | 456 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 confirmation->SetBaseFontList( | 511 confirmation->SetBaseFontList( |
521 ui::ResourceBundle::GetSharedInstance().GetFontList( | 512 ui::ResourceBundle::GetSharedInstance().GetFontList( |
522 ui::ResourceBundle::SmallFont)); | 513 ui::ResourceBundle::SmallFont)); |
523 confirmation->AddStyleRange( | 514 confirmation->AddStyleRange( |
524 parent_->model()->save_confirmation_link_range(), GetLinkStyle()); | 515 parent_->model()->save_confirmation_link_range(), GetLinkStyle()); |
525 | 516 |
526 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 517 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
527 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 518 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
528 layout->AddView(confirmation); | 519 layout->AddView(confirmation); |
529 | 520 |
530 ok_button_ = | 521 ok_button_ = views::MdTextButton::CreateSecondaryUiButton( |
531 GenerateButton(this, l10n_util::GetStringUTF16(IDS_OK)).release(); | 522 this, l10n_util::GetStringUTF16(IDS_OK)); |
532 | 523 |
533 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); | 524 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); |
534 layout->StartRowWithPadding( | 525 layout->StartRowWithPadding( |
535 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); | 526 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
536 layout->AddView(ok_button_); | 527 layout->AddView(ok_button_); |
537 | 528 |
538 parent_->set_initially_focused_view(ok_button_); | 529 parent_->set_initially_focused_view(ok_button_); |
539 } | 530 } |
540 | 531 |
541 ManagePasswordsBubbleView::SaveConfirmationView::~SaveConfirmationView() { | 532 ManagePasswordsBubbleView::SaveConfirmationView::~SaveConfirmationView() { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 if (parent->model()->ShouldShowMultipleAccountUpdateUI()) { | 643 if (parent->model()->ShouldShowMultipleAccountUpdateUI()) { |
653 selection_view_ = new CredentialsSelectionView( | 644 selection_view_ = new CredentialsSelectionView( |
654 parent->model(), parent->model()->local_credentials().get(), | 645 parent->model(), parent->model()->local_credentials().get(), |
655 parent->model()->pending_password().username_value); | 646 parent->model()->pending_password().username_value); |
656 item = selection_view_; | 647 item = selection_view_; |
657 } else { | 648 } else { |
658 std::vector<const autofill::PasswordForm*> forms; | 649 std::vector<const autofill::PasswordForm*> forms; |
659 forms.push_back(&parent->model()->pending_password()); | 650 forms.push_back(&parent->model()->pending_password()); |
660 item = new ManagePasswordItemsView(parent_->model(), forms); | 651 item = new ManagePasswordItemsView(parent_->model(), forms); |
661 } | 652 } |
662 nope_button_ = GenerateButton( | 653 nope_button_ = views::MdTextButton::CreateSecondaryUiButton( |
663 this, | 654 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON)); |
664 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON)).release(); | |
665 | 655 |
666 update_button_ = new views::BlueButton( | 656 update_button_ = new views::BlueButton( |
667 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UPDATE_BUTTON)); | 657 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UPDATE_BUTTON)); |
668 | 658 |
669 // Title row. | 659 // Title row. |
670 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 660 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
671 AddTitleRowWithLink(layout, parent_->model(), this); | 661 AddTitleRowWithLink(layout, parent_->model(), this); |
672 | 662 |
673 // Credential row. | 663 // Credential row. |
674 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 664 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 AddChildView(new SaveConfirmationView(this)); | 821 AddChildView(new SaveConfirmationView(this)); |
832 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) { | 822 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) { |
833 AddChildView(new AutoSigninView(this)); | 823 AddChildView(new AutoSigninView(this)); |
834 } else { | 824 } else { |
835 AddChildView(new ManageView(this)); | 825 AddChildView(new ManageView(this)); |
836 } | 826 } |
837 if (GetWidget()) | 827 if (GetWidget()) |
838 GetWidget()->UpdateWindowTitle(); | 828 GetWidget()->UpdateWindowTitle(); |
839 GetLayoutManager()->Layout(this); | 829 GetLayoutManager()->Layout(this); |
840 } | 830 } |
OLD | NEW |