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

Side by Side Diff: chrome/test/webdriver/session.cc

Issue 6705004: Return the full cookie details in TestingAutomationProvider and pass around (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 9 months 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
« no previous file with comments | « chrome/test/webdriver/session.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/webdriver/session_manager.h" 5 #include "chrome/test/webdriver/session_manager.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 RunSessionTask(NewRunnableMethod( 307 RunSessionTask(NewRunnableMethod(
308 automation_.get(), 308 automation_.get(),
309 &Automation::MouseDrag, 309 &Automation::MouseDrag,
310 current_target_.window_id, 310 current_target_.window_id,
311 start, 311 start,
312 end, 312 end,
313 &success)); 313 &success));
314 return success; 314 return success;
315 } 315 }
316 316
317 bool Session::GetCookies(const GURL& url, std::string* cookies) { 317 bool Session::GetCookies(const std::string& url, ListValue** cookies) {
318 bool success = false; 318 bool success = false;
319 RunSessionTask(NewRunnableMethod( 319 RunSessionTask(NewRunnableMethod(
320 automation_.get(), 320 automation_.get(),
321 &Automation::GetCookies, 321 &Automation::GetCookies,
322 url,
323 cookies,
324 &success));
325 return success;
326 }
327
328 bool Session::GetCookiesDeprecated(const GURL& url, std::string* cookies) {
329 bool success = false;
330 RunSessionTask(NewRunnableMethod(
331 automation_.get(),
332 &Automation::GetCookiesDeprecated,
322 current_target_.window_id, 333 current_target_.window_id,
323 url, 334 url,
324 cookies, 335 cookies,
325 &success)); 336 &success));
326 return success; 337 return success;
327 } 338 }
328 339
329 bool Session::GetCookieByName(const GURL& url, 340 bool Session::GetCookieByNameDeprecated(const GURL& url,
330 const std::string& cookie_name, 341 const std::string& cookie_name,
331 std::string* cookie) { 342 std::string* cookie) {
332 std::string cookies; 343 std::string cookies;
333 if (!GetCookies(url, &cookies)) 344 if (!GetCookiesDeprecated(url, &cookies))
334 return false; 345 return false;
335 346
336 std::string namestr = cookie_name + "="; 347 std::string namestr = cookie_name + "=";
337 std::string::size_type idx = cookies.find(namestr); 348 std::string::size_type idx = cookies.find(namestr);
338 if (idx != std::string::npos) { 349 if (idx != std::string::npos) {
339 cookies.erase(0, idx + namestr.length()); 350 cookies.erase(0, idx + namestr.length());
340 *cookie = cookies.substr(0, cookies.find(";")); 351 *cookie = cookies.substr(0, cookies.find(";"));
341 } else { 352 } else {
342 cookie->clear(); 353 cookie->clear();
343 } 354 }
344 355
345 return true; 356 return true;
346 } 357 }
347 358
348 bool Session::DeleteCookie(const GURL& url, const std::string& cookie_name) { 359 bool Session::DeleteCookie(const std::string& url,
360 const std::string& cookie_name) {
349 bool success = false; 361 bool success = false;
350 RunSessionTask(NewRunnableMethod( 362 RunSessionTask(NewRunnableMethod(
351 automation_.get(), 363 automation_.get(),
352 &Automation::DeleteCookie, 364 &Automation::DeleteCookie,
365 url,
366 cookie_name,
367 &success));
368 return success;
369 }
370
371 bool Session::DeleteCookieDeprecated(const GURL& url,
372 const std::string& cookie_name) {
373 bool success = false;
374 RunSessionTask(NewRunnableMethod(
375 automation_.get(),
376 &Automation::DeleteCookieDeprecated,
353 current_target_.window_id, 377 current_target_.window_id,
354 url, 378 url,
355 cookie_name, 379 cookie_name,
356 &success)); 380 &success));
357 return success; 381 return success;
358 } 382 }
359 383
360 bool Session::SetCookie(const GURL& url, const std::string& cookie) { 384 bool Session::SetCookie(const std::string& url, DictionaryValue* cookie_dict) {
361 bool success = false; 385 bool success = false;
362 RunSessionTask(NewRunnableMethod( 386 RunSessionTask(NewRunnableMethod(
363 automation_.get(), 387 automation_.get(),
364 &Automation::SetCookie, 388 &Automation::SetCookie,
389 url,
390 cookie_dict,
391 &success));
392 return success;
393 }
394
395 bool Session::SetCookieDeprecated(const GURL& url, const std::string& cookie) {
396 bool success = false;
397 RunSessionTask(NewRunnableMethod(
398 automation_.get(),
399 &Automation::SetCookieDeprecated,
365 current_target_.window_id, 400 current_target_.window_id,
366 url, 401 url,
367 cookie, 402 cookie,
368 &success)); 403 &success));
369 return success; 404 return success;
370 } 405 }
371 406
372 bool Session::GetWindowIds(std::vector<int>* window_ids) { 407 bool Session::GetWindowIds(std::vector<int>* window_ids) {
373 bool success = false; 408 bool success = false;
374 RunSessionTask(NewRunnableMethod( 409 RunSessionTask(NewRunnableMethod(
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 532
498 std::string Session::GetVersion() { 533 std::string Session::GetVersion() {
499 std::string version; 534 std::string version;
500 RunSessionTask(NewRunnableMethod( 535 RunSessionTask(NewRunnableMethod(
501 automation_.get(), 536 automation_.get(),
502 &Automation::GetVersion, 537 &Automation::GetVersion,
503 &version)); 538 &version));
504 return version; 539 return version;
505 } 540 }
506 541
542 bool Session::GetVersionAndCompare(int client_build_no,
Jason Leyba 2011/03/22 22:20:31 Rename this CompareVersion. Actually, to be more
543 int client_patch_no,
544 bool* is_newer_or_equal) {
545 std::string version = GetVersion();
546 std::vector<std::string> split_version;
547 base::SplitString(version, '.', &split_version);
548 if (split_version.size() != 4)
549 return false;
550 int build_no, patch_no;
551 if (!base::StringToInt(split_version[2], &build_no) ||
552 !base::StringToInt(split_version[3], &patch_no)) {
553 return false;
554 }
555 if (build_no < client_build_no)
556 *is_newer_or_equal = false;
557 else if (build_no > client_build_no)
558 *is_newer_or_equal = true;
559 else
560 *is_newer_or_equal = patch_no >= client_patch_no;
561 return true;
562 }
563
507 ErrorCode Session::FindElement(const FrameId& frame_id, 564 ErrorCode Session::FindElement(const FrameId& frame_id,
508 const WebElementId& root_element, 565 const WebElementId& root_element,
509 const std::string& locator, 566 const std::string& locator,
510 const std::string& query, 567 const std::string& query,
511 WebElementId* element) { 568 WebElementId* element) {
512 std::vector<WebElementId> elements; 569 std::vector<WebElementId> elements;
513 ErrorCode code = FindElementsHelper( 570 ErrorCode code = FindElementsHelper(
514 frame_id, root_element, locator, query, true, &elements); 571 frame_id, root_element, locator, query, true, &elements);
515 if (code == kSuccess) 572 if (code == kSuccess)
516 *element = elements[0]; 573 *element = elements[0];
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 if (!loc_dict->GetInteger("x", &x) || 919 if (!loc_dict->GetInteger("x", &x) ||
863 !loc_dict->GetInteger("y", &y)) { 920 !loc_dict->GetInteger("y", &y)) {
864 LOG(ERROR) << "Location atom returned bad coordinate dictionary"; 921 LOG(ERROR) << "Location atom returned bad coordinate dictionary";
865 code = kUnknownError; 922 code = kUnknownError;
866 } 923 }
867 *location = gfx::Point(x, y); 924 *location = gfx::Point(x, y);
868 return kSuccess; 925 return kSuccess;
869 } 926 }
870 927
871 } // namespace webdriver 928 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698