Chromium Code Reviews| 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 476f0ee594fae7a633d921ed024e025b4dfb4c75..6f694f13619b5fa85c9428e503918c8cbb603401 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" |
| @@ -1993,7 +1994,7 @@ void TestingAutomationProvider::CaptureEntirePageAsPNG( |
| if (render_view) { |
| // This will delete itself when finished. |
| PageSnapshotTaker* snapshot_taker = new PageSnapshotTaker( |
| - this, reply_message, render_view, path); |
| + this, reply_message, render_view, path, false); |
| snapshot_taker->Start(); |
| } else { |
| LOG(ERROR) << "Could not get render view for tab handle"; |
| @@ -2050,6 +2051,8 @@ void TestingAutomationProvider::SendJSONRequest(int handle, |
| &TestingAutomationProvider::GetTabURLJSON; |
| handler_map["GetTabTitle"] = |
| &TestingAutomationProvider::GetTabTitleJSON; |
| + handler_map["GetScreenShot"] = |
|
kkania
2011/03/16 18:19:10
change name here too
Joe
2011/03/17 00:15:25
Done.
|
| + &TestingAutomationProvider::GetScreenShotJSON; |
| handler_map["GetCookies"] = |
| &TestingAutomationProvider::GetCookiesJSON; |
| handler_map["DeleteCookie"] = |
| @@ -4952,6 +4955,46 @@ void TestingAutomationProvider::GetTabTitleJSON( |
| reply.SendSuccess(&dict); |
| } |
| +void TestingAutomationProvider::GetScreenShotJSON( |
| + 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; |
| + } |
| + |
| +#if defined(OS_WIN) |
| + string16 path_str; |
| +#elif defined(OS_POSIX) |
| + std::string path_str; |
| +#else |
|
kkania
2011/03/16 18:19:10
I think you can get rid of the #else part; as you
Joe
2011/03/17 00:15:25
Done.
|
| + NOTREACHED(); |
| +#endif |
|
kkania
2011/03/16 18:19:10
actually, I think you should be able to replace al
Joe
2011/03/17 00:15:25
Done.
|
| + |
| + if (!args->GetString("path", &path_str)) { |
| + AutomationJSONReply(this, reply_message) |
| + .SendError("'path' missing or invalid"); |
| + return; |
| + } |
| + |
| + FilePath path(path_str); |
| + RenderViewHost* render_view = tab_contents->render_view_host(); |
| + if (render_view) { |
| + // This will delete itself when finished. |
| + PageSnapshotTaker* snapshot_taker = new PageSnapshotTaker( |
| + this, reply_message, render_view, path, true); |
|
kkania
2011/03/16 18:19:10
just make the FilePath(path_str) here and get rid
Joe
2011/03/17 00:15:25
Done.
|
| + snapshot_taker->Start(); |
| + } else { |
| + LOG(ERROR) << "Could not get render view for tab handle"; |
|
kkania
2011/03/16 18:19:10
this should be replaced with a AutomationJSONRelpy
Joe
2011/03/17 00:15:25
Done.
|
| + AutomationMsg_CaptureEntirePageAsPNG::WriteReplyParams(reply_message, |
| + false); |
| + Send(reply_message); |
| + } |
| +} |
| + |
| void TestingAutomationProvider::GetCookiesJSON( |
| DictionaryValue* args, IPC::Message* reply_message) { |
| automation_util::GetCookiesJSON(this, args, reply_message); |