| 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 #include "components/autofill/content/browser/content_autofill_driver.h" | 5 #include "components/autofill/content/browser/content_autofill_driver.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "components/autofill/core/browser/test_autofill_client.h" | 21 #include "components/autofill/core/browser/test_autofill_client.h" |
| 22 #include "components/autofill/core/common/autofill_switches.h" | 22 #include "components/autofill/core/common/autofill_switches.h" |
| 23 #include "components/autofill/core/common/form_data_predictions.h" | 23 #include "components/autofill/core/common/form_data_predictions.h" |
| 24 #include "content/public/browser/browser_context.h" | 24 #include "content/public/browser/browser_context.h" |
| 25 #include "content/public/browser/navigation_details.h" | 25 #include "content/public/browser/navigation_details.h" |
| 26 #include "content/public/browser/storage_partition.h" | 26 #include "content/public/browser/storage_partition.h" |
| 27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/common/frame_navigate_params.h" | 28 #include "content/public/common/frame_navigate_params.h" |
| 29 #include "content/public/test/mock_render_process_host.h" | 29 #include "content/public/test/mock_render_process_host.h" |
| 30 #include "content/public/test/test_renderer_host.h" | 30 #include "content/public/test/test_renderer_host.h" |
| 31 #include "mojo/common/common_type_converters.h" | |
| 32 #include "mojo/public/cpp/bindings/binding_set.h" | 31 #include "mojo/public/cpp/bindings/binding_set.h" |
| 33 #include "services/shell/public/cpp/interface_provider.h" | 32 #include "services/shell/public/cpp/interface_provider.h" |
| 34 #include "testing/gmock/include/gmock/gmock.h" | 33 #include "testing/gmock/include/gmock/gmock.h" |
| 35 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
| 36 | 35 |
| 37 namespace autofill { | 36 namespace autofill { |
| 38 | 37 |
| 39 namespace { | 38 namespace { |
| 40 | 39 |
| 41 const char kAppLocale[] = "en-US"; | 40 const char kAppLocale[] = "en-US"; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 CallDone(); | 154 CallDone(); |
| 156 } | 155 } |
| 157 | 156 |
| 158 void PreviewForm(int32_t id, const FormData& form) override { | 157 void PreviewForm(int32_t id, const FormData& form) override { |
| 159 preview_form_id_ = id; | 158 preview_form_id_ = id; |
| 160 preview_form_form_ = form; | 159 preview_form_form_ = form; |
| 161 CallDone(); | 160 CallDone(); |
| 162 } | 161 } |
| 163 | 162 |
| 164 void FieldTypePredictionsAvailable( | 163 void FieldTypePredictionsAvailable( |
| 165 mojo::Array<FormDataPredictions> forms) override { | 164 const std::vector<FormDataPredictions>& forms) override { |
| 166 predictions_ = forms.PassStorage(); | 165 predictions_ = forms; |
| 167 CallDone(); | 166 CallDone(); |
| 168 } | 167 } |
| 169 | 168 |
| 170 void ClearForm() override { | 169 void ClearForm() override { |
| 171 called_clear_form_ = true; | 170 called_clear_form_ = true; |
| 172 CallDone(); | 171 CallDone(); |
| 173 } | 172 } |
| 174 | 173 |
| 175 void ClearPreviewedForm() override { | 174 void ClearPreviewedForm() override { |
| 176 called_clear_previewed_form_ = true; | 175 called_clear_previewed_form_ = true; |
| 177 CallDone(); | 176 CallDone(); |
| 178 } | 177 } |
| 179 | 178 |
| 180 void FillFieldWithValue(const mojo::String& value) override { | 179 void FillFieldWithValue(const base::string16& value) override { |
| 181 value_fill_field_ = value.To<base::string16>(); | 180 value_fill_field_ = value; |
| 182 CallDone(); | 181 CallDone(); |
| 183 } | 182 } |
| 184 | 183 |
| 185 void PreviewFieldWithValue(const mojo::String& value) override { | 184 void PreviewFieldWithValue(const base::string16& value) override { |
| 186 value_preview_field_ = value.To<base::string16>(); | 185 value_preview_field_ = value; |
| 187 CallDone(); | 186 CallDone(); |
| 188 } | 187 } |
| 189 | 188 |
| 190 void AcceptDataListSuggestion(const mojo::String& value) override { | 189 void AcceptDataListSuggestion(const base::string16& value) override { |
| 191 value_accept_data_ = value.To<base::string16>(); | 190 value_accept_data_ = value; |
| 192 CallDone(); | 191 CallDone(); |
| 193 } | 192 } |
| 194 | 193 |
| 195 void FillPasswordSuggestion(const mojo::String& username, | 194 void FillPasswordSuggestion(const base::string16& username, |
| 196 const mojo::String& password) override {} | 195 const base::string16& password) override {} |
| 197 | 196 |
| 198 void PreviewPasswordSuggestion(const mojo::String& username, | 197 void PreviewPasswordSuggestion(const base::string16& username, |
| 199 const mojo::String& password) override {} | 198 const base::string16& password) override {} |
| 200 | 199 |
| 201 void ShowInitialPasswordAccountSuggestions( | 200 void ShowInitialPasswordAccountSuggestions( |
| 202 int32_t key, | 201 int32_t key, |
| 203 const PasswordFormFillData& form_data) override {} | 202 const PasswordFormFillData& form_data) override {} |
| 204 | 203 |
| 205 mojo::BindingSet<mojom::AutofillAgent> bindings_; | 204 mojo::BindingSet<mojom::AutofillAgent> bindings_; |
| 206 | 205 |
| 207 base::Closure quit_closure_; | 206 base::Closure quit_closure_; |
| 208 | 207 |
| 209 // Records data received from FillForm() call. | 208 // Records data received from FillForm() call. |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 base::RunLoop run_loop; | 443 base::RunLoop run_loop; |
| 445 fake_agent_.SetQuitLoopClosure(run_loop.QuitClosure()); | 444 fake_agent_.SetQuitLoopClosure(run_loop.QuitClosure()); |
| 446 driver_->RendererShouldPreviewFieldWithValue(input_value); | 445 driver_->RendererShouldPreviewFieldWithValue(input_value); |
| 447 run_loop.RunUntilIdle(); | 446 run_loop.RunUntilIdle(); |
| 448 | 447 |
| 449 EXPECT_TRUE(fake_agent_.GetString16PreviewFieldWithValue(&output_value)); | 448 EXPECT_TRUE(fake_agent_.GetString16PreviewFieldWithValue(&output_value)); |
| 450 EXPECT_EQ(input_value, output_value); | 449 EXPECT_EQ(input_value, output_value); |
| 451 } | 450 } |
| 452 | 451 |
| 453 } // namespace autofill | 452 } // namespace autofill |
| OLD | NEW |