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

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, 1 month 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"
11 #include "base/json/json_value_serializer.h" 11 #include "base/json/json_value_serializer.h"
12 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
15 #include "base/test/test_timeouts.h" 15 #include "base/test/test_timeouts.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "chrome/common/automation_messages.h" 18 #include "chrome/common/automation_messages.h"
19 #include "chrome/test/automation/automation_proxy.h" 19 #include "chrome/test/automation/automation_proxy.h"
20 20
21 using base::DictionaryValue;
22 using base::ListValue;
23
21 namespace { 24 namespace {
22 25
23 bool SendAutomationJSONRequest(AutomationMessageSender* sender, 26 bool SendAutomationJSONRequest(AutomationMessageSender* sender,
24 const DictionaryValue& request_dict, 27 const DictionaryValue& request_dict,
25 DictionaryValue* reply_dict, 28 DictionaryValue* reply_dict,
26 std::string* error_msg) { 29 std::string* error_msg) {
27 std::string request, reply; 30 std::string request, reply;
28 base::JSONWriter::Write(&request_dict, false, &request); 31 base::JSONWriter::Write(&request_dict, false, &request);
29 std::string command; 32 std::string command;
30 request_dict.GetString("command", &command); 33 request_dict.GetString("command", &command);
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 AutomationMessageSender* sender, 605 AutomationMessageSender* sender,
603 int* version, 606 int* version,
604 std::string* error_msg) { 607 std::string* error_msg) {
605 DictionaryValue dict; 608 DictionaryValue dict;
606 dict.SetString("command", "GetChromeDriverAutomationVersion"); 609 dict.SetString("command", "GetChromeDriverAutomationVersion");
607 DictionaryValue reply_dict; 610 DictionaryValue reply_dict;
608 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg)) 611 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
609 return false; 612 return false;
610 return reply_dict.GetInteger("version", version); 613 return reply_dict.GetInteger("version", version);
611 } 614 }
615
616 bool SendGetExtensionsInfoJSONRequest(
617 AutomationMessageSender* sender,
618 ListValue* extensions_list,
619 std::string* error_msg) {
620 DictionaryValue dict;
621 dict.SetString("command", "GetExtensionsInfo");
622 DictionaryValue reply_dict;
623 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
624 return false;
625 ListValue* extensions_list_swap;
626 if (!reply_dict.GetList("extensions", &extensions_list_swap)) {
627 *error_msg = "Missing or invalid 'extensions'";
628 return false;
629 }
630 extensions_list->Swap(extensions_list_swap);
631 return true;
632 }
633
634 bool SendInstallExtensionJSONRequest(
635 AutomationMessageSender* sender,
636 const FilePath& path,
637 std::string* extension_id,
638 std::string* error_msg) {
639 DictionaryValue dict;
640 dict.SetString("command", "InstallExtension");
641 dict.SetString("path", path.value());
642 DictionaryValue reply_dict;
643 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
644 return false;
645 if (!reply_dict.GetString("id", extension_id)) {
646 *error_msg = "Missing or invalid 'id'";
647 return false;
648 }
649 return true;
650 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698