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/timer/timer.h" | 7 #include "base/timer/timer.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
11 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 11 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
12 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 12 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
13 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 13 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
| 14 #include "chrome/browser/ui/passwords/password_bubble_experiment.h" |
14 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" | 15 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" |
15 #include "chrome/browser/ui/views/frame/browser_view.h" | 16 #include "chrome/browser/ui/views/frame/browser_view.h" |
16 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" | 17 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" |
17 #include "chrome/browser/ui/views/passwords/manage_credential_item_view.h" | 18 #include "chrome/browser/ui/views/passwords/manage_credential_item_view.h" |
18 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" | 19 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" |
19 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" | 20 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" |
20 #include "chrome/browser/ui/views/passwords/save_account_more_combobox_model.h" | 21 #include "chrome/browser/ui/views/passwords/save_account_more_combobox_model.h" |
21 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
22 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 std::vector<const autofill::PasswordForm*> credentials( | 391 std::vector<const autofill::PasswordForm*> credentials( |
391 1, &parent->model()->pending_password()); | 392 1, &parent->model()->pending_password()); |
392 // Create the pending credential item, save button and refusal combobox. | 393 // Create the pending credential item, save button and refusal combobox. |
393 ManagePasswordItemsView* item = | 394 ManagePasswordItemsView* item = |
394 new ManagePasswordItemsView(parent_->model(), credentials); | 395 new ManagePasswordItemsView(parent_->model(), credentials); |
395 save_button_ = new views::BlueButton( | 396 save_button_ = new views::BlueButton( |
396 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); | 397 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); |
397 save_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | 398 save_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
398 ui::ResourceBundle::SmallFont)); | 399 ui::ResourceBundle::SmallFont)); |
399 | 400 |
400 combobox_model_.reset(new SavePasswordRefusalComboboxModel()); | 401 combobox_model_.reset(new SavePasswordRefusalComboboxModel( |
| 402 password_bubble_experiment::ShouldShowNeverForThisSiteDefault( |
| 403 parent_->model()->GetProfile()->GetPrefs()))); |
401 refuse_combobox_.reset(new views::Combobox(combobox_model_.get())); | 404 refuse_combobox_.reset(new views::Combobox(combobox_model_.get())); |
402 refuse_combobox_->set_listener(this); | 405 refuse_combobox_->set_listener(this); |
403 refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION); | 406 refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION); |
404 // TODO(mkwst): Need a mechanism to pipe a font list down into a combobox. | 407 // TODO(mkwst): Need a mechanism to pipe a font list down into a combobox. |
405 | 408 |
406 // Title row. | 409 // Title row. |
407 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 410 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
408 AddTitleRow(layout, parent_->model()); | 411 AddTitleRow(layout, parent_->model()); |
409 | 412 |
410 // Credential row. | 413 // Credential row. |
(...skipping 20 matching lines...) Expand all Loading... |
431 views::Button* sender, | 434 views::Button* sender, |
432 const ui::Event& event) { | 435 const ui::Event& event) { |
433 DCHECK(sender == save_button_); | 436 DCHECK(sender == save_button_); |
434 parent_->model()->OnSaveClicked(); | 437 parent_->model()->OnSaveClicked(); |
435 parent_->Close(); | 438 parent_->Close(); |
436 } | 439 } |
437 | 440 |
438 void ManagePasswordsBubbleView::PendingView::OnPerformAction( | 441 void ManagePasswordsBubbleView::PendingView::OnPerformAction( |
439 views::Combobox* source) { | 442 views::Combobox* source) { |
440 DCHECK_EQ(source, refuse_combobox_); | 443 DCHECK_EQ(source, refuse_combobox_); |
441 switch (refuse_combobox_->selected_index()) { | 444 if (source->selected_index() == combobox_model_->index_nope()) { |
442 case SavePasswordRefusalComboboxModel::INDEX_NOPE: | 445 parent_->model()->OnNopeClicked(); |
443 parent_->model()->OnNopeClicked(); | 446 parent_->Close(); |
444 parent_->Close(); | 447 } else if (source->selected_index() == combobox_model_->index_never()) { |
445 break; | 448 parent_->NotifyNeverForThisSiteClicked(); |
446 case SavePasswordRefusalComboboxModel::INDEX_NEVER_FOR_THIS_SITE: | 449 } else { |
447 parent_->NotifyNeverForThisSiteClicked(); | 450 NOTREACHED(); |
448 break; | |
449 } | 451 } |
450 } | 452 } |
451 | 453 |
452 // ManagePasswordsBubbleView::SaveAccountView --------------------------------- | 454 // ManagePasswordsBubbleView::SaveAccountView --------------------------------- |
453 | 455 |
454 // A view offering the user the ability to save credentials. Contains 2 buttons | 456 // A view offering the user the ability to save credentials. Contains 2 buttons |
455 // and a "More" combobox. | 457 // and a "More" combobox. |
456 class ManagePasswordsBubbleView::SaveAccountView | 458 class ManagePasswordsBubbleView::SaveAccountView |
457 : public views::View, | 459 : public views::View, |
458 public views::ButtonListener, | 460 public views::ButtonListener, |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { | 1196 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { |
1195 if (model()->local_credentials().empty()) { | 1197 if (model()->local_credentials().empty()) { |
1196 // Skip confirmation if there are no existing passwords for this site. | 1198 // Skip confirmation if there are no existing passwords for this site. |
1197 NotifyConfirmedNeverForThisSite(); | 1199 NotifyConfirmedNeverForThisSite(); |
1198 } else { | 1200 } else { |
1199 model()->OnConfirmationForNeverForThisSite(); | 1201 model()->OnConfirmationForNeverForThisSite(); |
1200 Refresh(); | 1202 Refresh(); |
1201 SizeToContents(); | 1203 SizeToContents(); |
1202 } | 1204 } |
1203 } | 1205 } |
OLD | NEW |