Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / passwords / manage_passwords_ui_controller_mock.cc
blobb69799dd0049588dc4c9da1db1fa5de7b0299d19
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
7 #include "components/password_manager/core/browser/password_form_manager.h"
8 #include "components/password_manager/core/common/credential_manager_types.h"
9 #include "content/public/browser/web_contents.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 ManagePasswordsUIControllerMock::ManagePasswordsUIControllerMock(
13 content::WebContents* contents)
14 : ManagePasswordsUIController(contents),
15 navigated_to_settings_page_(false),
16 saved_password_(false),
17 never_saved_password_(false),
18 unblacklist_site_(false),
19 choose_credential_(false),
20 manage_accounts_(false) {
21 // Do not silently replace an existing ManagePasswordsUIController because it
22 // unregisters itself in WebContentsDestroyed().
23 EXPECT_FALSE(contents->GetUserData(UserDataKey()));
24 contents->SetUserData(UserDataKey(), this);
25 set_client(&client_);
28 ManagePasswordsUIControllerMock::
29 ~ManagePasswordsUIControllerMock() {}
31 void ManagePasswordsUIControllerMock::
32 NavigateToPasswordManagerSettingsPage() {
33 navigated_to_settings_page_ = true;
36 const autofill::PasswordForm&
37 ManagePasswordsUIControllerMock::PendingPassword() const {
38 return pending_password_;
41 void ManagePasswordsUIControllerMock::SetPendingPassword(
42 autofill::PasswordForm pending_password) {
43 pending_password_ = pending_password;
46 void ManagePasswordsUIControllerMock::ManageAccounts() {
47 manage_accounts_ = true;
50 void ManagePasswordsUIControllerMock::UpdateBubbleAndIconVisibility() {
51 OnBubbleShown();
54 void ManagePasswordsUIControllerMock::
55 UpdateAndroidAccountChooserInfoBarVisibility() {
56 OnBubbleShown();
59 void ManagePasswordsUIControllerMock::SavePassword() {
60 saved_password_ = true;
63 void ManagePasswordsUIControllerMock::NeverSavePassword() {
64 never_saved_password_ = true;
67 void ManagePasswordsUIControllerMock::UnblacklistSite() {
68 unblacklist_site_ = true;
71 void ManagePasswordsUIControllerMock::ChooseCredential(
72 const autofill::PasswordForm& form,
73 password_manager::CredentialType form_type) {
74 EXPECT_FALSE(choose_credential_);
75 choose_credential_ = true;
76 chosen_credential_ = form;
79 void ManagePasswordsUIControllerMock::PretendSubmittedPassword(
80 ScopedVector<autofill::PasswordForm> best_matches) {
81 ASSERT_FALSE(best_matches.empty());
82 autofill::PasswordForm observed_form = *best_matches[0];
83 scoped_ptr<password_manager::PasswordFormManager> form_manager =
84 CreateFormManager(&client_, observed_form, best_matches.Pass());
85 OnPasswordSubmitted(form_manager.Pass());
88 // static
89 scoped_ptr<password_manager::PasswordFormManager>
90 ManagePasswordsUIControllerMock::CreateFormManager(
91 password_manager::PasswordManagerClient* client,
92 const autofill::PasswordForm& observed_form,
93 ScopedVector<autofill::PasswordForm> best_matches) {
94 scoped_ptr<password_manager::PasswordFormManager> test_form_manager(
95 new password_manager::PasswordFormManager(
96 nullptr, client,
97 base::WeakPtr<password_manager::PasswordManagerDriver>(),
98 observed_form, true));
99 test_form_manager->SimulateFetchMatchingLoginsFromPasswordStore();
100 test_form_manager->OnGetPasswordStoreResults(best_matches.Pass());
101 return test_form_manager.Pass();