OLD | NEW |
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 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_MOCK_H_ | 5 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_MOCK_H_ |
6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_MOCK_H_ | 6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_MOCK_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 9 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
| 10 #include "components/password_manager/core/browser/stub_password_manager_client.
h" |
10 #include "components/password_manager/core/common/password_manager_ui.h" | 11 #include "components/password_manager/core/common/password_manager_ui.h" |
11 #include "content/public/browser/navigation_details.h" | 12 #include "content/public/browser/navigation_details.h" |
12 | 13 |
13 namespace content { | 14 namespace content { |
14 class WebContents; | 15 class WebContents; |
15 } // namespace content | 16 } // namespace content |
16 | 17 |
17 namespace password_manager { | 18 namespace password_manager { |
18 enum class CredentialType : unsigned int; | 19 enum class CredentialType : unsigned int; |
19 } | 20 } |
(...skipping 11 matching lines...) Expand all Loading... |
31 // Navigation, surprisingly, is platform-specific; Android's settings page | 32 // Navigation, surprisingly, is platform-specific; Android's settings page |
32 // is native UI and therefore isn't available in a tab for unit tests. | 33 // is native UI and therefore isn't available in a tab for unit tests. |
33 // | 34 // |
34 // TODO(mkwst): Determine how to reasonably test this on that platform. | 35 // TODO(mkwst): Determine how to reasonably test this on that platform. |
35 void NavigateToPasswordManagerSettingsPage() override; | 36 void NavigateToPasswordManagerSettingsPage() override; |
36 bool navigated_to_settings_page() const { | 37 bool navigated_to_settings_page() const { |
37 return navigated_to_settings_page_; | 38 return navigated_to_settings_page_; |
38 } | 39 } |
39 | 40 |
40 // We don't have a FormManager in tests, so stub these out. | 41 // We don't have a FormManager in tests, so stub these out. |
41 void SavePasswordInternal() override; | 42 void SavePassword() override; |
42 bool saved_password() const { return saved_password_; } | 43 bool saved_password() const { return saved_password_; } |
43 | 44 |
44 void NeverSavePasswordInternal() override; | 45 void NeverSavePassword() override; |
45 bool never_saved_password() const { return never_saved_password_; } | 46 bool never_saved_password() const { return never_saved_password_; } |
46 | 47 |
| 48 void UnblacklistSite() override; |
| 49 bool unblacklist_site() const { return unblacklist_site_; } |
| 50 |
47 void ChooseCredential(const autofill::PasswordForm& form, | 51 void ChooseCredential(const autofill::PasswordForm& form, |
48 password_manager::CredentialType form_type) override; | 52 password_manager::CredentialType form_type) override; |
49 bool choose_credential() const { return choose_credential_; } | 53 bool choose_credential() const { return choose_credential_; } |
50 autofill::PasswordForm chosen_credential() { return chosen_credential_; } | 54 autofill::PasswordForm chosen_credential() { return chosen_credential_; } |
51 | 55 |
52 const autofill::PasswordForm& PendingPassword() const override; | 56 const autofill::PasswordForm& PendingPassword() const override; |
53 void SetPendingPassword(autofill::PasswordForm pending_password); | 57 void SetPendingPassword(autofill::PasswordForm pending_password); |
54 | 58 |
55 void UpdateBubbleAndIconVisibility() override; | 59 void UpdateBubbleAndIconVisibility() override; |
56 | 60 |
57 void UpdateAndroidAccountChooserInfoBarVisibility() override; | 61 void UpdateAndroidAccountChooserInfoBarVisibility() override; |
58 | 62 |
59 base::TimeDelta Elapsed() const override; | 63 // Simulate the pending password state. |best_matches| can't be empty. |
| 64 void PretendSubmittedPassword( |
| 65 ScopedVector<autofill::PasswordForm> best_matches); |
60 | 66 |
61 // Sneaky setters for testing. | 67 static scoped_ptr<password_manager::PasswordFormManager> CreateFormManager( |
62 void SetPasswordFormMap(const autofill::ConstPasswordFormMap& map) { | 68 password_manager::PasswordManagerClient* client, |
63 password_form_map_ = map; | 69 const autofill::PasswordForm& observed_form, |
64 } | 70 ScopedVector<autofill::PasswordForm> best_matches); |
65 using ManagePasswordsUIController::SetState; | |
66 | |
67 void SetElapsed(base::TimeDelta elapsed) { elapsed_ = elapsed; } | |
68 | |
69 // True if this controller is installed on |web_contents()|. | |
70 bool IsInstalled() const; | |
71 | |
72 using ManagePasswordsUIController::DidNavigateMainFrame; | |
73 | 71 |
74 private: | 72 private: |
75 bool navigated_to_settings_page_; | 73 bool navigated_to_settings_page_; |
76 bool saved_password_; | 74 bool saved_password_; |
77 bool never_saved_password_; | 75 bool never_saved_password_; |
| 76 bool unblacklist_site_; |
78 bool choose_credential_; | 77 bool choose_credential_; |
79 base::TimeDelta elapsed_; | 78 base::TimeDelta elapsed_; |
80 | 79 |
81 autofill::PasswordForm chosen_credential_; | 80 autofill::PasswordForm chosen_credential_; |
82 autofill::PasswordForm pending_password_; | 81 autofill::PasswordForm pending_password_; |
83 | 82 |
| 83 password_manager::StubPasswordManagerClient client_; |
| 84 |
84 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsUIControllerMock); | 85 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsUIControllerMock); |
85 }; | 86 }; |
86 | 87 |
87 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_MOCK_H_ | 88 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_MOCK_H_ |
OLD | NEW |