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

Side by Side 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: changed PageSnapshotTaker to use JSON interface 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/automation/testing_automation_provider.h" 5 #include "chrome/browser/automation/testing_automation_provider.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/file_path.h"
12 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
13 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
14 #include "base/json/string_escape.h" 15 #include "base/json/string_escape.h"
15 #include "base/path_service.h" 16 #include "base/path_service.h"
16 #include "base/process.h" 17 #include "base/process.h"
17 #include "base/process_util.h" 18 #include "base/process_util.h"
18 #include "base/stringprintf.h" 19 #include "base/stringprintf.h"
19 #include "base/threading/thread_restrictions.h" 20 #include "base/threading/thread_restrictions.h"
20 #include "base/time.h" 21 #include "base/time.h"
21 #include "base/utf_string_conversions.h" 22 #include "base/utf_string_conversions.h"
(...skipping 2023 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 handler_map["GoForward"] = 2046 handler_map["GoForward"] =
2046 &TestingAutomationProvider::GoForward; 2047 &TestingAutomationProvider::GoForward;
2047 handler_map["GoBack"] = 2048 handler_map["GoBack"] =
2048 &TestingAutomationProvider::GoBack; 2049 &TestingAutomationProvider::GoBack;
2049 handler_map["Reload"] = 2050 handler_map["Reload"] =
2050 &TestingAutomationProvider::ReloadJSON; 2051 &TestingAutomationProvider::ReloadJSON;
2051 handler_map["GetTabURL"] = 2052 handler_map["GetTabURL"] =
2052 &TestingAutomationProvider::GetTabURLJSON; 2053 &TestingAutomationProvider::GetTabURLJSON;
2053 handler_map["GetTabTitle"] = 2054 handler_map["GetTabTitle"] =
2054 &TestingAutomationProvider::GetTabTitleJSON; 2055 &TestingAutomationProvider::GetTabTitleJSON;
2056 handler_map["CaptureEntirePage"] =
2057 &TestingAutomationProvider::CaptureEntirePageJSON;
2055 handler_map["GetCookies"] = 2058 handler_map["GetCookies"] =
2056 &TestingAutomationProvider::GetCookiesJSON; 2059 &TestingAutomationProvider::GetCookiesJSON;
2057 handler_map["DeleteCookie"] = 2060 handler_map["DeleteCookie"] =
2058 &TestingAutomationProvider::DeleteCookieJSON; 2061 &TestingAutomationProvider::DeleteCookieJSON;
2059 handler_map["SetCookie"] = 2062 handler_map["SetCookie"] =
2060 &TestingAutomationProvider::SetCookieJSON; 2063 &TestingAutomationProvider::SetCookieJSON;
2061 handler_map["GetTabIds"] = 2064 handler_map["GetTabIds"] =
2062 &TestingAutomationProvider::GetTabIds; 2065 &TestingAutomationProvider::GetTabIds;
2063 handler_map["IsTabIdValid"] = 2066 handler_map["IsTabIdValid"] =
2064 &TestingAutomationProvider::IsTabIdValid; 2067 &TestingAutomationProvider::IsTabIdValid;
(...skipping 2884 matching lines...) Expand 10 before | Expand all | Expand 10 after
4949 std::string error; 4952 std::string error;
4950 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { 4953 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) {
4951 reply.SendError(error); 4954 reply.SendError(error);
4952 return; 4955 return;
4953 } 4956 }
4954 DictionaryValue dict; 4957 DictionaryValue dict;
4955 dict.SetString("title", tab_contents->GetTitle()); 4958 dict.SetString("title", tab_contents->GetTitle());
4956 reply.SendSuccess(&dict); 4959 reply.SendSuccess(&dict);
4957 } 4960 }
4958 4961
4962 void TestingAutomationProvider::CaptureEntirePageJSON(
4963 DictionaryValue* args,
4964 IPC::Message* reply_message) {
4965 TabContents* tab_contents;
4966 std::string error;
4967
4968 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) {
4969 AutomationJSONReply(this, reply_message).SendError(error);
4970 return;
4971 }
4972
4973 FilePath::StringType path_str;
4974 if (!args->GetString("path", &path_str)) {
4975 AutomationJSONReply(this, reply_message)
4976 .SendError("'path' missing or invalid");
4977 return;
4978 }
4979
4980 RenderViewHost* render_view = tab_contents->render_view_host();
4981 if (render_view) {
4982 FilePath path(path_str);
4983 // This will delete itself when finished.
4984 PageSnapshotTaker* snapshot_taker = new PageSnapshotTaker(
4985 this, reply_message, render_view, path);
4986 snapshot_taker->Start();
4987 } else {
4988 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
kkania 2011/03/22 21:08:56 this should be SendError("Tab has no associated Re
Joe 2011/03/22 22:08:19 Done.
4989 }
4990 }
4991
4959 void TestingAutomationProvider::GetCookiesJSON( 4992 void TestingAutomationProvider::GetCookiesJSON(
4960 DictionaryValue* args, IPC::Message* reply_message) { 4993 DictionaryValue* args, IPC::Message* reply_message) {
4961 automation_util::GetCookiesJSON(this, args, reply_message); 4994 automation_util::GetCookiesJSON(this, args, reply_message);
4962 } 4995 }
4963 4996
4964 void TestingAutomationProvider::DeleteCookieJSON( 4997 void TestingAutomationProvider::DeleteCookieJSON(
4965 DictionaryValue* args, IPC::Message* reply_message) { 4998 DictionaryValue* args, IPC::Message* reply_message) {
4966 automation_util::DeleteCookieJSON(this, args, reply_message); 4999 automation_util::DeleteCookieJSON(this, args, reply_message);
4967 } 5000 }
4968 5001
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
5200 // If you change this, update Observer for NotificationType::SESSION_END 5233 // If you change this, update Observer for NotificationType::SESSION_END
5201 // below. 5234 // below.
5202 MessageLoop::current()->PostTask(FROM_HERE, 5235 MessageLoop::current()->PostTask(FROM_HERE,
5203 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); 5236 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider));
5204 } 5237 }
5205 } 5238 }
5206 5239
5207 void TestingAutomationProvider::OnRemoveProvider() { 5240 void TestingAutomationProvider::OnRemoveProvider() {
5208 AutomationProviderList::GetInstance()->RemoveProvider(this); 5241 AutomationProviderList::GetInstance()->RemoveProvider(this);
5209 } 5242 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698