| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "base/threading/thread_restrictions.h" | 22 #include "base/threading/thread_restrictions.h" |
| 23 #include "base/time.h" | 23 #include "base/time.h" |
| 24 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
| 25 #include "chrome/app/chrome_command_ids.h" | 25 #include "chrome/app/chrome_command_ids.h" |
| 26 #include "chrome/browser/autocomplete/autocomplete.h" | 26 #include "chrome/browser/autocomplete/autocomplete.h" |
| 27 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 27 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 28 #include "chrome/browser/autocomplete/autocomplete_match.h" | 28 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 29 #include "chrome/browser/autofill/autofill_manager.h" | 29 #include "chrome/browser/autofill/autofill_manager.h" |
| 30 #include "chrome/browser/autofill/credit_card.h" | 30 #include "chrome/browser/autofill/credit_card.h" |
| 31 #include "chrome/browser/autofill/personal_data_manager.h" | 31 #include "chrome/browser/autofill/personal_data_manager.h" |
| 32 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 32 #include "chrome/browser/automation/automation_browser_tracker.h" | 33 #include "chrome/browser/automation/automation_browser_tracker.h" |
| 33 #include "chrome/browser/automation/automation_provider_json.h" | 34 #include "chrome/browser/automation/automation_provider_json.h" |
| 34 #include "chrome/browser/automation/automation_provider_list.h" | 35 #include "chrome/browser/automation/automation_provider_list.h" |
| 35 #include "chrome/browser/automation/automation_provider_observers.h" | 36 #include "chrome/browser/automation/automation_provider_observers.h" |
| 36 #include "chrome/browser/automation/automation_tab_tracker.h" | 37 #include "chrome/browser/automation/automation_tab_tracker.h" |
| 37 #include "chrome/browser/automation/automation_util.h" | 38 #include "chrome/browser/automation/automation_util.h" |
| 38 #include "chrome/browser/automation/automation_window_tracker.h" | 39 #include "chrome/browser/automation/automation_window_tracker.h" |
| 39 #include "chrome/browser/automation/ui_controls.h" | 40 #include "chrome/browser/automation/ui_controls.h" |
| 40 #include "chrome/browser/bookmarks/bookmark_model.h" | 41 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 41 #include "chrome/browser/bookmarks/bookmark_storage.h" | 42 #include "chrome/browser/bookmarks/bookmark_storage.h" |
| (...skipping 4349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4391 // Get the AutofillProfiles currently in the database. | 4392 // Get the AutofillProfiles currently in the database. |
| 4392 int tab_index = 0; | 4393 int tab_index = 0; |
| 4393 if (!args->GetInteger("tab_index", &tab_index)) { | 4394 if (!args->GetInteger("tab_index", &tab_index)) { |
| 4394 reply.SendError("Invalid or missing tab_index integer value."); | 4395 reply.SendError("Invalid or missing tab_index integer value."); |
| 4395 return; | 4396 return; |
| 4396 } | 4397 } |
| 4397 | 4398 |
| 4398 TabContentsWrapper* tab_contents = | 4399 TabContentsWrapper* tab_contents = |
| 4399 browser->GetTabContentsWrapperAt(tab_index); | 4400 browser->GetTabContentsWrapperAt(tab_index); |
| 4400 if (tab_contents) { | 4401 if (tab_contents) { |
| 4401 PersonalDataManager* pdm = tab_contents->profile()->GetOriginalProfile() | 4402 PersonalDataManager* pdm = PersonalDataManagerFactory::GetForProfile( |
| 4402 ->GetPersonalDataManager(); | 4403 tab_contents->profile()->GetOriginalProfile()); |
| 4403 if (pdm) { | 4404 if (pdm) { |
| 4404 std::vector<AutofillProfile*> autofill_profiles = pdm->profiles(); | 4405 std::vector<AutofillProfile*> autofill_profiles = pdm->profiles(); |
| 4405 std::vector<CreditCard*> credit_cards = pdm->credit_cards(); | 4406 std::vector<CreditCard*> credit_cards = pdm->credit_cards(); |
| 4406 | 4407 |
| 4407 ListValue* profiles = GetListFromAutofillProfiles(autofill_profiles); | 4408 ListValue* profiles = GetListFromAutofillProfiles(autofill_profiles); |
| 4408 ListValue* cards = GetListFromCreditCards(credit_cards); | 4409 ListValue* cards = GetListFromCreditCards(credit_cards); |
| 4409 | 4410 |
| 4410 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 4411 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 4411 | 4412 |
| 4412 return_value->Set("profiles", profiles); | 4413 return_value->Set("profiles", profiles); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4459 AutomationJSONReply(this, reply_message).SendError( | 4460 AutomationJSONReply(this, reply_message).SendError( |
| 4460 "Invalid or missing tab_index integer"); | 4461 "Invalid or missing tab_index integer"); |
| 4461 return; | 4462 return; |
| 4462 } | 4463 } |
| 4463 | 4464 |
| 4464 TabContentsWrapper* tab_contents = | 4465 TabContentsWrapper* tab_contents = |
| 4465 browser->GetTabContentsWrapperAt(tab_index); | 4466 browser->GetTabContentsWrapperAt(tab_index); |
| 4466 | 4467 |
| 4467 if (tab_contents) { | 4468 if (tab_contents) { |
| 4468 PersonalDataManager* pdm = | 4469 PersonalDataManager* pdm = |
| 4469 tab_contents->profile()->GetPersonalDataManager(); | 4470 PersonalDataManagerFactory::GetForProfile(tab_contents->profile()); |
| 4470 if (pdm) { | 4471 if (pdm) { |
| 4471 if (profiles || cards) { | 4472 if (profiles || cards) { |
| 4472 // This observer will delete itself. | 4473 // This observer will delete itself. |
| 4473 AutofillChangedObserver* observer = new AutofillChangedObserver( | 4474 AutofillChangedObserver* observer = new AutofillChangedObserver( |
| 4474 this, reply_message, autofill_profiles.size(), credit_cards.size()); | 4475 this, reply_message, autofill_profiles.size(), credit_cards.size()); |
| 4475 observer->Init(); | 4476 observer->Init(); |
| 4476 | 4477 |
| 4477 if (profiles) | 4478 if (profiles) |
| 4478 pdm->SetProfiles(&autofill_profiles); | 4479 pdm->SetProfiles(&autofill_profiles); |
| 4479 if (cards) | 4480 if (cards) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4519 AutomationJSONReply(this, reply_message) | 4520 AutomationJSONReply(this, reply_message) |
| 4520 .SendError("'frame_xpath' missing or invalid."); | 4521 .SendError("'frame_xpath' missing or invalid."); |
| 4521 return; | 4522 return; |
| 4522 } | 4523 } |
| 4523 if (!args->GetString("javascript", &javascript)) { | 4524 if (!args->GetString("javascript", &javascript)) { |
| 4524 AutomationJSONReply(this, reply_message) | 4525 AutomationJSONReply(this, reply_message) |
| 4525 .SendError("'javascript' missing or invalid."); | 4526 .SendError("'javascript' missing or invalid."); |
| 4526 return; | 4527 return; |
| 4527 } | 4528 } |
| 4528 | 4529 |
| 4529 PersonalDataManager* pdm = tab_contents->profile()->GetOriginalProfile() | 4530 PersonalDataManager* pdm = PersonalDataManagerFactory::GetForProfile( |
| 4530 ->GetPersonalDataManager(); | 4531 tab_contents->profile()->GetOriginalProfile()); |
| 4531 if (!pdm) { | 4532 if (!pdm) { |
| 4532 AutomationJSONReply(this, reply_message) | 4533 AutomationJSONReply(this, reply_message) |
| 4533 .SendError("No PersonalDataManager."); | 4534 .SendError("No PersonalDataManager."); |
| 4534 return; | 4535 return; |
| 4535 } | 4536 } |
| 4536 | 4537 |
| 4537 // This observer will delete itself. | 4538 // This observer will delete itself. |
| 4538 new AutofillFormSubmittedObserver(this, reply_message, pdm); | 4539 new AutofillFormSubmittedObserver(this, reply_message, pdm); |
| 4539 | 4540 |
| 4540 // Set the routing id of this message with the controller. | 4541 // Set the routing id of this message with the controller. |
| (...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6347 | 6348 |
| 6348 Send(reply_message_); | 6349 Send(reply_message_); |
| 6349 redirect_query_ = 0; | 6350 redirect_query_ = 0; |
| 6350 reply_message_ = NULL; | 6351 reply_message_ = NULL; |
| 6351 } | 6352 } |
| 6352 | 6353 |
| 6353 void TestingAutomationProvider::OnRemoveProvider() { | 6354 void TestingAutomationProvider::OnRemoveProvider() { |
| 6354 if (g_browser_process) | 6355 if (g_browser_process) |
| 6355 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6356 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 6356 } | 6357 } |
| OLD | NEW |