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 18 matching lines...) Expand all Loading... |
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: | 34 public: |
35 RenderViewImpl* render_view() const { return render_view_.get(); } | 35 RenderViewImpl* render_view() const { return render_view_.get(); } |
36 // Called only by tests to clean up before we blow away the MockRenderProcess. | 36 // Called only by tests to clean up before we blow away the MockRenderProcess. |
37 void Cleanup(); | 37 void Cleanup(); |
38 | 38 |
| 39 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 40 |
39 // Update Browser Plugin's DOM Node attribute |attribute_name| with the value | 41 // Update Browser Plugin's DOM Node attribute |attribute_name| with the value |
40 // |attribute_value|. | 42 // |attribute_value|. |
41 void UpdateDOMAttribute(const std::string& attribute_name, | 43 void UpdateDOMAttribute(const std::string& attribute_name, |
42 const std::string& attribute_value); | 44 const std::string& attribute_value); |
43 | 45 |
44 // Get the src attribute value of the BrowserPlugin instance. | 46 // Get the src attribute value of the BrowserPlugin instance. |
45 std::string src_attribute() const { return src_; } | 47 std::string src_attribute() const { return src_; } |
46 // Set the src attribute value of the BrowserPlugin instance. | 48 // Set the src attribute value of the BrowserPlugin instance. |
47 bool SetSrcAttribute(const std::string& src, std::string* error_message); | 49 bool SetSrcAttribute(const std::string& src, std::string* error_message); |
48 // Get the autosize attribute value. | 50 // Get the autosize attribute value. |
(...skipping 28 matching lines...) Expand all Loading... |
77 // Query whether the guest can navigate back to the previous entry. | 79 // Query whether the guest can navigate back to the previous entry. |
78 bool CanGoBack() const; | 80 bool CanGoBack() const; |
79 // Query whether the guest can navigation forward to the next entry. | 81 // Query whether the guest can navigation forward to the next entry. |
80 bool CanGoForward() const; | 82 bool CanGoForward() const; |
81 // This method can be successfully called only before the first navigation for | 83 // 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 | 84 // this instance of BrowserPlugin. If an error occurs, the |error_message| is |
83 // set appropriately to indicate the failure reason. | 85 // set appropriately to indicate the failure reason. |
84 bool SetPartitionAttribute(const std::string& partition_id, | 86 bool SetPartitionAttribute(const std::string& partition_id, |
85 std::string* error_message); | 87 std::string* error_message); |
86 | 88 |
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. | 89 // Inform the BrowserPlugin of the focus state of the embedder RenderView. |
114 void SetEmbedderFocus(bool focused); | 90 void SetEmbedderFocus(bool focused); |
115 // Informs the guest of an updated focus state. | 91 // Informs the guest of an updated focus state. |
116 void UpdateGuestFocusState(); | 92 void UpdateGuestFocusState(); |
117 // Indicates whether the guest should be focused. | 93 // Indicates whether the guest should be focused. |
118 bool ShouldGuestBeFocused() const; | 94 bool ShouldGuestBeFocused() const; |
119 | 95 |
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 | 96 // Tells the BrowserPlugin to tell the guest to navigate to the previous |
129 // navigation entry in the navigation history. | 97 // navigation entry in the navigation history. |
130 void Back(); | 98 void Back(); |
131 // Tells the BrowserPlugin to tell the guest to navigate to the next | 99 // Tells the BrowserPlugin to tell the guest to navigate to the next |
132 // navigation entry in the navigation history. | 100 // navigation entry in the navigation history. |
133 void Forward(); | 101 void Forward(); |
134 // Tells the BrowserPlugin to tell the guest to navigate to a position | 102 // Tells the BrowserPlugin to tell the guest to navigate to a position |
135 // relative to the current index in its navigation history. | 103 // relative to the current index in its navigation history. |
136 void Go(int relativeIndex); | 104 void Go(int relativeIndex); |
137 // Tells the BrowserPlugin to terminate the guest process. | 105 // Tells the BrowserPlugin to terminate the guest process. |
138 void TerminateGuest(); | 106 void TerminateGuest(); |
139 | 107 |
140 // A request from Javascript has been made to stop the loading of the page. | 108 // A request from Javascript has been made to stop the loading of the page. |
141 void Stop(); | 109 void Stop(); |
142 // A request from Javascript has been made to reload the page. | 110 // A request from Javascript has been made to reload the page. |
143 void Reload(); | 111 void Reload(); |
144 | 112 |
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. | 113 // 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 | 114 // Not OK to use this function for making security-sensitive decision since it |
150 // can return false positives when the plugin has rotation transformation | 115 // can return false positives when the plugin has rotation transformation |
151 // applied. | 116 // applied. |
152 bool InBounds(const gfx::Point& point) const; | 117 bool InBounds(const gfx::Point& point) const; |
153 | 118 |
154 gfx::Point ToLocalCoordinates(const gfx::Point& point) const; | 119 gfx::Point ToLocalCoordinates(const gfx::Point& point) const; |
155 | 120 |
156 // WebKit::WebPlugin implementation. | 121 // WebKit::WebPlugin implementation. |
157 virtual WebKit::WebPluginContainer* container() const OVERRIDE; | 122 virtual WebKit::WebPluginContainer* container() const OVERRIDE; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 240 |
276 #if defined(OS_MACOSX) | 241 #if defined(OS_MACOSX) |
277 bool DamageBufferMatches(const TransportDIB* damage_buffer, | 242 bool DamageBufferMatches(const TransportDIB* damage_buffer, |
278 const TransportDIB::Id& other_damage_buffer_id); | 243 const TransportDIB::Id& other_damage_buffer_id); |
279 #else | 244 #else |
280 bool DamageBufferMatches( | 245 bool DamageBufferMatches( |
281 const TransportDIB* damage_buffer, | 246 const TransportDIB* damage_buffer, |
282 const TransportDIB::Handle& other_damage_buffer_handle); | 247 const TransportDIB::Handle& other_damage_buffer_handle); |
283 #endif | 248 #endif |
284 | 249 |
| 250 // IPC message handlers. |
| 251 // Please keep in alphabetical order. |
| 252 void OnAdvanceFocus(int instance_id, bool reverse); |
| 253 void OnGuestContentWindowReady(int instance_id, |
| 254 int content_window_routing_id); |
| 255 void OnGuestGone(int instance_id, int process_id, int status); |
| 256 void OnGuestResponsive(int instance_id, int process_id); |
| 257 void OnGuestUnresponsive(int instance_id, int process_id); |
| 258 void OnLoadAbort(int instance_id, |
| 259 const GURL& url, |
| 260 bool is_top_level, |
| 261 const std::string& type); |
| 262 void OnLoadCommit(int instance_id, |
| 263 const BrowserPluginMsg_LoadCommit_Params& params); |
| 264 void OnLoadRedirect(int instance_id, |
| 265 const GURL& old_url, |
| 266 const GURL& new_url, |
| 267 bool is_top_level); |
| 268 void OnLoadStart(int instance_id, const GURL& url, bool is_top_level); |
| 269 void OnLoadStop(int instance_id); |
| 270 void OnSetCursor(int instance_id, const WebCursor& cursor); |
| 271 void OnShouldAcceptTouchEvents(int instance_id, bool accept); |
| 272 void OnUpdateRect(int instance_id, |
| 273 int message_id, |
| 274 const BrowserPluginMsg_UpdateRect_Params& params); |
| 275 |
285 int instance_id_; | 276 int instance_id_; |
286 base::WeakPtr<RenderViewImpl> render_view_; | 277 base::WeakPtr<RenderViewImpl> render_view_; |
287 // We cache the |render_view_|'s routing ID because we need it on destruction. | 278 // 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 | 279 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed |
289 // then we will attempt to access a NULL pointer. | 280 // then we will attempt to access a NULL pointer. |
290 int render_view_routing_id_; | 281 int render_view_routing_id_; |
291 WebKit::WebPluginContainer* container_; | 282 WebKit::WebPluginContainer* container_; |
292 scoped_ptr<BrowserPluginBindings> bindings_; | 283 scoped_ptr<BrowserPluginBindings> bindings_; |
293 scoped_ptr<BrowserPluginBackingStore> backing_store_; | 284 scoped_ptr<BrowserPluginBackingStore> backing_store_; |
294 TransportDIB* current_damage_buffer_; | 285 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 | 329 // the changes are not always obvious. For example, there is a maximum |
339 // number of entries and earlier ones will automatically be pruned. | 330 // number of entries and earlier ones will automatically be pruned. |
340 int current_nav_entry_index_; | 331 int current_nav_entry_index_; |
341 int nav_entry_count_; | 332 int nav_entry_count_; |
342 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 333 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
343 }; | 334 }; |
344 | 335 |
345 } // namespace content | 336 } // namespace content |
346 | 337 |
347 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 338 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
OLD | NEW |