diff options
Diffstat (limited to 'webkit/glue/plugins/webview_plugin.cc')
-rw-r--r-- | webkit/glue/plugins/webview_plugin.cc | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/webkit/glue/plugins/webview_plugin.cc b/webkit/glue/plugins/webview_plugin.cc index 413ae10..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; @@ -55,6 +80,7 @@ bool WebViewPlugin::initialize(WebPluginContainer* container) { void WebViewPlugin::destroy() { delegate_->WillDestroyPlugin(); delegate_ = NULL; + container_ = NULL; MessageLoop::current()->DeleteSoon(FROM_HERE, this); } @@ -104,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&, @@ -114,7 +159,7 @@ void WebViewPlugin::startDragging(const WebDragData&, void WebViewPlugin::didInvalidateRect(const WebRect& rect) { if (container_) - container_->invalidateRect(WebRect(rect)); + container_->invalidateRect(rect); } void WebViewPlugin::didChangeCursor(const WebCursorInfo& cursor) { @@ -122,7 +167,8 @@ void WebViewPlugin::didChangeCursor(const WebCursorInfo& cursor) { } void WebViewPlugin::didClearWindowObject(WebFrame* frame) { - delegate_->BindWebFrame(frame); + if (delegate_) + delegate_->BindWebFrame(frame); } bool WebViewPlugin::canHandleRequest(WebFrame* frame, |