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 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
7 | 7 |
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" | 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 struct BrowserPluginHostMsg_ResizeGuest_Params; | 23 struct BrowserPluginHostMsg_ResizeGuest_Params; |
24 struct BrowserPluginMsg_LoadCommit_Params; | 24 struct BrowserPluginMsg_LoadCommit_Params; |
25 struct BrowserPluginMsg_UpdateRect_Params; | 25 struct BrowserPluginMsg_UpdateRect_Params; |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 | 28 |
29 class BrowserPluginManager; | 29 class BrowserPluginManager; |
30 class MockBrowserPlugin; | 30 class MockBrowserPlugin; |
31 | 31 |
32 class CONTENT_EXPORT BrowserPlugin : | 32 class CONTENT_EXPORT BrowserPlugin : |
33 NON_EXPORTED_BASE(public WebKit::WebPlugin) { | 33 NON_EXPORTED_BASE(public WebKit::WebPlugin), |
34 public IPC::Listener { | |
sadrul
2012/12/14 16:08:39
The plugin doesn't need to be an IPC::Listener, ri
Fady Samuel
2012/12/14 17:05:54
It does not and I don't have immediate plans to pa
| |
34 public: | 35 public: |
35 RenderViewImpl* render_view() const { return render_view_.get(); } | 36 RenderViewImpl* render_view() const { return render_view_.get(); } |
36 // Called only by tests to clean up before we blow away the MockRenderProcess. | 37 // Called only by tests to clean up before we blow away the MockRenderProcess. |
37 void Cleanup(); | 38 void Cleanup(); |
38 | 39 |
40 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | |
41 | |
39 // Update Browser Plugin's DOM Node attribute |attribute_name| with the value | 42 // Update Browser Plugin's DOM Node attribute |attribute_name| with the value |
40 // |attribute_value|. | 43 // |attribute_value|. |
41 void UpdateDOMAttribute(const std::string& attribute_name, | 44 void UpdateDOMAttribute(const std::string& attribute_name, |
42 const std::string& attribute_value); | 45 const std::string& attribute_value); |
43 | 46 |
44 // Get the src attribute value of the BrowserPlugin instance. | 47 // Get the src attribute value of the BrowserPlugin instance. |
45 std::string src_attribute() const { return src_; } | 48 std::string src_attribute() const { return src_; } |
46 // Set the src attribute value of the BrowserPlugin instance. | 49 // Set the src attribute value of the BrowserPlugin instance. |
47 bool SetSrcAttribute(const std::string& src, std::string* error_message); | 50 bool SetSrcAttribute(const std::string& src, std::string* error_message); |
48 // Get the autosize attribute value. | 51 // Get the autosize attribute value. |
(...skipping 28 matching lines...) Expand all Loading... | |
77 // Query whether the guest can navigate back to the previous entry. | 80 // Query whether the guest can navigate back to the previous entry. |
78 bool CanGoBack() const; | 81 bool CanGoBack() const; |
79 // Query whether the guest can navigation forward to the next entry. | 82 // Query whether the guest can navigation forward to the next entry. |
80 bool CanGoForward() const; | 83 bool CanGoForward() const; |
81 // This method can be successfully called only before the first navigation for | 84 // This method can be successfully called only before the first navigation for |
82 // this instance of BrowserPlugin. If an error occurs, the |error_message| is | 85 // this instance of BrowserPlugin. If an error occurs, the |error_message| is |
83 // set appropriately to indicate the failure reason. | 86 // set appropriately to indicate the failure reason. |
84 bool SetPartitionAttribute(const std::string& partition_id, | 87 bool SetPartitionAttribute(const std::string& partition_id, |
85 std::string* error_message); | 88 std::string* error_message); |
86 | 89 |
87 // Inform the BrowserPlugin to update its backing store with the pixels in | |
88 // its damage buffer. | |
89 void UpdateRect(int message_id, | |
90 const BrowserPluginMsg_UpdateRect_Params& params); | |
91 // Inform the BrowserPlugin that its guest process is gone. | |
92 void GuestGone(int process_id, base::TerminationStatus status); | |
93 // Inform the BrowserPlugin that the guest process is unresponsive. | |
94 void GuestUnresponsive(int process_id); | |
95 // Inform the BrowserPlugin that the guest process is responsive again after | |
96 // being reported as unresponsive. | |
97 void GuestResponsive(int process_id); | |
98 // Inform the BrowserPlugin that the guest has navigated to a new URL. | |
99 void LoadCommit(const BrowserPluginMsg_LoadCommit_Params& params); | |
100 // Inform the BrowserPlugin that the guest has started loading a new page. | |
101 void LoadStart(const GURL& url, bool is_top_level); | |
102 // Inform the BrowserPlugin that the guest has finished loading a new page. | |
103 void LoadStop(); | |
104 // Inform the BrowserPlugin that the guest has aborted loading a new page. | |
105 void LoadAbort(const GURL& url, bool is_top_level, const std::string& type); | |
106 // Inform the BrowserPlugin that the guest has redirected a navigation. | |
107 void LoadRedirect(const GURL& old_url, | |
108 const GURL& new_url, | |
109 bool is_top_level); | |
110 // Tells the BrowserPlugin to advance the focus to the next (or previous) | |
111 // element. | |
112 void AdvanceFocus(bool reverse); | |
113 // Inform the BrowserPlugin of the focus state of the embedder RenderView. | 90 // Inform the BrowserPlugin of the focus state of the embedder RenderView. |
114 void SetEmbedderFocus(bool focused); | 91 void SetEmbedderFocus(bool focused); |
115 // Informs the guest of an updated focus state. | 92 // Informs the guest of an updated focus state. |
116 void UpdateGuestFocusState(); | 93 void UpdateGuestFocusState(); |
117 // Indicates whether the guest should be focused. | 94 // Indicates whether the guest should be focused. |
118 bool ShouldGuestBeFocused() const; | 95 bool ShouldGuestBeFocused() const; |
119 | 96 |
120 // Inform the BrowserPlugin that the guest's contentWindow is ready, | |
121 // and provide it with a routing ID to grab it. | |
122 void GuestContentWindowReady(int content_window_routing_id); | |
123 | |
124 // Informs the BrowserPlugin that the guest has started/stopped accepting | |
125 // touch events. | |
126 void SetAcceptTouchEvents(bool accept); | |
127 | |
128 // Tells the BrowserPlugin to tell the guest to navigate to the previous | 97 // Tells the BrowserPlugin to tell the guest to navigate to the previous |
129 // navigation entry in the navigation history. | 98 // navigation entry in the navigation history. |
130 void Back(); | 99 void Back(); |
131 // Tells the BrowserPlugin to tell the guest to navigate to the next | 100 // Tells the BrowserPlugin to tell the guest to navigate to the next |
132 // navigation entry in the navigation history. | 101 // navigation entry in the navigation history. |
133 void Forward(); | 102 void Forward(); |
134 // Tells the BrowserPlugin to tell the guest to navigate to a position | 103 // Tells the BrowserPlugin to tell the guest to navigate to a position |
135 // relative to the current index in its navigation history. | 104 // relative to the current index in its navigation history. |
136 void Go(int relativeIndex); | 105 void Go(int relativeIndex); |
137 // Tells the BrowserPlugin to terminate the guest process. | 106 // Tells the BrowserPlugin to terminate the guest process. |
138 void TerminateGuest(); | 107 void TerminateGuest(); |
139 | 108 |
140 // A request from Javascript has been made to stop the loading of the page. | 109 // A request from Javascript has been made to stop the loading of the page. |
141 void Stop(); | 110 void Stop(); |
142 // A request from Javascript has been made to reload the page. | 111 // A request from Javascript has been made to reload the page. |
143 void Reload(); | 112 void Reload(); |
144 | 113 |
145 // Informs the BrowserPlugin of the cursor that the guest has requested. | |
146 void SetCursor(const WebCursor& cursor); | |
147 | |
148 // Returns true if |point| lies within the bounds of the plugin rectangle. | 114 // Returns true if |point| lies within the bounds of the plugin rectangle. |
149 // Not OK to use this function for making security-sensitive decision since it | 115 // Not OK to use this function for making security-sensitive decision since it |
150 // can return false positives when the plugin has rotation transformation | 116 // can return false positives when the plugin has rotation transformation |
151 // applied. | 117 // applied. |
152 bool InBounds(const gfx::Point& point) const; | 118 bool InBounds(const gfx::Point& point) const; |
153 | 119 |
154 gfx::Point ToLocalCoordinates(const gfx::Point& point) const; | 120 gfx::Point ToLocalCoordinates(const gfx::Point& point) const; |
155 | 121 |
156 // WebKit::WebPlugin implementation. | 122 // WebKit::WebPlugin implementation. |
157 virtual WebKit::WebPluginContainer* container() const OVERRIDE; | 123 virtual WebKit::WebPluginContainer* container() const OVERRIDE; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 | 241 |
276 #if defined(OS_MACOSX) | 242 #if defined(OS_MACOSX) |
277 bool DamageBufferMatches(const TransportDIB* damage_buffer, | 243 bool DamageBufferMatches(const TransportDIB* damage_buffer, |
278 const TransportDIB::Id& other_damage_buffer_id); | 244 const TransportDIB::Id& other_damage_buffer_id); |
279 #else | 245 #else |
280 bool DamageBufferMatches( | 246 bool DamageBufferMatches( |
281 const TransportDIB* damage_buffer, | 247 const TransportDIB* damage_buffer, |
282 const TransportDIB::Handle& other_damage_buffer_handle); | 248 const TransportDIB::Handle& other_damage_buffer_handle); |
283 #endif | 249 #endif |
284 | 250 |
251 // IPC message handlers. | |
252 // Please keep in alphabetical order. | |
253 void OnAdvanceFocus(int instance_id, bool reverse); | |
254 void OnGuestContentWindowReady(int instance_id, | |
255 int content_window_routing_id); | |
256 void OnGuestGone(int instance_id, int process_id, int status); | |
257 void OnGuestResponsive(int instance_id, int process_id); | |
258 void OnGuestUnresponsive(int instance_id, int process_id); | |
259 void OnLoadAbort(int instance_id, | |
260 const GURL& url, | |
261 bool is_top_level, | |
262 const std::string& type); | |
263 void OnLoadCommit(int instance_id, | |
264 const BrowserPluginMsg_LoadCommit_Params& params); | |
265 void OnLoadRedirect(int instance_id, | |
266 const GURL& old_url, | |
267 const GURL& new_url, | |
268 bool is_top_level); | |
269 void OnLoadStart(int instance_id, const GURL& url, bool is_top_level); | |
270 void OnLoadStop(int instance_id); | |
271 void OnSetCursor(int instance_id, const WebCursor& cursor); | |
272 void OnShouldAcceptTouchEvents(int instance_id, bool accept); | |
273 void OnUpdateRect(int instance_id, | |
274 int message_id, | |
275 const BrowserPluginMsg_UpdateRect_Params& params); | |
276 | |
285 int instance_id_; | 277 int instance_id_; |
286 base::WeakPtr<RenderViewImpl> render_view_; | 278 base::WeakPtr<RenderViewImpl> render_view_; |
287 // We cache the |render_view_|'s routing ID because we need it on destruction. | 279 // We cache the |render_view_|'s routing ID because we need it on destruction. |
288 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed | 280 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed |
289 // then we will attempt to access a NULL pointer. | 281 // then we will attempt to access a NULL pointer. |
290 int render_view_routing_id_; | 282 int render_view_routing_id_; |
291 WebKit::WebPluginContainer* container_; | 283 WebKit::WebPluginContainer* container_; |
292 scoped_ptr<BrowserPluginBindings> bindings_; | 284 scoped_ptr<BrowserPluginBindings> bindings_; |
293 scoped_ptr<BrowserPluginBackingStore> backing_store_; | 285 scoped_ptr<BrowserPluginBackingStore> backing_store_; |
294 TransportDIB* current_damage_buffer_; | 286 TransportDIB* current_damage_buffer_; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 // the changes are not always obvious. For example, there is a maximum | 330 // the changes are not always obvious. For example, there is a maximum |
339 // number of entries and earlier ones will automatically be pruned. | 331 // number of entries and earlier ones will automatically be pruned. |
340 int current_nav_entry_index_; | 332 int current_nav_entry_index_; |
341 int nav_entry_count_; | 333 int nav_entry_count_; |
342 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 334 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
343 }; | 335 }; |
344 | 336 |
345 } // namespace content | 337 } // namespace content |
346 | 338 |
347 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 339 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
OLD | NEW |