OLD | NEW |
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/webdriver/commands/chrome_commands.h" | 5 #include "chrome/test/webdriver/commands/chrome_commands.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "chrome/test/automation/value_conversion_util.h" | 12 #include "chrome/test/automation/value_conversion_util.h" |
13 #include "chrome/test/webdriver/commands/response.h" | 13 #include "chrome/test/webdriver/commands/response.h" |
14 #include "chrome/test/webdriver/webdriver_error.h" | 14 #include "chrome/test/webdriver/webdriver_error.h" |
15 #include "chrome/test/webdriver/webdriver_session.h" | 15 #include "chrome/test/webdriver/webdriver_session.h" |
16 #include "chrome/test/webdriver/webdriver_util.h" | 16 #include "chrome/test/webdriver/webdriver_util.h" |
17 | 17 |
18 using base::DictionaryValue; | 18 using base::DictionaryValue; |
19 using base::ListValue; | 19 using base::ListValue; |
20 using base::Value; | 20 using base::Value; |
21 | 21 |
22 namespace webdriver { | 22 namespace webdriver { |
23 | 23 |
24 ExtensionsCommand::ExtensionsCommand( | 24 ExtensionsCommand::ExtensionsCommand( |
25 const std::vector<std::string>& path_segments, | 25 const std::vector<std::string>& path_segments, |
26 const DictionaryValue* const parameters) | 26 DictionaryValue* const parameters) |
27 : WebDriverCommand(path_segments, parameters) {} | 27 : WebDriverCommand(path_segments, parameters) {} |
28 | 28 |
29 ExtensionsCommand::~ExtensionsCommand() {} | 29 ExtensionsCommand::~ExtensionsCommand() {} |
30 | 30 |
31 bool ExtensionsCommand::DoesGet() { | 31 bool ExtensionsCommand::DoesGet() { |
32 return true; | 32 return true; |
33 } | 33 } |
34 | 34 |
35 bool ExtensionsCommand::DoesPost() { | 35 bool ExtensionsCommand::DoesPost() { |
36 return true; | 36 return true; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 FilePath(path_string), &extension_id); | 85 FilePath(path_string), &extension_id); |
86 if (error) { | 86 if (error) { |
87 response->SetError(error); | 87 response->SetError(error); |
88 return; | 88 return; |
89 } | 89 } |
90 response->SetValue(Value::CreateStringValue(extension_id)); | 90 response->SetValue(Value::CreateStringValue(extension_id)); |
91 } | 91 } |
92 | 92 |
93 ExtensionCommand::ExtensionCommand( | 93 ExtensionCommand::ExtensionCommand( |
94 const std::vector<std::string>& path_segments, | 94 const std::vector<std::string>& path_segments, |
95 const DictionaryValue* const parameters) | 95 DictionaryValue* const parameters) |
96 : WebDriverCommand(path_segments, parameters) {} | 96 : WebDriverCommand(path_segments, parameters) {} |
97 | 97 |
98 ExtensionCommand::~ExtensionCommand() {} | 98 ExtensionCommand::~ExtensionCommand() {} |
99 | 99 |
100 bool ExtensionCommand::Init(Response* const response) { | 100 bool ExtensionCommand::Init(Response* const response) { |
101 if (!WebDriverCommand::Init(response)) | 101 if (!WebDriverCommand::Init(response)) |
102 return false; | 102 return false; |
103 | 103 |
104 // Path: "/session/$sessionId/chrome/extension/$id". | 104 // Path: "/session/$sessionId/chrome/extension/$id". |
105 extension_id_ = GetPathVariable(5); | 105 extension_id_ = GetPathVariable(5); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 void ExtensionCommand::ExecuteDelete(Response* const response) { | 219 void ExtensionCommand::ExecuteDelete(Response* const response) { |
220 Error* error = session_->UninstallExtension(extension_id_); | 220 Error* error = session_->UninstallExtension(extension_id_); |
221 if (error) { | 221 if (error) { |
222 response->SetError(error); | 222 response->SetError(error); |
223 return; | 223 return; |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 ViewsCommand::ViewsCommand( | 227 ViewsCommand::ViewsCommand( |
228 const std::vector<std::string>& path_segments, | 228 const std::vector<std::string>& path_segments, |
229 const DictionaryValue* const parameters) | 229 DictionaryValue* const parameters) |
230 : WebDriverCommand(path_segments, parameters) {} | 230 : WebDriverCommand(path_segments, parameters) {} |
231 | 231 |
232 ViewsCommand::~ViewsCommand() {} | 232 ViewsCommand::~ViewsCommand() {} |
233 | 233 |
234 bool ViewsCommand::DoesGet() { | 234 bool ViewsCommand::DoesGet() { |
235 return true; | 235 return true; |
236 } | 236 } |
237 | 237 |
238 void ViewsCommand::ExecuteGet(Response* const response) { | 238 void ViewsCommand::ExecuteGet(Response* const response) { |
239 std::vector<WebViewInfo> views; | 239 std::vector<WebViewInfo> views; |
(...skipping 11 matching lines...) Expand all Loading... |
251 if (!views[i].extension_id.empty()) | 251 if (!views[i].extension_id.empty()) |
252 dict->SetString("extension_id", views[i].extension_id); | 252 dict->SetString("extension_id", views[i].extension_id); |
253 views_list->Append(dict); | 253 views_list->Append(dict); |
254 } | 254 } |
255 response->SetValue(views_list); | 255 response->SetValue(views_list); |
256 } | 256 } |
257 | 257 |
258 #if !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) | 258 #if !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) |
259 HeapProfilerDumpCommand::HeapProfilerDumpCommand( | 259 HeapProfilerDumpCommand::HeapProfilerDumpCommand( |
260 const std::vector<std::string>& ps, | 260 const std::vector<std::string>& ps, |
261 const DictionaryValue* const parameters) | 261 DictionaryValue* const parameters) |
262 : WebDriverCommand(ps, parameters) {} | 262 : WebDriverCommand(ps, parameters) {} |
263 | 263 |
264 HeapProfilerDumpCommand::~HeapProfilerDumpCommand() {} | 264 HeapProfilerDumpCommand::~HeapProfilerDumpCommand() {} |
265 | 265 |
266 bool HeapProfilerDumpCommand::DoesPost() { | 266 bool HeapProfilerDumpCommand::DoesPost() { |
267 return true; | 267 return true; |
268 } | 268 } |
269 | 269 |
270 void HeapProfilerDumpCommand::ExecutePost(Response* const response) { | 270 void HeapProfilerDumpCommand::ExecutePost(Response* const response) { |
271 std::string reason; | 271 std::string reason; |
272 if (!GetStringParameter("reason", &reason)) { | 272 if (!GetStringParameter("reason", &reason)) { |
273 response->SetError(new Error(kBadRequest, "'reason' missing or invalid")); | 273 response->SetError(new Error(kBadRequest, "'reason' missing or invalid")); |
274 return; | 274 return; |
275 } | 275 } |
276 | 276 |
277 Error* error = session_->HeapProfilerDump(reason); | 277 Error* error = session_->HeapProfilerDump(reason); |
278 if (error) { | 278 if (error) { |
279 response->SetError(error); | 279 response->SetError(error); |
280 return; | 280 return; |
281 } | 281 } |
282 } | 282 } |
283 #endif // !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) | 283 #endif // !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) |
284 | 284 |
285 } // namespace webdriver | 285 } // namespace webdriver |
OLD | NEW |