OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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. |
| 4 |
| 5 #ifndef CHROME_RENDERER_AUTOFILL_FAKE_CONTENT_PASSWORD_MANAGER_DRIVER_H_ |
| 6 #define CHROME_RENDERER_AUTOFILL_FAKE_CONTENT_PASSWORD_MANAGER_DRIVER_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/optional.h" |
| 12 #include "base/strings/string16.h" |
| 13 #include "components/autofill/content/public/interfaces/autofill_driver.mojom.h" |
| 14 #include "components/autofill/core/common/password_form.h" |
| 15 #include "mojo/public/cpp/bindings/binding_set.h" |
| 16 |
| 17 class FakeContentPasswordManagerDriver |
| 18 : public autofill::mojom::PasswordManagerDriver { |
| 19 public: |
| 20 FakeContentPasswordManagerDriver(); |
| 21 |
| 22 ~FakeContentPasswordManagerDriver() override; |
| 23 |
| 24 void BindRequest(autofill::mojom::PasswordManagerDriverRequest request); |
| 25 |
| 26 bool called_show_pw_suggestions() const { |
| 27 return called_show_pw_suggestions_; |
| 28 } |
| 29 |
| 30 int show_pw_suggestions_key() const { return show_pw_suggestions_key_; } |
| 31 |
| 32 const base::Optional<base::string16>& show_pw_suggestions_username() const { |
| 33 return show_pw_suggestions_username_; |
| 34 } |
| 35 |
| 36 int show_pw_suggestions_options() const { |
| 37 return show_pw_suggestions_options_; |
| 38 } |
| 39 |
| 40 void reset_show_pw_suggestions() { |
| 41 called_show_pw_suggestions_ = false; |
| 42 show_pw_suggestions_key_ = -1; |
| 43 show_pw_suggestions_username_ = base::nullopt; |
| 44 show_pw_suggestions_options_ = -1; |
| 45 } |
| 46 |
| 47 bool called_password_form_submitted() const { |
| 48 return called_password_form_submitted_; |
| 49 } |
| 50 |
| 51 const base::Optional<autofill::PasswordForm>& password_form_submitted() |
| 52 const { |
| 53 return password_form_submitted_; |
| 54 } |
| 55 |
| 56 bool called_inpage_navigation() const { return called_inpage_navigation_; } |
| 57 |
| 58 const base::Optional<autofill::PasswordForm>& |
| 59 password_form_inpage_navigation() const { |
| 60 return password_form_inpage_navigation_; |
| 61 } |
| 62 |
| 63 bool called_password_forms_rendered() const { |
| 64 return called_password_forms_rendered_; |
| 65 } |
| 66 |
| 67 const base::Optional<std::vector<autofill::PasswordForm>>& |
| 68 password_forms_rendered() const { |
| 69 return password_forms_rendered_; |
| 70 } |
| 71 |
| 72 void reset_password_forms_rendered() { |
| 73 called_password_forms_rendered_ = false; |
| 74 password_forms_rendered_ = base::nullopt; |
| 75 } |
| 76 |
| 77 bool called_record_save_progress() const { |
| 78 return called_record_save_progress_; |
| 79 } |
| 80 |
| 81 bool called_agent_constructed() const { return called_agent_constructed_; } |
| 82 |
| 83 bool called_save_generation_field() const { |
| 84 return called_save_generation_field_; |
| 85 } |
| 86 |
| 87 const base::Optional<base::string16>& save_generation_field() const { |
| 88 return save_generation_field_; |
| 89 } |
| 90 |
| 91 void reset_save_generation_field() { |
| 92 called_save_generation_field_ = false; |
| 93 save_generation_field_ = base::nullopt; |
| 94 } |
| 95 |
| 96 bool called_password_no_longer_generated() const { |
| 97 return called_password_no_longer_generated_; |
| 98 } |
| 99 |
| 100 void reset_called_password_no_longer_generated() { |
| 101 called_password_no_longer_generated_ = false; |
| 102 } |
| 103 |
| 104 bool called_presave_generated_password() const { |
| 105 return called_presave_generated_password_; |
| 106 } |
| 107 |
| 108 void reset_called_presave_generated_password() { |
| 109 called_presave_generated_password_ = false; |
| 110 } |
| 111 |
| 112 private: |
| 113 // mojom::PasswordManagerDriver: |
| 114 void PasswordFormsParsed( |
| 115 const std::vector<autofill::PasswordForm>& forms) override; |
| 116 |
| 117 void PasswordFormsRendered( |
| 118 const std::vector<autofill::PasswordForm>& visible_forms, |
| 119 bool did_stop_loading) override; |
| 120 |
| 121 void PasswordFormSubmitted( |
| 122 const autofill::PasswordForm& password_form) override; |
| 123 |
| 124 void InPageNavigation(const autofill::PasswordForm& password_form) override; |
| 125 |
| 126 void PresaveGeneratedPassword( |
| 127 const autofill::PasswordForm& password_form) override; |
| 128 |
| 129 void PasswordNoLongerGenerated( |
| 130 const autofill::PasswordForm& password_form) override; |
| 131 |
| 132 void ShowPasswordSuggestions(int key, |
| 133 base::i18n::TextDirection text_direction, |
| 134 const base::string16& typed_username, |
| 135 int options, |
| 136 const gfx::RectF& bounds) override; |
| 137 |
| 138 void PasswordAutofillAgentConstructed() override; |
| 139 |
| 140 void RecordSavePasswordProgress(const std::string& log) override; |
| 141 |
| 142 void SaveGenerationFieldDetectedByClassifier( |
| 143 const autofill::PasswordForm& password_form, |
| 144 const base::string16& generation_field) override; |
| 145 |
| 146 // Records whether ShowPasswordSuggestions() gets called. |
| 147 bool called_show_pw_suggestions_ = false; |
| 148 // Records data received via ShowPasswordSuggestions() call. |
| 149 int show_pw_suggestions_key_ = -1; |
| 150 base::Optional<base::string16> show_pw_suggestions_username_; |
| 151 int show_pw_suggestions_options_ = -1; |
| 152 // Records whether PasswordFormSubmitted() gets called. |
| 153 bool called_password_form_submitted_ = false; |
| 154 // Records data received via PasswordFormSubmitted() call. |
| 155 base::Optional<autofill::PasswordForm> password_form_submitted_; |
| 156 // Records whether InPageNavigation() gets called. |
| 157 bool called_inpage_navigation_ = false; |
| 158 // Records data received via InPageNavigation() call. |
| 159 base::Optional<autofill::PasswordForm> password_form_inpage_navigation_; |
| 160 // Records whether PasswordFormsRendered() gets called. |
| 161 bool called_password_forms_rendered_ = false; |
| 162 // Records data received via PasswordFormsRendered() call. |
| 163 base::Optional<std::vector<autofill::PasswordForm>> password_forms_rendered_; |
| 164 // Records whether RecordSavePasswordProgress() gets called. |
| 165 bool called_record_save_progress_ = false; |
| 166 // Records whether PasswordAutofillAgentConstructed() gets called. |
| 167 bool called_agent_constructed_ = false; |
| 168 // Records whether SaveGenerationFieldDetectedByClassifier() gets called. |
| 169 bool called_save_generation_field_ = false; |
| 170 // Records data received via SaveGenerationFieldDetectedByClassifier() call. |
| 171 base::Optional<base::string16> save_generation_field_; |
| 172 // Records whether PasswordNoLongerGenerated() gets called. |
| 173 bool called_password_no_longer_generated_ = false; |
| 174 // Records whether PresaveGeneratedPassword() gets called. |
| 175 bool called_presave_generated_password_ = false; |
| 176 |
| 177 mojo::BindingSet<autofill::mojom::PasswordManagerDriver> bindings_; |
| 178 }; |
| 179 |
| 180 #endif // CHROME_RENDERER_AUTOFILL_FAKE_CONTENT_PASSWORD_MANAGER_DRIVER_H_ |
OLD | NEW |