Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/ref_counted.h" | 7 #include "base/ref_counted.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/scoped_vector.h" | 9 #include "base/scoped_vector.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/tuple.h" | 13 #include "base/tuple.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/autocomplete_history_manager.h" | 15 #include "chrome/browser/autocomplete_history_manager.h" |
| 16 #include "chrome/browser/autofill/autofill_common_test.h" | 16 #include "chrome/browser/autofill/autofill_common_test.h" |
| 17 #include "chrome/browser/autofill/autofill_manager.h" | 17 #include "chrome/browser/autofill/autofill_manager.h" |
| 18 #include "chrome/browser/autofill/autofill_profile.h" | 18 #include "chrome/browser/autofill/autofill_profile.h" |
| 19 #include "chrome/browser/autofill/credit_card.h" | 19 #include "chrome/browser/autofill/credit_card.h" |
| 20 #include "chrome/browser/autofill/personal_data_manager.h" | 20 #include "chrome/browser/autofill/personal_data_manager.h" |
| 21 #include "chrome/browser/prefs/pref_service.h" | 21 #include "chrome/browser/prefs/pref_service.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/renderer_host/test/test_render_view_host.h" | 23 #include "chrome/browser/renderer_host/test/test_render_view_host.h" |
| 24 #include "chrome/browser/tab_contents/test_tab_contents.h" | 24 #include "chrome/browser/tab_contents/test_tab_contents.h" |
| 25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| 26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 27 #include "chrome/common/render_messages.h" | 27 #include "chrome/common/autofill_messages.h" |
|
Ilya Sherman
2011/01/26 04:43:12
nit: header order
| |
| 28 #include "chrome/test/testing_profile.h" | 28 #include "chrome/test/testing_profile.h" |
| 29 #include "googleurl/src/gurl.h" | 29 #include "googleurl/src/gurl.h" |
| 30 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
| 31 #include "ipc/ipc_test_sink.h" | 31 #include "ipc/ipc_test_sink.h" |
| 32 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
| 33 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 34 #include "webkit/glue/form_data.h" | 34 #include "webkit/glue/form_data.h" |
| 35 #include "webkit/glue/form_field.h" | 35 #include "webkit/glue/form_field.h" |
| 36 | 36 |
| 37 using webkit_glue::FormData; | 37 using webkit_glue::FormData; |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 472 const webkit_glue::FormField& field, | 472 const webkit_glue::FormField& field, |
| 473 int unique_id) { | 473 int unique_id) { |
| 474 autofill_manager_->OnFillAutoFillFormData(query_id, form, field, unique_id); | 474 autofill_manager_->OnFillAutoFillFormData(query_id, form, field, unique_id); |
| 475 } | 475 } |
| 476 | 476 |
| 477 bool GetAutoFillSuggestionsMessage(int* page_id, | 477 bool GetAutoFillSuggestionsMessage(int* page_id, |
| 478 std::vector<string16>* values, | 478 std::vector<string16>* values, |
| 479 std::vector<string16>* labels, | 479 std::vector<string16>* labels, |
| 480 std::vector<string16>* icons, | 480 std::vector<string16>* icons, |
| 481 std::vector<int>* unique_ids) { | 481 std::vector<int>* unique_ids) { |
| 482 const uint32 kMsgID = ViewMsg_AutoFillSuggestionsReturned::ID; | 482 const uint32 kMsgID = AutoFillMsg_SuggestionsReturned::ID; |
| 483 const IPC::Message* message = | 483 const IPC::Message* message = |
| 484 process()->sink().GetFirstMessageMatching(kMsgID); | 484 process()->sink().GetFirstMessageMatching(kMsgID); |
| 485 if (!message) | 485 if (!message) |
| 486 return false; | 486 return false; |
| 487 | 487 |
| 488 AutoFillParam autofill_param; | 488 AutoFillParam autofill_param; |
| 489 ViewMsg_AutoFillSuggestionsReturned::Read(message, &autofill_param); | 489 AutoFillMsg_SuggestionsReturned::Read(message, &autofill_param); |
| 490 if (page_id) | 490 if (page_id) |
| 491 *page_id = autofill_param.a; | 491 *page_id = autofill_param.a; |
| 492 if (values) | 492 if (values) |
| 493 *values = autofill_param.b; | 493 *values = autofill_param.b; |
| 494 if (labels) | 494 if (labels) |
| 495 *labels = autofill_param.c; | 495 *labels = autofill_param.c; |
| 496 if (icons) | 496 if (icons) |
| 497 *icons = autofill_param.d; | 497 *icons = autofill_param.d; |
| 498 if (unique_ids) | 498 if (unique_ids) |
| 499 *unique_ids = autofill_param.e; | 499 *unique_ids = autofill_param.e; |
| 500 | 500 |
| 501 autofill_manager_->tab_contents()->autocomplete_history_manager()-> | 501 autofill_manager_->tab_contents()->autocomplete_history_manager()-> |
| 502 CancelPendingQuery(); | 502 CancelPendingQuery(); |
| 503 process()->sink().ClearMessages(); | 503 process()->sink().ClearMessages(); |
| 504 return true; | 504 return true; |
| 505 } | 505 } |
| 506 | 506 |
| 507 bool GetAutoFillFormDataFilledMessage(int *page_id, FormData* results) { | 507 bool GetAutoFillFormDataFilledMessage(int *page_id, FormData* results) { |
| 508 const uint32 kMsgID = ViewMsg_AutoFillFormDataFilled::ID; | 508 const uint32 kMsgID = AutoFillMsg_FormDataFilled::ID; |
| 509 const IPC::Message* message = | 509 const IPC::Message* message = |
| 510 process()->sink().GetFirstMessageMatching(kMsgID); | 510 process()->sink().GetFirstMessageMatching(kMsgID); |
| 511 if (!message) | 511 if (!message) |
| 512 return false; | 512 return false; |
| 513 Tuple2<int, FormData> autofill_param; | 513 Tuple2<int, FormData> autofill_param; |
| 514 ViewMsg_AutoFillFormDataFilled::Read(message, &autofill_param); | 514 AutoFillMsg_FormDataFilled::Read(message, &autofill_param); |
| 515 if (page_id) | 515 if (page_id) |
| 516 *page_id = autofill_param.a; | 516 *page_id = autofill_param.a; |
| 517 if (results) | 517 if (results) |
| 518 *results = autofill_param.b; | 518 *results = autofill_param.b; |
| 519 | 519 |
| 520 process()->sink().ClearMessages(); | 520 process()->sink().ClearMessages(); |
| 521 return true; | 521 return true; |
| 522 } | 522 } |
| 523 | 523 |
| 524 protected: | 524 protected: |
| (...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1579 #else | 1579 #else |
| 1580 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( | 1580 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
| 1581 prefs::kAutoFillAuxiliaryProfilesEnabled)); | 1581 prefs::kAutoFillAuxiliaryProfilesEnabled)); |
| 1582 profile()->GetPrefs()->SetBoolean( | 1582 profile()->GetPrefs()->SetBoolean( |
| 1583 prefs::kAutoFillAuxiliaryProfilesEnabled, true); | 1583 prefs::kAutoFillAuxiliaryProfilesEnabled, true); |
| 1584 profile()->GetPrefs()->ClearPref(prefs::kAutoFillAuxiliaryProfilesEnabled); | 1584 profile()->GetPrefs()->ClearPref(prefs::kAutoFillAuxiliaryProfilesEnabled); |
| 1585 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( | 1585 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
| 1586 prefs::kAutoFillAuxiliaryProfilesEnabled)); | 1586 prefs::kAutoFillAuxiliaryProfilesEnabled)); |
| 1587 #endif | 1587 #endif |
| 1588 } | 1588 } |
| OLD | NEW |