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 "chrome/browser/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include "app/message_box_flags.h" | 7 #include "app/message_box_flags.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 3756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3767 // json input. | 3767 // json input. |
3768 // Sample json output: {} | 3768 // Sample json output: {} |
3769 void TestingAutomationProvider::FillAutoFillProfile( | 3769 void TestingAutomationProvider::FillAutoFillProfile( |
3770 Browser* browser, | 3770 Browser* browser, |
3771 DictionaryValue* args, | 3771 DictionaryValue* args, |
3772 IPC::Message* reply_message) { | 3772 IPC::Message* reply_message) { |
3773 AutomationJSONReply reply(this, reply_message); | 3773 AutomationJSONReply reply(this, reply_message); |
3774 ListValue* profiles = NULL; | 3774 ListValue* profiles = NULL; |
3775 ListValue* cards = NULL; | 3775 ListValue* cards = NULL; |
3776 | 3776 |
3777 if (!args->GetList("profiles", &profiles)) { | 3777 // It's ok for profiles/credit_cards elements to be missing. |
3778 reply.SendError("Invalid or missing profiles list"); | 3778 args->GetList("profiles", &profiles); |
3779 return; | 3779 args->GetList("credit_cards", &cards); |
3780 } | |
3781 | |
3782 if (!args->GetList("credit_cards", &cards)) { | |
3783 reply.SendError("Invalid or missing credit_cards list"); | |
3784 return; | |
3785 } | |
3786 | 3780 |
3787 std::string error_mesg; | 3781 std::string error_mesg; |
3788 | 3782 |
3789 std::vector<AutoFillProfile> autofill_profiles; | 3783 std::vector<AutoFillProfile> autofill_profiles; |
3790 std::vector<CreditCard> credit_cards; | 3784 std::vector<CreditCard> credit_cards; |
3791 // Create an AutoFillProfile for each of the dictionary profiles. | 3785 // Create an AutoFillProfile for each of the dictionary profiles. |
3792 if (profiles) { | 3786 if (profiles) { |
3793 autofill_profiles = GetAutoFillProfilesFromList(*profiles, &error_mesg); | 3787 autofill_profiles = GetAutoFillProfilesFromList(*profiles, &error_mesg); |
3794 } | 3788 } |
3795 // Create a CreditCard for each of the dictionary values. | 3789 // Create a CreditCard for each of the dictionary values. |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4517 // If you change this, update Observer for NotificationType::SESSION_END | 4511 // If you change this, update Observer for NotificationType::SESSION_END |
4518 // below. | 4512 // below. |
4519 MessageLoop::current()->PostTask(FROM_HERE, | 4513 MessageLoop::current()->PostTask(FROM_HERE, |
4520 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); | 4514 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); |
4521 } | 4515 } |
4522 } | 4516 } |
4523 | 4517 |
4524 void TestingAutomationProvider::OnRemoveProvider() { | 4518 void TestingAutomationProvider::OnRemoveProvider() { |
4525 AutomationProviderList::GetInstance()->RemoveProvider(this); | 4519 AutomationProviderList::GetInstance()->RemoveProvider(this); |
4526 } | 4520 } |
OLD | NEW |