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

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

Issue 21030009: Make element removal methods in DictionaryValue and ListValue take scoped_ptr's as outparams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 7 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/files/file_path.h" 8 #include "base/files/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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 return false; 277 return false;
278 *nav_response = static_cast<AutomationMsg_NavigationResponseValues>(response); 278 *nav_response = static_cast<AutomationMsg_NavigationResponseValues>(response);
279 return true; 279 return true;
280 } 280 }
281 281
282 bool SendExecuteJavascriptJSONRequest( 282 bool SendExecuteJavascriptJSONRequest(
283 AutomationMessageSender* sender, 283 AutomationMessageSender* sender,
284 const WebViewLocator& locator, 284 const WebViewLocator& locator,
285 const std::string& frame_xpath, 285 const std::string& frame_xpath,
286 const std::string& javascript, 286 const std::string& javascript,
287 Value** result, 287 scoped_ptr<Value>* result,
288 Error* error) { 288 Error* error) {
289 DictionaryValue dict; 289 DictionaryValue dict;
290 dict.SetString("command", "ExecuteJavascript"); 290 dict.SetString("command", "ExecuteJavascript");
291 locator.UpdateDictionary(&dict, "auto_id"); 291 locator.UpdateDictionary(&dict, "auto_id");
292 dict.SetString("frame_xpath", frame_xpath); 292 dict.SetString("frame_xpath", frame_xpath);
293 dict.SetString("javascript", javascript); 293 dict.SetString("javascript", javascript);
294 DictionaryValue reply_dict; 294 DictionaryValue reply_dict;
295 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error)) 295 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error))
296 return false; 296 return false;
297 297
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 locator.UpdateDictionary(&dict, "auto_id"); 375 locator.UpdateDictionary(&dict, "auto_id");
376 DictionaryValue reply_dict; 376 DictionaryValue reply_dict;
377 377
378 return SendAutomationJSONRequest(sender, dict, &reply_dict, error); 378 return SendAutomationJSONRequest(sender, dict, &reply_dict, error);
379 } 379 }
380 #endif // !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) 380 #endif // !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS))
381 381
382 bool SendGetCookiesJSONRequest( 382 bool SendGetCookiesJSONRequest(
383 AutomationMessageSender* sender, 383 AutomationMessageSender* sender,
384 const std::string& url, 384 const std::string& url,
385 ListValue** cookies, 385 scoped_ptr<ListValue>* cookies,
386 Error* error) { 386 Error* error) {
387 DictionaryValue dict; 387 DictionaryValue dict;
388 dict.SetString("command", "GetCookies"); 388 dict.SetString("command", "GetCookies");
389 dict.SetString("url", url); 389 dict.SetString("url", url);
390 DictionaryValue reply_dict; 390 DictionaryValue reply_dict;
391 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error)) 391 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error))
392 return false; 392 return false;
393 Value* cookies_unscoped_value; 393 scoped_ptr<Value> cookies_value;
394 if (!reply_dict.Remove("cookies", &cookies_unscoped_value)) 394 if (!reply_dict.Remove("cookies", &cookies_value))
395 return false; 395 return false;
396 scoped_ptr<Value> cookies_value(cookies_unscoped_value);
397 if (!cookies_value->IsType(Value::TYPE_LIST)) 396 if (!cookies_value->IsType(Value::TYPE_LIST))
398 return false; 397 return false;
399 *cookies = static_cast<ListValue*>(cookies_value.release()); 398 cookies->reset(static_cast<ListValue*>(cookies_value.release()));
400 return true; 399 return true;
401 } 400 }
402 401
403 bool SendDeleteCookieJSONRequest( 402 bool SendDeleteCookieJSONRequest(
404 AutomationMessageSender* sender, 403 AutomationMessageSender* sender,
405 const std::string& url, 404 const std::string& url,
406 const std::string& cookie_name, 405 const std::string& cookie_name,
407 Error* error) { 406 Error* error) {
408 DictionaryValue dict; 407 DictionaryValue dict;
409 dict.SetString("command", "DeleteCookie"); 408 dict.SetString("command", "DeleteCookie");
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 936
938 bool SendOverrideGeolocationJSONRequest( 937 bool SendOverrideGeolocationJSONRequest(
939 AutomationMessageSender* sender, 938 AutomationMessageSender* sender,
940 const base::DictionaryValue* geolocation, 939 const base::DictionaryValue* geolocation,
941 Error* error) { 940 Error* error) {
942 scoped_ptr<DictionaryValue> dict(geolocation->DeepCopy()); 941 scoped_ptr<DictionaryValue> dict(geolocation->DeepCopy());
943 dict->SetString("command", "OverrideGeoposition"); 942 dict->SetString("command", "OverrideGeoposition");
944 DictionaryValue reply_dict; 943 DictionaryValue reply_dict;
945 return SendAutomationJSONRequest(sender, *dict.get(), &reply_dict, error); 944 return SendAutomationJSONRequest(sender, *dict.get(), &reply_dict, error);
946 } 945 }
OLDNEW
« no previous file with comments | « chrome/test/automation/automation_json_requests.h ('k') | chrome/test/webdriver/commands/cookie_commands.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698