#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/numerics/safe_conversions.h"
-#include "content/public/renderer/web_preferences.h"
+#include "content/public/common/web_preferences.h"
+#include "content/public/renderer/render_view.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/public/platform/WebSize.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/platform/WebURLResponse.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebElement.h"
-#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
+#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebPluginContainer.h"
#include "third_party/WebKit/public/web/WebView.h"
-#include "webkit/common/webpreferences.h"
using blink::WebCanvas;
using blink::WebCursorInfo;
using blink::WebDragData;
using blink::WebDragOperationsMask;
-using blink::WebFrame;
using blink::WebImage;
using blink::WebInputEvent;
+using blink::WebLocalFrame;
using blink::WebMouseEvent;
using blink::WebPlugin;
using blink::WebPluginContainer;
using blink::WebURLResponse;
using blink::WebVector;
using blink::WebView;
+using content::WebPreferences;
-WebViewPlugin::WebViewPlugin(WebViewPlugin::Delegate* delegate)
+WebViewPlugin::WebViewPlugin(WebViewPlugin::Delegate* delegate,
+ const WebPreferences& preferences)
: delegate_(delegate),
container_(NULL),
web_view_(WebView::create(this)),
- web_frame_(WebFrame::create(this)),
- finished_loading_(false) {
+ finished_loading_(false),
+ focused_(false) {
+ // ApplyWebPreferences before making a WebLocalFrame so that the frame sees a
+ // consistent view of our preferences.
+ content::RenderView::ApplyWebPreferences(preferences, web_view_);
+ web_frame_ = WebLocalFrame::create(this);
web_view_->setMainFrame(web_frame_);
}
const WebPreferences& preferences,
const std::string& html_data,
const GURL& url) {
- WebViewPlugin* plugin = new WebViewPlugin(delegate);
- WebView* web_view = plugin->web_view();
- content::ApplyWebPreferences(preferences, web_view);
- web_view->mainFrame()->loadHTMLString(html_data, url);
+ WebViewPlugin* plugin = new WebViewPlugin(delegate, preferences);
+ plugin->web_view()->mainFrame()->loadHTMLString(html_data, url);
return plugin;
}
"PluginDocument.NumChunks",
(base::checked_cast<int, size_t>(data_.size())));
}
+ // We need to transfer the |focused_| to new plugin after it loaded.
+ if (focused_) {
+ plugin->updateFocus(true);
+ }
if (finished_loading_) {
plugin->didFinishLoading();
}
if (static_cast<gfx::Rect>(frame_rect) != rect_) {
rect_ = frame_rect;
WebSize newSize(frame_rect.width, frame_rect.height);
- web_view_->setFixedLayoutSize(newSize);
web_view_->resize(newSize);
}
}
+void WebViewPlugin::updateFocus(bool focused) {
+ focused_ = focused;
+}
+
bool WebViewPlugin::acceptsInputEvents() { return true; }
bool WebViewPlugin::handleInputEvent(const WebInputEvent& event,
container_->element().setAttribute("title", text);
}
-void WebViewPlugin::startDragging(WebFrame*,
+void WebViewPlugin::startDragging(WebLocalFrame*,
const WebDragData&,
WebDragOperationsMask,
const WebImage&,
web_view_->dragSourceSystemDragEnded();
}
+bool WebViewPlugin::allowsBrokenNullLayerTreeView() const {
+ return true;
+}
+
void WebViewPlugin::didInvalidateRect(const WebRect& rect) {
if (container_)
container_->invalidateRect(rect);
current_cursor_ = cursor;
}
-void WebViewPlugin::didClearWindowObject(WebFrame* frame, int world_id) {
+void WebViewPlugin::scheduleAnimation() {
+ if (container_)
+ container_->invalidate();
+}
+
+void WebViewPlugin::didClearWindowObject(WebLocalFrame* frame) {
if (delegate_)
delegate_->BindWebFrame(frame);
}
-void WebViewPlugin::didReceiveResponse(WebFrame* frame,
+void WebViewPlugin::didReceiveResponse(WebLocalFrame* frame,
unsigned identifier,
const WebURLResponse& response) {
WebFrameClient::didReceiveResponse(frame, identifier, response);