Chromium Code Reviews| 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..933d36ac05e861e3fd7c1be9a9ff5e6365e5023a |
| --- /dev/null |
| +++ b/content/browser/browser_plugin/browser_plugin_embedder.h |
| @@ -0,0 +1,107 @@ |
| +// 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/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; |
| +} |
| + |
| +struct BrowserPluginHostMsg_ResizeGuest_Params; |
| +struct ViewHostMsg_UpdateRect_Params; |
| + |
| +namespace content { |
| + |
| +class BrowserPluginGuest; |
| + |
| +typedef std::map<WebContents*, int64> GuestMap; |
| +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. |
| +class BrowserPluginEmbedder : public WebContentsObserver { |
| + public: |
| + BrowserPluginEmbedder(WebContentsImpl* web_contents, |
| + RenderViewHost* render_view_host); |
|
Charlie Reis
2012/08/27 20:23:59
This suggests that we'll need to update our RVH if
lazyboy
2012/08/28 19:07:14
Or create replace with a new embedder and attach t
Charlie Reis
2012/08/29 00:11:04
Since we don't really need to preserve anything wh
|
| + virtual ~BrowserPluginEmbedder(); |
| + |
| + const ContainerInstanceMap& guests_for_testing() const { |
| + return guests_by_instance_id_; |
| + } |
| + // Navigates to a guest (new or existing). |
|
Charlie Reis
2012/08/27 20:23:59
nit: s/to/in/
Also, please add a blank line above
lazyboy
2012/08/28 19:07:14
Done.
|
| + void NavigateGuest(RenderViewHost* render_view_host, |
| + int instance_id, |
| + int64 frame_id, |
| + const std::string& src, |
| + const gfx::Size& size); |
| + |
| + private: |
| + friend class BrowserPluginEmbedderHelper; |
| + |
| + // 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. |
| + 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); |
| + // Called when visiblity of web_contents changes, the embedder would show/hide |
|
Charlie Reis
2012/08/27 20:23:59
nit: so the embedder will
lazyboy
2012/08/28 19:07:14
Done.
|
| + // its guest. |
| + void WebContentsVisiblitlyChanged(bool visible); |
| + // Handles input event sent from the BrowserPlugin (renderer) by passing it to |
|
Charlie Reis
2012/08/27 20:23:59
nit: events / passing them
Also, let's clarify (r
lazyboy
2012/08/28 19:07:14
Done.
|
| + // 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 cleanup guests when a frame navigates |
|
Charlie Reis
2012/08/27 20:23:59
nit: clean up
lazyboy
2012/08/28 19:07:14
Done.
|
| + // 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; |
| + |
| + GuestMap guests_; |
|
Charlie Reis
2012/08/27 20:23:59
It's not clear what this map is, especially since
lazyboy
2012/08/28 19:07:14
Renamed the instance to guest_web_contents_contain
|
| + ContainerInstanceMap guests_by_instance_id_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ |