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

Unified Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 5572001: Send screenshots back to the client for debugging (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: need to push again to make sure rietveld didn't screw up Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/automation/testing_automation_provider.cc
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index b93d9a079f084b30a9a0e8ab9959b4e908f79e7e..3d076c85afca965489d72e671fed699dc1dff3d6 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -9,6 +9,7 @@
#include <vector>
#include "base/command_line.h"
+#include "base/file_path.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/json/string_escape.h"
@@ -358,8 +359,6 @@ bool TestingAutomationProvider::OnMessageReceived(
IPC_MESSAGE_HANDLER(AutomationMsg_WindowTitle, GetWindowTitle)
IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility)
IPC_MESSAGE_HANDLER(AutomationMsg_BlockedPopupCount, GetBlockedPopupCount)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CaptureEntirePageAsPNG,
- CaptureEntirePageAsPNG)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SendJSONRequest,
SendJSONRequest)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabCountToBecome,
@@ -1991,22 +1990,6 @@ void TestingAutomationProvider::GetBlockedPopupCount(int handle, int* count) {
}
}
-void TestingAutomationProvider::CaptureEntirePageAsPNG(
- int tab_handle, const FilePath& path, IPC::Message* reply_message) {
- RenderViewHost* render_view = GetViewForTab(tab_handle);
- if (render_view) {
- // This will delete itself when finished.
- PageSnapshotTaker* snapshot_taker = new PageSnapshotTaker(
- this, reply_message, render_view, path);
- snapshot_taker->Start();
- } else {
- LOG(ERROR) << "Could not get render view for tab handle";
- AutomationMsg_CaptureEntirePageAsPNG::WriteReplyParams(reply_message,
- false);
- Send(reply_message);
- }
-}
-
void TestingAutomationProvider::SendJSONRequest(int handle,
const std::string& json_request,
IPC::Message* reply_message) {
@@ -2054,6 +2037,8 @@ void TestingAutomationProvider::SendJSONRequest(int handle,
&TestingAutomationProvider::GetTabURLJSON;
handler_map["GetTabTitle"] =
&TestingAutomationProvider::GetTabTitleJSON;
+ handler_map["CaptureEntirePage"] =
+ &TestingAutomationProvider::CaptureEntirePageJSON;
handler_map["GetCookies"] =
&TestingAutomationProvider::GetCookiesJSON;
handler_map["DeleteCookie"] =
@@ -4961,6 +4946,37 @@ void TestingAutomationProvider::GetTabTitleJSON(
reply.SendSuccess(&dict);
}
+void TestingAutomationProvider::CaptureEntirePageJSON(
+ DictionaryValue* args,
+ IPC::Message* reply_message) {
+ TabContents* tab_contents;
+ std::string error;
+
+ if (!GetTabFromJSONArgs(args, &tab_contents, &error)) {
+ AutomationJSONReply(this, reply_message).SendError(error);
+ return;
+ }
+
+ FilePath::StringType path_str;
+ if (!args->GetString("path", &path_str)) {
+ AutomationJSONReply(this, reply_message)
+ .SendError("'path' missing or invalid");
+ return;
+ }
+
+ RenderViewHost* render_view = tab_contents->render_view_host();
+ if (render_view) {
+ FilePath path(path_str);
+ // This will delete itself when finished.
+ PageSnapshotTaker* snapshot_taker = new PageSnapshotTaker(
+ this, reply_message, render_view, path);
+ snapshot_taker->Start();
+ } else {
+ AutomationJSONReply(this, reply_message)
+ .SendError("Tab has no associated RenderViewHost");
+ }
+}
+
void TestingAutomationProvider::GetCookiesJSON(
DictionaryValue* args, IPC::Message* reply_message) {
automation_util::GetCookiesJSON(this, args, reply_message);
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698