Skip to content
Snippets Groups Projects
Commit 2661b331 authored by darin@chromium.org's avatar darin@chromium.org
Browse files

Eliminate WebViewImpl's dependency on WebDevToolsAgentImpl.

This CL decouples the implementation of WebDevToolsAgent from the
implementation of WebViewImpl.  While this allows me to postpone
the uplift of glue/devtools into webkit/api/src, I think it also
has the advantage of simplifying dependencies.

WebDevToolsAgentPrivate is introduced for the method calls made
by the FrameLoaderClientImpl to the WebDevToolsAgentImpl.

R=dglazkov
BUG=none
TEST=none

Review URL: http://codereview.chromium.org/342092

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30833 0039d316-1c4b-4281-b951-d872f2087c98
parent 48a70e20
No related merge requests found
Showing
with 112 additions and 73 deletions
......@@ -207,9 +207,6 @@ class PrintWebViewHelper : public WebKit::WebViewClient {
virtual void focusAccessibilityObject(
const WebKit::WebAccessibilityObject& object) {}
virtual void didUpdateInspectorSettings() {}
virtual WebKit::WebDevToolsAgentClient* devToolsAgentClient() {
return NULL;
}
virtual void queryAutofillSuggestions(
const WebKit::WebNode& node, const WebKit::WebString& name,
const WebKit::WebString& value) {}
......
......@@ -66,7 +66,7 @@
#include "skia/ext/image_operations.h"
#include "webkit/api/public/WebAccessibilityObject.h"
#include "webkit/api/public/WebDataSource.h"
#include "webkit/api/public/WebDevToolsAgentClient.h"
#include "webkit/api/public/WebDevToolsAgent.h"
#include "webkit/api/public/WebDragData.h"
#include "webkit/api/public/WebForm.h"
#include "webkit/api/public/WebFrame.h"
......@@ -121,7 +121,7 @@ using WebKit::WebConsoleMessage;
using WebKit::WebContextMenuData;
using WebKit::WebData;
using WebKit::WebDataSource;
using WebKit::WebDevToolsAgentClient;
using WebKit::WebDevToolsAgent;
using WebKit::WebDragData;
using WebKit::WebDragOperation;
using WebKit::WebDragOperationsMask;
......@@ -354,6 +354,8 @@ void RenderView::Init(gfx::NativeViewId parent_hwnd,
Singleton<ViewMap>::get()->insert(std::make_pair(webview(), this));
webkit_preferences_.Apply(webview());
webview()->initializeMainFrame(this);
webview()->setDevToolsAgent(
WebDevToolsAgent::create(webview(), devtools_agent_.get()));
OnSetRendererPrefs(renderer_prefs);
......@@ -1707,10 +1709,6 @@ void RenderView::didUpdateInspectorSettings() {
routing_id_, webview()->inspectorSettings().utf8()));
}
WebDevToolsAgentClient* RenderView::devToolsAgentClient() {
return devtools_agent_.get();
}
void RenderView::queryAutofillSuggestions(const WebNode& node,
const WebString& name,
const WebString& value) {
......
......@@ -257,7 +257,6 @@ class RenderView : public RenderWidget,
virtual void focusAccessibilityObject(
const WebKit::WebAccessibilityObject& acc_obj);
virtual void didUpdateInspectorSettings();
virtual WebKit::WebDevToolsAgentClient* devToolsAgentClient();
virtual void queryAutofillSuggestions(
const WebKit::WebNode& node, const WebKit::WebString& name,
const WebKit::WebString& value);
......
......@@ -34,11 +34,17 @@
#include "WebCommon.h"
namespace WebKit {
class WebDevToolsAgentClient;
class WebString;
class WebView;
struct WebPoint;
class WebDevToolsAgent {
public:
WEBKIT_API static WebDevToolsAgent* create(WebView*, WebDevToolsAgentClient*);
virtual ~WebDevToolsAgent() {}
virtual void attach() = 0;
virtual void detach() = 0;
......@@ -63,10 +69,7 @@ public:
// Installs dispatch handle that is going to be called periodically
// while on a breakpoint.
static void setMessageLoopDispatchHandler(MessageLoopDispatchHandler);
protected:
~WebDevToolsAgent() {}
WEBKIT_API static void setMessageLoopDispatchHandler(MessageLoopDispatchHandler);
};
} // namespace WebKit
......
......@@ -43,11 +43,10 @@ class WebView;
// direct and delegate Apis to the host.
class WebDevToolsFrontend {
public:
static WebDevToolsFrontend* create(WebView* view,
WebDevToolsFrontendClient* client,
const WebString& applicationLocale);
WEBKIT_API static WebDevToolsFrontend* create(WebView* view,
WebDevToolsFrontendClient* client,
const WebString& applicationLocale);
WebDevToolsFrontend() {}
virtual ~WebDevToolsFrontend() {}
virtual void dispatchMessageFromAgent(const WebString& className,
......
......@@ -206,7 +206,10 @@ namespace WebKit {
virtual WebString inspectorSettings() const = 0;
virtual void setInspectorSettings(const WebString&) = 0;
// The embedder may optionally engage a WebDevToolsAgent. This may only
// be set once per WebView.
virtual WebDevToolsAgent* devToolsAgent() = 0;
virtual void setDevToolsAgent(WebDevToolsAgent*) = 0;
// Accessibility -------------------------------------------------------
......
......@@ -40,7 +40,6 @@
namespace WebKit {
class WebAccessibilityObject;
class WebDevToolsAgentClient;
class WebDragData;
class WebFileChooserCompletion;
class WebFrame;
......@@ -257,8 +256,6 @@ namespace WebKit {
// changed and should be saved. See WebView::inspectorSettings.
virtual void didUpdateInspectorSettings() = 0;
virtual WebDevToolsAgentClient* devToolsAgentClient() = 0;
// Autofill ------------------------------------------------------------
......
......@@ -63,6 +63,7 @@
#include "WebViewClient.h"
#include "WebViewImpl.h"
#include "WebDataSourceImpl.h"
#include "WebDevToolsAgentPrivate.h"
#include "WebPluginContainerImpl.h"
#include "WebPluginLoadObserver.h"
#include "WindowFeatures.h"
......@@ -71,7 +72,6 @@
// FIXME: remove these
#include "net/base/mime_util.h"
#include "webkit/glue/webdevtoolsagent_impl.h"
using namespace WebCore;
......@@ -113,11 +113,8 @@ void FrameLoaderClientImpl::windowObjectCleared()
m_webFrame->client()->didClearWindowObject(m_webFrame);
WebViewImpl* webview = m_webFrame->viewImpl();
if (webview) {
WebDevToolsAgentImpl* toolsAgent = webview->devToolsAgentImpl();
if (toolsAgent)
toolsAgent->WindowObjectCleared(m_webFrame);
}
if (webview->devToolsAgentPrivate())
webview->devToolsAgentPrivate()->didClearWindowObject(m_webFrame);
}
void FrameLoaderClientImpl::documentElementAvailable()
......@@ -653,9 +650,8 @@ void FrameLoaderClientImpl::dispatchDidCommitLoad()
if (m_webFrame->client())
m_webFrame->client()->didCommitProvisionalLoad(m_webFrame, isNewNavigation);
WebDevToolsAgentImpl* toolsAgent = webview->devToolsAgentImpl();
if (toolsAgent)
toolsAgent->DidCommitLoadForFrame(webview, m_webFrame, isNewNavigation);
if (webview->devToolsAgentPrivate())
webview->devToolsAgentPrivate()->didCommitProvisionalLoad(m_webFrame, isNewNavigation);
}
void FrameLoaderClientImpl::dispatchDidFailProvisionalLoad(
......
......@@ -44,9 +44,6 @@
#include "WebViewImpl.h"
#include <wtf/Vector.h>
// FIXME: Remove this once WebDevToolsAgentImpl and WebViewImpl move out of glue/.
#include "webkit/glue/webdevtoolsagent_impl.h"
using namespace WebCore;
namespace WebKit {
......@@ -76,7 +73,7 @@ Page* InspectorClientImpl::createPage()
void InspectorClientImpl::showWindow()
{
ASSERT(m_inspectedWebView->devToolsAgentImpl());
ASSERT(m_inspectedWebView->devToolsAgentPrivate());
m_inspectedWebView->page()->inspectorController()->setWindowVisible(true);
}
......@@ -88,7 +85,7 @@ void InspectorClientImpl::closeWindow()
bool InspectorClientImpl::windowVisible()
{
ASSERT(m_inspectedWebView->devToolsAgentImpl());
ASSERT(m_inspectedWebView->devToolsAgentPrivate());
return false;
}
......
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WebDevToolsAgentPrivate_h
#define WebDevToolsAgentPrivate_h
// FIXME: This relative path is a temporary hack to support using this
// header from webkit/glue.
#include "../public/WebDevToolsAgent.h"
namespace WebKit {
class WebFrameImpl;
class WebDevToolsAgentPrivate : public WebDevToolsAgent {
public:
// Notifications from FrameLoaderClientImpl:
// The window object for the frame has been cleared of any extra properties
// that may have been set by script from the previously loaded document.
virtual void didClearWindowObject(WebFrameImpl*) = 0;
// The provisional datasource is now committed. The first part of the
// response body has been received, and the encoding of the response body
// is known.
virtual void didCommitProvisionalLoad(WebFrameImpl*, bool isNewNavigation) = 0;
};
} // namespace WebKit
#endif
......@@ -77,6 +77,7 @@
#include "Settings.h"
#include "TypingCommand.h"
#include "WebAccessibilityObject.h"
#include "WebDevToolsAgentPrivate.h"
#include "WebDragData.h"
#include "WebFrameImpl.h"
#include "WebInputEvent.h"
......@@ -99,9 +100,6 @@
#include "RenderTheme.h"
#endif
// FIXME
#include "webkit/glue/webdevtoolsagent_impl.h"
// Get rid of WTF's pow define so we can use std::pow.
#undef pow
#include <cmath> // for std::pow
......@@ -176,12 +174,6 @@ void WebViewImpl::initializeMainFrame(WebFrameClient* frameClient) {
frame->initializeAsMainFrame(this);
if (m_client) {
WebDevToolsAgentClient* toolsClient = m_client->devToolsAgentClient();
if (toolsClient)
m_devToolsAgent.set(new WebDevToolsAgentImpl(this, toolsClient));
}
// Restrict the access to the local file system
// (see WebView.mm WebView::_commonInitializationWithFrameName).
SecurityOrigin::setLocalLoadPolicy(SecurityOrigin::AllowLocalLoadsForLocalOnly);
......@@ -777,7 +769,7 @@ void WebViewImpl::close()
m_page.clear();
}
// Should happen after m_page.reset().
// Should happen after m_page.clear().
if (m_devToolsAgent.get())
m_devToolsAgent.clear();
......@@ -1498,6 +1490,12 @@ WebDevToolsAgent* WebViewImpl::devToolsAgent()
return m_devToolsAgent.get();
}
void WebViewImpl::setDevToolsAgent(WebDevToolsAgent* devToolsAgent)
{
ASSERT(!m_devToolsAgent.get()); // May only set once!
m_devToolsAgent.set(static_cast<WebDevToolsAgentPrivate*>(devToolsAgent));
}
WebAccessibilityObject WebViewImpl::accessibilityObject()
{
if (!mainFrameImpl())
......@@ -1583,11 +1581,6 @@ bool WebViewImpl::setDropEffect(bool accept) {
return false;
}
WebDevToolsAgentImpl* WebViewImpl::devToolsAgentImpl()
{
return m_devToolsAgent.get();
}
void WebViewImpl::setIsTransparent(bool isTransparent)
{
// Set any existing frames to be transparent.
......
......@@ -61,12 +61,11 @@ class RenderTheme;
class Widget;
}
class WebDevToolsAgentImpl;
namespace WebKit {
class AutocompletePopupMenuClient;
class ContextMenuClientImpl;
class WebAccessibilityObject;
class WebDevToolsAgentPrivate;
class WebFrameImpl;
class WebKeyboardEvent;
class WebMouseEvent;
......@@ -149,6 +148,7 @@ public:
virtual WebString inspectorSettings() const;
virtual void setInspectorSettings(const WebString& settings);
virtual WebDevToolsAgent* devToolsAgent();
virtual void setDevToolsAgent(WebDevToolsAgent*);
virtual WebAccessibilityObject accessibilityObject();
virtual void applyAutofillSuggestions(
const WebNode&,
......@@ -159,7 +159,7 @@ public:
// WebViewImpl
void setIgnoreInputEvents(bool newValue);
WebDevToolsAgentImpl* devToolsAgentImpl();
WebDevToolsAgentPrivate* devToolsAgentPrivate() { return m_devToolsAgent.get(); }
const WebPoint& lastMouseDownPoint() const
{
......@@ -393,7 +393,7 @@ private:
// The autocomplete client.
OwnPtr<AutocompletePopupMenuClient> m_autocompletePopupClient;
OwnPtr<WebDevToolsAgentImpl> m_devToolsAgent;
OwnPtr<WebDevToolsAgentPrivate> m_devToolsAgent;
// Whether the webview is rendering transparently.
bool m_isTransparent;
......
......@@ -30,6 +30,7 @@
#include "webkit/api/public/WebString.h"
#include "webkit/api/public/WebURL.h"
#include "webkit/api/public/WebURLRequest.h"
#include "webkit/api/src/WebFrameImpl.h"
#include "webkit/api/src/WebViewImpl.h"
#include "webkit/glue/devtools/bound_object.h"
#include "webkit/glue/devtools/debugger_agent_impl.h"
......@@ -159,19 +160,18 @@ void WebDevToolsAgentImpl::didNavigate() {
DebuggerAgentManager::OnNavigate();
}
void WebDevToolsAgentImpl::DidCommitLoadForFrame(
WebViewImpl* webview,
WebFrame* frame,
void WebDevToolsAgentImpl::didCommitProvisionalLoad(
WebFrameImpl* webframe,
bool is_new_navigation) {
if (!attached_) {
return;
}
WebDataSource* ds = frame->dataSource();
WebDataSource* ds = webframe->dataSource();
const WebURLRequest& request = ds->request();
WebURL url = ds->hasUnreachableURL() ?
ds->unreachableURL() :
request.url();
if (webview->mainFrame() == frame) {
if (!webframe->parent()) {
ResetInspectorFrontendProxy();
tools_agent_delegate_stub_->FrameNavigate(
webkit_glue::WebURLToKURL(url).string());
......@@ -180,7 +180,7 @@ void WebDevToolsAgentImpl::DidCommitLoadForFrame(
}
}
void WebDevToolsAgentImpl::WindowObjectCleared(WebFrameImpl* webframe) {
void WebDevToolsAgentImpl::didClearWindowObject(WebFrameImpl* webframe) {
DebuggerAgentManager::SetHostId(webframe, host_id_);
if (attached_) {
// Push context id into the client if it is already attached.
......@@ -460,6 +460,12 @@ v8::Handle<v8::Value> WebDevToolsAgentImpl::JsOnRuntimeFeatureStateChanged(
namespace WebKit {
// static
WebDevToolsAgent* WebDevToolsAgent::create(WebView* webview,
WebDevToolsAgentClient* client) {
return new WebDevToolsAgentImpl(static_cast<WebViewImpl*>(webview), client);
}
// static
void WebDevToolsAgent::executeDebuggerCommand(
const WebString& command,
......
......@@ -10,7 +10,7 @@
#include <wtf/OwnPtr.h>
#include "v8.h"
#include "webkit/api/public/WebDevToolsAgent.h"
#include "webkit/api/src/WebDevToolsAgentPrivate.h"
#include "webkit/glue/devtools/devtools_rpc.h"
#include "webkit/glue/devtools/apu_agent_delegate.h"
#include "webkit/glue/devtools/tools_agent.h"
......@@ -35,7 +35,7 @@ class DebuggerAgentDelegateStub;
class DebuggerAgentImpl;
class Value;
class WebDevToolsAgentImpl : public WebKit::WebDevToolsAgent,
class WebDevToolsAgentImpl : public WebKit::WebDevToolsAgentPrivate,
public ToolsAgent,
public DevToolsRpc::Delegate {
public:
......@@ -57,6 +57,11 @@ class WebDevToolsAgentImpl : public WebKit::WebDevToolsAgent,
int call_id,
int identifier);
// WebDevToolsAgentPrivate implementation.
virtual void didClearWindowObject(WebKit::WebFrameImpl* frame);
virtual void didCommitProvisionalLoad(
WebKit::WebFrameImpl* frame, bool is_new_navigation);
// WebDevToolsAgent implementation.
virtual void attach();
virtual void detach();
......@@ -78,14 +83,6 @@ class WebDevToolsAgentImpl : public WebKit::WebDevToolsAgent,
const WebCore::String& param2,
const WebCore::String& param3);
// Methods called by the glue.
void SetMainFrameDocumentReady(bool ready);
void DidCommitLoadForFrame(WebKit::WebViewImpl* webview,
WebKit::WebFrame* frame,
bool is_new_navigation);
void WindowObjectCleared(WebKit::WebFrameImpl* webframe);
void ForceRepaint();
int host_id() { return host_id_; }
......
......@@ -143,9 +143,6 @@ class TestWebViewDelegate : public WebKit::WebViewClient,
virtual void focusAccessibilityObject(
const WebKit::WebAccessibilityObject& object);
virtual void didUpdateInspectorSettings() {}
virtual WebKit::WebDevToolsAgentClient* devToolsAgentClient() {
return NULL;
}
virtual void queryAutofillSuggestions(
const WebKit::WebNode&, const WebKit::WebString& name,
const WebKit::WebString& value) {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment