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

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: sync + Address Albert's comments. 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 virtual ~BrowserPluginGuest();
45
46 static BrowserPluginGuest* Create(int instance_id,
47 WebContentsImpl* web_contents,
48 content::RenderViewHost* render_view_host);
49
50 // Overrides factory for testing. Default (NULL) value indicates regular
51 // (non-test) environment.
52 static void set_factory_for_testing(BrowserPluginHostFactory* factory) {
53 content::BrowserPluginGuest::factory_ = factory;
54 }
55
56 // WebContentsObserver implementation.
57 virtual void DidCommitProvisionalLoadForFrame(
58 int64 frame_id,
59 bool is_main_frame,
60 const GURL& url,
61 PageTransition transition_type,
62 RenderViewHost* render_view_host) OVERRIDE;
63 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
64
65 // WebContentsDelegate implementation.
66 virtual void RendererUnresponsive(WebContents* source) OVERRIDE;
67
68 private:
69 friend class BrowserPluginEmbedder;
70 friend class BrowserPluginGuestHelper;
71 friend class TestBrowserPluginGuest;
72
73 BrowserPluginGuest(int instance_id,
74 WebContentsImpl* web_contents,
75 RenderViewHost* render_view_host);
76
77 void set_embedder_render_process_host(
78 RenderProcessHost* render_process_host) {
79 embedder_render_process_host_ = render_process_host;
80 }
81 RenderProcessHost* embedder_render_process_host() {
82 return embedder_render_process_host_;
83 }
84 // Returns the identifier that uniquely identifies a browser plugin guest
85 // within an embedder.
86 int instance_id() const { return instance_id_; }
87
88 void SetDamageBuffer(TransportDIB* damage_buffer,
89 const gfx::Size& size,
90 float scale_factor);
91 TransportDIB* damage_buffer() const { return damage_buffer_.get(); }
92 const gfx::Size& damage_buffer_size() const { return damage_buffer_size_; }
93 float damage_buffer_scale_factor() const {
94 return damage_buffer_scale_factor_;
95 }
96
97 void UpdateRect(RenderViewHost* render_view_host,
98 const ViewHostMsg_UpdateRect_Params& params);
99 void UpdateRectACK(int message_id, const gfx::Size& size);
100 // Handles input event routed through the embedder (which is initiated in the
101 // browser plugin (renderer side of the embedder)).
102 void HandleInputEvent(RenderViewHost* render_view_host,
103 const gfx::Rect& guest_rect,
104 const WebKit::WebInputEvent& event,
105 IPC::Message* reply_message);
106 // Overrides default ShowWidget message so we show them on the correct
107 // coordinates.
108 void ShowWidget(RenderViewHost* render_view_host,
109 int route_id,
110 const gfx::Rect& initial_pos);
111 void SetFocus(bool focused);
112 void SetCursor(const WebCursor& cursor);
113 // Handles input event acks so they are sent to browser plugin host (via
114 // embedder) instead of default view/widget host.
115 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled);
116
117 void Destroy();
118
119 // Helper to send messages to embedder. Overriden in test implementation since
120 // we want to intercept certain messages for testing.
121 virtual void SendMessageToEmbedder(IPC::Message*);
122
123 // Static factory instance (always NULL for non-test).
124 static content::BrowserPluginHostFactory* factory_;
125
126 bool ViewTakeFocus(bool reverse);
127
128 RenderProcessHost* embedder_render_process_host_;
129 // An identifier that uniquely identifies a browser plugin guest within an
130 // embedder.
131 int instance_id_;
132 scoped_ptr<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