Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(879)

Unified Diff: content/browser/browser_plugin/browser_plugin_embedder.h

Issue 10868012: Browser Plugin: New Implementation (Browser Side) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master-trial-obrowser
Patch Set: Fix incorrect sync+rebase. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/browser_plugin/browser_plugin_embedder.h
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.h b/content/browser/browser_plugin/browser_plugin_embedder.h
new file mode 100644
index 0000000000000000000000000000000000000000..d3bfca26ff58f0364ee240009555e0e86f8c4ce4
--- /dev/null
+++ b/content/browser/browser_plugin/browser_plugin_embedder.h
@@ -0,0 +1,139 @@
+// 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.
+
+#ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
+#define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
+
+#include <string>
+
+#include "base/compiler_specific.h"
+#include "content/browser/browser_plugin/browser_plugin_host_factory.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/render_view_host_observer.h"
+#include "content/public/browser/web_contents_delegate.h"
+#include "content/public/browser/web_contents_observer.h"
+#include "ipc/ipc_channel_handle.h"
+#include "ipc/ipc_sync_message.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
+#include "ui/surface/transport_dib.h"
+#include "webkit/glue/webcursor.h"
+
+namespace gfx {
+class Size;
+}
+
+class WebContentsImpl;
+
+struct BrowserPluginHostMsg_ResizeGuest_Params;
+struct ViewHostMsg_UpdateRect_Params;
+
+namespace content {
+
+class BrowserPluginGuest;
+class BrowserPluginHostFactory;
+
+typedef std::map<WebContents*, int64> GuestWebContentsMap;
+typedef std::map<int, BrowserPluginGuest*> ContainerInstanceMap;
+
+// A browser plugin embedder provides functionality for WebContents to operate
+// in the 'embedder' role, manages list of guests inside the embedder.
awong 2012/08/31 18:08:08 role, manages -> role. It manages
lazyboy 2012/08/31 18:49:18 Done.
+class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver,
+ public NotificationObserver {
+ public:
+ BrowserPluginEmbedder(WebContentsImpl* web_contents,
awong 2012/08/31 18:08:08 If we have a factory method, why do we have a publ
lazyboy 2012/08/31 18:49:18 Done.
+ RenderViewHost* render_view_host);
+ virtual ~BrowserPluginEmbedder();
+
+ static BrowserPluginEmbedder* Create(WebContentsImpl* web_contents,
+ RenderViewHost* render_view_host);
+
+ // Navigates in a guest (new or existing).
+ void NavigateGuest(RenderViewHost* render_view_host,
+ int instance_id,
+ int64 frame_id,
+ const std::string& src,
+ const gfx::Size& size);
+
+ // Overrides factory for testing. Default (NULL) value indicates regular
+ // (non-test) environment.
+ static void set_factory_for_testing(BrowserPluginHostFactory* factory) {
+ factory_ = factory;
+ }
+
+ // Returns true if this Embedder is associated with the RenderViewHost.
+ bool IsForRenderViewHost(RenderViewHost* rvh);
+
+ private:
+ friend class BrowserPluginEmbedderHelper;
+ // For testing.
awong 2012/08/31 18:08:08 For testing. is obvious from the class name :)
lazyboy 2012/08/31 18:49:18 Removed comment.
+ friend class TestBrowserPluginEmbedder;
+
+ // Returns a guest browser plugin delegate by its container ID specified
+ // in BrowserPlugin.
+ BrowserPluginGuest* GetGuestByInstanceID(int instance_id) const;
+ // Adds a new guest to the embedder (overridable in test).
+ virtual void AddGuest(int instance_id,
+ BrowserPluginGuest* guest,
+ int64 frame_id);
+ void DestroyGuestByInstanceID(int instance_id);
+ void DestroyGuests();
+
+ // Message handlers (direct/indirect via BrowserPluginEmbedderHelper).
+ // Routes update rect ack message to the appropriate guest.
+ void UpdateRectACK(int instance_id, int message_id, const gfx::Size& size);
+ void SetFocus(int instance_id, bool focused);
+ void ResizeGuest(int instance_id,
+ TransportDIB* damage_buffer,
+ int width,
+ int height,
+ bool resize_pending,
+ float scale_factor);
+ // Handles input events sent from the BrowserPlugin (embedder's renderer
+ // process) by passing them to appropriate guest's input handler.
+ void HandleInputEvent(int instance_id,
+ RenderViewHost* render_view_host,
+ const gfx::Rect& guest_rect,
+ const WebKit::WebInputEvent& event,
+ IPC::Message* reply_message);
+ void PluginDestroyed(int instance_id);
+
+ // WebContentsObserver implementation.
+ // Used to monitor frame navigation to clean up guests when a frame navigates
+ // away from the browser plugin it's hosting.
+ virtual void DidCommitProvisionalLoadForFrame(
+ int64 frame_id,
+ bool is_main_frame,
+ const GURL& url,
+ PageTransition transition_type,
+ RenderViewHost* render_view_host) OVERRIDE;
+ virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
+ virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
+
+ // NotificationObserver method override.
+ virtual void Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) OVERRIDE;
+
+ // Called when visiblity of web_contents changes, so the embedder will
+ // show/hide its guest.
+ void WebContentsVisibilityChanged(bool visible);
+
+ // Static factory instance (always NULL for non-test).
+ static BrowserPluginHostFactory* factory_;
+
+ // A scoped container for notification registries.
+ NotificationRegistrar registrar_;
+
+ // Contains guests' WebContents, mapping to their frame ids.
+ GuestWebContentsMap guest_web_contents_container_;
+ ContainerInstanceMap guests_by_instance_id_;
+ RenderViewHost* render_view_host_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_

Powered by Google App Engine
This is Rietveld 408576698