Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ | |
| 6 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "content/public/browser/render_view_host_observer.h" | |
| 12 #include "content/public/browser/web_contents_delegate.h" | |
| 13 #include "content/public/browser/web_contents_observer.h" | |
| 14 #include "ipc/ipc_channel_handle.h" | |
| 15 #include "ipc/ipc_sync_message.h" | |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | |
| 17 #include "ui/surface/transport_dib.h" | |
| 18 #include "webkit/glue/webcursor.h" | |
| 19 | |
| 20 namespace gfx { | |
| 21 class Size; | |
| 22 } | |
| 23 | |
| 24 struct BrowserPluginHostMsg_ResizeGuest_Params; | |
| 25 struct ViewHostMsg_UpdateRect_Params; | |
| 26 | |
| 27 namespace content { | |
| 28 | |
| 29 class BrowserPluginGuest; | |
| 30 | |
| 31 typedef std::map<WebContents*, int64> GuestMap; | |
| 32 typedef std::map<int, BrowserPluginGuest*> ContainerInstanceMap; | |
| 33 | |
| 34 // A browser plugin embedder provides functionality for WebContents to operate | |
| 35 // in the 'embedder' role, manages list of guests inside the embedder. | |
| 36 class BrowserPluginEmbedder : public WebContentsObserver { | |
| 37 public: | |
| 38 BrowserPluginEmbedder(WebContentsImpl* web_contents, | |
| 39 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
| |
| 40 virtual ~BrowserPluginEmbedder(); | |
| 41 | |
| 42 const ContainerInstanceMap& guests_for_testing() const { | |
| 43 return guests_by_instance_id_; | |
| 44 } | |
| 45 // 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.
| |
| 46 void NavigateGuest(RenderViewHost* render_view_host, | |
| 47 int instance_id, | |
| 48 int64 frame_id, | |
| 49 const std::string& src, | |
| 50 const gfx::Size& size); | |
| 51 | |
| 52 private: | |
| 53 friend class BrowserPluginEmbedderHelper; | |
| 54 | |
| 55 // Returns a guest browser plugin delegate by its container ID specified | |
| 56 // in BrowserPlugin. | |
| 57 BrowserPluginGuest* GetGuestByInstanceID(int instance_id) const; | |
| 58 // Adds a new guest to the embedder. | |
| 59 void AddGuest(int instance_id, | |
| 60 BrowserPluginGuest* guest, | |
| 61 int64 frame_id); | |
| 62 void DestroyGuestByInstanceID(int instance_id); | |
| 63 void DestroyGuests(); | |
| 64 | |
| 65 // Message handlers (direct/indirect via BrowserPluginEmbedderHelper). | |
| 66 // Routes update rect ack message to the appropriate guest. | |
| 67 void UpdateRectACK(int instance_id, int message_id, const gfx::Size& size); | |
| 68 void SetFocus(int instance_id, bool focused); | |
| 69 void ResizeGuest(int instance_id, | |
| 70 TransportDIB* damage_buffer, | |
| 71 int width, | |
| 72 int height, | |
| 73 bool resize_pending, | |
| 74 float scale_factor); | |
| 75 // 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.
| |
| 76 // its guest. | |
| 77 void WebContentsVisiblitlyChanged(bool visible); | |
| 78 // 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.
| |
| 79 // appropriate guest's input handler. | |
| 80 void HandleInputEvent(int instance_id, | |
| 81 RenderViewHost* render_view_host, | |
| 82 const gfx::Rect& guest_rect, | |
| 83 const WebKit::WebInputEvent& event, | |
| 84 IPC::Message* reply_message); | |
| 85 void PluginDestroyed(int instance_id); | |
| 86 | |
| 87 // WebContentsObserver implementation. | |
| 88 // 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.
| |
| 89 // away from the browser plugin it's hosting. | |
| 90 virtual void DidCommitProvisionalLoadForFrame( | |
| 91 int64 frame_id, | |
| 92 bool is_main_frame, | |
| 93 const GURL& url, | |
| 94 PageTransition transition_type, | |
| 95 RenderViewHost* render_view_host) OVERRIDE; | |
| 96 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; | |
| 97 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | |
| 98 | |
| 99 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
| |
| 100 ContainerInstanceMap guests_by_instance_id_; | |
| 101 | |
| 102 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); | |
| 103 }; | |
| 104 | |
| 105 } // namespace content | |
| 106 | |
| 107 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ | |
| OLD | NEW |