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

Unified Diff: content/renderer/devtools/devtools_agent.cc

Issue 1932623003: DevTools: Introduce Page.getManifest remote debugging protocol method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: browser test updated Created 4 years, 8 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 | « content/renderer/devtools/devtools_agent.h ('k') | content/renderer/manifest/manifest_debug_info.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/devtools/devtools_agent.cc
diff --git a/content/renderer/devtools/devtools_agent.cc b/content/renderer/devtools/devtools_agent.cc
index 64dacd3a3e7dac3f4df51685392b6b3697ecf0ca..b8836832340e68ecfe6e69636f7d33a07af59c86 100644
--- a/content/renderer/devtools/devtools_agent.cc
+++ b/content/renderer/devtools/devtools_agent.cc
@@ -8,14 +8,17 @@
#include <map>
+#include "base/json/json_writer.h"
#include "base/lazy_instance.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_event.h"
#include "content/common/devtools_messages.h"
#include "content/common/frame_messages.h"
+#include "content/public/common/manifest.h"
#include "content/renderer/devtools/devtools_client.h"
#include "content/renderer/devtools/devtools_cpu_throttler.h"
+#include "content/renderer/manifest/manifest_manager.h"
#include "content/renderer/render_frame_impl.h"
#include "content/renderer/render_widget.h"
#include "ipc/ipc_channel.h"
@@ -37,6 +40,8 @@ namespace content {
namespace {
const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4;
+const char kPageGetAppManifest[] = "Page.getAppManifest";
+
class WebKitClientMessageLoopImpl
: public WebDevToolsAgentClient::WebKitClientMessageLoop {
@@ -66,7 +71,8 @@ DevToolsAgent::DevToolsAgent(RenderFrameImpl* frame)
paused_in_mouse_move_(false),
paused_(false),
frame_(frame),
- cpu_throttler_(new DevToolsCPUThrottler()) {
+ cpu_throttler_(new DevToolsCPUThrottler()),
+ weak_factory_(this) {
g_agent_for_routing_id.Get()[routing_id()] = this;
frame_->GetWebFrame()->setDevToolsAgentClient(this);
}
@@ -232,6 +238,13 @@ void DevToolsAgent::OnDispatchOnInspectorBackend(int session_id,
const std::string& method,
const std::string& message) {
TRACE_EVENT0("devtools", "DevToolsAgent::OnDispatchOnInspectorBackend");
+ if (method == kPageGetAppManifest) {
+ ManifestManager* manager = frame_->manifest_manager();
+ manager->GetManifest(
+ base::Bind(&DevToolsAgent::GotManifest,
+ weak_factory_.GetWeakPtr(), session_id, call_id));
+ return;
+ }
GetWebAgent()->dispatchOnInspectorBackend(session_id,
call_id,
WebString::fromUTF8(method),
@@ -269,4 +282,38 @@ bool DevToolsAgent::IsAttached() {
return is_attached_;
}
+void DevToolsAgent::GotManifest(int session_id,
+ int call_id,
+ const Manifest& manifest,
+ const ManifestDebugInfo& debug_info) {
+ if (!is_attached_)
+ return;
+
+ std::unique_ptr<base::DictionaryValue> response(new base::DictionaryValue());
+ response->SetInteger("id", call_id);
+ std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
+ std::unique_ptr<base::ListValue> errors(new base::ListValue());
+
+ bool failed = false;
+ for (const auto& error : debug_info.errors) {
+ base::DictionaryValue* error_value = new base::DictionaryValue();
+ errors->Append(error_value);
+ error_value->SetString("message", error.message);
+ error_value->SetBoolean("critical", error.critical);
+ error_value->SetInteger("line", error.line);
+ error_value->SetInteger("column", error.column);
+ if (error.critical)
+ failed = true;
+ }
+ if (!failed)
+ result->SetString("data", debug_info.raw_data);
+ result->Set("errors", errors.release());
+ response->Set("result", result.release());
+
+ std::string json_message;
+ base::JSONWriter::Write(*response, &json_message);
+ SendChunkedProtocolMessage(this, routing_id(), session_id, call_id,
+ json_message, std::string());
+}
+
} // namespace content
« no previous file with comments | « content/renderer/devtools/devtools_agent.h ('k') | content/renderer/manifest/manifest_debug_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698