Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.cc

Issue 1009953002: Integrate ManagePasswordsState into ManagePasswordsUIController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed the comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/passwords/manage_passwords_ui_controller_mock.h" 5 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
6 6
7 #include "components/password_manager/content/common/credential_manager_types.h" 7 #include "components/password_manager/content/common/credential_manager_types.h"
8 #include "components/password_manager/core/browser/password_form_manager.h"
8 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 ManagePasswordsUIControllerMock::ManagePasswordsUIControllerMock( 12 ManagePasswordsUIControllerMock::ManagePasswordsUIControllerMock(
12 content::WebContents* contents) 13 content::WebContents* contents)
13 : ManagePasswordsUIController(contents), 14 : ManagePasswordsUIController(contents),
14 navigated_to_settings_page_(false), 15 navigated_to_settings_page_(false),
15 saved_password_(false), 16 saved_password_(false),
16 never_saved_password_(false), 17 never_saved_password_(false),
18 unblacklist_site_(false),
17 choose_credential_(false) { 19 choose_credential_(false) {
18 // Do not silently replace an existing ManagePasswordsUIController because it 20 // Do not silently replace an existing ManagePasswordsUIController because it
19 // unregisters itself in WebContentsDestroyed(). 21 // unregisters itself in WebContentsDestroyed().
20 EXPECT_FALSE(contents->GetUserData(UserDataKey())); 22 EXPECT_FALSE(contents->GetUserData(UserDataKey()));
21 contents->SetUserData(UserDataKey(), this); 23 contents->SetUserData(UserDataKey(), this);
24 set_client(&client_);
22 } 25 }
23 26
24 ManagePasswordsUIControllerMock:: 27 ManagePasswordsUIControllerMock::
25 ~ManagePasswordsUIControllerMock() {} 28 ~ManagePasswordsUIControllerMock() {}
26 29
27 void ManagePasswordsUIControllerMock:: 30 void ManagePasswordsUIControllerMock::
28 NavigateToPasswordManagerSettingsPage() { 31 NavigateToPasswordManagerSettingsPage() {
29 navigated_to_settings_page_ = true; 32 navigated_to_settings_page_ = true;
30 } 33 }
31 34
32 const autofill::PasswordForm& 35 const autofill::PasswordForm&
33 ManagePasswordsUIControllerMock::PendingPassword() const { 36 ManagePasswordsUIControllerMock::PendingPassword() const {
34 return pending_password_; 37 return pending_password_;
35 } 38 }
36 39
37 void ManagePasswordsUIControllerMock::SetPendingPassword( 40 void ManagePasswordsUIControllerMock::SetPendingPassword(
38 autofill::PasswordForm pending_password) { 41 autofill::PasswordForm pending_password) {
39 pending_password_ = pending_password; 42 pending_password_ = pending_password;
40 } 43 }
41 44
42 void ManagePasswordsUIControllerMock::UpdateBubbleAndIconVisibility() { 45 void ManagePasswordsUIControllerMock::UpdateBubbleAndIconVisibility() {
43 ManagePasswordsUIController::UpdateBubbleAndIconVisibility();
44 OnBubbleShown(); 46 OnBubbleShown();
45 } 47 }
46 48
47 void ManagePasswordsUIControllerMock:: 49 void ManagePasswordsUIControllerMock::
48 UpdateAndroidAccountChooserInfoBarVisibility() { 50 UpdateAndroidAccountChooserInfoBarVisibility() {
49 OnBubbleShown(); 51 OnBubbleShown();
50 } 52 }
51 53
52 base::TimeDelta ManagePasswordsUIControllerMock::Elapsed() const { 54 void ManagePasswordsUIControllerMock::SavePassword() {
53 return elapsed_;
54 }
55
56 bool ManagePasswordsUIControllerMock::IsInstalled() const {
57 return web_contents()->GetUserData(UserDataKey()) == this;
58 }
59
60 void ManagePasswordsUIControllerMock::SavePasswordInternal() {
61 saved_password_ = true; 55 saved_password_ = true;
62 } 56 }
63 57
64 void ManagePasswordsUIControllerMock::NeverSavePasswordInternal() { 58 void ManagePasswordsUIControllerMock::NeverSavePassword() {
65 never_saved_password_ = true; 59 never_saved_password_ = true;
66 } 60 }
67 61
62 void ManagePasswordsUIControllerMock::UnblacklistSite() {
63 unblacklist_site_ = true;
64 }
65
68 void ManagePasswordsUIControllerMock::ChooseCredential( 66 void ManagePasswordsUIControllerMock::ChooseCredential(
69 const autofill::PasswordForm& form, 67 const autofill::PasswordForm& form,
70 password_manager::CredentialType form_type) { 68 password_manager::CredentialType form_type) {
71 SetState(password_manager::ui::INACTIVE_STATE);
72 EXPECT_FALSE(choose_credential_); 69 EXPECT_FALSE(choose_credential_);
73 choose_credential_ = true; 70 choose_credential_ = true;
74 chosen_credential_ = form; 71 chosen_credential_ = form;
75 } 72 }
73
74 void ManagePasswordsUIControllerMock::PretendSubmittedPassword(
75 ScopedVector<autofill::PasswordForm> best_matches) {
76 ASSERT_FALSE(best_matches.empty());
77 autofill::PasswordForm observed_form = *best_matches[0];
78 scoped_ptr<password_manager::PasswordFormManager> form_manager =
79 CreateFormManager(&client_, observed_form, best_matches.Pass());
80 OnPasswordSubmitted(form_manager.Pass());
81 }
82
83 // static
84 scoped_ptr<password_manager::PasswordFormManager>
85 ManagePasswordsUIControllerMock::CreateFormManager(
86 password_manager::PasswordManagerClient* client,
87 const autofill::PasswordForm& observed_form,
88 ScopedVector<autofill::PasswordForm> best_matches) {
89 scoped_ptr<password_manager::PasswordFormManager> test_form_manager(
90 new password_manager::PasswordFormManager(
91 nullptr, client,
92 base::WeakPtr<password_manager::PasswordManagerDriver>(),
93 observed_form, true));
94 test_form_manager->SimulateFetchMatchingLoginsFromPasswordStore();
95 test_form_manager->OnGetPasswordStoreResults(best_matches.Pass());
96 return test_form_manager.Pass();
97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698