summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins/webview_plugin.cc
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-02 09:17:20 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-02 09:17:20 +0000
commit9420283b16b82f3765e2c32a6f5035fe65c267f5 (patch)
tree98281b2bc31ab9525e7df703e855a871097240fe /webkit/glue/plugins/webview_plugin.cc
parent2f29377e44efc45a2b7346af87886818ace70b79 (diff)
downloadchromium_src-9420283b16b82f3765e2c32a6f5035fe65c267f5.zip
chromium_src-9420283b16b82f3765e2c32a6f5035fe65c267f5.tar.gz
chromium_src-9420283b16b82f3765e2c32a6f5035fe65c267f5.tar.bz2
Record received data in WebViewPlugin and replay it when loading the real plugin.
BUG=49686 TEST=Block all plugins, directly open a page that is displayed by a plugin (an SWF file, or a PDF if the plugin works), and click on the placeholder. The plugin should load normally. Review URL: http://codereview.chromium.org/3038027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54523 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins/webview_plugin.cc')
-rw-r--r--webkit/glue/plugins/webview_plugin.cc46
1 files changed, 45 insertions, 1 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&,