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

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: Rewrite test to *not* use NOTIFICATION_* 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 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
6 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
7
8 #include <string>
9 #include <map>
10
11 #include "base/compiler_specific.h"
12 #include "base/id_map.h"
13 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
14 #include "content/public/browser/render_view_host_observer.h"
15 #include "content/public/browser/web_contents_delegate.h"
16 #include "content/public/browser/web_contents_observer.h"
17 #include "ipc/ipc_channel_handle.h"
18 #include "ipc/ipc_sync_message.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
20 #include "ui/surface/transport_dib.h"
21 #include "ui/gfx/rect.h"
22 #include "ui/gfx/size.h"
23 #include "webkit/glue/webcursor.h"
24
25 namespace gfx {
26 class Size;
27 }
28
29 struct BrowserPluginHostMsg_ResizeGuest_Params;
30 struct ViewHostMsg_UpdateRect_Params;
31
32 namespace content {
33
34 class BrowserPluginHostFactory;
35 class BrowserPluginEmbedder;
36 class RenderProcessHost;
37
38 // A browser plugin guest provides functionality for WebContents to operate in
39 // the guest role and implements guest specific overrides for ViewHostMsg_*
40 // messages.
41 class CONTENT_EXPORT BrowserPluginGuest : public WebContentsDelegate,
42 public WebContentsObserver {
43 public:
44 BrowserPluginGuest(int instance_id,
45 WebContentsImpl* web_contents,
46 RenderViewHost* render_view_host);
47 virtual ~BrowserPluginGuest();
48
49 static BrowserPluginGuest* CreateInstance(
50 int instance_id,
51 WebContentsImpl* web_contents,
52 content::RenderViewHost* render_view_host);
53
54 // Overrides factory for testing. Default (NULL) value indicates regular
55 // (non-test) environment.
56 static void set_factory_for_testing(BrowserPluginHostFactory* factory) {
57 content::BrowserPluginGuest::factory_ = factory;
58 }
59
60 private:
61 friend class BrowserPluginEmbedder;
62 friend class BrowserPluginGuestHelper;
63 // For testing.
64 friend class TestBrowserPluginGuest;
65
66 void set_embedder_render_process_host(
67 RenderProcessHost* render_process_host) {
68 embedder_render_process_host_ = render_process_host;
69 }
70 RenderProcessHost* embedder_render_process_host() {
71 return embedder_render_process_host_;
72 }
73 // Returns the identifier that uniquely identifies a browser plugin guest
74 // within an embedder.
75 int instance_id() const { return instance_id_; }
76
77 void SetDamageBuffer(TransportDIB* damage_buffer,
78 const gfx::Size& size,
79 float scale_factor);
80 TransportDIB* damage_buffer() const { return damage_buffer_; }
81 const gfx::Size& damage_buffer_size() const { return damage_buffer_size_; }
82 float damage_buffer_scale_factor() const {
83 return damage_buffer_scale_factor_;
84 }
85
86 void UpdateRect(RenderViewHost* render_view_host,
87 const ViewHostMsg_UpdateRect_Params& params);
88 void UpdateRectACK(int message_id, const gfx::Size& size);
89 // Handles input event routed through the embedder (which is initiated in the
90 // browser plugin (renderer side of the embedder)).
91 void HandleInputEvent(RenderViewHost* render_view_host,
92 const gfx::Rect& guest_rect,
93 const WebKit::WebInputEvent& event,
94 IPC::Message* reply_message);
95 // Overrides default ShowWidget message so we show them on the correct
96 // coordinates.
97 void ShowWidget(RenderViewHost* render_view_host,
98 int route_id,
99 const gfx::Rect& initial_pos);
100 void SetFocus(bool focused);
101 void SetCursor(const WebCursor& cursor);
102 // Handles input event acks so they are sent to browser plugin host (via
103 // embedder) instead of default view/widget host.
104 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled);
105
106 void Destroy();
107
108 // WebContentsObserver implementation.
109 virtual void DidCommitProvisionalLoadForFrame(
110 int64 frame_id,
111 bool is_main_frame,
112 const GURL& url,
113 PageTransition transition_type,
114 RenderViewHost* render_view_host) OVERRIDE;
115 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
116
117 // WebContentsDelegate implementation.
118 virtual bool TakeFocus(bool reverse) OVERRIDE;
119 virtual void RendererUnresponsive(WebContents* source) OVERRIDE;
120
121 // Helper to send messages to embedder. Overriden in test implementation since
122 // we want to intercept certain messages for testing.
123 virtual void SendMessageToEmbedder(IPC::Message*);
124
125 // Static factory instance (always NULL for non-test).
126 static content::BrowserPluginHostFactory* factory_;
127
128 RenderProcessHost* embedder_render_process_host_;
129 // An identifier that uniquely identifies a browser plugin container within an
130 // embedder.
131 int instance_id_;
132 TransportDIB* damage_buffer_;
133 gfx::Size damage_buffer_size_;
134 float damage_buffer_scale_factor_;
135 scoped_ptr<IPC::Message> pending_input_event_reply_;
136 gfx::Rect guest_rect_;
137 WebCursor cursor_;
138 IDMap<RenderViewHost> pending_updates_;
139 int pending_update_counter_;
140
141 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
142 };
143
144 } // namespace content
145
146 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698