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

Side by Side Diff: chrome/browser/devtools/devtools_protocol.cc

Issue 2813553005: Add a new set of commands to resize and position windows (Closed)
Patch Set: use interactive_ui_tests Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/devtools/devtools_protocol.h" 5 #include "chrome/browser/devtools/devtools_protocol.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 13
14 namespace { 14 namespace {
15 15
16 const char kErrorCodeParam[] = "code"; 16 const char kErrorCodeParam[] = "code";
17 const char kErrorParam[] = "error"; 17 const char kErrorParam[] = "error";
18 const char kErrorMessageParam[] = "message"; 18 const char kErrorMessageParam[] = "message";
19 const char kIdParam[] = "id"; 19 const char kIdParam[] = "id";
20 const char kMethodParam[] = "method"; 20 const char kMethodParam[] = "method";
21 const char kParamsParam[] = "params"; 21 const char kParamsParam[] = "params";
22 const char kResultParam[] = "result"; 22 const char kResultParam[] = "result";
23 23
24 // JSON RPC 2.0 spec: http://www.jsonrpc.org/specification#error_object 24 // JSON RPC 2.0 spec: http://www.jsonrpc.org/specification#error_object
25 enum Error { kErrorInvalidParams = -32602 }; 25 enum Error { kErrorInvalidParams = -32602, kErrorServerError = -32000 };
26 26
27 } // namespace 27 } // namespace
28 28
29 // static 29 // static
30 std::string DevToolsProtocol::SerializeCommand( 30 std::string DevToolsProtocol::SerializeCommand(
31 int command_id, 31 int command_id,
32 const std::string& method, 32 const std::string& method,
33 std::unique_ptr<base::DictionaryValue> params) { 33 std::unique_ptr<base::DictionaryValue> params) {
34 base::DictionaryValue command; 34 base::DictionaryValue command;
35 command.SetInteger(kIdParam, command_id); 35 command.SetInteger(kIdParam, command_id);
(...skipping 15 matching lines...) Expand all
51 auto error_object = base::MakeUnique<base::DictionaryValue>(); 51 auto error_object = base::MakeUnique<base::DictionaryValue>();
52 error_object->SetInteger(kErrorCodeParam, kErrorInvalidParams); 52 error_object->SetInteger(kErrorCodeParam, kErrorInvalidParams);
53 error_object->SetString(kErrorMessageParam, 53 error_object->SetString(kErrorMessageParam,
54 base::StringPrintf("Missing or invalid '%s' parameter", param.c_str())); 54 base::StringPrintf("Missing or invalid '%s' parameter", param.c_str()));
55 response->Set(kErrorParam, std::move(error_object)); 55 response->Set(kErrorParam, std::move(error_object));
56 56
57 return response; 57 return response;
58 } 58 }
59 59
60 // static 60 // static
61 std::unique_ptr<base::DictionaryValue> DevToolsProtocol::CreateErrorResponse(
62 int command_id,
63 const std::string& error_message) {
64 std::unique_ptr<base::DictionaryValue> response(new base::DictionaryValue());
65 response->SetInteger(kIdParam, command_id);
66 auto error_object = base::MakeUnique<base::DictionaryValue>();
67 error_object->SetInteger(kErrorCodeParam, kErrorServerError);
68 error_object->SetString(kErrorMessageParam, error_message);
69 response->Set(kErrorParam, std::move(error_object));
70
71 return response;
72 }
73
74 // static
61 std::unique_ptr<base::DictionaryValue> DevToolsProtocol::CreateSuccessResponse( 75 std::unique_ptr<base::DictionaryValue> DevToolsProtocol::CreateSuccessResponse(
62 int command_id, 76 int command_id,
63 std::unique_ptr<base::DictionaryValue> result) { 77 std::unique_ptr<base::DictionaryValue> result) {
64 std::unique_ptr<base::DictionaryValue> response(new base::DictionaryValue()); 78 std::unique_ptr<base::DictionaryValue> response(new base::DictionaryValue());
65 response->SetInteger(kIdParam, command_id); 79 response->SetInteger(kIdParam, command_id);
66 response->Set(kResultParam, result 80 response->Set(kResultParam, result
67 ? std::move(result) 81 ? std::move(result)
68 : base::MakeUnique<base::DictionaryValue>()); 82 : base::MakeUnique<base::DictionaryValue>());
69 83
70 return response; 84 return response;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 140
127 if (!dict->GetInteger(kIdParam, command_id)) 141 if (!dict->GetInteger(kIdParam, command_id))
128 return false; 142 return false;
129 143
130 *error_code = 0; 144 *error_code = 0;
131 base::DictionaryValue* error_dict = nullptr; 145 base::DictionaryValue* error_dict = nullptr;
132 if (dict->GetDictionary(kErrorParam, &error_dict)) 146 if (dict->GetDictionary(kErrorParam, &error_dict))
133 error_dict->GetInteger(kErrorCodeParam, error_code); 147 error_dict->GetInteger(kErrorCodeParam, error_code);
134 return true; 148 return true;
135 } 149 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_protocol.h ('k') | chrome/browser/devtools/devtools_sanity_interactive_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698