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 // A BrowserPluginGuest represents the browser side of browser <--> renderer | |
awong
2012/09/07 20:51:03
This comment block could use some paragraphs break
lazyboy
2012/09/08 02:12:22
Done.
| |
6 // communication (a browser plugin (which is a WebPlugin) is on the renderer | |
awong
2012/09/07 20:51:03
Make the parenthetical statement its own sentence.
lazyboy
2012/09/08 02:12:22
Done.
| |
7 // side). It lives on the UI thread of the browser process. It has a helper, | |
8 // BrowserPluginGuestHelper, which is a RenderViewHostObserver. The helper | |
9 // object receives messages (RenderViewHostMsg_*) directed at the browser plugin | |
awong
2012/09/07 20:51:03
Is there a way to know which RenderViewHostMsg_* w
lazyboy
2012/09/08 02:12:22
Fady can you answer this one? Thanks.
Fady Samuel
2012/09/10 16:24:11
Firstly, I believe that should say ViewHostMsg_* r
awong
2012/09/10 19:21:07
Yeah...you're right. feel free to ignore my commen
lazyboy
2012/09/10 23:40:56
Fixed the note here saying ViewHostMsg_* instead o
| |
10 // and redirects them to this class. Since BrowserPlugin is a WebPlugin, we need | |
11 // to provide overriden behaviors for messages like handleInputEvent, | |
12 // updateGeometry. Such messages gets routed into BrowserPluginGuest via its | |
13 // embedder (BrowserPluginEmbedder). These are BrowserPluginHost_* messages sent | |
14 // from the BrowserPlugin. | |
15 // It knows about its embedder process, communication to renderer happens | |
awong
2012/09/07 20:51:03
s/It/BrowserPluginGuest/
Otherwise the antecedent
lazyboy
2012/09/08 02:12:22
Done.
| |
16 // through the embedder process. | |
17 // A BrowserPluginGuest is also associated directly with the WebContents related | |
18 // to the BrowserPlugin, its a WebContentsDelegate and WebContentsObserver for | |
awong
2012/09/07 20:51:03
, its -> . It is
lazyboy
2012/09/08 02:12:22
Done.
| |
19 // it. | |
awong
2012/09/07 20:51:03
"it" twice in one sentence referring to 2 differen
lazyboy
2012/09/08 02:12:22
Done.
| |
20 | |
21 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | |
22 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | |
23 | |
24 #include <string> | |
25 #include <map> | |
26 | |
27 #include "base/compiler_specific.h" | |
28 #include "base/id_map.h" | |
29 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" | |
30 #include "content/public/browser/render_view_host_observer.h" | |
31 #include "content/public/browser/web_contents_delegate.h" | |
32 #include "content/public/browser/web_contents_observer.h" | |
33 #include "ipc/ipc_channel_handle.h" | |
34 #include "ipc/ipc_sync_message.h" | |
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | |
36 #include "ui/surface/transport_dib.h" | |
37 #include "ui/gfx/rect.h" | |
38 #include "ui/gfx/size.h" | |
39 #include "webkit/glue/webcursor.h" | |
40 | |
41 namespace gfx { | |
42 class Size; | |
43 } | |
44 | |
45 struct BrowserPluginHostMsg_ResizeGuest_Params; | |
46 struct ViewHostMsg_UpdateRect_Params; | |
47 | |
48 namespace content { | |
49 | |
50 class BrowserPluginHostFactory; | |
51 class BrowserPluginEmbedder; | |
52 class RenderProcessHost; | |
53 | |
54 // A browser plugin guest provides functionality for WebContents to operate in | |
55 // the guest role and implements guest specific overrides for ViewHostMsg_* | |
56 // messages. | |
awong
2012/09/07 20:51:03
Newline between paragraphs. Please fix here and i
lazyboy
2012/09/08 02:12:22
Done.
| |
57 // BrowserPluginEmbedder is responsible for creating and destroying a guest. | |
58 class CONTENT_EXPORT BrowserPluginGuest : public WebContentsDelegate, | |
59 public WebContentsObserver { | |
60 public: | |
61 virtual ~BrowserPluginGuest(); | |
62 | |
63 static BrowserPluginGuest* Create(int instance_id, | |
64 WebContentsImpl* web_contents, | |
65 content::RenderViewHost* render_view_host); | |
66 | |
67 // Overrides factory for testing. Default (NULL) value indicates regular | |
68 // (non-test) environment. | |
69 static void set_factory_for_testing(BrowserPluginHostFactory* factory) { | |
70 content::BrowserPluginGuest::factory_ = factory; | |
71 } | |
72 | |
73 // WebContentsObserver implementation. | |
74 virtual void DidCommitProvisionalLoadForFrame( | |
75 int64 frame_id, | |
76 bool is_main_frame, | |
77 const GURL& url, | |
78 PageTransition transition_type, | |
79 RenderViewHost* render_view_host) OVERRIDE; | |
80 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | |
81 | |
82 // WebContentsDelegate implementation. | |
83 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; | |
84 | |
85 private: | |
86 friend class BrowserPluginEmbedder; | |
87 friend class BrowserPluginGuestHelper; | |
88 friend class TestBrowserPluginGuest; | |
89 | |
90 BrowserPluginGuest(int instance_id, | |
91 WebContentsImpl* web_contents, | |
92 RenderViewHost* render_view_host); | |
93 | |
94 void set_embedder_render_process_host( | |
95 RenderProcessHost* render_process_host) { | |
96 embedder_render_process_host_ = render_process_host; | |
97 } | |
98 RenderProcessHost* embedder_render_process_host() { | |
99 return embedder_render_process_host_; | |
100 } | |
101 // Returns the identifier that uniquely identifies a browser plugin guest | |
102 // within an embedder. | |
103 int instance_id() const { return instance_id_; } | |
104 | |
105 void SetDamageBuffer(TransportDIB* damage_buffer, | |
106 const gfx::Size& size, | |
107 float scale_factor); | |
108 TransportDIB* damage_buffer() const { return damage_buffer_.get(); } | |
109 const gfx::Size& damage_buffer_size() const { return damage_buffer_size_; } | |
110 float damage_buffer_scale_factor() const { | |
111 return damage_buffer_scale_factor_; | |
112 } | |
113 | |
114 void UpdateRect(RenderViewHost* render_view_host, | |
115 const ViewHostMsg_UpdateRect_Params& params); | |
116 void UpdateRectACK(int message_id, const gfx::Size& size); | |
117 // Handles input event routed through the embedder (which is initiated in the | |
118 // browser plugin (renderer side of the embedder)). | |
119 void HandleInputEvent(RenderViewHost* render_view_host, | |
120 const gfx::Rect& guest_rect, | |
121 const WebKit::WebInputEvent& event, | |
122 IPC::Message* reply_message); | |
123 // Overrides default ShowWidget message so we show them on the correct | |
124 // coordinates. | |
125 void ShowWidget(RenderViewHost* render_view_host, | |
126 int route_id, | |
127 const gfx::Rect& initial_pos); | |
128 void SetFocus(bool focused); | |
129 void SetCursor(const WebCursor& cursor); | |
130 // Handles input event acks so they are sent to browser plugin host (via | |
131 // embedder) instead of default view/widget host. | |
132 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled); | |
133 | |
134 void Destroy(); | |
135 | |
136 // Helper to send messages to embedder. Overriden in test implementation since | |
137 // we want to intercept certain messages for testing. | |
138 virtual void SendMessageToEmbedder(IPC::Message*); | |
139 | |
140 // Static factory instance (always NULL for non-test). | |
141 static content::BrowserPluginHostFactory* factory_; | |
142 | |
143 bool ViewTakeFocus(bool reverse); | |
144 | |
145 RenderProcessHost* embedder_render_process_host_; | |
146 // An identifier that uniquely identifies a browser plugin guest within an | |
147 // embedder. | |
148 int instance_id_; | |
149 scoped_ptr<TransportDIB> damage_buffer_; | |
150 gfx::Size damage_buffer_size_; | |
151 float damage_buffer_scale_factor_; | |
152 scoped_ptr<IPC::Message> pending_input_event_reply_; | |
153 gfx::Rect guest_rect_; | |
154 WebCursor cursor_; | |
155 IDMap<RenderViewHost> pending_updates_; | |
156 int pending_update_counter_; | |
157 | |
158 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | |
159 }; | |
160 | |
161 } // namespace content | |
162 | |
163 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | |
OLD | NEW |