| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/core/browser/autofill_manager.h" |
| 6 |
| 5 #include <stddef.h> | 7 #include <stddef.h> |
| 6 | 8 |
| 7 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> |
| 8 #include <vector> | 11 #include <vector> |
| 9 | 12 |
| 10 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 11 #include "base/format_macros.h" | 14 #include "base/format_macros.h" |
| 12 #include "base/macros.h" | 15 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
| 16 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
| 17 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
| 18 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 20 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/test/histogram_tester.h" | 24 #include "base/test/histogram_tester.h" |
| 23 #include "base/thread_task_runner_handle.h" | 25 #include "base/thread_task_runner_handle.h" |
| 24 #include "base/time/time.h" | 26 #include "base/time/time.h" |
| 25 #include "build/build_config.h" | 27 #include "build/build_config.h" |
| 26 #include "components/autofill/core/browser/autocomplete_history_manager.h" | 28 #include "components/autofill/core/browser/autocomplete_history_manager.h" |
| 27 #include "components/autofill/core/browser/autofill_download_manager.h" | 29 #include "components/autofill/core/browser/autofill_download_manager.h" |
| 28 #include "components/autofill/core/browser/autofill_manager.h" | |
| 29 #include "components/autofill/core/browser/autofill_profile.h" | 30 #include "components/autofill/core/browser/autofill_profile.h" |
| 30 #include "components/autofill/core/browser/autofill_test_utils.h" | 31 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 31 #include "components/autofill/core/browser/credit_card.h" | 32 #include "components/autofill/core/browser/credit_card.h" |
| 32 #include "components/autofill/core/browser/personal_data_manager.h" | 33 #include "components/autofill/core/browser/personal_data_manager.h" |
| 33 #include "components/autofill/core/browser/popup_item_ids.h" | 34 #include "components/autofill/core/browser/popup_item_ids.h" |
| 34 #include "components/autofill/core/browser/test_autofill_client.h" | 35 #include "components/autofill/core/browser/test_autofill_client.h" |
| 35 #include "components/autofill/core/browser/test_autofill_driver.h" | 36 #include "components/autofill/core/browser/test_autofill_driver.h" |
| 36 #include "components/autofill/core/browser/test_autofill_external_delegate.h" | 37 #include "components/autofill/core/browser/test_autofill_external_delegate.h" |
| 37 #include "components/autofill/core/browser/validation.h" | 38 #include "components/autofill/core/browser/validation.h" |
| 38 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 39 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 payments::PaymentsClientDelegate* delegate) | 82 payments::PaymentsClientDelegate* delegate) |
| 82 : PaymentsClient(context_getter, delegate), delegate_(delegate) {} | 83 : PaymentsClient(context_getter, delegate), delegate_(delegate) {} |
| 83 | 84 |
| 84 ~TestPaymentsClient() override {} | 85 ~TestPaymentsClient() override {} |
| 85 | 86 |
| 86 void GetUploadDetails(const std::string& app_locale) override { | 87 void GetUploadDetails(const std::string& app_locale) override { |
| 87 delegate_->OnDidGetUploadDetails( | 88 delegate_->OnDidGetUploadDetails( |
| 88 app_locale == "en-US" ? AutofillClient::SUCCESS | 89 app_locale == "en-US" ? AutofillClient::SUCCESS |
| 89 : AutofillClient::PERMANENT_FAILURE, | 90 : AutofillClient::PERMANENT_FAILURE, |
| 90 ASCIIToUTF16("this is a context token"), | 91 ASCIIToUTF16("this is a context token"), |
| 91 scoped_ptr<base::DictionaryValue>(nullptr)); | 92 std::unique_ptr<base::DictionaryValue>(nullptr)); |
| 92 } | 93 } |
| 93 | 94 |
| 94 void UploadCard(const payments::PaymentsClient::UploadRequestDetails& | 95 void UploadCard(const payments::PaymentsClient::UploadRequestDetails& |
| 95 request_details) override { | 96 request_details) override { |
| 96 delegate_->OnDidUploadCard(AutofillClient::SUCCESS); | 97 delegate_->OnDidUploadCard(AutofillClient::SUCCESS); |
| 97 } | 98 } |
| 98 | 99 |
| 99 private: | 100 private: |
| 100 payments::PaymentsClientDelegate* const delegate_; | 101 payments::PaymentsClientDelegate* const delegate_; |
| 101 | 102 |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 }; | 600 }; |
| 600 | 601 |
| 601 // Weak reference. | 602 // Weak reference. |
| 602 TestPersonalDataManager* personal_data_; | 603 TestPersonalDataManager* personal_data_; |
| 603 | 604 |
| 604 bool autofill_enabled_; | 605 bool autofill_enabled_; |
| 605 bool credit_card_upload_enabled_; | 606 bool credit_card_upload_enabled_; |
| 606 bool credit_card_was_uploaded_; | 607 bool credit_card_was_uploaded_; |
| 607 bool expected_observed_submission_; | 608 bool expected_observed_submission_; |
| 608 | 609 |
| 609 scoped_ptr<base::RunLoop> run_loop_; | 610 std::unique_ptr<base::RunLoop> run_loop_; |
| 610 | 611 |
| 611 std::string submitted_form_signature_; | 612 std::string submitted_form_signature_; |
| 612 std::vector<ServerFieldTypeSet> expected_submitted_field_types_; | 613 std::vector<ServerFieldTypeSet> expected_submitted_field_types_; |
| 613 | 614 |
| 614 DISALLOW_COPY_AND_ASSIGN(TestAutofillManager); | 615 DISALLOW_COPY_AND_ASSIGN(TestAutofillManager); |
| 615 }; | 616 }; |
| 616 | 617 |
| 617 class TestAutofillExternalDelegate : public AutofillExternalDelegate { | 618 class TestAutofillExternalDelegate : public AutofillExternalDelegate { |
| 618 public: | 619 public: |
| 619 explicit TestAutofillExternalDelegate(AutofillManager* autofill_manager, | 620 explicit TestAutofillExternalDelegate(AutofillManager* autofill_manager, |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 form->fields[2], *card); | 919 form->fields[2], *card); |
| 919 autofill_manager_->FillOrPreviewCreditCardForm( | 920 autofill_manager_->FillOrPreviewCreditCardForm( |
| 920 AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, *form, | 921 AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, *form, |
| 921 form->fields[3], *card); | 922 form->fields[3], *card); |
| 922 #endif // defined(OS_IOS) | 923 #endif // defined(OS_IOS) |
| 923 } | 924 } |
| 924 | 925 |
| 925 protected: | 926 protected: |
| 926 base::MessageLoop message_loop_; | 927 base::MessageLoop message_loop_; |
| 927 MockAutofillClient autofill_client_; | 928 MockAutofillClient autofill_client_; |
| 928 scoped_ptr<MockAutofillDriver> autofill_driver_; | 929 std::unique_ptr<MockAutofillDriver> autofill_driver_; |
| 929 scoped_ptr<TestAutofillManager> autofill_manager_; | 930 std::unique_ptr<TestAutofillManager> autofill_manager_; |
| 930 scoped_ptr<TestAutofillExternalDelegate> external_delegate_; | 931 std::unique_ptr<TestAutofillExternalDelegate> external_delegate_; |
| 931 scoped_refptr<net::TestURLRequestContextGetter> request_context_; | 932 scoped_refptr<net::TestURLRequestContextGetter> request_context_; |
| 932 TestPaymentsClient* payments_client_; | 933 TestPaymentsClient* payments_client_; |
| 933 TestAutofillDownloadManager* download_manager_; | 934 TestAutofillDownloadManager* download_manager_; |
| 934 TestPersonalDataManager personal_data_; | 935 TestPersonalDataManager personal_data_; |
| 935 }; | 936 }; |
| 936 | 937 |
| 937 class TestFormStructure : public FormStructure { | 938 class TestFormStructure : public FormStructure { |
| 938 public: | 939 public: |
| 939 explicit TestFormStructure(const FormData& form) | 940 explicit TestFormStructure(const FormData& form) |
| 940 : FormStructure(form) {} | 941 : FormStructure(form) {} |
| (...skipping 3890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4831 FormsSeen(mixed_forms); | 4832 FormsSeen(mixed_forms); |
| 4832 | 4833 |
| 4833 // Suggestions should always be displayed. | 4834 // Suggestions should always be displayed. |
| 4834 for (const FormFieldData& field : mixed_form.fields) { | 4835 for (const FormFieldData& field : mixed_form.fields) { |
| 4835 GetAutofillSuggestions(mixed_form, field); | 4836 GetAutofillSuggestions(mixed_form, field); |
| 4836 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); | 4837 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); |
| 4837 } | 4838 } |
| 4838 } | 4839 } |
| 4839 | 4840 |
| 4840 } // namespace autofill | 4841 } // namespace autofill |
| OLD | NEW |