Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Side by Side Diff: chrome/test/automation/automation_json_requests.cc

Issue 8649004: Allow chromedriver to install an extension and get all installed extension IDs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/test/automation/automation_json_requests.h" 5 #include "chrome/test/automation/automation_json_requests.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 ui::KeyboardCode key_code, 73 ui::KeyboardCode key_code,
74 const std::string& unmodified_text, 74 const std::string& unmodified_text,
75 const std::string& modified_text, 75 const std::string& modified_text,
76 int modifiers) 76 int modifiers)
77 : type(type), 77 : type(type),
78 key_code(key_code), 78 key_code(key_code),
79 unmodified_text(unmodified_text), 79 unmodified_text(unmodified_text),
80 modified_text(modified_text), 80 modified_text(modified_text),
81 modifiers(modifiers) {} 81 modifiers(modifiers) {}
82 82
83 WebViewInfo::WebViewInfo(
84 AutomationId::Type type,
85 const WebViewId& view_id,
86 const std::string& extension_id)
87 : type(type),
88 view_id(view_id),
89 extension_id(extension_id) {}
90
91 WebViewInfo::~WebViewInfo() {}
92
93 /*
94 WebViewLocator::WebViewLocator() {}
95
96 WebViewLocator::~WebViewLocator() {}
97 */
98
99 void WebViewLocator::UpdateDictionary(DictionaryValue* dict) const {
100 if (type == kTypeIndexPair) {
101 dict->SetInteger("windex", locator.index_pair.browser_index);
102 dict->SetInteger("tab_index", locator.index_pair.tab_index);
103 } else if (type == kTypeViewId) {
104 dict->Set("view_id", locator.view_id.ToValue());
105 }
106 }
107
108 void WebViewId::UpdateDictionary(DictionaryValue* dict) const {
109 if (type == kTypeTabId) {
110 dict->SetInteger("id", id.tab_id);
111 } else if (type == kTypeViewId) {
112 dict->Set("view_id", id.view_id.ToValue());
113 }
114 }
115
116 /*
117 WebViewId::WebViewId() {}
118
119 WebViewId::~WebViewId() {}
120 */
121
83 bool SendAutomationJSONRequest(AutomationMessageSender* sender, 122 bool SendAutomationJSONRequest(AutomationMessageSender* sender,
84 const std::string& request, 123 const std::string& request,
85 int timeout_ms, 124 int timeout_ms,
86 std::string* reply, 125 std::string* reply,
87 bool* success) { 126 bool* success) {
88 return sender->Send(new AutomationMsg_SendJSONRequest( 127 return sender->Send(new AutomationMsg_SendJSONRequest(
89 -1, request, reply, success), timeout_ms); 128 -1, request, reply, success), timeout_ms);
90 } 129 }
91 130
92 bool SendAutomationJSONRequestWithDefaultTimeout( 131 bool SendAutomationJSONRequestWithDefaultTimeout(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 return false; 194 return false;
156 int response = 0; 195 int response = 0;
157 if (!reply_dict.GetInteger("result", &response)) 196 if (!reply_dict.GetInteger("result", &response))
158 return false; 197 return false;
159 *nav_response = static_cast<AutomationMsg_NavigationResponseValues>(response); 198 *nav_response = static_cast<AutomationMsg_NavigationResponseValues>(response);
160 return true; 199 return true;
161 } 200 }
162 201
163 bool SendExecuteJavascriptJSONRequest( 202 bool SendExecuteJavascriptJSONRequest(
164 AutomationMessageSender* sender, 203 AutomationMessageSender* sender,
165 int browser_index, 204 const WebViewLocator& locator,
166 int tab_index,
167 const std::string& frame_xpath, 205 const std::string& frame_xpath,
168 const std::string& javascript, 206 const std::string& javascript,
169 Value** result, 207 Value** result,
170 std::string* error_msg) { 208 std::string* error_msg) {
171 DictionaryValue dict; 209 DictionaryValue dict;
172 dict.SetString("command", "ExecuteJavascript"); 210 dict.SetString("command", "ExecuteJavascript");
173 dict.SetInteger("windex", browser_index); 211 locator.UpdateDictionary(&dict);
174 dict.SetInteger("tab_index", tab_index);
175 dict.SetString("frame_xpath", frame_xpath); 212 dict.SetString("frame_xpath", frame_xpath);
176 dict.SetString("javascript", javascript); 213 dict.SetString("javascript", javascript);
177 DictionaryValue reply_dict; 214 DictionaryValue reply_dict;
178 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg)) 215 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
179 return false; 216 return false;
180 217
181 std::string json; 218 std::string json;
182 if (!reply_dict.GetString("result", &json)) { 219 if (!reply_dict.GetString("result", &json)) {
183 LOG(ERROR) << "Executed javascript but received no 'result'"; 220 LOG(ERROR) << "Executed javascript but received no 'result'";
184 return false; 221 return false;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 DictionaryValue dict; 283 DictionaryValue dict;
247 dict.SetString("command", "CaptureEntirePage"); 284 dict.SetString("command", "CaptureEntirePage");
248 dict.SetInteger("windex", browser_index); 285 dict.SetInteger("windex", browser_index);
249 dict.SetInteger("tab_index", tab_index); 286 dict.SetInteger("tab_index", tab_index);
250 dict.SetString("path", path.value()); 287 dict.SetString("path", path.value());
251 DictionaryValue reply_dict; 288 DictionaryValue reply_dict;
252 289
253 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); 290 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
254 } 291 }
255 292
256 bool SendGetTabURLJSONRequest(
257 AutomationMessageSender* sender,
258 int browser_index,
259 int tab_index,
260 std::string* url,
261 std::string* error_msg) {
262 DictionaryValue dict;
263 dict.SetString("command", "GetTabURL");
264 dict.SetInteger("windex", browser_index);
265 dict.SetInteger("tab_index", tab_index);
266 DictionaryValue reply_dict;
267 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
268 return false;
269 return reply_dict.GetString("url", url);
270 }
271
272 bool SendGetTabTitleJSONRequest(
273 AutomationMessageSender* sender,
274 int browser_index,
275 int tab_index,
276 std::string* tab_title,
277 std::string* error_msg) {
278 DictionaryValue dict;
279 dict.SetString("command", "GetTabTitle");
280 dict.SetInteger("windex", browser_index);
281 dict.SetInteger("tab_index", tab_index);
282 DictionaryValue reply_dict;
283 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
284 return false;
285 return reply_dict.GetString("title", tab_title);
286 }
287
288 bool SendGetCookiesJSONRequest( 293 bool SendGetCookiesJSONRequest(
289 AutomationMessageSender* sender, 294 AutomationMessageSender* sender,
290 const std::string& url, 295 const std::string& url,
291 ListValue** cookies, 296 ListValue** cookies,
292 std::string* error_msg) { 297 std::string* error_msg) {
293 DictionaryValue dict; 298 DictionaryValue dict;
294 dict.SetString("command", "GetCookies"); 299 dict.SetString("command", "GetCookies");
295 dict.SetString("url", url); 300 dict.SetString("url", url);
296 DictionaryValue reply_dict; 301 DictionaryValue reply_dict;
297 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg)) 302 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
(...skipping 29 matching lines...) Expand all
327 DictionaryValue dict; 332 DictionaryValue dict;
328 dict.SetString("command", "SetCookie"); 333 dict.SetString("command", "SetCookie");
329 dict.SetString("url", url); 334 dict.SetString("url", url);
330 dict.Set("cookie", cookie_dict->DeepCopy()); 335 dict.Set("cookie", cookie_dict->DeepCopy());
331 DictionaryValue reply_dict; 336 DictionaryValue reply_dict;
332 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); 337 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
333 } 338 }
334 339
335 bool SendGetTabIdsJSONRequest( 340 bool SendGetTabIdsJSONRequest(
336 AutomationMessageSender* sender, 341 AutomationMessageSender* sender,
337 std::vector<int>* tab_ids, 342 std::vector<WebViewInfo>* views,
338 std::string* error_msg) { 343 std::string* error_msg) {
339 DictionaryValue dict; 344 DictionaryValue dict;
340 dict.SetString("command", "GetTabIds"); 345 dict.SetString("command", "GetTabIds");
341 DictionaryValue reply_dict; 346 DictionaryValue reply_dict;
342 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg)) 347 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
343 return false; 348 return false;
344 ListValue* id_list; 349 ListValue* id_list;
345 if (!reply_dict.GetList("ids", &id_list)) { 350 if (reply_dict.GetList("ids", &id_list)) {
346 LOG(ERROR) << "Returned 'ids' key is missing or invalid"; 351 for (size_t i = 0; i < id_list->GetSize(); ++i) {
352 int id;
353 if (!id_list->GetInteger(i, &id)) {
354 *error_msg = "Returned id in 'tab_ids' is not an integer";
355 return false;
356 }
357 views->push_back(WebViewInfo(
358 AutomationId::kTypeTab, WebViewId::ForTab(id), std::string()));
359 }
360 }
361 return true;
362 }
363
364 bool SendGetWebViewsJSONRequest(
365 AutomationMessageSender* sender,
366 std::vector<WebViewInfo>* views,
367 std::string* error_msg) {
368 DictionaryValue dict;
369 dict.SetString("command", "GetViews");
370 DictionaryValue reply_dict;
371 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
372 return false;
373 ListValue* views_list;
374 if (!reply_dict.GetList("views", &views_list)) {
375 *error_msg = "Returned 'views' key is missing or invalid";
347 return false; 376 return false;
348 } 377 }
349 std::vector<int> temp_ids; 378 for (size_t i = 0; i < views_list->GetSize(); ++i) {
350 for (size_t i = 0; i < id_list->GetSize(); ++i) { 379 DictionaryValue* view_dict;
351 int id; 380 if (!views_list->GetDictionary(i, &view_dict)) {
352 if (!id_list->GetInteger(i, &id)) { 381 *error_msg = "Returned 'views' key contains non-dictionary values";
353 LOG(ERROR) << "Returned 'ids' key contains non-integer values";
354 return false; 382 return false;
355 } 383 }
356 temp_ids.push_back(id); 384 Value* view_id_value;
385 std::string extension_id;
386 if (!view_dict->Get("view_id", &view_id_value)) {
387 *error_msg = "Missing 'view_id'";
388 return false;
389 }
390 AutomationId view_id;
391 if (!AutomationId::FromValue(view_id_value, &view_id, error_msg))
392 return false;
393 view_dict->GetString("extension_id", &extension_id);
394 views->push_back(WebViewInfo(
395 static_cast<AutomationId::Type>(0), WebViewId::ForView(view_id), extensi on_id));
357 } 396 }
358 *tab_ids = temp_ids;
359 return true; 397 return true;
360 } 398 }
361 399
362 bool SendIsTabIdValidJSONRequest( 400 bool SendIsTabIdValidJSONRequest(
363 AutomationMessageSender* sender, 401 AutomationMessageSender* sender,
364 int tab_id, 402 const WebViewId& view_id,
365 bool* is_valid, 403 bool* is_valid,
366 std::string* error_msg) { 404 std::string* error_msg) {
367 DictionaryValue dict; 405 DictionaryValue dict;
368 dict.SetString("command", "IsTabIdValid"); 406 dict.SetString("command", "IsTabIdValid");
369 dict.SetInteger("id", tab_id); 407 view_id.UpdateDictionary(&dict);
370 DictionaryValue reply_dict; 408 DictionaryValue reply_dict;
371 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg)) 409 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
372 return false; 410 return false;
373 return reply_dict.GetBoolean("is_valid", is_valid); 411 return reply_dict.GetBoolean("is_valid", is_valid);
374 } 412 }
375 413
414 bool SendDoesViewExistJSONRequest(
415 AutomationMessageSender* sender,
416 const WebViewId& view_id,
417 bool* does_exist,
418 std::string* error_msg) {
419 DictionaryValue dict;
420 dict.SetString("command", "DoesViewExist");
421 view_id.UpdateDictionary(&dict);
422 DictionaryValue reply_dict;
423 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
424 return false;
425 return reply_dict.GetBoolean("does_exist", does_exist);
426 }
427
376 bool SendCloseTabJSONRequest( 428 bool SendCloseTabJSONRequest(
377 AutomationMessageSender* sender, 429 AutomationMessageSender* sender,
378 int browser_index, 430 int browser_index,
379 int tab_index, 431 int tab_index,
380 std::string* error_msg) { 432 std::string* error_msg) {
381 DictionaryValue dict; 433 DictionaryValue dict;
382 dict.SetString("command", "CloseTab"); 434 dict.SetString("command", "CloseTab");
383 dict.SetInteger("windex", browser_index); 435 dict.SetInteger("windex", browser_index);
384 dict.SetInteger("tab_index", tab_index); 436 dict.SetInteger("tab_index", tab_index);
385 DictionaryValue reply_dict; 437 DictionaryValue reply_dict;
386 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); 438 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
387 } 439 }
388 440
389 bool SendMouseMoveJSONRequest( 441 bool SendMouseMoveJSONRequest(
390 AutomationMessageSender* sender, 442 AutomationMessageSender* sender,
391 int browser_index, 443 const WebViewLocator& locator,
392 int tab_index,
393 int x, 444 int x,
394 int y, 445 int y,
395 std::string* error_msg) { 446 std::string* error_msg) {
396 DictionaryValue dict; 447 DictionaryValue dict;
397 dict.SetString("command", "WebkitMouseMove"); 448 dict.SetString("command", "WebkitMouseMove");
398 dict.SetInteger("windex", browser_index); 449 locator.UpdateDictionary(&dict);
399 dict.SetInteger("tab_index", tab_index);
400 dict.SetInteger("x", x); 450 dict.SetInteger("x", x);
401 dict.SetInteger("y", y); 451 dict.SetInteger("y", y);
402 DictionaryValue reply_dict; 452 DictionaryValue reply_dict;
403 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); 453 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
404 } 454 }
405 455
406 bool SendMouseClickJSONRequest( 456 bool SendMouseClickJSONRequest(
407 AutomationMessageSender* sender, 457 AutomationMessageSender* sender,
408 int browser_index, 458 const WebViewLocator& locator,
409 int tab_index,
410 automation::MouseButton button, 459 automation::MouseButton button,
411 int x, 460 int x,
412 int y, 461 int y,
413 std::string* error_msg) { 462 std::string* error_msg) {
414 DictionaryValue dict; 463 DictionaryValue dict;
415 dict.SetString("command", "WebkitMouseClick"); 464 dict.SetString("command", "WebkitMouseClick");
416 dict.SetInteger("windex", browser_index); 465 locator.UpdateDictionary(&dict);
417 dict.SetInteger("tab_index", tab_index);
418 dict.SetInteger("button", button); 466 dict.SetInteger("button", button);
419 dict.SetInteger("x", x); 467 dict.SetInteger("x", x);
420 dict.SetInteger("y", y); 468 dict.SetInteger("y", y);
421 DictionaryValue reply_dict; 469 DictionaryValue reply_dict;
422 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); 470 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
423 } 471 }
424 472
425 bool SendMouseDragJSONRequest( 473 bool SendMouseDragJSONRequest(
426 AutomationMessageSender* sender, 474 AutomationMessageSender* sender,
427 int browser_index, 475 const WebViewLocator& locator,
428 int tab_index,
429 int start_x, 476 int start_x,
430 int start_y, 477 int start_y,
431 int end_x, 478 int end_x,
432 int end_y, 479 int end_y,
433 std::string* error_msg) { 480 std::string* error_msg) {
434 DictionaryValue dict; 481 DictionaryValue dict;
435 dict.SetString("command", "WebkitMouseDrag"); 482 dict.SetString("command", "WebkitMouseDrag");
436 dict.SetInteger("windex", browser_index); 483 locator.UpdateDictionary(&dict);
437 dict.SetInteger("tab_index", tab_index);
438 dict.SetInteger("start_x", start_x); 484 dict.SetInteger("start_x", start_x);
439 dict.SetInteger("start_y", start_y); 485 dict.SetInteger("start_y", start_y);
440 dict.SetInteger("end_x", end_x); 486 dict.SetInteger("end_x", end_x);
441 dict.SetInteger("end_y", end_y); 487 dict.SetInteger("end_y", end_y);
442 DictionaryValue reply_dict; 488 DictionaryValue reply_dict;
443 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); 489 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
444 } 490 }
445 491
446 bool SendMouseButtonDownJSONRequest( 492 bool SendMouseButtonDownJSONRequest(
447 AutomationMessageSender* sender, 493 AutomationMessageSender* sender,
448 int browser_index, 494 const WebViewLocator& locator,
449 int tab_index,
450 int x, 495 int x,
451 int y, 496 int y,
452 std::string* error_msg) { 497 std::string* error_msg) {
453 DictionaryValue dict; 498 DictionaryValue dict;
454 dict.SetString("command", "WebkitMouseButtonDown"); 499 dict.SetString("command", "WebkitMouseButtonDown");
455 dict.SetInteger("windex", browser_index); 500 locator.UpdateDictionary(&dict);
456 dict.SetInteger("tab_index", tab_index);
457 dict.SetInteger("x", x); 501 dict.SetInteger("x", x);
458 dict.SetInteger("y", y); 502 dict.SetInteger("y", y);
459 DictionaryValue reply_dict; 503 DictionaryValue reply_dict;
460 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); 504 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
461 } 505 }
462 506
463 bool SendMouseButtonUpJSONRequest( 507 bool SendMouseButtonUpJSONRequest(
464 AutomationMessageSender* sender, 508 AutomationMessageSender* sender,
465 int browser_index, 509 const WebViewLocator& locator,
466 int tab_index,
467 int x, 510 int x,
468 int y, 511 int y,
469 std::string* error_msg) { 512 std::string* error_msg) {
470 DictionaryValue dict; 513 DictionaryValue dict;
471 dict.SetString("command", "WebkitMouseButtonUp"); 514 dict.SetString("command", "WebkitMouseButtonUp");
472 dict.SetInteger("windex", browser_index); 515 locator.UpdateDictionary(&dict);
473 dict.SetInteger("tab_index", tab_index);
474 dict.SetInteger("x", x); 516 dict.SetInteger("x", x);
475 dict.SetInteger("y", y); 517 dict.SetInteger("y", y);
476 DictionaryValue reply_dict; 518 DictionaryValue reply_dict;
477 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); 519 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
478 } 520 }
479 521
480 bool SendMouseDoubleClickJSONRequest( 522 bool SendMouseDoubleClickJSONRequest(
481 AutomationMessageSender* sender, 523 AutomationMessageSender* sender,
482 int browser_index, 524 const WebViewLocator& locator,
483 int tab_index,
484 int x, 525 int x,
485 int y, 526 int y,
486 std::string* error_msg) { 527 std::string* error_msg) {
487 DictionaryValue dict; 528 DictionaryValue dict;
488 dict.SetString("command", "WebkitMouseDoubleClick"); 529 dict.SetString("command", "WebkitMouseDoubleClick");
489 dict.SetInteger("windex", browser_index); 530 locator.UpdateDictionary(&dict);
490 dict.SetInteger("tab_index", tab_index);
491 dict.SetInteger("x", x); 531 dict.SetInteger("x", x);
492 dict.SetInteger("y", y); 532 dict.SetInteger("y", y);
493 DictionaryValue reply_dict; 533 DictionaryValue reply_dict;
494 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); 534 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
495 } 535 }
496 536
497 bool SendWebKeyEventJSONRequest( 537 bool SendWebKeyEventJSONRequest(
498 AutomationMessageSender* sender, 538 AutomationMessageSender* sender,
499 int browser_index, 539 const WebViewLocator& locator,
500 int tab_index,
501 const WebKeyEvent& key_event, 540 const WebKeyEvent& key_event,
502 std::string* error_msg) { 541 std::string* error_msg) {
503 DictionaryValue dict; 542 DictionaryValue dict;
504 dict.SetString("command", "SendWebkitKeyEvent"); 543 dict.SetString("command", "SendWebkitKeyEvent");
505 dict.SetInteger("windex", browser_index); 544 locator.UpdateDictionary(&dict);
506 dict.SetInteger("tab_index", tab_index);
507 dict.SetInteger("type", key_event.type); 545 dict.SetInteger("type", key_event.type);
508 dict.SetInteger("nativeKeyCode", key_event.key_code); 546 dict.SetInteger("nativeKeyCode", key_event.key_code);
509 dict.SetInteger("windowsKeyCode", key_event.key_code); 547 dict.SetInteger("windowsKeyCode", key_event.key_code);
510 dict.SetString("unmodifiedText", key_event.unmodified_text); 548 dict.SetString("unmodifiedText", key_event.unmodified_text);
511 dict.SetString("text", key_event.modified_text); 549 dict.SetString("text", key_event.modified_text);
512 dict.SetInteger("modifiers", key_event.modifiers); 550 dict.SetInteger("modifiers", key_event.modifiers);
513 dict.SetBoolean("isSystemKey", false); 551 dict.SetBoolean("isSystemKey", false);
514 DictionaryValue reply_dict; 552 DictionaryValue reply_dict;
515 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); 553 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
516 } 554 }
(...skipping 10 matching lines...) Expand all
527 dict.SetInteger("windex", browser_index); 565 dict.SetInteger("windex", browser_index);
528 dict.SetInteger("tab_index", tab_index); 566 dict.SetInteger("tab_index", tab_index);
529 dict.SetInteger("keyCode", key_code); 567 dict.SetInteger("keyCode", key_code);
530 dict.SetInteger("modifiers", modifiers); 568 dict.SetInteger("modifiers", modifiers);
531 DictionaryValue reply_dict; 569 DictionaryValue reply_dict;
532 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg); 570 return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
533 } 571 }
534 572
535 bool SendDragAndDropFilePathsJSONRequest( 573 bool SendDragAndDropFilePathsJSONRequest(
536 AutomationMessageSender* sender, 574 AutomationMessageSender* sender,
537 int browser_index, 575 const WebViewLocator& locator,
538 int tab_index,
539 int x, 576 int x,
540 int y, 577 int y,
541 const std::vector<FilePath::StringType>& paths, 578 const std::vector<FilePath::StringType>& paths,
542 std::string* error_msg) { 579 std::string* error_msg) {
543 DictionaryValue dict; 580 DictionaryValue dict;
544 dict.SetString("command", "DragAndDropFilePaths"); 581 dict.SetString("command", "DragAndDropFilePaths");
545 dict.SetInteger("windex", browser_index); 582 locator.UpdateDictionary(&dict);
546 dict.SetInteger("tab_index", tab_index);
547 dict.SetInteger("x", x); 583 dict.SetInteger("x", x);
548 dict.SetInteger("y", y); 584 dict.SetInteger("y", y);
549 585
550 ListValue* list_value = new ListValue(); 586 ListValue* list_value = new ListValue();
551 for (size_t path_index = 0; path_index < paths.size(); ++path_index) { 587 for (size_t path_index = 0; path_index < paths.size(); ++path_index) {
552 list_value->Append(Value::CreateStringValue(paths[path_index])); 588 list_value->Append(Value::CreateStringValue(paths[path_index]));
553 } 589 }
554 dict.Set("paths", list_value); 590 dict.Set("paths", list_value);
555 591
556 DictionaryValue reply_dict; 592 DictionaryValue reply_dict;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 dict.SetBoolean("with_ui", with_ui); 679 dict.SetBoolean("with_ui", with_ui);
644 DictionaryValue reply_dict; 680 DictionaryValue reply_dict;
645 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg)) 681 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
646 return false; 682 return false;
647 if (!reply_dict.GetString("id", extension_id)) { 683 if (!reply_dict.GetString("id", extension_id)) {
648 *error_msg = "Missing or invalid 'id'"; 684 *error_msg = "Missing or invalid 'id'";
649 return false; 685 return false;
650 } 686 }
651 return true; 687 return true;
652 } 688 }
OLDNEW
« no previous file with comments | « chrome/test/automation/automation_json_requests.h ('k') | chrome/test/webdriver/commands/chrome_commands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698