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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.h

Issue 10868012: Browser Plugin: New Implementation (Browser Side) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master-trial-obrowser
Patch Set: @tott + Address comments + fix win_rel trybot flakiness Created 8 years, 3 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 unified diff | Download patch
OLDNEW
(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
6 // communication. A BrowserPlugin (a WebPlugin) is on the renderer side of
7 // browser <--> guest renderer communication. The 'guest' renderer is a
8 // <browser> tag.
9 //
10 // BrowserPluginGuest lives on the UI thread of the browser process. It has a
11 // helper, BrowserPluginGuestHelper, which is a RenderViewHostObserver. The
12 // helper object receives messages (ViewHostMsg_*) directed at the browser
13 // plugin and redirects them to this class. Any messages the embedder might be
14 // interested in knowing or modifying about the guest should be listened for
15 // here.
16 //
17 // Since BrowserPlugin is a WebPlugin, we need to provide overridden behaviors
18 // for messages like handleInputEvent, updateGeometry. Such messages get
19 // routed into BrowserPluginGuest via its embedder (BrowserPluginEmbedder).
20 // These are BrowserPluginHost_* messages sent from the BrowserPlugin.
21 //
22 // BrowserPluginGuest knows about its embedder process. Communication to
23 // renderer happens through the embedder process.
24 //
25 // A BrowserPluginGuest is also associated directly with the WebContents related
26 // to the BrowserPlugin. BrowserPluginGuest is a WebContentsDelegate and
27 // WebContentsObserver for the WebContents.
28
29 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
30 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
31
32 #include <string>
jam 2012/09/17 17:47:52 nit: order. also, including string is really unnec
lazyboy 2012/09/17 20:22:24 Done.
33 #include <map>
34
35 #include "base/compiler_specific.h"
36 #include "base/id_map.h"
37 #include "base/time.h"
38 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
39 #include "content/public/browser/render_view_host_observer.h"
jam 2012/09/17 17:47:53 nit: why?
lazyboy 2012/09/17 20:22:24 Removed (this class used to be RVHObserver).
40 #include "content/public/browser/web_contents_delegate.h"
41 #include "content/public/browser/web_contents_observer.h"
42 #include "ipc/ipc_channel_handle.h"
jam 2012/09/17 17:47:53 nit: why?
lazyboy 2012/09/17 20:22:24 Removed.
43 #include "ipc/ipc_sync_message.h"
jam 2012/09/17 17:47:53 why?
lazyboy 2012/09/17 20:22:24 Removed.
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
jam 2012/09/17 17:47:53 forward declare instead of including?
lazyboy 2012/09/17 20:22:24 Done.
45 #include "ui/surface/transport_dib.h"
46 #include "ui/gfx/rect.h"
47 #include "ui/gfx/size.h"
jam 2012/09/17 17:47:53 not needed since you include rect
lazyboy 2012/09/17 20:22:24 Done. Doesn't this contradict style rule: "Do not
jam 2012/09/17 20:47:57 we don't include parent headers. i.e. if you inclu
lazyboy 2012/09/17 21:07:54 I see, found one such view_message occurrence, Rem
48 #include "webkit/glue/webcursor.h"
49
50 namespace gfx {
51 class Size;
jam 2012/09/17 17:47:53 not needed since you include the header.
lazyboy 2012/09/17 20:22:24 Done.
52 }
53
54 struct BrowserPluginHostMsg_ResizeGuest_Params;
55 struct ViewHostMsg_UpdateRect_Params;
56
57 namespace content {
58
59 class BrowserPluginHostFactory;
60 class BrowserPluginEmbedder;
61 class RenderProcessHost;
62
63 // A browser plugin guest provides functionality for WebContents to operate in
64 // the guest role and implements guest specific overrides for ViewHostMsg_*
65 // messages.
66 //
67 // BrowserPluginEmbedder is responsible for creating and destroying a guest.
68 class CONTENT_EXPORT BrowserPluginGuest : public WebContentsDelegate,
69 public WebContentsObserver {
70 public:
71 virtual ~BrowserPluginGuest();
72
73 static BrowserPluginGuest* Create(int instance_id,
74 WebContentsImpl* web_contents,
75 content::RenderViewHost* render_view_host);
76
77 // Overrides factory for testing. Default (NULL) value indicates regular
78 // (non-test) environment.
79 static void set_factory_for_testing(BrowserPluginHostFactory* factory) {
80 content::BrowserPluginGuest::factory_ = factory;
81 }
82
83 void SetGuestHangTimeoutForTesting(const base::TimeDelta& timeout) {
jam 2012/09/17 17:47:53 nit: since this is inline: set_guest_hang_timeout_
lazyboy 2012/09/17 20:22:24 Done.
84 guest_hang_timeout_ = timeout;
85 }
86
87 // WebContentsObserver implementation.
88 virtual void DidCommitProvisionalLoadForFrame(
89 int64 frame_id,
90 bool is_main_frame,
91 const GURL& url,
92 PageTransition transition_type,
93 RenderViewHost* render_view_host) OVERRIDE;
94 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
95
96 // WebContentsDelegate implementation.
97 virtual void RendererUnresponsive(WebContents* source) OVERRIDE;
98
99 private:
100 friend class BrowserPluginEmbedder;
101 friend class BrowserPluginGuestHelper;
102 friend class TestBrowserPluginGuest;
103
104 BrowserPluginGuest(int instance_id,
105 WebContentsImpl* web_contents,
106 RenderViewHost* render_view_host);
107
108 void set_embedder_render_process_host(
jam 2012/09/17 17:47:53 to make this header easier to read, can you: -put
lazyboy 2012/09/17 20:22:24 Done.
jam 2012/09/17 22:13:36 doesn't look like it?
lazyboy 2012/09/17 22:37:48 Sorry, not sure if I follow the first one: this fu
jam 2012/09/17 23:08:56 exactly
109 RenderProcessHost* render_process_host) {
110 embedder_render_process_host_ = render_process_host;
111 }
112 RenderProcessHost* embedder_render_process_host() {
113 return embedder_render_process_host_;
114 }
115 // Returns the identifier that uniquely identifies a browser plugin guest
116 // within an embedder.
117 int instance_id() const { return instance_id_; }
118
119 void SetDamageBuffer(TransportDIB* damage_buffer,
120 #if defined(OS_WIN)
121 int damage_buffer_size,
122 #endif
123 const gfx::Size& damage_view_size,
124 float scale_factor);
125 TransportDIB* damage_buffer() const { return damage_buffer_.get(); }
126 const gfx::Size& damage_view_size() const { return damage_view_size_; }
127 float damage_buffer_scale_factor() const {
128 return damage_buffer_scale_factor_;
129 }
130
131 void UpdateRect(RenderViewHost* render_view_host,
132 const ViewHostMsg_UpdateRect_Params& params);
133 void UpdateRectACK(int message_id, const gfx::Size& size);
134 // Handles input event routed through the embedder (which is initiated in the
135 // browser plugin (renderer side of the embedder)).
136 void HandleInputEvent(RenderViewHost* render_view_host,
137 const gfx::Rect& guest_rect,
138 const WebKit::WebInputEvent& event,
139 IPC::Message* reply_message);
140 // Overrides default ShowWidget message so we show them on the correct
141 // coordinates.
142 void ShowWidget(RenderViewHost* render_view_host,
143 int route_id,
144 const gfx::Rect& initial_pos);
145 // Overridden in tests.
146 virtual void SetFocus(bool focused);
147 void SetCursor(const WebCursor& cursor);
148 // Handles input event acks so they are sent to browser plugin host (via
149 // embedder) instead of default view/widget host.
150 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled);
151
152 // Helper to send messages to embedder. Overridden in test implementation
153 // since we want to intercept certain messages for testing.
154 virtual void SendMessageToEmbedder(IPC::Message*);
jam 2012/09/17 17:47:53 nit: chrome style is to always list the parameter
lazyboy 2012/09/17 20:22:24 Done.
155
156 // Static factory instance (always NULL for non-test).
157 static content::BrowserPluginHostFactory* factory_;
158
159 // Overridden in tests.
160 virtual bool ViewTakeFocus(bool reverse);
161
162 RenderProcessHost* embedder_render_process_host_;
163 // An identifier that uniquely identifies a browser plugin guest within an
164 // embedder.
165 int instance_id_;
166 scoped_ptr<TransportDIB> damage_buffer_;
167 #if defined(OS_WIN)
168 size_t damage_buffer_size_;
169 #endif
170 gfx::Size damage_view_size_;
171 float damage_buffer_scale_factor_;
172 scoped_ptr<IPC::Message> pending_input_event_reply_;
173 gfx::Rect guest_rect_;
174 WebCursor cursor_;
175 IDMap<RenderViewHost> pending_updates_;
176 int pending_update_counter_;
177 base::TimeDelta guest_hang_timeout_;
178
179 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
180 };
181
182 } // namespace content
183
184 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698