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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "components/autofill/core/browser/personal_data_manager.h" | 34 #include "components/autofill/core/browser/personal_data_manager.h" |
35 #include "components/autofill/core/browser/test_autofill_driver.h" | 35 #include "components/autofill/core/browser/test_autofill_driver.h" |
36 #include "components/autofill/core/browser/test_autofill_external_delegate.h" | 36 #include "components/autofill/core/browser/test_autofill_external_delegate.h" |
37 #include "components/autofill/core/browser/test_autofill_manager_delegate.h" | 37 #include "components/autofill/core/browser/test_autofill_manager_delegate.h" |
38 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 38 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
39 #include "components/autofill/core/common/autofill_messages.h" | 39 #include "components/autofill/core/common/autofill_messages.h" |
40 #include "components/autofill/core/common/autofill_pref_names.h" | 40 #include "components/autofill/core/common/autofill_pref_names.h" |
41 #include "components/autofill/core/common/form_data.h" | 41 #include "components/autofill/core/common/form_data.h" |
42 #include "components/autofill/core/common/form_field_data.h" | 42 #include "components/autofill/core/common/form_field_data.h" |
43 #include "components/autofill/core/common/forms_seen_state.h" | 43 #include "components/autofill/core/common/forms_seen_state.h" |
| 44 #include "components/autofill/core/common/password_form.h" |
44 #include "components/user_prefs/user_prefs.h" | 45 #include "components/user_prefs/user_prefs.h" |
45 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
46 #include "content/public/test/mock_render_process_host.h" | 47 #include "content/public/test/mock_render_process_host.h" |
47 #include "content/public/test/test_utils.h" | 48 #include "content/public/test/test_utils.h" |
48 #include "grit/component_strings.h" | 49 #include "grit/component_strings.h" |
49 #include "ipc/ipc_test_sink.h" | 50 #include "ipc/ipc_test_sink.h" |
50 #include "testing/gmock/include/gmock/gmock.h" | 51 #include "testing/gmock/include/gmock/gmock.h" |
51 #include "testing/gtest/include/gtest/gtest.h" | 52 #include "testing/gtest/include/gtest/gtest.h" |
52 #include "third_party/WebKit/public/web/WebAutofillClient.h" | 53 #include "third_party/WebKit/public/web/WebAutofillClient.h" |
53 #include "ui/base/l10n/l10n_util.h" | 54 #include "ui/base/l10n/l10n_util.h" |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 AutofillManager* autofill_manager, | 537 AutofillManager* autofill_manager, |
537 AutofillDriver* autofill_driver) | 538 AutofillDriver* autofill_driver) |
538 : AutofillExternalDelegate(autofill_manager, autofill_driver), | 539 : AutofillExternalDelegate(autofill_manager, autofill_driver), |
539 on_query_seen_(false), | 540 on_query_seen_(false), |
540 on_suggestions_returned_seen_(false) {} | 541 on_suggestions_returned_seen_(false) {} |
541 virtual ~TestAutofillExternalDelegate() {} | 542 virtual ~TestAutofillExternalDelegate() {} |
542 | 543 |
543 virtual void OnQuery(int query_id, | 544 virtual void OnQuery(int query_id, |
544 const FormData& form, | 545 const FormData& form, |
545 const FormFieldData& field, | 546 const FormFieldData& field, |
| 547 const PasswordForm& password_form, |
546 const gfx::RectF& bounds, | 548 const gfx::RectF& bounds, |
547 bool display_warning) OVERRIDE { | 549 bool display_warning) OVERRIDE { |
548 on_query_seen_ = true; | 550 on_query_seen_ = true; |
549 on_suggestions_returned_seen_ = false; | 551 on_suggestions_returned_seen_ = false; |
550 } | 552 } |
551 | 553 |
552 virtual void OnSuggestionsReturned( | 554 virtual void OnSuggestionsReturned( |
553 int query_id, | 555 int query_id, |
554 const std::vector<base::string16>& autofill_values, | 556 const std::vector<base::string16>& autofill_values, |
555 const std::vector<base::string16>& autofill_labels, | 557 const std::vector<base::string16>& autofill_labels, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 ChromeRenderViewHostTestHarness::TearDown(); | 654 ChromeRenderViewHostTestHarness::TearDown(); |
653 | 655 |
654 // Remove the AutofillWebDataService so TestPersonalDataManager does not | 656 // Remove the AutofillWebDataService so TestPersonalDataManager does not |
655 // need to care about removing self as an observer in destruction. | 657 // need to care about removing self as an observer in destruction. |
656 personal_data_.set_database(scoped_refptr<AutofillWebDataService>(NULL)); | 658 personal_data_.set_database(scoped_refptr<AutofillWebDataService>(NULL)); |
657 } | 659 } |
658 | 660 |
659 void GetAutofillSuggestions(int query_id, | 661 void GetAutofillSuggestions(int query_id, |
660 const FormData& form, | 662 const FormData& form, |
661 const FormFieldData& field) { | 663 const FormFieldData& field) { |
662 autofill_manager_->OnQueryFormFieldAutofill(query_id, | 664 PasswordForm password_form; |
663 form, | 665 autofill_manager_->OnQueryFormFieldAutofill( |
664 field, | 666 query_id, form, field, password_form, gfx::Rect(), false); |
665 gfx::Rect(), | |
666 false); | |
667 } | 667 } |
668 | 668 |
669 void GetAutofillSuggestions(const FormData& form, | 669 void GetAutofillSuggestions(const FormData& form, |
670 const FormFieldData& field) { | 670 const FormFieldData& field) { |
671 GetAutofillSuggestions(kDefaultPageID, form, field); | 671 GetAutofillSuggestions(kDefaultPageID, form, field); |
672 } | 672 } |
673 | 673 |
674 void AutocompleteSuggestionsReturned( | 674 void AutocompleteSuggestionsReturned( |
675 const std::vector<base::string16>& result) { | 675 const std::vector<base::string16>& result) { |
676 autofill_manager_->autocomplete_history_manager_->SendSuggestions(&result); | 676 autofill_manager_->autocomplete_history_manager_->SendSuggestions(&result); |
(...skipping 2246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2923 test::CreateTestAddressFormData(&form); | 2923 test::CreateTestAddressFormData(&form); |
2924 std::vector<FormData> forms(1, form); | 2924 std::vector<FormData> forms(1, form); |
2925 FormsSeen(forms); | 2925 FormsSeen(forms); |
2926 const FormFieldData& field = form.fields[0]; | 2926 const FormFieldData& field = form.fields[0]; |
2927 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 2927 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
2928 | 2928 |
2929 EXPECT_TRUE(external_delegate_->on_query_seen()); | 2929 EXPECT_TRUE(external_delegate_->on_query_seen()); |
2930 } | 2930 } |
2931 | 2931 |
2932 } // namespace autofill | 2932 } // namespace autofill |
OLD | NEW |