Index: content/browser/browser_plugin/browser_plugin_host_guest_role.cc |
diff --git a/content/browser/browser_plugin/browser_plugin_host_guest_role.cc b/content/browser/browser_plugin/browser_plugin_host_guest_role.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..75359f1ca18d297e777bba03960fa3d9f275f71f |
--- /dev/null |
+++ b/content/browser/browser_plugin/browser_plugin_host_guest_role.cc |
@@ -0,0 +1,80 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/browser/browser_plugin/browser_plugin_host_guest_role.h" |
+ |
+#include "base/time.h" |
+#include "content/browser/browser_plugin/browser_plugin_host_guest_delegate.h" |
+#include "content/browser/renderer_host/render_view_host_impl.h" |
+#include "content/browser/renderer_host/render_widget_host_impl.h" |
+#include "content/browser/web_contents/web_contents_impl.h" |
+#include "content/common/browser_plugin_messages.h" |
+#include "content/public/browser/notification_details.h" |
+#include "content/public/browser/notification_service.h" |
+#include "content/public/browser/notification_source.h" |
+#include "content/public/browser/notification_types.h" |
+#include "content/common/view_messages.h" |
+#include "content/public/browser/render_process_host.h" |
+#include "content/public/browser/render_view_host.h" |
+#include "content/public/browser/render_widget_host_view.h" |
+#include "ui/gfx/size.h" |
+ |
+namespace content { |
+ |
+BrowserPluginHostGuestRole::BrowserPluginHostGuestRole(int instance_id, |
+ WebContentsImpl* web_contents, RenderViewHost* render_view_host) |
+ : RenderViewHostObserver(render_view_host) { |
+ delegate_.reset( |
+ new BrowserPluginHostGuestDelegate(instance_id, web_contents)); |
+} |
+ |
+BrowserPluginHostGuestRole::~BrowserPluginHostGuestRole() { |
+} |
+ |
+BrowserPluginHostGuestDelegate* BrowserPluginHostGuestRole::GetDelegate() { |
+ return delegate_.get(); |
+} |
+ |
+bool BrowserPluginHostGuestRole::OnMessageReceived( |
+ const IPC::Message& message) { |
+ bool handled = true; |
+ IPC_BEGIN_MESSAGE_MAP(BrowserPluginHostGuestRole, message) |
+ IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) |
+ IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, OnHandleInputEventAck) |
+ IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
+ IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) |
+ IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) |
+ IPC_MESSAGE_UNHANDLED(handled = false) |
+ IPC_END_MESSAGE_MAP() |
+ return handled; |
+} |
+ |
+void BrowserPluginHostGuestRole::OnUpdateRect( |
+ const ViewHostMsg_UpdateRect_Params& params) { |
+ RenderWidgetHostImpl* render_widget_host = |
+ RenderWidgetHostImpl::From(render_view_host()); |
+ render_widget_host->ResetFlags(); |
+ delegate_->UpdateRect(render_view_host(), params); |
+} |
+ |
+void BrowserPluginHostGuestRole::OnHandleInputEventAck( |
+ WebKit::WebInputEvent::Type event_type, |
+ bool processed) { |
+ delegate_->HandleInputEventAck(render_view_host(), processed); |
+} |
+ |
+void BrowserPluginHostGuestRole::OnTakeFocus(bool reverse) { |
+ delegate_->TakeFocus(reverse); |
+} |
+ |
+void BrowserPluginHostGuestRole::OnShowWidget(int route_id, |
+ const gfx::Rect& initial_pos) { |
+ delegate_->ShowWidget(render_view_host(), route_id, initial_pos); |
+} |
+ |
+void BrowserPluginHostGuestRole::OnSetCursor(const WebCursor& cursor) { |
+ delegate_->SetCursor(cursor); |
+} |
+ |
+} // namespace content |