| OLD | NEW |
| 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/commands/source_command.h" | 5 #include "chrome/test/webdriver/commands/source_command.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/test/webdriver/commands/response.h" | 10 #include "chrome/test/webdriver/commands/response.h" |
| 11 #include "chrome/test/webdriver/webdriver_error.h" | 11 #include "chrome/test/webdriver/webdriver_error.h" |
| 12 #include "chrome/test/webdriver/webdriver_session.h" | 12 #include "chrome/test/webdriver/webdriver_session.h" |
| 13 | 13 |
| 14 namespace webdriver { | 14 namespace webdriver { |
| 15 | 15 |
| 16 // Private atom to find source code of the page. | 16 // Private atom to find source code of the page. |
| 17 const char* const kSource = | 17 const char* const kSource = |
| 18 "return new XMLSerializer().serializeToString(document);"; | 18 "return new XMLSerializer().serializeToString(document);"; |
| 19 | 19 |
| 20 SourceCommand::SourceCommand(const std::vector<std::string>& path_segments, | 20 SourceCommand::SourceCommand(const std::vector<std::string>& path_segments, |
| 21 const DictionaryValue* const parameters) | 21 DictionaryValue* const parameters) |
| 22 : WebDriverCommand(path_segments, parameters) {} | 22 : WebDriverCommand(path_segments, parameters) {} |
| 23 | 23 |
| 24 SourceCommand::~SourceCommand() {} | 24 SourceCommand::~SourceCommand() {} |
| 25 | 25 |
| 26 bool SourceCommand::DoesGet() { | 26 bool SourceCommand::DoesGet() { |
| 27 return true; | 27 return true; |
| 28 } | 28 } |
| 29 | 29 |
| 30 void SourceCommand::ExecuteGet(Response* const response) { | 30 void SourceCommand::ExecuteGet(Response* const response) { |
| 31 ListValue args; | 31 ListValue args; |
| 32 Value* result = NULL; | 32 Value* result = NULL; |
| 33 Error* error = session_->ExecuteScript(kSource, &args, &result); | 33 Error* error = session_->ExecuteScript(kSource, &args, &result); |
| 34 if (error) { | 34 if (error) { |
| 35 response->SetError(error); | 35 response->SetError(error); |
| 36 return; | 36 return; |
| 37 } | 37 } |
| 38 response->SetValue(result); | 38 response->SetValue(result); |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace webdriver | 41 } // namespace webdriver |
| OLD | NEW |