summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webdevtoolsagent_impl.cc
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 09:53:27 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 09:53:27 +0000
commitb004209b94e258e9ca5a2356e4bd108f8443e142 (patch)
tree5f0170dfafbaa7b3a7e0fc48e502396e6e09004e /webkit/glue/webdevtoolsagent_impl.cc
parentbc296f37929b762850ce2c3b317f8542bdace2a1 (diff)
downloadchromium_src-b004209b94e258e9ca5a2356e4bd108f8443e142.zip
chromium_src-b004209b94e258e9ca5a2356e4bd108f8443e142.tar.gz
chromium_src-b004209b94e258e9ca5a2356e4bd108f8443e142.tar.bz2
DevTools: Migrate to InspectorController for network and console events.
- introduced bound object on the agent side; - established remote dispatch of WebInspector calls - using fake InspectorFrontend for serializing events and sending them over the ipc - removed net agents from both sides - moved GetResource stuff to tools agent Assumes following is landed: https://bugs.webkit.org/show_bug.cgi?id=26010 Review URL: http://codereview.chromium.org/113836 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16980 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webdevtoolsagent_impl.cc')
-rw-r--r--webkit/glue/webdevtoolsagent_impl.cc111
1 files changed, 56 insertions, 55 deletions
diff --git a/webkit/glue/webdevtoolsagent_impl.cc b/webkit/glue/webdevtoolsagent_impl.cc
index 793ca5d..50c676f 100644
--- a/webkit/glue/webdevtoolsagent_impl.cc
+++ b/webkit/glue/webdevtoolsagent_impl.cc
@@ -9,19 +9,24 @@
#include "Document.h"
#include "EventListener.h"
#include "InspectorController.h"
+#include "InspectorFrontend.h"
+#include "InspectorResource.h"
#include "Node.h"
#include "Page.h"
#include "PlatformString.h"
+#include "ScriptObject.h"
+#include "ScriptState.h"
#include "ScriptValue.h"
#include "v8_proxy.h"
#include <wtf/OwnPtr.h>
#undef LOG
+#include "V8Binding.h"
#include "base/values.h"
+#include "webkit/glue/devtools/bound_object.h"
#include "webkit/glue/devtools/debugger_agent_impl.h"
#include "webkit/glue/devtools/debugger_agent_manager.h"
#include "webkit/glue/devtools/dom_agent_impl.h"
-#include "webkit/glue/devtools/net_agent_impl.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/webdatasource.h"
#include "webkit/glue/webdevtoolsagent_delegate.h"
@@ -31,14 +36,13 @@
using WebCore::Document;
using WebCore::InspectorController;
+using WebCore::InspectorFrontend;
+using WebCore::InspectorResource;
using WebCore::Node;
using WebCore::Page;
using WebCore::ScriptValue;
using WebCore::String;
-// Maximum size of the console message cache.
-static const size_t kMaxConsoleMessages = 200;
-
WebDevToolsAgentImpl::WebDevToolsAgentImpl(
WebViewImpl* web_view_impl,
WebDevToolsAgentDelegate* delegate)
@@ -49,11 +53,7 @@ WebDevToolsAgentImpl::WebDevToolsAgentImpl(
attached_(false) {
debugger_agent_delegate_stub_.set(new DebuggerAgentDelegateStub(this));
dom_agent_delegate_stub_.set(new DomAgentDelegateStub(this));
- net_agent_delegate_stub_.set(new NetAgentDelegateStub(this));
tools_agent_delegate_stub_.set(new ToolsAgentDelegateStub(this));
-
- // Sniff for requests from the beginning, do not wait for attach.
- net_agent_impl_.set(new NetAgentImpl(net_agent_delegate_stub_.get()));
}
WebDevToolsAgentImpl::~WebDevToolsAgentImpl() {
@@ -84,26 +84,32 @@ void WebDevToolsAgentImpl::Attach() {
debugger_agent_impl_->ResetUtilityContext(doc, &utility_context_);
}
dom_agent_impl_->SetDocument(doc);
- net_agent_impl_->SetDocument(doc);
- }
-
- // Populate console.
- for (Vector<ConsoleMessage>::iterator it = console_log_.begin();
- it != console_log_.end(); ++it) {
- DictionaryValue message;
- Serialize(*it, &message);
- tools_agent_delegate_stub_->AddMessageToConsole(message);
+ web_inspector_stub_.set(
+ new BoundObject(utility_context_, this, "RemoteWebInspector"));
+ web_inspector_stub_->AddProtoFunction(
+ "dispatch",
+ WebDevToolsAgentImpl::JsDispatchOnClient);
+ web_inspector_stub_->Build();
+
+ InspectorController* ic = web_view_impl_->page()->inspectorController();
+ v8::HandleScope scope;
+ ic->setFrontendProxyObject(
+ scriptStateFromPage(web_view_impl_->page()),
+ utility_context_->Global());
+ // Allow controller to send messages to the frontend.
+ ic->setWindowVisible(true, false);
}
-
- net_agent_impl_->Attach();
attached_ = true;
}
void WebDevToolsAgentImpl::Detach() {
+ // Prevent controller from sending messages to the frontend.
+ InspectorController* ic = web_view_impl_->page()->inspectorController();
+ ic->setWindowVisible(false, false);
HideDOMNodeHighlight();
+ web_inspector_stub_.set(NULL);
debugger_agent_impl_.set(NULL);
dom_agent_impl_.set(NULL);
- net_agent_impl_->Detach();
attached_ = false;
}
@@ -122,16 +128,12 @@ void WebDevToolsAgentImpl::SetMainFrameDocumentReady(bool ready) {
}
debugger_agent_impl_->ResetUtilityContext(doc, &utility_context_);
dom_agent_impl_->SetDocument(doc);
- net_agent_impl_->SetDocument(doc);
}
void WebDevToolsAgentImpl::DidCommitLoadForFrame(
WebViewImpl* webview,
WebFrame* frame,
bool is_new_navigation) {
- if (webview->GetMainFrame() == frame) {
- net_agent_impl_->DidCommitMainResourceLoad();
- }
if (!attached_) {
return;
}
@@ -145,25 +147,6 @@ void WebDevToolsAgentImpl::DidCommitLoadForFrame(
webview->GetMainFrame() == frame);
}
-void WebDevToolsAgentImpl::AddMessageToConsole(
- int source,
- int level,
- const String& text,
- unsigned int line_no,
- const String& source_id) {
- ConsoleMessage cm(source, level, text, line_no, source_id);
- console_log_.append(cm);
- if (console_log_.size() >= kMaxConsoleMessages) {
- // Batch shifts to save ticks.
- console_log_.remove(0, kMaxConsoleMessages / 5);
- }
- if (attached_) {
- DictionaryValue message;
- Serialize(cm, &message);
- tools_agent_delegate_stub_->AddMessageToConsole(message);
- }
-}
-
void WebDevToolsAgentImpl::WindowObjectCleared(WebFrameImpl* webframe) {
DebuggerAgentManager::SetHostId(webframe, host_id_);
}
@@ -226,7 +209,25 @@ void WebDevToolsAgentImpl::ExecuteUtilityFunction(
}
void WebDevToolsAgentImpl::ClearConsoleMessages() {
- console_log_.clear();
+ Page* page = web_view_impl_->page();
+ if (page) {
+ page->inspectorController()->clearConsoleMessages();
+ }
+}
+
+void WebDevToolsAgentImpl::GetResourceContent(
+ int call_id,
+ int identifier) {
+ Page* page = web_view_impl_->page();
+ if (!page) {
+ return;
+ }
+ RefPtr<InspectorResource> resource =
+ page->inspectorController()->resources().get(identifier);
+ if (resource.get()) {
+ tools_agent_delegate_stub_->DidGetResourceContent(call_id,
+ resource->sourceString());
+ }
}
void WebDevToolsAgentImpl::DispatchMessageFromClient(
@@ -251,9 +252,6 @@ void WebDevToolsAgentImpl::DispatchMessageFromClient(
if (DomAgentDispatch::Dispatch(dom_agent_impl_.get(), *message.get())) {
return;
}
- if (NetAgentDispatch::Dispatch(net_agent_impl_.get(), *message.get())) {
- return;
- }
}
void WebDevToolsAgentImpl::InspectElement(int x, int y) {
@@ -271,14 +269,17 @@ void WebDevToolsAgentImpl::SendRpcMessage(const std::string& raw_msg) {
}
// static
-void WebDevToolsAgentImpl::Serialize(const ConsoleMessage& message,
- DictionaryValue* value) {
- value->SetInteger(L"source", message.source);
- value->SetInteger(L"level", message.level);
- value->SetString(L"text", webkit_glue::StringToStdString(message.text));
- value->SetString(L"sourceId",
- webkit_glue::StringToStdString(message.source_id));
- value->SetInteger(L"line", message.line_no);
+v8::Handle<v8::Value> WebDevToolsAgentImpl::JsDispatchOnClient(
+ const v8::Arguments& args) {
+ v8::TryCatch exception_catcher;
+ String message = WebCore::toWebCoreStringWithNullCheck(args[0]);
+ if (message.isEmpty() || exception_catcher.HasCaught()) {
+ return v8::Undefined();
+ }
+ WebDevToolsAgentImpl* agent = static_cast<WebDevToolsAgentImpl*>(
+ v8::External::Cast(*args.Data())->Value());
+ agent->tools_agent_delegate_stub_->DispatchOnClient(message);
+ return v8::Undefined();
}
// static