Chromium Code Reviews| Index: chrome/test/webdriver/commands/screenshot_command.cc |
| diff --git a/chrome/test/webdriver/commands/screenshot_command.cc b/chrome/test/webdriver/commands/screenshot_command.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..993fdb83e2907051c989d5ae930d1dece0f3d49c |
| --- /dev/null |
| +++ b/chrome/test/webdriver/commands/screenshot_command.cc |
| @@ -0,0 +1,40 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/test/webdriver/commands/screenshot_command.h" |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/values.h" |
| +#include "chrome/test/webdriver/error_codes.h" |
| +#include "chrome/test/webdriver/session.h" |
| +#include "chrome/test/webdriver/commands/response.h" |
|
kkania
2011/02/24 22:05:02
this include should go above the error_codes one
Joe
2011/03/02 02:21:25
Done.
|
| + |
| +namespace webdriver { |
| + |
| +ScreenshotCommand::ScreenshotCommand(const std::vector<std::string>& ps, |
| + const DictionaryValue* const parameters) |
| + : WebDriverCommand(ps, parameters) {} |
| + |
| +ScreenshotCommand::~ScreenshotCommand() {} |
| + |
| +bool ScreenshotCommand::DoesGet() { |
| + return true; |
| +} |
| + |
| +void ScreenshotCommand::ExecuteGet(Response* const response) { |
| + std::string screenshot; |
| + if (!session_->ScreenshotAsBase64(&screenshot)) { |
| + SET_WEBDRIVER_ERROR(response, "Screenshot of current page failed", |
| + kInternalServerError); |
| + return; |
| + } |
| + |
| + response->SetValue(new StringValue(screenshot)); |
| + response->SetStatus(kSuccess); |
| +} |
| + |
| +} // namespace webdriver |
| + |