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

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

Issue 10965009: BrowserPluginGuest/Embedder: Remove friend helper classes, made necessary calls public (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync again @tott 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // A BrowserPluginGuest represents the browser side of browser <--> renderer 5 // A BrowserPluginGuest represents the browser side of browser <--> renderer
6 // communication. A BrowserPlugin (a WebPlugin) is on the renderer side of 6 // communication. A BrowserPlugin (a WebPlugin) is on the renderer side of
7 // browser <--> guest renderer communication. The 'guest' renderer is a 7 // browser <--> guest renderer communication. The 'guest' renderer is a
8 // <browser> tag. 8 // <browser> tag.
9 // 9 //
10 // BrowserPluginGuest lives on the UI thread of the browser process. It has a 10 // BrowserPluginGuest lives on the UI thread of the browser process. It has a
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // Overrides factory for testing. Default (NULL) value indicates regular 69 // Overrides factory for testing. Default (NULL) value indicates regular
70 // (non-test) environment. 70 // (non-test) environment.
71 static void set_factory_for_testing(BrowserPluginHostFactory* factory) { 71 static void set_factory_for_testing(BrowserPluginHostFactory* factory) {
72 content::BrowserPluginGuest::factory_ = factory; 72 content::BrowserPluginGuest::factory_ = factory;
73 } 73 }
74 74
75 void set_guest_hang_timeout_for_testing(const base::TimeDelta& timeout) { 75 void set_guest_hang_timeout_for_testing(const base::TimeDelta& timeout) {
76 guest_hang_timeout_ = timeout; 76 guest_hang_timeout_ = timeout;
77 } 77 }
78 78
79 void set_embedder_render_process_host(
80 RenderProcessHost* render_process_host) {
81 embedder_render_process_host_ = render_process_host;
82 }
83
79 // WebContentsObserver implementation. 84 // WebContentsObserver implementation.
80 virtual void DidCommitProvisionalLoadForFrame( 85 virtual void DidCommitProvisionalLoadForFrame(
81 int64 frame_id, 86 int64 frame_id,
82 bool is_main_frame, 87 bool is_main_frame,
83 const GURL& url, 88 const GURL& url,
84 PageTransition transition_type, 89 PageTransition transition_type,
85 RenderViewHost* render_view_host) OVERRIDE; 90 RenderViewHost* render_view_host) OVERRIDE;
86 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; 91 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
87 92
88 // WebContentsDelegate implementation. 93 // WebContentsDelegate implementation.
89 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; 94 virtual void RendererUnresponsive(WebContents* source) OVERRIDE;
90 95
91 private:
92 friend class BrowserPluginEmbedder;
93 friend class BrowserPluginGuestHelper;
94 friend class TestBrowserPluginGuest;
95
96 BrowserPluginGuest(int instance_id,
97 WebContentsImpl* web_contents,
98 RenderViewHost* render_view_host);
99
100 void set_embedder_render_process_host(
101 RenderProcessHost* render_process_host) {
102 embedder_render_process_host_ = render_process_host;
103 }
104 RenderProcessHost* embedder_render_process_host() {
105 return embedder_render_process_host_;
106 }
107 // Returns the identifier that uniquely identifies a browser plugin guest
108 // within an embedder.
109 int instance_id() const { return instance_id_; }
110 TransportDIB* damage_buffer() const { return damage_buffer_.get(); }
111 const gfx::Size& damage_view_size() const { return damage_view_size_; }
112 float damage_buffer_scale_factor() const {
113 return damage_buffer_scale_factor_;
114 }
115 void SetDamageBuffer(TransportDIB* damage_buffer, 96 void SetDamageBuffer(TransportDIB* damage_buffer,
116 #if defined(OS_WIN) 97 #if defined(OS_WIN)
117 int damage_buffer_size, 98 int damage_buffer_size,
118 #endif 99 #endif
119 const gfx::Size& damage_view_size, 100 const gfx::Size& damage_view_size,
120 float scale_factor); 101 float scale_factor);
121 102
122 void UpdateRect(RenderViewHost* render_view_host, 103 void UpdateRect(RenderViewHost* render_view_host,
123 const ViewHostMsg_UpdateRect_Params& params); 104 const ViewHostMsg_UpdateRect_Params& params);
124 void UpdateRectACK(int message_id, const gfx::Size& size); 105 void UpdateRectACK(int message_id, const gfx::Size& size);
125 // Handles input event routed through the embedder (which is initiated in the 106 // Handles input event routed through the embedder (which is initiated in the
126 // browser plugin (renderer side of the embedder)). 107 // browser plugin (renderer side of the embedder)).
127 void HandleInputEvent(RenderViewHost* render_view_host, 108 void HandleInputEvent(RenderViewHost* render_view_host,
128 const gfx::Rect& guest_rect, 109 const gfx::Rect& guest_rect,
129 const WebKit::WebInputEvent& event, 110 const WebKit::WebInputEvent& event,
130 IPC::Message* reply_message); 111 IPC::Message* reply_message);
131 // Overrides default ShowWidget message so we show them on the correct 112 // Overrides default ShowWidget message so we show them on the correct
132 // coordinates. 113 // coordinates.
133 void ShowWidget(RenderViewHost* render_view_host, 114 void ShowWidget(RenderViewHost* render_view_host,
134 int route_id, 115 int route_id,
135 const gfx::Rect& initial_pos); 116 const gfx::Rect& initial_pos);
136 void SetCursor(const WebCursor& cursor); 117 void SetCursor(const WebCursor& cursor);
137 // Handles input event acks so they are sent to browser plugin host (via 118 // Handles input event acks so they are sent to browser plugin host (via
138 // embedder) instead of default view/widget host. 119 // embedder) instead of default view/widget host.
139 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled); 120 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled);
140 121
141 // Helper to send messages to embedder. Overridden in test implementation 122 // Exposes the protected web_contents() from WebContentsObserver.
142 // since we want to intercept certain messages for testing. 123 WebContents* GetWebContents();
143 virtual void SendMessageToEmbedder(IPC::Message* msg); 124
125 // Overridden in tests.
126 virtual bool ViewTakeFocus(bool reverse);
144 // Overridden in tests. 127 // Overridden in tests.
145 virtual void SetFocus(bool focused); 128 virtual void SetFocus(bool focused);
146 // Overridden in tests.
147 virtual bool ViewTakeFocus(bool reverse);
148 // Reload the guest. 129 // Reload the guest.
149 virtual void Reload(); 130 virtual void Reload();
150 // Stop loading the guest. 131 // Stop loading the guest.
151 virtual void Stop(); 132 virtual void Stop();
152 133
134 private:
135 friend class TestBrowserPluginGuest;
136
137 BrowserPluginGuest(int instance_id,
138 WebContentsImpl* web_contents,
139 RenderViewHost* render_view_host);
140
141 RenderProcessHost* embedder_render_process_host() {
142 return embedder_render_process_host_;
143 }
144 // Returns the identifier that uniquely identifies a browser plugin guest
145 // within an embedder.
146 int instance_id() const { return instance_id_; }
147 TransportDIB* damage_buffer() const { return damage_buffer_.get(); }
148 const gfx::Size& damage_view_size() const { return damage_view_size_; }
149 float damage_buffer_scale_factor() const {
150 return damage_buffer_scale_factor_;
151 }
152
153 // Helper to send messages to embedder. Overridden in test implementation
154 // since we want to intercept certain messages for testing.
155 virtual void SendMessageToEmbedder(IPC::Message* msg);
156
153 // Static factory instance (always NULL for non-test). 157 // Static factory instance (always NULL for non-test).
154 static content::BrowserPluginHostFactory* factory_; 158 static content::BrowserPluginHostFactory* factory_;
155 159
156 RenderProcessHost* embedder_render_process_host_; 160 RenderProcessHost* embedder_render_process_host_;
157 // An identifier that uniquely identifies a browser plugin guest within an 161 // An identifier that uniquely identifies a browser plugin guest within an
158 // embedder. 162 // embedder.
159 int instance_id_; 163 int instance_id_;
160 scoped_ptr<TransportDIB> damage_buffer_; 164 scoped_ptr<TransportDIB> damage_buffer_;
161 #if defined(OS_WIN) 165 #if defined(OS_WIN)
162 size_t damage_buffer_size_; 166 size_t damage_buffer_size_;
163 #endif 167 #endif
164 gfx::Size damage_view_size_; 168 gfx::Size damage_view_size_;
165 float damage_buffer_scale_factor_; 169 float damage_buffer_scale_factor_;
166 scoped_ptr<IPC::Message> pending_input_event_reply_; 170 scoped_ptr<IPC::Message> pending_input_event_reply_;
167 gfx::Rect guest_rect_; 171 gfx::Rect guest_rect_;
168 WebCursor cursor_; 172 WebCursor cursor_;
169 IDMap<RenderViewHost> pending_updates_; 173 IDMap<RenderViewHost> pending_updates_;
170 int pending_update_counter_; 174 int pending_update_counter_;
171 base::TimeDelta guest_hang_timeout_; 175 base::TimeDelta guest_hang_timeout_;
172 176
173 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 177 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
174 }; 178 };
175 179
176 } // namespace content 180 } // namespace content
177 181
178 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 182 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_embedder.cc ('k') | content/browser/browser_plugin/browser_plugin_guest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698