| Index: webkit/glue/webdevtoolsagent_impl.cc
|
| ===================================================================
|
| --- webkit/glue/webdevtoolsagent_impl.cc (revision 16977)
|
| +++ webkit/glue/webdevtoolsagent_impl.cc (working copy)
|
| @@ -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 @@
|
| 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 @@
|
| debugger_agent_impl_->ResetUtilityContext(doc, &utility_context_);
|
| }
|
| dom_agent_impl_->SetDocument(doc);
|
| - net_agent_impl_->SetDocument(doc);
|
| - }
|
| + web_inspector_stub_.set(
|
| + new BoundObject(utility_context_, this, "RemoteWebInspector"));
|
| + web_inspector_stub_->AddProtoFunction(
|
| + "dispatch",
|
| + WebDevToolsAgentImpl::JsDispatchOnClient);
|
| + web_inspector_stub_->Build();
|
|
|
| - // 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);
|
| + 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 @@
|
| }
|
| 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 @@
|
| 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,9 +209,27 @@
|
| }
|
|
|
| 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(
|
| const std::string& raw_msg) {
|
| OwnPtr<ListValue> message(
|
| @@ -251,9 +252,6 @@
|
| 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 @@
|
| }
|
|
|
| // 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
|
|
|