OLD | NEW |
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 16 matching lines...) Expand all Loading... |
27 // WebContentsObserver for the WebContents. | 27 // WebContentsObserver for the WebContents. |
28 | 28 |
29 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 29 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
30 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 30 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
31 | 31 |
32 #include <map> | 32 #include <map> |
33 | 33 |
34 #include "base/compiler_specific.h" | 34 #include "base/compiler_specific.h" |
35 #include "base/id_map.h" | 35 #include "base/id_map.h" |
36 #include "base/time.h" | 36 #include "base/time.h" |
| 37 #include "content/public/browser/notification_observer.h" |
| 38 #include "content/public/browser/notification_registrar.h" |
37 #include "content/public/browser/web_contents_delegate.h" | 39 #include "content/public/browser/web_contents_delegate.h" |
38 #include "content/public/browser/web_contents_observer.h" | 40 #include "content/public/browser/web_contents_observer.h" |
39 #include "ui/gfx/rect.h" | 41 #include "ui/gfx/rect.h" |
40 #include "webkit/glue/webcursor.h" | 42 #include "webkit/glue/webcursor.h" |
41 | 43 |
42 class TransportDIB; | 44 class TransportDIB; |
43 struct ViewHostMsg_UpdateRect_Params; | 45 struct ViewHostMsg_UpdateRect_Params; |
44 | 46 |
45 namespace WebKit { | 47 namespace WebKit { |
46 class WebInputEvent; | 48 class WebInputEvent; |
47 } | 49 } |
48 | 50 |
49 namespace content { | 51 namespace content { |
50 | 52 |
51 class BrowserPluginHostFactory; | 53 class BrowserPluginHostFactory; |
52 class BrowserPluginEmbedder; | 54 class BrowserPluginEmbedder; |
53 class RenderProcessHost; | 55 class RenderProcessHost; |
54 | 56 |
55 // A browser plugin guest provides functionality for WebContents to operate in | 57 // A browser plugin guest provides functionality for WebContents to operate in |
56 // the guest role and implements guest specific overrides for ViewHostMsg_* | 58 // the guest role and implements guest specific overrides for ViewHostMsg_* |
57 // messages. | 59 // messages. |
58 // | 60 // |
59 // BrowserPluginEmbedder is responsible for creating and destroying a guest. | 61 // BrowserPluginEmbedder is responsible for creating and destroying a guest. |
60 class CONTENT_EXPORT BrowserPluginGuest : public WebContentsDelegate, | 62 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, |
| 63 public WebContentsDelegate, |
61 public WebContentsObserver { | 64 public WebContentsObserver { |
62 public: | 65 public: |
63 virtual ~BrowserPluginGuest(); | 66 virtual ~BrowserPluginGuest(); |
64 | 67 |
65 static BrowserPluginGuest* Create(int instance_id, | 68 static BrowserPluginGuest* Create(int instance_id, |
66 WebContentsImpl* web_contents, | 69 WebContentsImpl* web_contents, |
67 content::RenderViewHost* render_view_host); | 70 content::RenderViewHost* render_view_host); |
68 | 71 |
69 // Overrides factory for testing. Default (NULL) value indicates regular | 72 // Overrides factory for testing. Default (NULL) value indicates regular |
70 // (non-test) environment. | 73 // (non-test) environment. |
71 static void set_factory_for_testing(BrowserPluginHostFactory* factory) { | 74 static void set_factory_for_testing(BrowserPluginHostFactory* factory) { |
72 content::BrowserPluginGuest::factory_ = factory; | 75 content::BrowserPluginGuest::factory_ = factory; |
73 } | 76 } |
74 | 77 |
75 void set_guest_hang_timeout_for_testing(const base::TimeDelta& timeout) { | 78 void set_guest_hang_timeout_for_testing(const base::TimeDelta& timeout) { |
76 guest_hang_timeout_ = timeout; | 79 guest_hang_timeout_ = timeout; |
77 } | 80 } |
78 | 81 |
79 void set_embedder_render_process_host( | 82 void set_embedder_render_process_host( |
80 RenderProcessHost* render_process_host) { | 83 RenderProcessHost* render_process_host) { |
81 embedder_render_process_host_ = render_process_host; | 84 embedder_render_process_host_ = render_process_host; |
82 } | 85 } |
83 | 86 |
| 87 // NotificationObserver implementation. |
| 88 virtual void Observe(int type, |
| 89 const NotificationSource& source, |
| 90 const NotificationDetails& details) OVERRIDE; |
| 91 |
84 // WebContentsObserver implementation. | 92 // WebContentsObserver implementation. |
85 virtual void DidStartProvisionalLoadForFrame( | 93 virtual void DidStartProvisionalLoadForFrame( |
86 int64 frame_id, | 94 int64 frame_id, |
87 bool is_main_frame, | 95 bool is_main_frame, |
88 const GURL& validated_url, | 96 const GURL& validated_url, |
89 bool is_error_page, | 97 bool is_error_page, |
90 RenderViewHost* render_view_host) OVERRIDE; | 98 RenderViewHost* render_view_host) OVERRIDE; |
91 virtual void DidFailProvisionalLoad( | 99 virtual void DidFailProvisionalLoad( |
92 int64 frame_id, | 100 int64 frame_id, |
93 bool is_main_frame, | 101 bool is_main_frame, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 TransportDIB* damage_buffer() const { return damage_buffer_.get(); } | 181 TransportDIB* damage_buffer() const { return damage_buffer_.get(); } |
174 const gfx::Size& damage_view_size() const { return damage_view_size_; } | 182 const gfx::Size& damage_view_size() const { return damage_view_size_; } |
175 float damage_buffer_scale_factor() const { | 183 float damage_buffer_scale_factor() const { |
176 return damage_buffer_scale_factor_; | 184 return damage_buffer_scale_factor_; |
177 } | 185 } |
178 | 186 |
179 // Helper to send messages to embedder. Overridden in test implementation | 187 // Helper to send messages to embedder. Overridden in test implementation |
180 // since we want to intercept certain messages for testing. | 188 // since we want to intercept certain messages for testing. |
181 virtual void SendMessageToEmbedder(IPC::Message* msg); | 189 virtual void SendMessageToEmbedder(IPC::Message* msg); |
182 | 190 |
| 191 // Called when a redirect notification occurs. |
| 192 void LoadRedirect(const GURL& old_url, |
| 193 const GURL& new_url, |
| 194 bool is_top_level); |
| 195 |
183 // Static factory instance (always NULL for non-test). | 196 // Static factory instance (always NULL for non-test). |
184 static content::BrowserPluginHostFactory* factory_; | 197 static content::BrowserPluginHostFactory* factory_; |
185 | 198 |
| 199 NotificationRegistrar notification_registrar_; |
186 RenderProcessHost* embedder_render_process_host_; | 200 RenderProcessHost* embedder_render_process_host_; |
187 // An identifier that uniquely identifies a browser plugin guest within an | 201 // An identifier that uniquely identifies a browser plugin guest within an |
188 // embedder. | 202 // embedder. |
189 int instance_id_; | 203 int instance_id_; |
190 scoped_ptr<TransportDIB> damage_buffer_; | 204 scoped_ptr<TransportDIB> damage_buffer_; |
191 #if defined(OS_WIN) | 205 #if defined(OS_WIN) |
192 size_t damage_buffer_size_; | 206 size_t damage_buffer_size_; |
193 #endif | 207 #endif |
194 gfx::Size damage_view_size_; | 208 gfx::Size damage_view_size_; |
195 float damage_buffer_scale_factor_; | 209 float damage_buffer_scale_factor_; |
196 scoped_ptr<IPC::Message> pending_input_event_reply_; | 210 scoped_ptr<IPC::Message> pending_input_event_reply_; |
197 gfx::Rect guest_rect_; | 211 gfx::Rect guest_rect_; |
198 WebCursor cursor_; | 212 WebCursor cursor_; |
199 IDMap<RenderViewHost> pending_updates_; | 213 IDMap<RenderViewHost> pending_updates_; |
200 int pending_update_counter_; | 214 int pending_update_counter_; |
201 base::TimeDelta guest_hang_timeout_; | 215 base::TimeDelta guest_hang_timeout_; |
202 | 216 |
203 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 217 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
204 }; | 218 }; |
205 | 219 |
206 } // namespace content | 220 } // namespace content |
207 | 221 |
208 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 222 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
OLD | NEW |