| 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 2499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2510 if (infobar->AsConfirmInfoBarDelegate()) { | 2510 if (infobar->AsConfirmInfoBarDelegate()) { |
| 2511 // Also covers ThemeInstalledInfoBarDelegate. | 2511 // Also covers ThemeInstalledInfoBarDelegate. |
| 2512 infobar_item->SetString("type", "confirm_infobar"); | 2512 infobar_item->SetString("type", "confirm_infobar"); |
| 2513 ConfirmInfoBarDelegate* confirm_infobar = | 2513 ConfirmInfoBarDelegate* confirm_infobar = |
| 2514 infobar->AsConfirmInfoBarDelegate(); | 2514 infobar->AsConfirmInfoBarDelegate(); |
| 2515 infobar_item->SetString("text", confirm_infobar->GetMessageText()); | 2515 infobar_item->SetString("text", confirm_infobar->GetMessageText()); |
| 2516 infobar_item->SetString("link_text", confirm_infobar->GetLinkText()); | 2516 infobar_item->SetString("link_text", confirm_infobar->GetLinkText()); |
| 2517 ListValue* buttons_list = new ListValue; | 2517 ListValue* buttons_list = new ListValue; |
| 2518 int buttons = confirm_infobar->GetButtons(); | 2518 int buttons = confirm_infobar->GetButtons(); |
| 2519 if (buttons & ConfirmInfoBarDelegate::BUTTON_OK) { | 2519 if (buttons & ConfirmInfoBarDelegate::BUTTON_OK) { |
| 2520 StringValue* button_label = new StringValue( | 2520 StringValue* button_label = base::StringValue::New( |
| 2521 confirm_infobar->GetButtonLabel( | 2521 confirm_infobar->GetButtonLabel( |
| 2522 ConfirmInfoBarDelegate::BUTTON_OK)); | 2522 ConfirmInfoBarDelegate::BUTTON_OK)); |
| 2523 buttons_list->Append(button_label); | 2523 buttons_list->Append(button_label); |
| 2524 } | 2524 } |
| 2525 if (buttons & ConfirmInfoBarDelegate::BUTTON_CANCEL) { | 2525 if (buttons & ConfirmInfoBarDelegate::BUTTON_CANCEL) { |
| 2526 StringValue* button_label = new StringValue( | 2526 StringValue* button_label = base::StringValue::New( |
| 2527 confirm_infobar->GetButtonLabel( | 2527 confirm_infobar->GetButtonLabel( |
| 2528 ConfirmInfoBarDelegate::BUTTON_CANCEL)); | 2528 ConfirmInfoBarDelegate::BUTTON_CANCEL)); |
| 2529 buttons_list->Append(button_label); | 2529 buttons_list->Append(button_label); |
| 2530 } | 2530 } |
| 2531 infobar_item->Set("buttons", buttons_list); | 2531 infobar_item->Set("buttons", buttons_list); |
| 2532 } else if (infobar->AsLinkInfoBarDelegate()) { | 2532 } else if (infobar->AsLinkInfoBarDelegate()) { |
| 2533 infobar_item->SetString("type", "link_infobar"); | 2533 infobar_item->SetString("type", "link_infobar"); |
| 2534 LinkInfoBarDelegate* link_infobar = infobar->AsLinkInfoBarDelegate(); | 2534 LinkInfoBarDelegate* link_infobar = infobar->AsLinkInfoBarDelegate(); |
| 2535 infobar_item->SetString("link_text", link_infobar->GetLinkText()); | 2535 infobar_item->SetString("link_text", link_infobar->GetLinkText()); |
| 2536 } else if (infobar->AsTranslateInfoBarDelegate()) { | 2536 } else if (infobar->AsTranslateInfoBarDelegate()) { |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3422 ++type_it) { | 3422 ++type_it) { |
| 3423 DictionaryValue* mime_type = new DictionaryValue(); | 3423 DictionaryValue* mime_type = new DictionaryValue(); |
| 3424 mime_type->SetString("mimeType", type_it->mime_type); | 3424 mime_type->SetString("mimeType", type_it->mime_type); |
| 3425 mime_type->SetString("description", type_it->description); | 3425 mime_type->SetString("description", type_it->description); |
| 3426 | 3426 |
| 3427 ListValue* file_extensions = new ListValue(); | 3427 ListValue* file_extensions = new ListValue(); |
| 3428 for (std::vector<std::string>::const_iterator ext_it = | 3428 for (std::vector<std::string>::const_iterator ext_it = |
| 3429 type_it->file_extensions.begin(); | 3429 type_it->file_extensions.begin(); |
| 3430 ext_it != type_it->file_extensions.end(); | 3430 ext_it != type_it->file_extensions.end(); |
| 3431 ++ext_it) { | 3431 ++ext_it) { |
| 3432 file_extensions->Append(new StringValue(*ext_it)); | 3432 file_extensions->Append(base::StringValue::New(*ext_it)); |
| 3433 } | 3433 } |
| 3434 mime_type->Set("fileExtensions", file_extensions); | 3434 mime_type->Set("fileExtensions", file_extensions); |
| 3435 | 3435 |
| 3436 mime_types->Append(mime_type); | 3436 mime_types->Append(mime_type); |
| 3437 } | 3437 } |
| 3438 item->Set("mimeTypes", mime_types); | 3438 item->Set("mimeTypes", mime_types); |
| 3439 items->Append(item); | 3439 items->Append(item); |
| 3440 } | 3440 } |
| 3441 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3441 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 3442 return_value->Set("plugins", items); // return_value owns items. | 3442 return_value->Set("plugins", items); // return_value owns items. |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4126 ListValue* GetHostPermissions(const Extension* ext, bool effective_perm) { | 4126 ListValue* GetHostPermissions(const Extension* ext, bool effective_perm) { |
| 4127 URLPatternSet pattern_set; | 4127 URLPatternSet pattern_set; |
| 4128 if (effective_perm) | 4128 if (effective_perm) |
| 4129 pattern_set = ext->GetEffectiveHostPermissions(); | 4129 pattern_set = ext->GetEffectiveHostPermissions(); |
| 4130 else | 4130 else |
| 4131 pattern_set = ext->GetActivePermissions()->explicit_hosts(); | 4131 pattern_set = ext->GetActivePermissions()->explicit_hosts(); |
| 4132 | 4132 |
| 4133 ListValue* permissions = new ListValue; | 4133 ListValue* permissions = new ListValue; |
| 4134 for (URLPatternSet::const_iterator perm = pattern_set.begin(); | 4134 for (URLPatternSet::const_iterator perm = pattern_set.begin(); |
| 4135 perm != pattern_set.end(); ++perm) { | 4135 perm != pattern_set.end(); ++perm) { |
| 4136 permissions->Append(new StringValue(perm->GetAsString())); | 4136 permissions->Append(base::StringValue::New(perm->GetAsString())); |
| 4137 } | 4137 } |
| 4138 | 4138 |
| 4139 return permissions; | 4139 return permissions; |
| 4140 } | 4140 } |
| 4141 | 4141 |
| 4142 ListValue* GetAPIPermissions(const Extension* ext) { | 4142 ListValue* GetAPIPermissions(const Extension* ext) { |
| 4143 ListValue* permissions = new ListValue; | 4143 ListValue* permissions = new ListValue; |
| 4144 std::set<std::string> perm_list = | 4144 std::set<std::string> perm_list = |
| 4145 ext->GetActivePermissions()->GetAPIsAsStrings(); | 4145 ext->GetActivePermissions()->GetAPIsAsStrings(); |
| 4146 for (std::set<std::string>::const_iterator perm = perm_list.begin(); | 4146 for (std::set<std::string>::const_iterator perm = perm_list.begin(); |
| 4147 perm != perm_list.end(); ++perm) { | 4147 perm != perm_list.end(); ++perm) { |
| 4148 permissions->Append(new StringValue(perm->c_str())); | 4148 permissions->Append(base::StringValue::New(perm->c_str())); |
| 4149 } | 4149 } |
| 4150 return permissions; | 4150 return permissions; |
| 4151 } | 4151 } |
| 4152 | 4152 |
| 4153 } // namespace | 4153 } // namespace |
| 4154 | 4154 |
| 4155 // Sample json input: { "command": "GetExtensionsInfo" } | 4155 // Sample json input: { "command": "GetExtensionsInfo" } |
| 4156 // See GetExtensionsInfo() in chrome/test/pyautolib/pyauto.py for sample json | 4156 // See GetExtensionsInfo() in chrome/test/pyautolib/pyauto.py for sample json |
| 4157 // output. | 4157 // output. |
| 4158 void TestingAutomationProvider::GetExtensionsInfo( | 4158 void TestingAutomationProvider::GetExtensionsInfo( |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4553 sync_info->SetString("sync url", service->sync_service_url().host()); | 4553 sync_info->SetString("sync url", service->sync_service_url().host()); |
| 4554 sync_info->SetBoolean("authenticated", status.authenticated); | 4554 sync_info->SetBoolean("authenticated", status.authenticated); |
| 4555 sync_info->SetString("last synced", service->GetLastSyncedTimeString()); | 4555 sync_info->SetString("last synced", service->GetLastSyncedTimeString()); |
| 4556 sync_info->SetInteger("updates received", status.updates_received); | 4556 sync_info->SetInteger("updates received", status.updates_received); |
| 4557 ListValue* synced_datatype_list = new ListValue; | 4557 ListValue* synced_datatype_list = new ListValue; |
| 4558 syncable::ModelTypeSet synced_datatypes; | 4558 syncable::ModelTypeSet synced_datatypes; |
| 4559 service->GetPreferredDataTypes(&synced_datatypes); | 4559 service->GetPreferredDataTypes(&synced_datatypes); |
| 4560 for (syncable::ModelTypeSet::iterator it = synced_datatypes.begin(); | 4560 for (syncable::ModelTypeSet::iterator it = synced_datatypes.begin(); |
| 4561 it != synced_datatypes.end(); ++it) { | 4561 it != synced_datatypes.end(); ++it) { |
| 4562 synced_datatype_list->Append( | 4562 synced_datatype_list->Append( |
| 4563 new StringValue(syncable::ModelTypeToString(*it))); | 4563 base::StringValue::New(syncable::ModelTypeToString(*it))); |
| 4564 } | 4564 } |
| 4565 sync_info->Set("synced datatypes", synced_datatype_list); | 4565 sync_info->Set("synced datatypes", synced_datatype_list); |
| 4566 } | 4566 } |
| 4567 return_value->Set("sync_info", sync_info); | 4567 return_value->Set("sync_info", sync_info); |
| 4568 reply.SendSuccess(return_value.get()); | 4568 reply.SendSuccess(return_value.get()); |
| 4569 } | 4569 } |
| 4570 | 4570 |
| 4571 // Sample json output: { "success": true } | 4571 // Sample json output: { "success": true } |
| 4572 void TestingAutomationProvider::AwaitSyncCycleCompletion( | 4572 void TestingAutomationProvider::AwaitSyncCycleCompletion( |
| 4573 Browser* browser, | 4573 Browser* browser, |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4783 for (std::map<AutofillFieldType, std::string>::iterator | 4783 for (std::map<AutofillFieldType, std::string>::iterator |
| 4784 type_it = autofill_type_to_string.begin(); | 4784 type_it = autofill_type_to_string.begin(); |
| 4785 type_it != autofill_type_to_string.end(); ++type_it) { | 4785 type_it != autofill_type_to_string.end(); ++type_it) { |
| 4786 std::vector<string16> value_list; | 4786 std::vector<string16> value_list; |
| 4787 profile->GetMultiInfo(type_it->first, &value_list); | 4787 profile->GetMultiInfo(type_it->first, &value_list); |
| 4788 ListValue* values_to_return = new ListValue; | 4788 ListValue* values_to_return = new ListValue; |
| 4789 for (std::vector<string16>::iterator value_it = value_list.begin(); | 4789 for (std::vector<string16>::iterator value_it = value_list.begin(); |
| 4790 value_it != value_list.end(); ++value_it) { | 4790 value_it != value_list.end(); ++value_it) { |
| 4791 string16 value = *value_it; | 4791 string16 value = *value_it; |
| 4792 if (value.length()) // If there was something stored for that value. | 4792 if (value.length()) // If there was something stored for that value. |
| 4793 values_to_return->Append(new StringValue(value)); | 4793 values_to_return->Append(base::StringValue::New(value)); |
| 4794 } | 4794 } |
| 4795 if (!values_to_return->empty()) | 4795 if (!values_to_return->empty()) |
| 4796 profile_info->Set(type_it->second, values_to_return); | 4796 profile_info->Set(type_it->second, values_to_return); |
| 4797 } | 4797 } |
| 4798 profiles->Append(profile_info); | 4798 profiles->Append(profile_info); |
| 4799 } | 4799 } |
| 4800 return profiles; | 4800 return profiles; |
| 4801 } | 4801 } |
| 4802 | 4802 |
| 4803 /* static */ | 4803 /* static */ |
| (...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5892 | 5892 |
| 5893 void TestingAutomationProvider::GetTabIds( | 5893 void TestingAutomationProvider::GetTabIds( |
| 5894 DictionaryValue* args, IPC::Message* reply_message) { | 5894 DictionaryValue* args, IPC::Message* reply_message) { |
| 5895 ListValue* id_list = new ListValue(); | 5895 ListValue* id_list = new ListValue(); |
| 5896 BrowserList::const_iterator iter = BrowserList::begin(); | 5896 BrowserList::const_iterator iter = BrowserList::begin(); |
| 5897 for (; iter != BrowserList::end(); ++iter) { | 5897 for (; iter != BrowserList::end(); ++iter) { |
| 5898 Browser* browser = *iter; | 5898 Browser* browser = *iter; |
| 5899 for (int i = 0; i < browser->tab_count(); ++i) { | 5899 for (int i = 0; i < browser->tab_count(); ++i) { |
| 5900 int id = browser->GetTabContentsWrapperAt(i)->restore_tab_helper()-> | 5900 int id = browser->GetTabContentsWrapperAt(i)->restore_tab_helper()-> |
| 5901 session_id().id(); | 5901 session_id().id(); |
| 5902 id_list->Append(Value::CreateIntegerValue(id)); | 5902 id_list->Append(base::NumberValue::New(id)); |
| 5903 } | 5903 } |
| 5904 } | 5904 } |
| 5905 DictionaryValue dict; | 5905 DictionaryValue dict; |
| 5906 dict.Set("ids", id_list); | 5906 dict.Set("ids", id_list); |
| 5907 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 5907 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 5908 } | 5908 } |
| 5909 | 5909 |
| 5910 void TestingAutomationProvider::IsTabIdValid( | 5910 void TestingAutomationProvider::IsTabIdValid( |
| 5911 DictionaryValue* args, IPC::Message* reply_message) { | 5911 DictionaryValue* args, IPC::Message* reply_message) { |
| 5912 AutomationJSONReply reply(this, reply_message); | 5912 AutomationJSONReply reply(this, reply_message); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6153 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl); | 6153 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl); |
| 6154 | 6154 |
| 6155 Send(reply_message_); | 6155 Send(reply_message_); |
| 6156 redirect_query_ = 0; | 6156 redirect_query_ = 0; |
| 6157 reply_message_ = NULL; | 6157 reply_message_ = NULL; |
| 6158 } | 6158 } |
| 6159 | 6159 |
| 6160 void TestingAutomationProvider::OnRemoveProvider() { | 6160 void TestingAutomationProvider::OnRemoveProvider() { |
| 6161 AutomationProviderList::GetInstance()->RemoveProvider(this); | 6161 AutomationProviderList::GetInstance()->RemoveProvider(this); |
| 6162 } | 6162 } |
| OLD | NEW |