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 "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 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 ListValue* paths = NULL; | 893 ListValue* paths = NULL; |
894 if (!args->GetList("paths", &paths)) { | 894 if (!args->GetList("paths", &paths)) { |
895 AutomationJSONReply(this, reply_message) | 895 AutomationJSONReply(this, reply_message) |
896 .SendError("'paths' missing or invalid"); | 896 .SendError("'paths' missing or invalid"); |
897 return; | 897 return; |
898 } | 898 } |
899 | 899 |
900 // Emulate drag and drop to set the file paths to the file upload control. | 900 // Emulate drag and drop to set the file paths to the file upload control. |
901 content::DropData drop_data; | 901 content::DropData drop_data; |
902 for (size_t path_index = 0; path_index < paths->GetSize(); ++path_index) { | 902 for (size_t path_index = 0; path_index < paths->GetSize(); ++path_index) { |
903 string16 path; | 903 base::string16 path; |
904 if (!paths->GetString(path_index, &path)) { | 904 if (!paths->GetString(path_index, &path)) { |
905 AutomationJSONReply(this, reply_message) | 905 AutomationJSONReply(this, reply_message) |
906 .SendError("'paths' contains a non-string type"); | 906 .SendError("'paths' contains a non-string type"); |
907 return; | 907 return; |
908 } | 908 } |
909 | 909 |
910 drop_data.filenames.push_back( | 910 drop_data.filenames.push_back( |
911 content::DropData::FileInfo(path, string16())); | 911 content::DropData::FileInfo(path, base::string16())); |
912 } | 912 } |
913 | 913 |
914 const gfx::Point client(x, y); | 914 const gfx::Point client(x, y); |
915 // We don't set any values in screen variable because DragTarget*** ignore the | 915 // We don't set any values in screen variable because DragTarget*** ignore the |
916 // screen argument. | 916 // screen argument. |
917 const gfx::Point screen; | 917 const gfx::Point screen; |
918 | 918 |
919 int operations = 0; | 919 int operations = 0; |
920 operations |= blink::WebDragOperationCopy; | 920 operations |= blink::WebDragOperationCopy; |
921 operations |= blink::WebDragOperationLink; | 921 operations |= blink::WebDragOperationLink; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 *success = false; | 994 *success = false; |
995 if (tab_tracker_->ContainsHandle(handle)) { | 995 if (tab_tracker_->ContainsHandle(handle)) { |
996 NavigationController* tab = tab_tracker_->GetResource(handle); | 996 NavigationController* tab = tab_tracker_->GetResource(handle); |
997 // Return what the user would see in the location bar. | 997 // Return what the user would see in the location bar. |
998 *url = tab->GetActiveEntry()->GetVirtualURL(); | 998 *url = tab->GetActiveEntry()->GetVirtualURL(); |
999 *success = true; | 999 *success = true; |
1000 } | 1000 } |
1001 } | 1001 } |
1002 | 1002 |
1003 void TestingAutomationProvider::ExecuteJavascriptInRenderViewFrame( | 1003 void TestingAutomationProvider::ExecuteJavascriptInRenderViewFrame( |
1004 const string16& frame_xpath, | 1004 const base::string16& frame_xpath, |
1005 const string16& script, | 1005 const base::string16& script, |
1006 IPC::Message* reply_message, | 1006 IPC::Message* reply_message, |
1007 RenderViewHost* render_view_host) { | 1007 RenderViewHost* render_view_host) { |
1008 // Set the routing id of this message with the controller. | 1008 // Set the routing id of this message with the controller. |
1009 // This routing id needs to be remembered for the reverse | 1009 // This routing id needs to be remembered for the reverse |
1010 // communication while sending back the response of | 1010 // communication while sending back the response of |
1011 // this javascript execution. | 1011 // this javascript execution. |
1012 render_view_host->ExecuteJavascriptInWebFrame( | 1012 render_view_host->ExecuteJavascriptInWebFrame( |
1013 frame_xpath, | 1013 frame_xpath, |
1014 UTF8ToUTF16("window.domAutomationController.setAutomationId(0);")); | 1014 UTF8ToUTF16("window.domAutomationController.setAutomationId(0);")); |
1015 render_view_host->ExecuteJavascriptInWebFrame( | 1015 render_view_host->ExecuteJavascriptInWebFrame( |
(...skipping 18 matching lines...) Expand all Loading... |
1034 web_contents->GetRenderViewHost()); | 1034 web_contents->GetRenderViewHost()); |
1035 } | 1035 } |
1036 | 1036 |
1037 // Sample json input: { "command": "OpenNewBrowserWindowWithNewProfile" } | 1037 // Sample json input: { "command": "OpenNewBrowserWindowWithNewProfile" } |
1038 // Sample output: {} | 1038 // Sample output: {} |
1039 void TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile( | 1039 void TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile( |
1040 base::DictionaryValue* args, IPC::Message* reply_message) { | 1040 base::DictionaryValue* args, IPC::Message* reply_message) { |
1041 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1041 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
1042 new BrowserOpenedWithNewProfileNotificationObserver(this, reply_message); | 1042 new BrowserOpenedWithNewProfileNotificationObserver(this, reply_message); |
1043 profile_manager->CreateMultiProfileAsync( | 1043 profile_manager->CreateMultiProfileAsync( |
1044 string16(), string16(), ProfileManager::CreateCallback(), std::string()); | 1044 base::string16(), base::string16(), ProfileManager::CreateCallback(), std:
:string()); |
1045 } | 1045 } |
1046 | 1046 |
1047 // Sample json input: { "command": "GetMultiProfileInfo" } | 1047 // Sample json input: { "command": "GetMultiProfileInfo" } |
1048 // See GetMultiProfileInfo() in pyauto.py for sample output. | 1048 // See GetMultiProfileInfo() in pyauto.py for sample output. |
1049 void TestingAutomationProvider::GetMultiProfileInfo( | 1049 void TestingAutomationProvider::GetMultiProfileInfo( |
1050 base::DictionaryValue* args, IPC::Message* reply_message) { | 1050 base::DictionaryValue* args, IPC::Message* reply_message) { |
1051 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 1051 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
1052 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1052 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
1053 const ProfileInfoCache& profile_info_cache = | 1053 const ProfileInfoCache& profile_info_cache = |
1054 profile_manager->GetProfileInfoCache(); | 1054 profile_manager->GetProfileInfoCache(); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 return; | 1291 return; |
1292 } | 1292 } |
1293 } | 1293 } |
1294 | 1294 |
1295 void TestingAutomationProvider::AddBookmark( | 1295 void TestingAutomationProvider::AddBookmark( |
1296 DictionaryValue* args, | 1296 DictionaryValue* args, |
1297 IPC::Message* reply_message) { | 1297 IPC::Message* reply_message) { |
1298 AutomationJSONReply reply(this, reply_message); | 1298 AutomationJSONReply reply(this, reply_message); |
1299 Browser* browser; | 1299 Browser* browser; |
1300 std::string error_msg, url; | 1300 std::string error_msg, url; |
1301 string16 title; | 1301 base::string16 title; |
1302 int parent_id, index; | 1302 int parent_id, index; |
1303 bool folder; | 1303 bool folder; |
1304 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 1304 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
1305 reply.SendError(error_msg); | 1305 reply.SendError(error_msg); |
1306 return; | 1306 return; |
1307 } | 1307 } |
1308 if (!args->GetBoolean("is_folder", &folder)) { | 1308 if (!args->GetBoolean("is_folder", &folder)) { |
1309 reply.SendError("'is_folder' missing or invalid"); | 1309 reply.SendError("'is_folder' missing or invalid"); |
1310 return; | 1310 return; |
1311 } | 1311 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 } | 1389 } |
1390 model->Move(node, new_parent, index); | 1390 model->Move(node, new_parent, index); |
1391 reply.SendSuccess(NULL); | 1391 reply.SendSuccess(NULL); |
1392 } | 1392 } |
1393 | 1393 |
1394 void TestingAutomationProvider::SetBookmarkTitle(DictionaryValue* args, | 1394 void TestingAutomationProvider::SetBookmarkTitle(DictionaryValue* args, |
1395 IPC::Message* reply_message) { | 1395 IPC::Message* reply_message) { |
1396 AutomationJSONReply reply(this, reply_message); | 1396 AutomationJSONReply reply(this, reply_message); |
1397 Browser* browser; | 1397 Browser* browser; |
1398 std::string error_msg; | 1398 std::string error_msg; |
1399 string16 title; | 1399 base::string16 title; |
1400 int id; | 1400 int id; |
1401 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 1401 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
1402 reply.SendError(error_msg); | 1402 reply.SendError(error_msg); |
1403 return; | 1403 return; |
1404 } | 1404 } |
1405 if (!args->GetInteger("id", &id)) { | 1405 if (!args->GetInteger("id", &id)) { |
1406 reply.SendError("'id' missing or invalid"); | 1406 reply.SendError("'id' missing or invalid"); |
1407 return; | 1407 return; |
1408 } | 1408 } |
1409 if (!args->GetString("title", &title)) { | 1409 if (!args->GetString("title", &title)) { |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2410 } | 2410 } |
2411 | 2411 |
2412 // Sample json input: { "command": "GetHistoryInfo", | 2412 // Sample json input: { "command": "GetHistoryInfo", |
2413 // "search_text": "some text" } | 2413 // "search_text": "some text" } |
2414 // Refer chrome/test/pyautolib/history_info.py for sample json output. | 2414 // Refer chrome/test/pyautolib/history_info.py for sample json output. |
2415 void TestingAutomationProvider::GetHistoryInfo(Browser* browser, | 2415 void TestingAutomationProvider::GetHistoryInfo(Browser* browser, |
2416 DictionaryValue* args, | 2416 DictionaryValue* args, |
2417 IPC::Message* reply_message) { | 2417 IPC::Message* reply_message) { |
2418 consumer_.CancelAllRequests(); | 2418 consumer_.CancelAllRequests(); |
2419 | 2419 |
2420 string16 search_text; | 2420 base::string16 search_text; |
2421 args->GetString("search_text", &search_text); | 2421 args->GetString("search_text", &search_text); |
2422 | 2422 |
2423 // Fetch history. | 2423 // Fetch history. |
2424 HistoryService* hs = HistoryServiceFactory::GetForProfile( | 2424 HistoryService* hs = HistoryServiceFactory::GetForProfile( |
2425 browser->profile(), Profile::EXPLICIT_ACCESS); | 2425 browser->profile(), Profile::EXPLICIT_ACCESS); |
2426 history::QueryOptions options; | 2426 history::QueryOptions options; |
2427 // The observer owns itself. It deletes itself after it fetches history. | 2427 // The observer owns itself. It deletes itself after it fetches history. |
2428 AutomationProviderHistoryObserver* history_observer = | 2428 AutomationProviderHistoryObserver* history_observer = |
2429 new AutomationProviderHistoryObserver(this, reply_message); | 2429 new AutomationProviderHistoryObserver(this, reply_message); |
2430 hs->QueryHistory( | 2430 hs->QueryHistory( |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2699 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 2699 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
2700 } | 2700 } |
2701 | 2701 |
2702 // Refer to pyauto.py for sample JSON input. | 2702 // Refer to pyauto.py for sample JSON input. |
2703 void TestingAutomationProvider::AddOrEditSearchEngine( | 2703 void TestingAutomationProvider::AddOrEditSearchEngine( |
2704 Browser* browser, | 2704 Browser* browser, |
2705 DictionaryValue* args, | 2705 DictionaryValue* args, |
2706 IPC::Message* reply_message) { | 2706 IPC::Message* reply_message) { |
2707 TemplateURLService* url_model = | 2707 TemplateURLService* url_model = |
2708 TemplateURLServiceFactory::GetForProfile(browser->profile()); | 2708 TemplateURLServiceFactory::GetForProfile(browser->profile()); |
2709 string16 new_title; | 2709 base::string16 new_title; |
2710 string16 new_keyword; | 2710 base::string16 new_keyword; |
2711 std::string new_url; | 2711 std::string new_url; |
2712 std::string keyword; | 2712 std::string keyword; |
2713 if (!args->GetString("new_title", &new_title) || | 2713 if (!args->GetString("new_title", &new_title) || |
2714 !args->GetString("new_keyword", &new_keyword) || | 2714 !args->GetString("new_keyword", &new_keyword) || |
2715 !args->GetString("new_url", &new_url)) { | 2715 !args->GetString("new_url", &new_url)) { |
2716 AutomationJSONReply(this, reply_message).SendError( | 2716 AutomationJSONReply(this, reply_message).SendError( |
2717 "One or more inputs invalid"); | 2717 "One or more inputs invalid"); |
2718 return; | 2718 return; |
2719 } | 2719 } |
2720 std::string new_ref_url = TemplateURLRef::DisplayURLToURLRef( | 2720 std::string new_ref_url = TemplateURLRef::DisplayURLToURLRef( |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2916 return_value->Set("properties", properties); | 2916 return_value->Set("properties", properties); |
2917 | 2917 |
2918 reply.SendSuccess(return_value.get()); | 2918 reply.SendSuccess(return_value.get()); |
2919 } | 2919 } |
2920 | 2920 |
2921 // Sample json input: { "command": "SetOmniboxText", | 2921 // Sample json input: { "command": "SetOmniboxText", |
2922 // "text": "goog" } | 2922 // "text": "goog" } |
2923 void TestingAutomationProvider::SetOmniboxText(Browser* browser, | 2923 void TestingAutomationProvider::SetOmniboxText(Browser* browser, |
2924 DictionaryValue* args, | 2924 DictionaryValue* args, |
2925 IPC::Message* reply_message) { | 2925 IPC::Message* reply_message) { |
2926 string16 text; | 2926 base::string16 text; |
2927 AutomationJSONReply reply(this, reply_message); | 2927 AutomationJSONReply reply(this, reply_message); |
2928 if (!args->GetString("text", &text)) { | 2928 if (!args->GetString("text", &text)) { |
2929 reply.SendError("text missing"); | 2929 reply.SendError("text missing"); |
2930 return; | 2930 return; |
2931 } | 2931 } |
2932 chrome::FocusLocationBar(browser); | 2932 chrome::FocusLocationBar(browser); |
2933 LocationBar* loc_bar = browser->window()->GetLocationBar(); | 2933 LocationBar* loc_bar = browser->window()->GetLocationBar(); |
2934 if (!loc_bar) { | 2934 if (!loc_bar) { |
2935 reply.SendError("The specified browser does not have a location bar."); | 2935 reply.SendError("The specified browser does not have a location bar."); |
2936 return; | 2936 return; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3155 // If the time is specified, change time to the specified time. | 3155 // If the time is specified, change time to the specified time. |
3156 base::Time time = base::Time::Now(); | 3156 base::Time time = base::Time::Now(); |
3157 int it; | 3157 int it; |
3158 double dt; | 3158 double dt; |
3159 if (password_dict.GetInteger("time", &it)) | 3159 if (password_dict.GetInteger("time", &it)) |
3160 time = base::Time::FromTimeT(it); | 3160 time = base::Time::FromTimeT(it); |
3161 else if (password_dict.GetDouble("time", &dt)) | 3161 else if (password_dict.GetDouble("time", &dt)) |
3162 time = base::Time::FromDoubleT(dt); | 3162 time = base::Time::FromDoubleT(dt); |
3163 | 3163 |
3164 std::string signon_realm; | 3164 std::string signon_realm; |
3165 string16 username_value; | 3165 base::string16 username_value; |
3166 string16 password_value; | 3166 base::string16 password_value; |
3167 string16 origin_url_text; | 3167 base::string16 origin_url_text; |
3168 string16 username_element; | 3168 base::string16 username_element; |
3169 string16 password_element; | 3169 base::string16 password_element; |
3170 string16 submit_element; | 3170 base::string16 submit_element; |
3171 string16 action_target_text; | 3171 base::string16 action_target_text; |
3172 bool blacklist; | 3172 bool blacklist; |
3173 string16 old_password_element; | 3173 base::string16 old_password_element; |
3174 string16 old_password_value; | 3174 base::string16 old_password_value; |
3175 | 3175 |
3176 // We don't care if any of these fail - they are either optional or checked | 3176 // We don't care if any of these fail - they are either optional or checked |
3177 // before this function is called. | 3177 // before this function is called. |
3178 password_dict.GetString("signon_realm", &signon_realm); | 3178 password_dict.GetString("signon_realm", &signon_realm); |
3179 password_dict.GetString("username_value", &username_value); | 3179 password_dict.GetString("username_value", &username_value); |
3180 password_dict.GetString("password_value", &password_value); | 3180 password_dict.GetString("password_value", &password_value); |
3181 password_dict.GetString("origin_url", &origin_url_text); | 3181 password_dict.GetString("origin_url", &origin_url_text); |
3182 password_dict.GetString("username_element", &username_element); | 3182 password_dict.GetString("username_element", &username_element); |
3183 password_dict.GetString("password_element", &password_element); | 3183 password_dict.GetString("password_element", &password_element); |
3184 password_dict.GetString("submit_element", &submit_element); | 3184 password_dict.GetString("submit_element", &submit_element); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3344 Browser* browser, | 3344 Browser* browser, |
3345 DictionaryValue* args, | 3345 DictionaryValue* args, |
3346 IPC::Message* reply_message) { | 3346 IPC::Message* reply_message) { |
3347 std::string error_message; | 3347 std::string error_message; |
3348 WebContents* web_contents = | 3348 WebContents* web_contents = |
3349 GetWebContentsFromDict(browser, args, &error_message); | 3349 GetWebContentsFromDict(browser, args, &error_message); |
3350 if (!web_contents) { | 3350 if (!web_contents) { |
3351 AutomationJSONReply(this, reply_message).SendError(error_message); | 3351 AutomationJSONReply(this, reply_message).SendError(error_message); |
3352 return; | 3352 return; |
3353 } | 3353 } |
3354 string16 search_string; | 3354 base::string16 search_string; |
3355 bool forward; | 3355 bool forward; |
3356 bool match_case; | 3356 bool match_case; |
3357 bool find_next; | 3357 bool find_next; |
3358 if (!args->GetString("search_string", &search_string)) { | 3358 if (!args->GetString("search_string", &search_string)) { |
3359 AutomationJSONReply(this, reply_message). | 3359 AutomationJSONReply(this, reply_message). |
3360 SendError("Must include search_string string."); | 3360 SendError("Must include search_string string."); |
3361 return; | 3361 return; |
3362 } | 3362 } |
3363 if (!args->GetBoolean("forward", &forward)) { | 3363 if (!args->GetBoolean("forward", &forward)) { |
3364 AutomationJSONReply(this, reply_message). | 3364 AutomationJSONReply(this, reply_message). |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4070 base::KillProcess(process, 0, false); | 4070 base::KillProcess(process, 0, false); |
4071 base::CloseProcessHandle(process); | 4071 base::CloseProcessHandle(process); |
4072 } | 4072 } |
4073 | 4073 |
4074 bool TestingAutomationProvider::BuildWebKeyEventFromArgs( | 4074 bool TestingAutomationProvider::BuildWebKeyEventFromArgs( |
4075 DictionaryValue* args, | 4075 DictionaryValue* args, |
4076 std::string* error, | 4076 std::string* error, |
4077 NativeWebKeyboardEvent* event) { | 4077 NativeWebKeyboardEvent* event) { |
4078 int type, modifiers; | 4078 int type, modifiers; |
4079 bool is_system_key; | 4079 bool is_system_key; |
4080 string16 unmodified_text, text; | 4080 base::string16 unmodified_text, text; |
4081 std::string key_identifier; | 4081 std::string key_identifier; |
4082 if (!args->GetInteger("type", &type)) { | 4082 if (!args->GetInteger("type", &type)) { |
4083 *error = "'type' missing or invalid."; | 4083 *error = "'type' missing or invalid."; |
4084 return false; | 4084 return false; |
4085 } | 4085 } |
4086 if (!args->GetBoolean("isSystemKey", &is_system_key)) { | 4086 if (!args->GetBoolean("isSystemKey", &is_system_key)) { |
4087 *error = "'isSystemKey' missing or invalid."; | 4087 *error = "'isSystemKey' missing or invalid."; |
4088 return false; | 4088 return false; |
4089 } | 4089 } |
4090 if (!args->GetString("unmodifiedText", &unmodified_text)) { | 4090 if (!args->GetString("unmodifiedText", &unmodified_text)) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4122 event->type = blink::WebInputEvent::KeyDown; | 4122 event->type = blink::WebInputEvent::KeyDown; |
4123 } else if (type == automation::kKeyUpType) { | 4123 } else if (type == automation::kKeyUpType) { |
4124 event->type = blink::WebInputEvent::KeyUp; | 4124 event->type = blink::WebInputEvent::KeyUp; |
4125 } else if (type == automation::kCharType) { | 4125 } else if (type == automation::kCharType) { |
4126 event->type = blink::WebInputEvent::Char; | 4126 event->type = blink::WebInputEvent::Char; |
4127 } else { | 4127 } else { |
4128 *error = "'type' refers to an unrecognized keyboard event type"; | 4128 *error = "'type' refers to an unrecognized keyboard event type"; |
4129 return false; | 4129 return false; |
4130 } | 4130 } |
4131 | 4131 |
4132 string16 unmodified_text_truncated = unmodified_text.substr( | 4132 base::string16 unmodified_text_truncated = unmodified_text.substr( |
4133 0, blink::WebKeyboardEvent::textLengthCap - 1); | 4133 0, blink::WebKeyboardEvent::textLengthCap - 1); |
4134 memcpy(event->unmodifiedText, | 4134 memcpy(event->unmodifiedText, |
4135 unmodified_text_truncated.c_str(), | 4135 unmodified_text_truncated.c_str(), |
4136 unmodified_text_truncated.length() + 1); | 4136 unmodified_text_truncated.length() + 1); |
4137 string16 text_truncated = text.substr( | 4137 base::string16 text_truncated = text.substr( |
4138 0, blink::WebKeyboardEvent::textLengthCap - 1); | 4138 0, blink::WebKeyboardEvent::textLengthCap - 1); |
4139 memcpy(event->text, text_truncated.c_str(), text_truncated.length() + 1); | 4139 memcpy(event->text, text_truncated.c_str(), text_truncated.length() + 1); |
4140 | 4140 |
4141 event->modifiers = 0; | 4141 event->modifiers = 0; |
4142 if (modifiers & automation::kShiftKeyMask) | 4142 if (modifiers & automation::kShiftKeyMask) |
4143 event->modifiers |= blink::WebInputEvent::ShiftKey; | 4143 event->modifiers |= blink::WebInputEvent::ShiftKey; |
4144 if (modifiers & automation::kControlKeyMask) | 4144 if (modifiers & automation::kControlKeyMask) |
4145 event->modifiers |= blink::WebInputEvent::ControlKey; | 4145 event->modifiers |= blink::WebInputEvent::ControlKey; |
4146 if (modifiers & automation::kAltKeyMask) | 4146 if (modifiers & automation::kAltKeyMask) |
4147 event->modifiers |= blink::WebInputEvent::AltKey; | 4147 event->modifiers |= blink::WebInputEvent::AltKey; |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4714 return; | 4714 return; |
4715 } | 4715 } |
4716 } | 4716 } |
4717 | 4717 |
4718 void TestingAutomationProvider::ExecuteJavascriptJSON( | 4718 void TestingAutomationProvider::ExecuteJavascriptJSON( |
4719 DictionaryValue* args, | 4719 DictionaryValue* args, |
4720 IPC::Message* reply_message) { | 4720 IPC::Message* reply_message) { |
4721 if (SendErrorIfModalDialogActive(this, reply_message)) | 4721 if (SendErrorIfModalDialogActive(this, reply_message)) |
4722 return; | 4722 return; |
4723 | 4723 |
4724 string16 frame_xpath, javascript; | 4724 base::string16 frame_xpath, javascript; |
4725 std::string error; | 4725 std::string error; |
4726 RenderViewHost* render_view; | 4726 RenderViewHost* render_view; |
4727 if (!GetRenderViewFromJSONArgs(args, profile(), &render_view, &error)) { | 4727 if (!GetRenderViewFromJSONArgs(args, profile(), &render_view, &error)) { |
4728 AutomationJSONReply(this, reply_message).SendError(error); | 4728 AutomationJSONReply(this, reply_message).SendError(error); |
4729 return; | 4729 return; |
4730 } | 4730 } |
4731 if (!args->GetString("frame_xpath", &frame_xpath)) { | 4731 if (!args->GetString("frame_xpath", &frame_xpath)) { |
4732 AutomationJSONReply(this, reply_message) | 4732 AutomationJSONReply(this, reply_message) |
4733 .SendError("'frame_xpath' missing or invalid"); | 4733 .SendError("'frame_xpath' missing or invalid"); |
4734 return; | 4734 return; |
4735 } | 4735 } |
4736 if (!args->GetString("javascript", &javascript)) { | 4736 if (!args->GetString("javascript", &javascript)) { |
4737 AutomationJSONReply(this, reply_message) | 4737 AutomationJSONReply(this, reply_message) |
4738 .SendError("'javascript' missing or invalid"); | 4738 .SendError("'javascript' missing or invalid"); |
4739 return; | 4739 return; |
4740 } | 4740 } |
4741 | 4741 |
4742 new DomOperationMessageSender(this, reply_message, true); | 4742 new DomOperationMessageSender(this, reply_message, true); |
4743 ExecuteJavascriptInRenderViewFrame(frame_xpath, javascript, reply_message, | 4743 ExecuteJavascriptInRenderViewFrame(frame_xpath, javascript, reply_message, |
4744 render_view); | 4744 render_view); |
4745 } | 4745 } |
4746 | 4746 |
4747 void TestingAutomationProvider::ExecuteJavascriptInRenderView( | 4747 void TestingAutomationProvider::ExecuteJavascriptInRenderView( |
4748 DictionaryValue* args, | 4748 DictionaryValue* args, |
4749 IPC::Message* reply_message) { | 4749 IPC::Message* reply_message) { |
4750 string16 frame_xpath, javascript, extension_id, url_text; | 4750 base::string16 frame_xpath, javascript, extension_id, url_text; |
4751 int render_process_id, render_view_id; | 4751 int render_process_id, render_view_id; |
4752 if (!args->GetString("frame_xpath", &frame_xpath)) { | 4752 if (!args->GetString("frame_xpath", &frame_xpath)) { |
4753 AutomationJSONReply(this, reply_message) | 4753 AutomationJSONReply(this, reply_message) |
4754 .SendError("'frame_xpath' missing or invalid"); | 4754 .SendError("'frame_xpath' missing or invalid"); |
4755 return; | 4755 return; |
4756 } | 4756 } |
4757 if (!args->GetString("javascript", &javascript)) { | 4757 if (!args->GetString("javascript", &javascript)) { |
4758 AutomationJSONReply(this, reply_message) | 4758 AutomationJSONReply(this, reply_message) |
4759 .SendError("'javascript' missing or invalid"); | 4759 .SendError("'javascript' missing or invalid"); |
4760 return; | 4760 return; |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5452 if (g_browser_process) | 5452 if (g_browser_process) |
5453 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 5453 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
5454 } | 5454 } |
5455 | 5455 |
5456 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 5456 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
5457 WebContents* tab) { | 5457 WebContents* tab) { |
5458 TabStripModel* tab_strip = browser->tab_strip_model(); | 5458 TabStripModel* tab_strip = browser->tab_strip_model(); |
5459 if (tab_strip->GetActiveWebContents() != tab) | 5459 if (tab_strip->GetActiveWebContents() != tab) |
5460 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); | 5460 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); |
5461 } | 5461 } |
OLD | NEW |