diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-16 18:51:34 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-16 18:51:34 +0000 |
commit | 611cad45a3bc67189d273eaba0171b96f7bdbd97 (patch) | |
tree | 3fc4655ab572b37310dc43c53a510affd430496d /webkit | |
parent | 12e0eed769a220d8ff490f092a7235af6f68270e (diff) | |
download | chromium_src-611cad45a3bc67189d273eaba0171b96f7bdbd97.zip chromium_src-611cad45a3bc67189d273eaba0171b96f7bdbd97.tar.gz chromium_src-611cad45a3bc67189d273eaba0171b96f7bdbd97.tar.bz2 |
Wire DevTools agent in the Glue to the Renderer DevTools IPC transport: DevToolsAgent now implements WebDevToolsAgentDelegate, DevToolsClient covers WebDevToolsClientDelegate.
WebDevToolsAgent instance is being created by the WebView early in the init code and belongs to it. WebView exposes interface for accessing the agent; it also extends its delegate interface to pass WebDevToolsAgentDelegate into it.
Note that there is no call overhead unless particular sub-agents are enabled in the WebDevToolsAgent.
WebDevToolsClient instance is being created externally by the DevToolsClient.
Review URL: http://codereview.chromium.org/46032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11752 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/webframeloaderclient_impl.cc | 74 | ||||
-rw-r--r-- | webkit/glue/webframeloaderclient_impl.h | 4 | ||||
-rw-r--r-- | webkit/glue/webview.h | 4 | ||||
-rw-r--r-- | webkit/glue/webview_delegate.h | 7 | ||||
-rw-r--r-- | webkit/glue/webview_impl.cc | 15 | ||||
-rw-r--r-- | webkit/glue/webview_impl.h | 7 |
6 files changed, 102 insertions, 9 deletions
diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index 7634fb0..7855cb6 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -44,11 +44,13 @@ MSVC_POP_WARNING(); #endif #include "webkit/glue/autofill_form.h" #include "webkit/glue/alt_404_page_resource_fetcher.h" +#include "webkit/glue/devtools/net_agent_impl.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/password_form_dom_manager.h" #include "webkit/glue/plugins/plugin_list.h" #include "webkit/glue/searchable_form_data.h" #include "webkit/glue/webdatasource_impl.h" +#include "webkit/glue/webdevtoolsagent_impl.h" #include "webkit/glue/weberror_impl.h" #include "webkit/glue/webframeloaderclient_impl.h" #include "webkit/glue/webhistoryitem_impl.h" @@ -163,6 +165,10 @@ void WebFrameLoaderClient::assignIdentifierToInitialRequest( WebRequestImpl webreq(request); d->AssignIdentifierToRequest(webview, identifier, webreq); } + NetAgentImpl* net_agent = GetNetAgentImpl(); + if (net_agent) { + net_agent->AssignIdentifierToRequest(loader, identifier, request); + } } // Determines whether the request being loaded by |loader| is a frame or a @@ -212,6 +218,10 @@ void WebFrameLoaderClient::dispatchWillSendRequest( d->WillSendRequest(webview, identifier, &webreq); request = webreq.frame_load_request().resourceRequest(); } + NetAgentImpl* net_agent = GetNetAgentImpl(); + if (net_agent) { + net_agent->WillSendRequest(loader, identifier, request); + } } bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*, @@ -276,12 +286,21 @@ void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader* loader, // Cancel any pending loads. alt_404_page_fetcher_.reset(NULL); + + NetAgentImpl* net_agent = GetNetAgentImpl(); + if (net_agent) { + net_agent->DidReceiveResponse(loader, identifier, response); + } } -void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader* loader, - unsigned long identifier, - int lengthReceived) { - // FIXME +void WebFrameLoaderClient::dispatchDidReceiveContentLength( + DocumentLoader* loader, + unsigned long identifier, + int length_received) { + NetAgentImpl* net_agent = GetNetAgentImpl(); + if (net_agent) { + net_agent->DidReceiveContentLength(loader, identifier, length_received); + } } // Called when a particular resource load completes @@ -301,6 +320,11 @@ void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader* loader, WebViewDelegate* d = webview->delegate(); if (d) d->DidFinishLoading(webview, identifier); + + NetAgentImpl* net_agent = GetNetAgentImpl(); + if (net_agent) { + net_agent->DidFinishLoading(loader, identifier); + } } GURL WebFrameLoaderClient::GetAlt404PageUrl(DocumentLoader* loader) { @@ -342,6 +366,10 @@ void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, webview->delegate()->DidFailLoadingWithError(webview, identifier, WebErrorImpl(error)); } + NetAgentImpl* net_agent = GetNetAgentImpl(); + if (net_agent) { + net_agent->DidFailLoading(loader, identifier, error); + } } void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() { @@ -392,14 +420,23 @@ bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache( int length) { WebViewImpl* webview = webframe_->webview_impl(); WebViewDelegate* d = webview->delegate(); + + bool result = false; if (d) { WebRequestImpl webreq(request); WebResponseImpl webresp(response); - return d->DidLoadResourceFromMemoryCache(webview, webreq, webresp, - webframe_); + result = d->DidLoadResourceFromMemoryCache(webview, webreq, webresp, + webframe_); } - - return false; + NetAgentImpl* net_agent = GetNetAgentImpl(); + if (net_agent) { + net_agent->DidLoadResourceFromMemoryCache( + loader, + request, + response, + length); + } + return result; } void WebFrameLoaderClient::dispatchDidHandleOnloadEvents() { @@ -1048,7 +1085,13 @@ void WebFrameLoaderClient::postProgressFinishedNotification() { } void WebFrameLoaderClient::setMainFrameDocumentReady(bool ready) { - // FIXME + if (hasWebView()) { + WebDevToolsAgentImpl* tools_agent = + webframe_->webview_impl()->GetWebDevToolsAgentImpl(); + if (tools_agent) { + tools_agent->SetMainFrameDocumentReady(ready); + } + } } // Creates a new connection and begins downloading from that (contrast this @@ -1520,3 +1563,16 @@ bool WebFrameLoaderClient::ActionSpecifiesDisposition( *disposition = shift ? NEW_WINDOW : SAVE_TO_DISK; return true; } + +NetAgentImpl* WebFrameLoaderClient::GetNetAgentImpl() { + WebViewImpl* web_view = webframe_->webview_impl(); + if (!web_view) { + return NULL; + } + WebDevToolsAgentImpl* tools_agent = web_view->GetWebDevToolsAgentImpl(); + if (tools_agent) { + return tools_agent->net_agent_impl(); + } else { + return NULL; + } +} diff --git a/webkit/glue/webframeloaderclient_impl.h b/webkit/glue/webframeloaderclient_impl.h index 4281d2f..b322f10 100644 --- a/webkit/glue/webframeloaderclient_impl.h +++ b/webkit/glue/webframeloaderclient_impl.h @@ -25,6 +25,7 @@ class Widget; } class Alt404PageResourceFetcher; +class NetAgentImpl; class WebFrameImpl; class WebPluginContainer; @@ -216,6 +217,9 @@ class WebFrameLoaderClient : public WebCore::FrameLoaderClient { // otherwise returns NavigationGestureUnknown. NavigationGesture NavigationGestureForLastLoad(); + // Returns NetAgent instance if network tracking is enabled. + NetAgentImpl* GetNetAgentImpl(); + // The WebFrame that owns this object and manages its lifetime. Therefore, // the web frame object is guaranteed to exist. WebFrameImpl* webframe_; diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h index e2e9520..4a569d6 100644 --- a/webkit/glue/webview.h +++ b/webkit/glue/webview.h @@ -14,6 +14,7 @@ struct WebDropData; struct WebPreferences; class GURL; +class WebDevToolsAgent; class WebFrame; class WebViewDelegate; @@ -196,6 +197,9 @@ class WebView : public WebWidget { // Hides the autofill popup if any are showing. virtual void HideAutofillPopup() = 0; + // Returns development tools agent instance belonging to this view. + virtual WebDevToolsAgent* GetWebDevToolsAgent() = 0; + private: DISALLOW_EVIL_CONSTRUCTORS(WebView); }; diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index a1a90d2..b7e9d0d 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -45,6 +45,7 @@ struct WebDropData; struct WebPreferences; class AutofillForm; class SkBitmap; +class WebDevToolsAgentDelegate; class WebError; class WebFrame; class WebHistoryItem; @@ -741,6 +742,12 @@ class WebViewDelegate : virtual public WebWidgetDelegate { virtual void DownloadUrl(const GURL& url, const GURL& referrer) { } + // DevTools ---------------------------------------------------------------- + + virtual WebDevToolsAgentDelegate* GetWebDevToolsAgentDelegate() { + return NULL; + } + // Editor Client ----------------------------------------------------------- // Returns true if the word is spelled correctly. The word may begin or end diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index 0d05a2b..ca57b7b 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -86,6 +86,7 @@ MSVC_POP_WARNING(); #include "webkit/glue/chrome_client_impl.h" #include "webkit/glue/clipboard_conversion.h" #include "webkit/glue/context_menu_client_impl.h" +#include "webkit/glue/webdevtoolsagent_impl.h" #include "webkit/glue/dragclient_impl.h" #include "webkit/glue/editor_client_impl.h" #include "webkit/glue/event_conversion.h" @@ -99,6 +100,8 @@ MSVC_POP_WARNING(); #include "webkit/glue/webinputevent.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" +#include "webkit/glue/webdevtoolsagent.h" +#include "webkit/glue/webdevtoolsclient.h" #include "webkit/glue/webview_delegate.h" #include "webkit/glue/webview_impl.h" #include "webkit/glue/webwidget_impl.h" @@ -315,6 +318,9 @@ WebView* WebView::Create(WebViewDelegate* delegate, // Set the delegate after initializing the main frame, to avoid trying to // respond to notifications before we're fully initialized. instance->delegate_ = delegate; + instance->devtools_agent_.reset( + new WebDevToolsAgentImpl(instance, + delegate->GetWebDevToolsAgentDelegate())); // Restrict the access to the local file system // (see WebView.mm WebView::_commonInitializationWithFrameName). FrameLoader::setLocalLoadPolicy( @@ -815,6 +821,7 @@ void WebViewImpl::Close() { // Do this first to prevent reentrant notifications from being sent to the // initiator of the close. delegate_ = NULL; + devtools_agent_.reset(NULL); if (page_.get()) { // Initiate shutdown for the entire frameset. This will cause a lot of @@ -1605,6 +1612,14 @@ void WebViewImpl::AutofillSuggestionsForNode( } } +WebDevToolsAgent* WebViewImpl::GetWebDevToolsAgent() { + return GetWebDevToolsAgentImpl(); +} + +WebDevToolsAgentImpl* WebViewImpl::GetWebDevToolsAgentImpl() { + return devtools_agent_.get(); +} + void WebViewImpl::DidCommitLoad(bool* is_new_navigation) { if (is_new_navigation) *is_new_navigation = observed_new_navigation_; diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h index 61bb396..78e0a63 100644 --- a/webkit/glue/webview_impl.h +++ b/webkit/glue/webview_impl.h @@ -42,6 +42,8 @@ class WebHistoryItemImpl; class WebKeyboardEvent; class WebMouseEvent; class WebMouseWheelEvent; +class WebDevToolsAgent; +class WebDevToolsAgentImpl; class WebViewDelegate; class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { @@ -107,6 +109,9 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { int default_suggestion_index); virtual void HideAutofillPopup(); + virtual WebDevToolsAgent* GetWebDevToolsAgent(); + WebDevToolsAgentImpl* GetWebDevToolsAgentImpl(); + // WebViewImpl const gfx::Size& size() const { return size_; } @@ -311,6 +316,8 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { // The autocomplete client. scoped_ptr<AutocompletePopupMenuClient> autocomplete_popup_client_; + scoped_ptr<WebDevToolsAgentImpl> devtools_agent_; + // HACK: current_input_event is for ChromeClientImpl::show(), until we can fix // WebKit to pass enough information up into ChromeClient::show() so we can // decide if the window.open event was caused by a middle-mouse click |