diff options
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/plugins/webview_plugin.cc | 46 | ||||
-rw-r--r-- | webkit/glue/plugins/webview_plugin.h | 27 |
2 files changed, 65 insertions, 8 deletions
diff --git a/webkit/glue/plugins/webview_plugin.cc b/webkit/glue/plugins/webview_plugin.cc index 1d50be6..231bd37 100644 --- a/webkit/glue/plugins/webview_plugin.cc +++ b/webkit/glue/plugins/webview_plugin.cc @@ -4,6 +4,7 @@ #include "webkit/glue/plugins/webview_plugin.h" +#include "base/histogram.h" #include "base/message_loop.h" #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" @@ -12,6 +13,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" +#include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h" #if WEBKIT_USING_CG @@ -27,18 +29,21 @@ using WebKit::WebDragOperationsMask; using WebKit::WebFrame; using WebKit::WebImage; using WebKit::WebInputEvent; +using WebKit::WebPlugin; using WebKit::WebPluginContainer; using WebKit::WebPoint; using WebKit::WebRect; using WebKit::WebSize; using WebKit::WebURLError; using WebKit::WebURLRequest; +using WebKit::WebURLResponse; using WebKit::WebVector; using WebKit::WebView; WebViewPlugin::WebViewPlugin(WebViewPlugin::Delegate* delegate) : delegate_(delegate), - container_(NULL) { + container_(NULL), + finished_loading_(false) { web_view_ = WebView::create(this, NULL); web_view_->initializeMainFrame(this); } @@ -47,6 +52,26 @@ WebViewPlugin::~WebViewPlugin() { web_view_->close(); } +void WebViewPlugin::ReplayReceivedData(WebPlugin* plugin) { + if (!response_.isNull()) { + plugin->didReceiveResponse(response_); + size_t total_bytes = 0; + for (std::list<std::string>::iterator it = data_.begin(); + it != data_.end(); ++it) { + plugin->didReceiveData(it->c_str(), it->length()); + total_bytes += it->length(); + } + UMA_HISTOGRAM_MEMORY_KB("PluginDocument.Memory", (total_bytes / 1024)); + UMA_HISTOGRAM_COUNTS("PluginDocument.NumChunks", data_.size()); + } + if (finished_loading_) { + plugin->didFinishLoading(); + } + if (error_.get()) { + plugin->didFailLoading(*error_); + } +} + bool WebViewPlugin::initialize(WebPluginContainer* container) { container_ = container; return true; @@ -105,6 +130,25 @@ bool WebViewPlugin::handleInputEvent(const WebInputEvent& event, return handled; } +void WebViewPlugin::didReceiveResponse(const WebURLResponse& response) { + DCHECK(response_.isNull()); + response_ = response; +} + +void WebViewPlugin::didReceiveData(const char* data, int data_length) { + data_.push_back(std::string(data, data_length)); +} + +void WebViewPlugin::didFinishLoading() { + DCHECK(!finished_loading_); + finished_loading_ = true; +} + +void WebViewPlugin::didFailLoading(const WebURLError& error) { + DCHECK(!error_.get()); + error_.reset(new WebURLError(error)); +} + void WebViewPlugin::startDragging(const WebDragData&, WebDragOperationsMask, const WebImage&, diff --git a/webkit/glue/plugins/webview_plugin.h b/webkit/glue/plugins/webview_plugin.h index 2e41218..757a012 100644 --- a/webkit/glue/plugins/webview_plugin.h +++ b/webkit/glue/plugins/webview_plugin.h @@ -5,11 +5,14 @@ #ifndef WEBKIT_GLUE_PLUGINS_WEBVIEW_PLUGIN_H_ #define WEBKIT_GLUE_PLUGINS_WEBVIEW_PLUGIN_H_ +#include <list> + #include "base/scoped_ptr.h" #include "base/task.h" #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" -#include "third_party/WebKit/WebKit/chromium/public/WebPlugin.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrameClient.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPlugin.h" +#include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" #include "third_party/WebKit/WebKit/chromium/public/WebViewClient.h" // This class implements the WebPlugin interface by forwarding drawing and @@ -36,9 +39,14 @@ class WebViewPlugin: public WebKit::WebPlugin, public WebKit::WebViewClient, explicit WebViewPlugin(Delegate* delegate); - virtual WebKit::WebView* web_view() { return web_view_; } + WebKit::WebView* web_view() { return web_view_; } - virtual WebKit::WebPluginContainer* container() { return container_; } + WebKit::WebPluginContainer* container() { return container_; } + + // When loading a plug-in document (i.e. a full page plug-in not embedded in + // another page), we save all data that has been received, and replay it with + // this method on the actual plug-in. + void ReplayReceivedData(WebKit::WebPlugin* plugin); // WebPlugin methods: virtual bool initialize(WebKit::WebPluginContainer*); @@ -60,10 +68,10 @@ class WebViewPlugin: public WebKit::WebPlugin, public WebKit::WebViewClient, virtual bool handleInputEvent(const WebKit::WebInputEvent& event, WebKit::WebCursorInfo& cursor_info); - virtual void didReceiveResponse(const WebKit::WebURLResponse& response) { } - virtual void didReceiveData(const char* data, int data_length) { } - virtual void didFinishLoading() { } - virtual void didFailLoading(const WebKit::WebURLError& error) { } + virtual void didReceiveResponse(const WebKit::WebURLResponse& response); + virtual void didReceiveData(const char* data, int data_length); + virtual void didFinishLoading(); + virtual void didFailLoading(const WebKit::WebURLError& error); // Called in response to WebPluginContainer::loadFrameRequest virtual void didFinishLoadingFrameRequest( @@ -102,6 +110,11 @@ class WebViewPlugin: public WebKit::WebPlugin, public WebKit::WebViewClient, WebKit::WebPluginContainer* container_; WebKit::WebView* web_view_; gfx::Rect rect_; + + WebKit::WebURLResponse response_; + std::list<std::string> data_; + bool finished_loading_; + scoped_ptr<WebKit::WebURLError> error_; }; #endif // WEBKIT_GLUE_PLUGINS_WEBVIEW_PLUGIN_H_ |