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 #include "content/renderer/browser_plugin/browser_plugin.h" | 5 #include "content/renderer/browser_plugin/browser_plugin_impl.h" |
6 | 6 |
7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "content/common/browser_plugin_messages.h" | 12 #include "content/common/browser_plugin_messages.h" |
13 #include "content/common/view_messages.h" | 13 #include "content/common/view_messages.h" |
14 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
15 #include "content/public/renderer/browser_plugin/browser_plugin_observer.h" | |
15 #include "content/public/renderer/content_renderer_client.h" | 16 #include "content/public/renderer/content_renderer_client.h" |
16 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" | 17 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" |
17 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 18 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
18 #include "content/renderer/render_process_impl.h" | 19 #include "content/renderer/render_process_impl.h" |
19 #include "content/renderer/render_thread_impl.h" | 20 #include "content/renderer/render_thread_impl.h" |
20 #include "content/renderer/v8_value_converter_impl.h" | 21 #include "content/renderer/v8_value_converter_impl.h" |
21 #include "skia/ext/platform_canvas.h" | 22 #include "skia/ext/platform_canvas.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMCustomEvent.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMCustomEvent.h" |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 case base::TERMINATION_STATUS_PROCESS_CRASHED: | 91 case base::TERMINATION_STATUS_PROCESS_CRASHED: |
91 return "crashed"; | 92 return "crashed"; |
92 default: | 93 default: |
93 // This should never happen. | 94 // This should never happen. |
94 DCHECK(false); | 95 DCHECK(false); |
95 return "unknown"; | 96 return "unknown"; |
96 } | 97 } |
97 } | 98 } |
98 } | 99 } |
99 | 100 |
100 BrowserPlugin::BrowserPlugin( | 101 BrowserPluginImpl::BrowserPluginImpl( |
101 int instance_id, | 102 int instance_id, |
102 RenderViewImpl* render_view, | 103 RenderViewImpl* render_view, |
103 WebKit::WebFrame* frame, | 104 WebKit::WebFrame* frame, |
104 const WebPluginParams& params) | 105 const WebPluginParams& params) |
105 : instance_id_(instance_id), | 106 : instance_id_(instance_id), |
106 render_view_(render_view->AsWeakPtr()), | 107 render_view_(render_view->AsWeakPtr()), |
107 render_view_routing_id_(render_view->GetRoutingID()), | 108 render_view_routing_id_(render_view->GetRoutingID()), |
108 container_(NULL), | 109 container_(NULL), |
109 damage_buffer_sequence_id_(0), | 110 damage_buffer_sequence_id_(0), |
110 resize_ack_received_(true), | 111 resize_ack_received_(true), |
(...skipping 14 matching lines...) Expand all Loading... | |
125 visible_(true), | 126 visible_(true), |
126 size_changed_in_flight_(false), | 127 size_changed_in_flight_(false), |
127 browser_plugin_manager_(render_view->browser_plugin_manager()), | 128 browser_plugin_manager_(render_view->browser_plugin_manager()), |
128 current_nav_entry_index_(0), | 129 current_nav_entry_index_(0), |
129 nav_entry_count_(0), | 130 nav_entry_count_(0), |
130 compositing_enabled_(false) { | 131 compositing_enabled_(false) { |
131 browser_plugin_manager()->AddBrowserPlugin(instance_id, this); | 132 browser_plugin_manager()->AddBrowserPlugin(instance_id, this); |
132 bindings_.reset(new BrowserPluginBindings(this)); | 133 bindings_.reset(new BrowserPluginBindings(this)); |
133 | 134 |
134 ParseAttributes(params); | 135 ParseAttributes(params); |
136 GetContentClient()->renderer()->BrowserPluginCreated(this); | |
135 } | 137 } |
136 | 138 |
137 BrowserPlugin::~BrowserPlugin() { | 139 BrowserPluginImpl::~BrowserPluginImpl() { |
138 browser_plugin_manager()->RemoveBrowserPlugin(instance_id_); | 140 browser_plugin_manager()->RemoveBrowserPlugin(instance_id_); |
139 browser_plugin_manager()->Send( | 141 Send(new BrowserPluginHostMsg_PluginDestroyed( |
140 new BrowserPluginHostMsg_PluginDestroyed( | 142 render_view_routing_id_, |
141 render_view_routing_id_, | 143 instance_id_)); |
142 instance_id_)); | |
143 } | 144 } |
144 | 145 |
145 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { | 146 void BrowserPluginImpl::AddObserver(BrowserPluginObserver* observer) { |
147 observers_.AddObserver(observer); | |
148 } | |
149 | |
150 void BrowserPluginImpl::RemoveObserver(BrowserPluginObserver* observer) { | |
151 observers_.RemoveObserver(observer); | |
152 } | |
153 | |
154 bool BrowserPluginImpl::OnMessageReceived(const IPC::Message& message) { | |
155 ObserverListBase<BrowserPluginObserver>::Iterator it(observers_); | |
sadrul
2013/01/09 15:21:54
Check observers_.might_have_observers() first.
Fady Samuel
2013/01/09 17:41:24
Done.
| |
156 BrowserPluginObserver* observer; | |
157 while ((observer = it.GetNext()) != NULL) { | |
158 if (observer->OnMessageReceived(message)) | |
159 return true; | |
160 } | |
161 | |
146 bool handled = true; | 162 bool handled = true; |
147 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message) | 163 IPC_BEGIN_MESSAGE_MAP(BrowserPluginImpl, message) |
148 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) | 164 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) |
149 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestContentWindowReady, | 165 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestContentWindowReady, |
150 OnGuestContentWindowReady) | 166 OnGuestContentWindowReady) |
151 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) | 167 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) |
152 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestResponsive, OnGuestResponsive) | 168 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestResponsive, OnGuestResponsive) |
153 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestUnresponsive, OnGuestUnresponsive) | 169 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestUnresponsive, OnGuestUnresponsive) |
154 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadAbort, OnLoadAbort) | 170 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadAbort, OnLoadAbort) |
155 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadCommit, OnLoadCommit) | 171 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadCommit, OnLoadCommit) |
156 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadRedirect, OnLoadRedirect) | 172 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadRedirect, OnLoadRedirect) |
157 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStart, OnLoadStart) | 173 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStart, OnLoadStart) |
158 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStop, OnLoadStop) | 174 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStop, OnLoadStop) |
159 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, | 175 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, |
160 OnShouldAcceptTouchEvents) | 176 OnShouldAcceptTouchEvents) |
161 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) | 177 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) |
162 IPC_MESSAGE_HANDLER(BrowserPluginMsg_UpdateRect, OnUpdateRect) | 178 IPC_MESSAGE_HANDLER(BrowserPluginMsg_UpdateRect, OnUpdateRect) |
163 IPC_MESSAGE_UNHANDLED(handled = false) | 179 IPC_MESSAGE_UNHANDLED(handled = false) |
164 IPC_END_MESSAGE_MAP() | 180 IPC_END_MESSAGE_MAP() |
165 return handled; | 181 return handled; |
166 } | 182 } |
167 | 183 |
168 void BrowserPlugin::UpdateDOMAttribute( | 184 void BrowserPluginImpl::UpdateDOMAttribute( |
169 const std::string& attribute_name, | 185 const std::string& attribute_name, |
170 const std::string& attribute_value) { | 186 const std::string& attribute_value) { |
171 if (!container()) | 187 if (!container()) |
172 return; | 188 return; |
173 | 189 |
174 WebKit::WebElement element = container()->element(); | 190 WebKit::WebElement element = container()->element(); |
175 WebKit::WebString web_attribute_name = | 191 WebKit::WebString web_attribute_name = |
176 WebKit::WebString::fromUTF8(attribute_name); | 192 WebKit::WebString::fromUTF8(attribute_name); |
177 std::string current_value(element.getAttribute(web_attribute_name).utf8()); | 193 std::string current_value(element.getAttribute(web_attribute_name).utf8()); |
178 if (current_value == attribute_value) | 194 if (current_value == attribute_value) |
179 return; | 195 return; |
180 | 196 |
181 if (attribute_value.empty()) { | 197 if (attribute_value.empty()) { |
182 element.removeAttribute(web_attribute_name); | 198 element.removeAttribute(web_attribute_name); |
183 } else { | 199 } else { |
184 element.setAttribute(web_attribute_name, | 200 element.setAttribute(web_attribute_name, |
185 WebKit::WebString::fromUTF8(attribute_value)); | 201 WebKit::WebString::fromUTF8(attribute_value)); |
186 } | 202 } |
187 } | 203 } |
188 | 204 |
189 bool BrowserPlugin::SetSrcAttribute(const std::string& src, | 205 bool BrowserPluginImpl::SetSrcAttribute(const std::string& src, |
190 std::string* error_message) { | 206 std::string* error_message) { |
191 if (!valid_partition_id_) { | 207 if (!valid_partition_id_) { |
192 *error_message = kErrorInvalidPartition; | 208 *error_message = kErrorInvalidPartition; |
193 return false; | 209 return false; |
194 } | 210 } |
195 | 211 |
196 if (src.empty() || (src == src_ && !guest_crashed_)) | 212 if (src.empty() || (src == src_ && !guest_crashed_)) |
197 return true; | 213 return true; |
198 | 214 |
199 // If we haven't created the guest yet, do so now. We will navigate it right | 215 // If we haven't created the guest yet, do so now. We will navigate it right |
200 // after creation. If |src| is empty, we can delay the creation until we | 216 // after creation. If |src| is empty, we can delay the creation until we |
201 // acutally need it. | 217 // acutally need it. |
202 if (!navigate_src_sent_) { | 218 if (!navigate_src_sent_) { |
203 BrowserPluginHostMsg_CreateGuest_Params create_guest_params; | 219 BrowserPluginHostMsg_CreateGuest_Params create_guest_params; |
204 create_guest_params.storage_partition_id = storage_partition_id_; | 220 create_guest_params.storage_partition_id = storage_partition_id_; |
205 create_guest_params.persist_storage = persist_storage_; | 221 create_guest_params.persist_storage = persist_storage_; |
206 create_guest_params.focused = ShouldGuestBeFocused(); | 222 create_guest_params.focused = ShouldGuestBeFocused(); |
207 create_guest_params.visible = visible_; | 223 create_guest_params.visible = visible_; |
208 GetDamageBufferWithSizeParams(&create_guest_params.auto_size_params, | 224 GetDamageBufferWithSizeParams(&create_guest_params.auto_size_params, |
209 &create_guest_params.resize_guest_params); | 225 &create_guest_params.resize_guest_params); |
210 browser_plugin_manager()->Send( | 226 Send(new BrowserPluginHostMsg_CreateGuest( |
211 new BrowserPluginHostMsg_CreateGuest( | 227 render_view_routing_id_, |
212 render_view_routing_id_, | 228 instance_id_, |
213 instance_id_, | 229 create_guest_params)); |
214 create_guest_params)); | |
215 } | 230 } |
216 | 231 |
217 browser_plugin_manager()->Send( | 232 Send(new BrowserPluginHostMsg_NavigateGuest( |
218 new BrowserPluginHostMsg_NavigateGuest( | 233 render_view_routing_id_, |
219 render_view_routing_id_, | 234 instance_id_, |
220 instance_id_, | 235 src)); |
221 src)); | |
222 // Record that we sent a NavigateGuest message to embedder. | 236 // Record that we sent a NavigateGuest message to embedder. |
223 // Once this instance has navigated, the storage partition cannot be changed, | 237 // Once this instance has navigated, the storage partition cannot be changed, |
224 // so this value is used for enforcing this. | 238 // so this value is used for enforcing this. |
225 navigate_src_sent_ = true; | 239 navigate_src_sent_ = true; |
226 src_ = src; | 240 src_ = src; |
227 return true; | 241 return true; |
228 } | 242 } |
229 | 243 |
230 void BrowserPlugin::SetAutoSizeAttribute(bool auto_size) { | 244 void BrowserPluginImpl::SetAutoSizeAttribute(bool auto_size) { |
231 if (auto_size_ == auto_size) | 245 if (auto_size_ == auto_size) |
232 return; | 246 return; |
233 auto_size_ = auto_size; | 247 auto_size_ = auto_size; |
234 last_view_size_ = plugin_rect_.size(); | 248 last_view_size_ = plugin_rect_.size(); |
235 UpdateGuestAutoSizeState(); | 249 UpdateGuestAutoSizeState(); |
236 } | 250 } |
237 | 251 |
238 void BrowserPlugin::PopulateAutoSizeParameters( | 252 void BrowserPluginImpl::PopulateAutoSizeParameters( |
239 BrowserPluginHostMsg_AutoSize_Params* params) { | 253 BrowserPluginHostMsg_AutoSize_Params* params) { |
240 // If maxWidth or maxHeight have not been set, set them to the container size. | 254 // If maxWidth or maxHeight have not been set, set them to the container size. |
241 max_height_ = max_height_ ? max_height_ : height(); | 255 max_height_ = max_height_ ? max_height_ : height(); |
242 max_width_ = max_width_ ? max_width_ : width(); | 256 max_width_ = max_width_ ? max_width_ : width(); |
243 // minWidth should not be bigger than maxWidth, and minHeight should not be | 257 // minWidth should not be bigger than maxWidth, and minHeight should not be |
244 // bigger than maxHeight. | 258 // bigger than maxHeight. |
245 min_height_ = std::min(min_height_, max_height_); | 259 min_height_ = std::min(min_height_, max_height_); |
246 min_width_ = std::min(min_width_, max_width_); | 260 min_width_ = std::min(min_width_, max_width_); |
247 params->enable = auto_size_; | 261 params->enable = auto_size_; |
248 params->max_size = gfx::Size(max_width_, max_height_); | 262 params->max_size = gfx::Size(max_width_, max_height_); |
249 params->min_size = gfx::Size(min_width_, min_height_); | 263 params->min_size = gfx::Size(min_width_, min_height_); |
250 } | 264 } |
251 | 265 |
252 void BrowserPlugin::UpdateGuestAutoSizeState() { | 266 void BrowserPluginImpl::UpdateGuestAutoSizeState() { |
253 // If we haven't yet heard back from the guest about the last resize request, | 267 // If we haven't yet heard back from the guest about the last resize request, |
254 // then we don't issue another request until we do in | 268 // then we don't issue another request until we do in |
255 // BrowserPlugin::UpdateRect. | 269 // BrowserPluginImpl::UpdateRect. |
256 if (!navigate_src_sent_ || !resize_ack_received_) | 270 if (!navigate_src_sent_ || !resize_ack_received_) |
257 return; | 271 return; |
258 BrowserPluginHostMsg_AutoSize_Params auto_size_params; | 272 BrowserPluginHostMsg_AutoSize_Params auto_size_params; |
259 BrowserPluginHostMsg_ResizeGuest_Params resize_guest_params; | 273 BrowserPluginHostMsg_ResizeGuest_Params resize_guest_params; |
260 GetDamageBufferWithSizeParams(&auto_size_params, &resize_guest_params); | 274 GetDamageBufferWithSizeParams(&auto_size_params, &resize_guest_params); |
261 resize_ack_received_ = false; | 275 resize_ack_received_ = false; |
262 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetAutoSize( | 276 Send(new BrowserPluginHostMsg_SetAutoSize( |
263 render_view_routing_id_, | 277 render_view_routing_id_, |
264 instance_id_, | 278 instance_id_, |
265 auto_size_params, | 279 auto_size_params, |
266 resize_guest_params)); | 280 resize_guest_params)); |
267 } | 281 } |
268 | 282 |
269 void BrowserPlugin::SizeChangedDueToAutoSize(const gfx::Size& old_view_size) { | 283 void BrowserPluginImpl::SizeChangedDueToAutoSize( |
284 const gfx::Size& old_view_size) { | |
270 size_changed_in_flight_ = false; | 285 size_changed_in_flight_ = false; |
271 | 286 |
272 std::map<std::string, base::Value*> props; | 287 std::map<std::string, base::Value*> props; |
273 props[kOldHeight] = base::Value::CreateIntegerValue(old_view_size.height()); | 288 props[kOldHeight] = base::Value::CreateIntegerValue(old_view_size.height()); |
274 props[kOldWidth] = base::Value::CreateIntegerValue(old_view_size.width()); | 289 props[kOldWidth] = base::Value::CreateIntegerValue(old_view_size.width()); |
275 props[kNewHeight] = base::Value::CreateIntegerValue(last_view_size_.height()); | 290 props[kNewHeight] = base::Value::CreateIntegerValue(last_view_size_.height()); |
276 props[kNewWidth] = base::Value::CreateIntegerValue(last_view_size_.width()); | 291 props[kNewWidth] = base::Value::CreateIntegerValue(last_view_size_.width()); |
277 TriggerEvent(kEventSizeChanged, &props); | 292 TriggerEvent(kEventSizeChanged, &props); |
278 } | 293 } |
279 | 294 |
280 // static | 295 // static |
281 bool BrowserPlugin::UsesDamageBuffer( | 296 bool BrowserPluginImpl::UsesDamageBuffer( |
282 const BrowserPluginMsg_UpdateRect_Params& params) { | 297 const BrowserPluginMsg_UpdateRect_Params& params) { |
283 return params.damage_buffer_sequence_id != 0; | 298 return params.damage_buffer_sequence_id != 0; |
284 } | 299 } |
285 | 300 |
286 bool BrowserPlugin::UsesPendingDamageBuffer( | 301 bool BrowserPluginImpl::UsesPendingDamageBuffer( |
287 const BrowserPluginMsg_UpdateRect_Params& params) { | 302 const BrowserPluginMsg_UpdateRect_Params& params) { |
288 if (!pending_damage_buffer_.get()) | 303 if (!pending_damage_buffer_.get()) |
289 return false; | 304 return false; |
290 return damage_buffer_sequence_id_ == params.damage_buffer_sequence_id; | 305 return damage_buffer_sequence_id_ == params.damage_buffer_sequence_id; |
291 } | 306 } |
292 | 307 |
293 void BrowserPlugin::OnAdvanceFocus(int instance_id, bool reverse) { | 308 void BrowserPluginImpl::OnAdvanceFocus(int instance_id, bool reverse) { |
294 DCHECK(render_view_); | 309 DCHECK(render_view_); |
295 render_view_->GetWebView()->advanceFocus(reverse); | 310 render_view_->GetWebView()->advanceFocus(reverse); |
296 } | 311 } |
297 | 312 |
298 void BrowserPlugin::OnGuestContentWindowReady(int instance_id, | 313 void BrowserPluginImpl::OnGuestContentWindowReady( |
299 int content_window_routing_id) { | 314 int instance_id, |
315 int content_window_routing_id) { | |
300 DCHECK(content_window_routing_id != MSG_ROUTING_NONE); | 316 DCHECK(content_window_routing_id != MSG_ROUTING_NONE); |
301 content_window_routing_id_ = content_window_routing_id; | 317 content_window_routing_id_ = content_window_routing_id; |
302 } | 318 } |
303 | 319 |
304 void BrowserPlugin::OnGuestGone(int instance_id, int process_id, int status) { | 320 void BrowserPluginImpl::OnGuestGone(int instance_id, |
321 int process_id, | |
322 int status) { | |
305 // We fire the event listeners before painting the sad graphic to give the | 323 // We fire the event listeners before painting the sad graphic to give the |
306 // developer an opportunity to display an alternative overlay image on crash. | 324 // developer an opportunity to display an alternative overlay image on crash. |
307 std::string termination_status = TerminationStatusToString( | 325 std::string termination_status = TerminationStatusToString( |
308 static_cast<base::TerminationStatus>(status)); | 326 static_cast<base::TerminationStatus>(status)); |
309 std::map<std::string, base::Value*> props; | 327 std::map<std::string, base::Value*> props; |
310 props[kProcessId] = base::Value::CreateIntegerValue(process_id); | 328 props[kProcessId] = base::Value::CreateIntegerValue(process_id); |
311 props[kReason] = base::Value::CreateStringValue(termination_status); | 329 props[kReason] = base::Value::CreateStringValue(termination_status); |
312 | 330 |
313 // Event listeners may remove the BrowserPlugin from the document. If that | 331 // Event listeners may remove the BrowserPlugin from the document. If that |
314 // happens, the BrowserPlugin will be scheduled for later deletion (see | 332 // happens, the BrowserPlugin will be scheduled for later deletion (see |
315 // BrowserPlugin::destroy()). That will clear the container_ reference, | 333 // BrowserPluginImpl::destroy()). That will clear the container_ reference, |
316 // but leave other member variables valid below. | 334 // but leave other member variables valid below. |
317 TriggerEvent(kEventExit, &props); | 335 TriggerEvent(kEventExit, &props); |
318 | 336 |
319 guest_crashed_ = true; | 337 guest_crashed_ = true; |
320 // We won't paint the contents of the current backing store again so we might | 338 // We won't paint the contents of the current backing store again so we might |
321 // as well toss it out and save memory. | 339 // as well toss it out and save memory. |
322 backing_store_.reset(); | 340 backing_store_.reset(); |
323 // If the BrowserPlugin is scheduled to be deleted, then container_ will be | 341 // If the BrowserPlugin is scheduled to be deleted, then container_ will be |
324 // NULL so we shouldn't attempt to access it. | 342 // NULL so we shouldn't attempt to access it. |
325 if (container_) | 343 if (container_) |
326 container_->invalidate(); | 344 container_->invalidate(); |
327 } | 345 } |
328 | 346 |
329 void BrowserPlugin::OnGuestResponsive(int instance_id, int process_id) { | 347 void BrowserPluginImpl::OnGuestResponsive(int instance_id, int process_id) { |
330 std::map<std::string, base::Value*> props; | 348 std::map<std::string, base::Value*> props; |
331 props[kProcessId] = base::Value::CreateIntegerValue(process_id); | 349 props[kProcessId] = base::Value::CreateIntegerValue(process_id); |
332 TriggerEvent(kEventResponsive, &props); | 350 TriggerEvent(kEventResponsive, &props); |
333 } | 351 } |
334 | 352 |
335 void BrowserPlugin::OnGuestUnresponsive(int instance_id, int process_id) { | 353 void BrowserPluginImpl::OnGuestUnresponsive(int instance_id, int process_id) { |
336 std::map<std::string, base::Value*> props; | 354 std::map<std::string, base::Value*> props; |
337 props[kProcessId] = base::Value::CreateIntegerValue(process_id); | 355 props[kProcessId] = base::Value::CreateIntegerValue(process_id); |
338 TriggerEvent(kEventUnresponsive, &props); | 356 TriggerEvent(kEventUnresponsive, &props); |
339 } | 357 } |
340 | 358 |
341 void BrowserPlugin::OnLoadAbort(int instance_id, | 359 void BrowserPluginImpl::OnLoadAbort(int instance_id, |
342 const GURL& url, | 360 const GURL& url, |
343 bool is_top_level, | 361 bool is_top_level, |
344 const std::string& type) { | 362 const std::string& type) { |
345 std::map<std::string, base::Value*> props; | 363 std::map<std::string, base::Value*> props; |
346 props[kURL] = base::Value::CreateStringValue(url.spec()); | 364 props[kURL] = base::Value::CreateStringValue(url.spec()); |
347 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); | 365 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); |
348 props[kReason] = base::Value::CreateStringValue(type); | 366 props[kReason] = base::Value::CreateStringValue(type); |
349 TriggerEvent(kEventLoadAbort, &props); | 367 TriggerEvent(kEventLoadAbort, &props); |
350 } | 368 } |
351 | 369 |
352 void BrowserPlugin::OnLoadCommit( | 370 void BrowserPluginImpl::OnLoadCommit( |
353 int instance_id, | 371 int instance_id, |
354 const BrowserPluginMsg_LoadCommit_Params& params) { | 372 const BrowserPluginMsg_LoadCommit_Params& params) { |
355 // If the guest has just committed a new navigation then it is no longer | 373 // If the guest has just committed a new navigation then it is no longer |
356 // crashed. | 374 // crashed. |
357 guest_crashed_ = false; | 375 guest_crashed_ = false; |
358 if (params.is_top_level) { | 376 if (params.is_top_level) { |
359 src_ = params.url.spec(); | 377 src_ = params.url.spec(); |
360 UpdateDOMAttribute(kSrc, src_.c_str()); | 378 UpdateDOMAttribute(kSrc, src_.c_str()); |
361 } | 379 } |
362 process_id_ = params.process_id; | 380 process_id_ = params.process_id; |
363 current_nav_entry_index_ = params.current_entry_index; | 381 current_nav_entry_index_ = params.current_entry_index; |
364 nav_entry_count_ = params.entry_count; | 382 nav_entry_count_ = params.entry_count; |
365 | 383 |
366 std::map<std::string, base::Value*> props; | 384 std::map<std::string, base::Value*> props; |
367 props[kURL] = base::Value::CreateStringValue(params.url.spec()); | 385 props[kURL] = base::Value::CreateStringValue(params.url.spec()); |
368 props[kIsTopLevel] = base::Value::CreateBooleanValue(params.is_top_level); | 386 props[kIsTopLevel] = base::Value::CreateBooleanValue(params.is_top_level); |
369 TriggerEvent(kEventLoadCommit, &props); | 387 TriggerEvent(kEventLoadCommit, &props); |
370 } | 388 } |
371 | 389 |
372 void BrowserPlugin::OnLoadRedirect(int instance_id, | 390 void BrowserPluginImpl::OnLoadRedirect(int instance_id, |
373 const GURL& old_url, | 391 const GURL& old_url, |
374 const GURL& new_url, | 392 const GURL& new_url, |
375 bool is_top_level) { | 393 bool is_top_level) { |
376 std::map<std::string, base::Value*> props; | 394 std::map<std::string, base::Value*> props; |
377 props[kOldURL] = base::Value::CreateStringValue(old_url.spec()); | 395 props[kOldURL] = base::Value::CreateStringValue(old_url.spec()); |
378 props[kNewURL] = base::Value::CreateStringValue(new_url.spec()); | 396 props[kNewURL] = base::Value::CreateStringValue(new_url.spec()); |
379 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); | 397 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); |
380 TriggerEvent(kEventLoadRedirect, &props); | 398 TriggerEvent(kEventLoadRedirect, &props); |
381 } | 399 } |
382 | 400 |
383 void BrowserPlugin::OnLoadStart(int instance_id, | 401 void BrowserPluginImpl::OnLoadStart(int instance_id, |
384 const GURL& url, | 402 const GURL& url, |
385 bool is_top_level) { | 403 bool is_top_level) { |
386 std::map<std::string, base::Value*> props; | 404 std::map<std::string, base::Value*> props; |
387 props[kURL] = base::Value::CreateStringValue(url.spec()); | 405 props[kURL] = base::Value::CreateStringValue(url.spec()); |
388 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); | 406 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); |
389 | 407 |
390 TriggerEvent(kEventLoadStart, &props); | 408 TriggerEvent(kEventLoadStart, &props); |
391 } | 409 } |
392 | 410 |
393 void BrowserPlugin::OnLoadStop(int instance_id) { | 411 void BrowserPluginImpl::OnLoadStop(int instance_id) { |
394 TriggerEvent(kEventLoadStop, NULL); | 412 TriggerEvent(kEventLoadStop, NULL); |
395 } | 413 } |
396 | 414 |
397 void BrowserPlugin::OnSetCursor(int instance_id, const WebCursor& cursor) { | 415 void BrowserPluginImpl::OnSetCursor(int instance_id, const WebCursor& cursor) { |
398 cursor_ = cursor; | 416 cursor_ = cursor; |
399 } | 417 } |
400 | 418 |
401 void BrowserPlugin::OnShouldAcceptTouchEvents(int instance_id, bool accept) { | 419 void BrowserPluginImpl::OnShouldAcceptTouchEvents(int instance_id, |
420 bool accept) { | |
402 if (container()) { | 421 if (container()) { |
403 container()->requestTouchEventType(accept ? | 422 container()->requestTouchEventType(accept ? |
404 WebKit::WebPluginContainer::TouchEventRequestTypeRaw : | 423 WebKit::WebPluginContainer::TouchEventRequestTypeRaw : |
405 WebKit::WebPluginContainer::TouchEventRequestTypeNone); | 424 WebKit::WebPluginContainer::TouchEventRequestTypeNone); |
406 } | 425 } |
407 } | 426 } |
408 | 427 |
409 void BrowserPlugin::OnUpdateRect( | 428 void BrowserPluginImpl::OnUpdateRect( |
410 int instance_id, | 429 int instance_id, |
411 const BrowserPluginMsg_UpdateRect_Params& params) { | 430 const BrowserPluginMsg_UpdateRect_Params& params) { |
412 bool use_new_damage_buffer = !backing_store_; | 431 bool use_new_damage_buffer = !backing_store_; |
413 BrowserPluginHostMsg_AutoSize_Params auto_size_params; | 432 BrowserPluginHostMsg_AutoSize_Params auto_size_params; |
414 BrowserPluginHostMsg_ResizeGuest_Params resize_guest_params; | 433 BrowserPluginHostMsg_ResizeGuest_Params resize_guest_params; |
415 // If we have a pending damage buffer, and the guest has begun to use the | 434 // If we have a pending damage buffer, and the guest has begun to use the |
416 // damage buffer then we know the guest will no longer use the current | 435 // damage buffer then we know the guest will no longer use the current |
417 // damage buffer. At this point, we drop the current damage buffer, and | 436 // damage buffer. At this point, we drop the current damage buffer, and |
418 // mark the pending damage buffer as the current damage buffer. | 437 // mark the pending damage buffer as the current damage buffer. |
419 if (UsesPendingDamageBuffer(params)) { | 438 if (UsesPendingDamageBuffer(params)) { |
(...skipping 12 matching lines...) Expand all Loading... | |
432 // The guest has not yet responded to the last resize request, and | 451 // The guest has not yet responded to the last resize request, and |
433 // so we don't want to do anything at this point other than ACK the guest. | 452 // so we don't want to do anything at this point other than ACK the guest. |
434 PopulateAutoSizeParameters(&auto_size_params); | 453 PopulateAutoSizeParameters(&auto_size_params); |
435 } else { | 454 } else { |
436 // If we have no pending damage buffer, then the guest has not caught up | 455 // If we have no pending damage buffer, then the guest has not caught up |
437 // with the BrowserPlugin container. We now tell the guest about the new | 456 // with the BrowserPlugin container. We now tell the guest about the new |
438 // container size. | 457 // container size. |
439 GetDamageBufferWithSizeParams(&auto_size_params, | 458 GetDamageBufferWithSizeParams(&auto_size_params, |
440 &resize_guest_params); | 459 &resize_guest_params); |
441 } | 460 } |
442 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( | 461 Send(new BrowserPluginHostMsg_UpdateRect_ACK( |
443 render_view_routing_id_, | 462 render_view_routing_id_, |
444 instance_id_, | 463 instance_id_, |
445 auto_size_params, | 464 auto_size_params, |
446 resize_guest_params)); | 465 resize_guest_params)); |
447 return; | 466 return; |
448 } | 467 } |
449 | 468 |
450 if (auto_size_ && (params.view_size != last_view_size_)) { | 469 if (auto_size_ && (params.view_size != last_view_size_)) { |
451 if (backing_store_) | 470 if (backing_store_) |
452 backing_store_->Clear(SK_ColorWHITE); | 471 backing_store_->Clear(SK_ColorWHITE); |
453 gfx::Size old_view_size = last_view_size_; | 472 gfx::Size old_view_size = last_view_size_; |
454 last_view_size_ = params.view_size; | 473 last_view_size_ = params.view_size; |
455 // Schedule a SizeChanged instead of calling it directly to ensure that | 474 // Schedule a SizeChanged instead of calling it directly to ensure that |
456 // the backing store has been updated before the developer attempts to | 475 // the backing store has been updated before the developer attempts to |
457 // resize to avoid flicker. |size_changed_in_flight_| acts as a form of | 476 // resize to avoid flicker. |size_changed_in_flight_| acts as a form of |
458 // flow control for SizeChanged events. If the guest's view size is changing | 477 // flow control for SizeChanged events. If the guest's view size is changing |
459 // rapidly before a SizeChanged event fires, then we avoid scheduling | 478 // rapidly before a SizeChanged event fires, then we avoid scheduling |
460 // another SizeChanged event. SizeChanged reads the new size from | 479 // another SizeChanged event. SizeChanged reads the new size from |
461 // |last_view_size_| so we can be sure that it always fires an event | 480 // |last_view_size_| so we can be sure that it always fires an event |
462 // with the last seen view size. | 481 // with the last seen view size. |
463 if (container_ && !size_changed_in_flight_) { | 482 if (container_ && !size_changed_in_flight_) { |
464 size_changed_in_flight_ = true; | 483 size_changed_in_flight_ = true; |
465 MessageLoop::current()->PostTask( | 484 MessageLoop::current()->PostTask( |
466 FROM_HERE, | 485 FROM_HERE, |
467 base::Bind(&BrowserPlugin::SizeChangedDueToAutoSize, | 486 base::Bind(&BrowserPluginImpl::SizeChangedDueToAutoSize, |
468 base::Unretained(this), | 487 base::Unretained(this), |
469 old_view_size)); | 488 old_view_size)); |
470 } | 489 } |
471 } | 490 } |
472 | 491 |
473 // No more work to do since the guest is no longer using a damage buffer. | 492 // No more work to do since the guest is no longer using a damage buffer. |
474 if (!UsesDamageBuffer(params)) | 493 if (!UsesDamageBuffer(params)) |
475 return; | 494 return; |
476 | 495 |
477 // If we are seeing damage buffers, HW compositing should be turned off. | 496 // If we are seeing damage buffers, HW compositing should be turned off. |
(...skipping 21 matching lines...) Expand all Loading... | |
499 backing_store_->PaintToBackingStore(params.bitmap_rect, | 518 backing_store_->PaintToBackingStore(params.bitmap_rect, |
500 params.copy_rects, | 519 params.copy_rects, |
501 current_damage_buffer_->memory()); | 520 current_damage_buffer_->memory()); |
502 } | 521 } |
503 // Invalidate the container. | 522 // Invalidate the container. |
504 // If the BrowserPlugin is scheduled to be deleted, then container_ will be | 523 // If the BrowserPlugin is scheduled to be deleted, then container_ will be |
505 // NULL so we shouldn't attempt to access it. | 524 // NULL so we shouldn't attempt to access it. |
506 if (container_) | 525 if (container_) |
507 container_->invalidate(); | 526 container_->invalidate(); |
508 PopulateAutoSizeParameters(&auto_size_params); | 527 PopulateAutoSizeParameters(&auto_size_params); |
509 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( | 528 Send(new BrowserPluginHostMsg_UpdateRect_ACK( |
510 render_view_routing_id_, | 529 render_view_routing_id_, |
511 instance_id_, | 530 instance_id_, |
512 auto_size_params, | 531 auto_size_params, |
513 resize_guest_params)); | 532 resize_guest_params)); |
514 } | 533 } |
515 | 534 |
516 void BrowserPlugin::SetMaxHeightAttribute(int max_height) { | 535 void BrowserPluginImpl::SetMaxHeightAttribute(int max_height) { |
517 if (max_height_ == max_height) | 536 if (max_height_ == max_height) |
518 return; | 537 return; |
519 max_height_ = max_height; | 538 max_height_ = max_height; |
520 if (!auto_size_) | 539 if (!auto_size_) |
521 return; | 540 return; |
522 UpdateGuestAutoSizeState(); | 541 UpdateGuestAutoSizeState(); |
523 } | 542 } |
524 | 543 |
525 void BrowserPlugin::SetMaxWidthAttribute(int max_width) { | 544 void BrowserPluginImpl::SetMaxWidthAttribute(int max_width) { |
526 if (max_width_ == max_width) | 545 if (max_width_ == max_width) |
527 return; | 546 return; |
528 max_width_ = max_width; | 547 max_width_ = max_width; |
529 if (!auto_size_) | 548 if (!auto_size_) |
530 return; | 549 return; |
531 UpdateGuestAutoSizeState(); | 550 UpdateGuestAutoSizeState(); |
532 } | 551 } |
533 | 552 |
534 void BrowserPlugin::SetMinHeightAttribute(int min_height) { | 553 void BrowserPluginImpl::SetMinHeightAttribute(int min_height) { |
535 if (min_height_ == min_height) | 554 if (min_height_ == min_height) |
536 return; | 555 return; |
537 min_height_ = min_height; | 556 min_height_ = min_height; |
538 if (!auto_size_) | 557 if (!auto_size_) |
539 return; | 558 return; |
540 UpdateGuestAutoSizeState(); | 559 UpdateGuestAutoSizeState(); |
541 } | 560 } |
542 | 561 |
543 void BrowserPlugin::SetMinWidthAttribute(int min_width) { | 562 void BrowserPluginImpl::SetMinWidthAttribute(int min_width) { |
544 if (min_width_ == min_width) | 563 if (min_width_ == min_width) |
545 return; | 564 return; |
546 min_width_ = min_width; | 565 min_width_ = min_width; |
547 if (!auto_size_) | 566 if (!auto_size_) |
548 return; | 567 return; |
549 UpdateGuestAutoSizeState(); | 568 UpdateGuestAutoSizeState(); |
550 } | 569 } |
551 | 570 |
552 bool BrowserPlugin::InAutoSizeBounds(const gfx::Size& size) const { | 571 bool BrowserPluginImpl::InAutoSizeBounds(const gfx::Size& size) const { |
553 return size.width() <= max_width_ && size.height() <= max_height_; | 572 return size.width() <= max_width_ && size.height() <= max_height_; |
554 } | 573 } |
555 | 574 |
556 NPObject* BrowserPlugin::GetContentWindow() const { | 575 NPObject* BrowserPluginImpl::GetContentWindow() const { |
557 if (content_window_routing_id_ == MSG_ROUTING_NONE) | 576 if (content_window_routing_id_ == MSG_ROUTING_NONE) |
558 return NULL; | 577 return NULL; |
559 RenderViewImpl* guest_render_view = static_cast<RenderViewImpl*>( | 578 RenderViewImpl* guest_render_view = static_cast<RenderViewImpl*>( |
560 ChildThread::current()->ResolveRoute(content_window_routing_id_)); | 579 ChildThread::current()->ResolveRoute(content_window_routing_id_)); |
561 if (!guest_render_view) | 580 if (!guest_render_view) |
562 return NULL; | 581 return NULL; |
563 WebKit::WebFrame* guest_frame = guest_render_view->GetWebView()->mainFrame(); | 582 WebKit::WebFrame* guest_frame = guest_render_view->GetWebView()->mainFrame(); |
564 return guest_frame->windowObject(); | 583 return guest_frame->windowObject(); |
565 } | 584 } |
566 | 585 |
567 std::string BrowserPlugin::GetPartitionAttribute() const { | 586 std::string BrowserPluginImpl::GetPartitionAttribute() const { |
568 std::string value; | 587 std::string value; |
569 if (persist_storage_) | 588 if (persist_storage_) |
570 value.append(kPersistPrefix); | 589 value.append(kPersistPrefix); |
571 | 590 |
572 value.append(storage_partition_id_); | 591 value.append(storage_partition_id_); |
573 return value; | 592 return value; |
574 } | 593 } |
575 | 594 |
576 bool BrowserPlugin::CanGoBack() const { | 595 bool BrowserPluginImpl::CanGoBack() const { |
577 return nav_entry_count_ > 1 && current_nav_entry_index_ > 0; | 596 return nav_entry_count_ > 1 && current_nav_entry_index_ > 0; |
578 } | 597 } |
579 | 598 |
580 bool BrowserPlugin::CanGoForward() const { | 599 bool BrowserPluginImpl::CanGoForward() const { |
581 return current_nav_entry_index_ >= 0 && | 600 return current_nav_entry_index_ >= 0 && |
582 current_nav_entry_index_ < (nav_entry_count_ - 1); | 601 current_nav_entry_index_ < (nav_entry_count_ - 1); |
583 } | 602 } |
584 | 603 |
585 bool BrowserPlugin::SetPartitionAttribute(const std::string& partition_id, | 604 bool BrowserPluginImpl::SetPartitionAttribute(const std::string& partition_id, |
586 std::string* error_message) { | 605 std::string* error_message) { |
587 if (navigate_src_sent_) { | 606 if (navigate_src_sent_) { |
588 *error_message = kErrorAlreadyNavigated; | 607 *error_message = kErrorAlreadyNavigated; |
589 return false; | 608 return false; |
590 } | 609 } |
591 | 610 |
592 std::string input = partition_id; | 611 std::string input = partition_id; |
593 | 612 |
594 // Since the "persist:" prefix is in ASCII, StartsWith will work fine on | 613 // Since the "persist:" prefix is in ASCII, StartsWith will work fine on |
595 // UTF-8 encoded |partition_id|. If the prefix is a match, we can safely | 614 // UTF-8 encoded |partition_id|. If the prefix is a match, we can safely |
596 // remove the prefix without splicing in the middle of a multi-byte codepoint. | 615 // remove the prefix without splicing in the middle of a multi-byte codepoint. |
(...skipping 11 matching lines...) Expand all Loading... | |
608 persist_storage_ = true; | 627 persist_storage_ = true; |
609 } else { | 628 } else { |
610 persist_storage_ = false; | 629 persist_storage_ = false; |
611 } | 630 } |
612 | 631 |
613 valid_partition_id_ = true; | 632 valid_partition_id_ = true; |
614 storage_partition_id_ = input; | 633 storage_partition_id_ = input; |
615 return true; | 634 return true; |
616 } | 635 } |
617 | 636 |
618 void BrowserPlugin::ParseAttributes(const WebKit::WebPluginParams& params) { | 637 void BrowserPluginImpl::ParseAttributes(const WebKit::WebPluginParams& params) { |
619 std::string src; | 638 std::string src; |
620 | 639 |
621 // Get the src attribute from the attributes vector | 640 // Get the src attribute from the attributes vector |
622 for (unsigned i = 0; i < params.attributeNames.size(); ++i) { | 641 for (unsigned i = 0; i < params.attributeNames.size(); ++i) { |
623 std::string attributeName = params.attributeNames[i].utf8(); | 642 std::string attributeName = params.attributeNames[i].utf8(); |
624 if (LowerCaseEqualsASCII(attributeName, kSrc)) { | 643 if (LowerCaseEqualsASCII(attributeName, kSrc)) { |
625 src = params.attributeValues[i].utf8(); | 644 src = params.attributeValues[i].utf8(); |
626 } else if (LowerCaseEqualsASCII(attributeName, kPartition)) { | 645 } else if (LowerCaseEqualsASCII(attributeName, kPartition)) { |
627 std::string error; | 646 std::string error; |
628 SetPartitionAttribute(params.attributeValues[i].utf8(), &error); | 647 SetPartitionAttribute(params.attributeValues[i].utf8(), &error); |
629 } | 648 } |
630 } | 649 } |
631 | 650 |
632 // Set the 'src' attribute last, as it will set the has_navigated_ flag to | 651 // Set the 'src' attribute last, as it will set the has_navigated_ flag to |
633 // true, which prevents changing the 'partition' attribute. | 652 // true, which prevents changing the 'partition' attribute. |
634 std::string error; | 653 std::string error; |
635 SetSrcAttribute(src, &error); | 654 SetSrcAttribute(src, &error); |
636 } | 655 } |
637 | 656 |
638 float BrowserPlugin::GetDeviceScaleFactor() const { | 657 float BrowserPluginImpl::GetDeviceScaleFactor() const { |
639 if (!render_view_) | 658 if (!render_view_) |
640 return 1.0f; | 659 return 1.0f; |
641 return render_view_->GetWebView()->deviceScaleFactor(); | 660 return render_view_->GetWebView()->deviceScaleFactor(); |
642 } | 661 } |
643 | 662 |
644 void BrowserPlugin::TriggerEvent(const std::string& event_name, | 663 void BrowserPluginImpl::TriggerEvent( |
645 std::map<std::string, base::Value*>* props) { | 664 const std::string& event_name, |
665 std::map<std::string, base::Value*>* props) { | |
646 if (!container() || !container()->element().document().frame()) | 666 if (!container() || !container()->element().document().frame()) |
647 return; | 667 return; |
648 v8::HandleScope handle_scope; | 668 v8::HandleScope handle_scope; |
649 std::string json_string; | 669 std::string json_string; |
650 if (props) { | 670 if (props) { |
651 base::DictionaryValue dict; | 671 base::DictionaryValue dict; |
652 for (std::map<std::string, base::Value*>::iterator iter = props->begin(), | 672 for (std::map<std::string, base::Value*>::iterator iter = props->begin(), |
653 end = props->end(); iter != end; ++iter) { | 673 end = props->end(); iter != end; ++iter) { |
654 dict.Set(iter->first, iter->second); | 674 dict.Set(iter->first, iter->second); |
655 } | 675 } |
(...skipping 14 matching lines...) Expand all Loading... | |
670 std::string internal_name = base::StringPrintf("-internal-%s", | 690 std::string internal_name = base::StringPrintf("-internal-%s", |
671 event_name.c_str()); | 691 event_name.c_str()); |
672 event.initCustomEvent( | 692 event.initCustomEvent( |
673 WebKit::WebString::fromUTF8(internal_name.c_str()), | 693 WebKit::WebString::fromUTF8(internal_name.c_str()), |
674 false, false, | 694 false, false, |
675 WebKit::WebSerializedScriptValue::serialize( | 695 WebKit::WebSerializedScriptValue::serialize( |
676 v8::String::New(json_string.c_str(), json_string.size()))); | 696 v8::String::New(json_string.c_str(), json_string.size()))); |
677 container()->element().dispatchEvent(event); | 697 container()->element().dispatchEvent(event); |
678 } | 698 } |
679 | 699 |
680 void BrowserPlugin::Back() { | 700 void BrowserPluginImpl::Back() { |
681 if (!navigate_src_sent_) | 701 if (!navigate_src_sent_) |
682 return; | 702 return; |
683 browser_plugin_manager()->Send( | 703 Send(new BrowserPluginHostMsg_Go(render_view_routing_id_, |
684 new BrowserPluginHostMsg_Go(render_view_routing_id_, | 704 instance_id_, -1)); |
685 instance_id_, -1)); | |
686 } | 705 } |
687 | 706 |
688 void BrowserPlugin::Forward() { | 707 void BrowserPluginImpl::Forward() { |
689 if (!navigate_src_sent_) | 708 if (!navigate_src_sent_) |
690 return; | 709 return; |
691 browser_plugin_manager()->Send( | 710 Send(new BrowserPluginHostMsg_Go(render_view_routing_id_, |
692 new BrowserPluginHostMsg_Go(render_view_routing_id_, | 711 instance_id_, 1)); |
693 instance_id_, 1)); | |
694 } | 712 } |
695 | 713 |
696 void BrowserPlugin::Go(int relative_index) { | 714 void BrowserPluginImpl::Go(int relative_index) { |
697 if (!navigate_src_sent_) | 715 if (!navigate_src_sent_) |
698 return; | 716 return; |
699 browser_plugin_manager()->Send( | 717 Send(new BrowserPluginHostMsg_Go(render_view_routing_id_, |
700 new BrowserPluginHostMsg_Go(render_view_routing_id_, | 718 instance_id_, |
701 instance_id_, | 719 relative_index)); |
702 relative_index)); | |
703 } | 720 } |
704 | 721 |
705 void BrowserPlugin::TerminateGuest() { | 722 void BrowserPluginImpl::TerminateGuest() { |
706 if (!navigate_src_sent_) | 723 if (!navigate_src_sent_) |
707 return; | 724 return; |
708 browser_plugin_manager()->Send( | 725 Send(new BrowserPluginHostMsg_TerminateGuest(render_view_routing_id_, |
709 new BrowserPluginHostMsg_TerminateGuest(render_view_routing_id_, | 726 instance_id_)); |
710 instance_id_)); | |
711 } | 727 } |
712 | 728 |
713 void BrowserPlugin::Stop() { | 729 void BrowserPluginImpl::Stop() { |
714 if (!navigate_src_sent_) | 730 if (!navigate_src_sent_) |
715 return; | 731 return; |
716 browser_plugin_manager()->Send( | 732 Send(new BrowserPluginHostMsg_Stop(render_view_routing_id_, |
717 new BrowserPluginHostMsg_Stop(render_view_routing_id_, | 733 instance_id_)); |
718 instance_id_)); | |
719 } | 734 } |
720 | 735 |
721 void BrowserPlugin::Reload() { | 736 void BrowserPluginImpl::Reload() { |
722 if (!navigate_src_sent_) | 737 if (!navigate_src_sent_) |
723 return; | 738 return; |
724 browser_plugin_manager()->Send( | 739 Send(new BrowserPluginHostMsg_Reload(render_view_routing_id_, |
725 new BrowserPluginHostMsg_Reload(render_view_routing_id_, | 740 instance_id_)); |
726 instance_id_)); | |
727 } | 741 } |
728 | 742 |
729 void BrowserPlugin::SetEmbedderFocus(bool focused) { | 743 void BrowserPluginImpl::SetEmbedderFocus(bool focused) { |
730 if (embedder_focused_ == focused) | 744 if (embedder_focused_ == focused) |
731 return; | 745 return; |
732 | 746 |
733 bool old_guest_focus_state = ShouldGuestBeFocused(); | 747 bool old_guest_focus_state = ShouldGuestBeFocused(); |
734 embedder_focused_ = focused; | 748 embedder_focused_ = focused; |
735 | 749 |
736 if (ShouldGuestBeFocused() != old_guest_focus_state) | 750 if (ShouldGuestBeFocused() != old_guest_focus_state) |
737 UpdateGuestFocusState(); | 751 UpdateGuestFocusState(); |
738 } | 752 } |
739 | 753 |
740 void BrowserPlugin::UpdateGuestFocusState() { | 754 void BrowserPluginImpl::UpdateGuestFocusState() { |
741 if (!navigate_src_sent_) | 755 if (!navigate_src_sent_) |
742 return; | 756 return; |
743 bool should_be_focused = ShouldGuestBeFocused(); | 757 bool should_be_focused = ShouldGuestBeFocused(); |
744 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetFocus( | 758 Send(new BrowserPluginHostMsg_SetFocus( |
745 render_view_routing_id_, | 759 render_view_routing_id_, |
746 instance_id_, | 760 instance_id_, |
747 should_be_focused)); | 761 should_be_focused)); |
748 } | 762 } |
749 | 763 |
750 bool BrowserPlugin::ShouldGuestBeFocused() const { | 764 bool BrowserPluginImpl::ShouldGuestBeFocused() const { |
751 return plugin_focused_ && embedder_focused_; | 765 return plugin_focused_ && embedder_focused_; |
752 } | 766 } |
753 | 767 |
754 WebKit::WebPluginContainer* BrowserPlugin::container() const { | 768 WebKit::WebPluginContainer* BrowserPluginImpl::container() const { |
755 return container_; | 769 return container_; |
756 } | 770 } |
757 | 771 |
758 bool BrowserPlugin::initialize(WebPluginContainer* container) { | 772 bool BrowserPluginImpl::initialize(WebPluginContainer* container) { |
759 container_ = container; | 773 container_ = container; |
760 container_->setWantsWheelEvents(true); | 774 container_->setWantsWheelEvents(true); |
761 return true; | 775 return true; |
762 } | 776 } |
763 | 777 |
764 void BrowserPlugin::EnableCompositing(bool enable) { | 778 void BrowserPluginImpl::EnableCompositing(bool enable) { |
765 if (enable) { | 779 if (enable) { |
766 LOG(ERROR) << "BrowserPlugin compositing not yet implemented."; | 780 LOG(ERROR) << "BrowserPlugin compositing not yet implemented."; |
767 return; | 781 return; |
768 } | 782 } |
769 | 783 |
770 compositing_enabled_ = enable; | 784 compositing_enabled_ = enable; |
771 } | 785 } |
772 | 786 |
773 void BrowserPlugin::destroy() { | 787 void BrowserPluginImpl::destroy() { |
774 // The BrowserPlugin's WebPluginContainer is deleted immediately after this | 788 // The BrowserPlugin's WebPluginContainer is deleted immediately after this |
775 // call returns, so let's not keep a reference to it around. | 789 // call returns, so let's not keep a reference to it around. |
776 container_ = NULL; | 790 container_ = NULL; |
791 FOR_EACH_OBSERVER(BrowserPluginObserver, observers_, BrowserPluginGone()); | |
792 FOR_EACH_OBSERVER(BrowserPluginObserver, observers_, OnDestruct()); | |
777 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 793 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
778 } | 794 } |
779 | 795 |
780 NPObject* BrowserPlugin::scriptableObject() { | 796 NPObject* BrowserPluginImpl::scriptableObject() { |
781 NPObject* browser_plugin_np_object(bindings_->np_object()); | 797 NPObject* browser_plugin_np_object(bindings_->np_object()); |
782 // The object is expected to be retained before it is returned. | 798 // The object is expected to be retained before it is returned. |
783 WebKit::WebBindings::retainObject(browser_plugin_np_object); | 799 WebKit::WebBindings::retainObject(browser_plugin_np_object); |
784 return browser_plugin_np_object; | 800 return browser_plugin_np_object; |
785 } | 801 } |
786 | 802 |
787 bool BrowserPlugin::supportsKeyboardFocus() const { | 803 bool BrowserPluginImpl::supportsKeyboardFocus() const { |
788 return true; | 804 return true; |
789 } | 805 } |
790 | 806 |
791 bool BrowserPlugin::canProcessDrag() const { | 807 bool BrowserPluginImpl::canProcessDrag() const { |
792 return true; | 808 return true; |
793 } | 809 } |
794 | 810 |
795 void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) { | 811 void BrowserPluginImpl::paint(WebCanvas* canvas, const WebRect& rect) { |
796 if (guest_crashed_) { | 812 if (guest_crashed_) { |
797 if (!sad_guest_) // Lazily initialize bitmap. | 813 if (!sad_guest_) // Lazily initialize bitmap. |
798 sad_guest_ = content::GetContentClient()->renderer()-> | 814 sad_guest_ = GetContentClient()->renderer()->GetSadWebViewBitmap(); |
799 GetSadWebViewBitmap(); | |
800 // content_shell does not have the sad plugin bitmap, so we'll paint black | 815 // content_shell does not have the sad plugin bitmap, so we'll paint black |
801 // instead to make it clear that something went wrong. | 816 // instead to make it clear that something went wrong. |
802 if (sad_guest_) { | 817 if (sad_guest_) { |
803 webkit::PaintSadPlugin(canvas, plugin_rect_, *sad_guest_); | 818 webkit::PaintSadPlugin(canvas, plugin_rect_, *sad_guest_); |
804 return; | 819 return; |
805 } | 820 } |
806 } | 821 } |
807 SkAutoCanvasRestore auto_restore(canvas, true); | 822 SkAutoCanvasRestore auto_restore(canvas, true); |
808 canvas->translate(plugin_rect_.x(), plugin_rect_.y()); | 823 canvas->translate(plugin_rect_.x(), plugin_rect_.y()); |
809 SkRect image_data_rect = SkRect::MakeXYWH( | 824 SkRect image_data_rect = SkRect::MakeXYWH( |
(...skipping 10 matching lines...) Expand all Loading... | |
820 canvas->drawRect(image_data_rect, paint); | 835 canvas->drawRect(image_data_rect, paint); |
821 // Stay a solid color if we have never set a non-empty src, or we don't have a | 836 // Stay a solid color if we have never set a non-empty src, or we don't have a |
822 // backing store. | 837 // backing store. |
823 if (!backing_store_.get() || !navigate_src_sent_) | 838 if (!backing_store_.get() || !navigate_src_sent_) |
824 return; | 839 return; |
825 float inverse_scale_factor = 1.0f / backing_store_->GetScaleFactor(); | 840 float inverse_scale_factor = 1.0f / backing_store_->GetScaleFactor(); |
826 canvas->scale(inverse_scale_factor, inverse_scale_factor); | 841 canvas->scale(inverse_scale_factor, inverse_scale_factor); |
827 canvas->drawBitmap(backing_store_->GetBitmap(), 0, 0); | 842 canvas->drawBitmap(backing_store_->GetBitmap(), 0, 0); |
828 } | 843 } |
829 | 844 |
830 bool BrowserPlugin::InBounds(const gfx::Point& position) const { | 845 bool BrowserPluginImpl::InBounds(const gfx::Point& position) const { |
831 // Note that even for plugins that are rotated using rotate transformations, | 846 // Note that even for plugins that are rotated using rotate transformations, |
832 // we use the the |plugin_rect_| provided by updateGeometry, which means we | 847 // we use the the |plugin_rect_| provided by updateGeometry, which means we |
833 // will be off if |position| is within the plugin rect but does not fall | 848 // will be off if |position| is within the plugin rect but does not fall |
834 // within the actual plugin boundary. Not supporting such edge case is OK | 849 // within the actual plugin boundary. Not supporting such edge case is OK |
835 // since this function should not be used for making security-sensitive | 850 // since this function should not be used for making security-sensitive |
836 // decisions. | 851 // decisions. |
837 // This also does not take overlapping plugins into account. | 852 // This also does not take overlapping plugins into account. |
838 bool result = position.x() >= plugin_rect_.x() && | 853 bool result = position.x() >= plugin_rect_.x() && |
839 position.x() < plugin_rect_.x() + plugin_rect_.width() && | 854 position.x() < plugin_rect_.x() + plugin_rect_.width() && |
840 position.y() >= plugin_rect_.y() && | 855 position.y() >= plugin_rect_.y() && |
841 position.y() < plugin_rect_.y() + plugin_rect_.height(); | 856 position.y() < plugin_rect_.y() + plugin_rect_.height(); |
842 return result; | 857 return result; |
843 } | 858 } |
844 | 859 |
845 gfx::Point BrowserPlugin::ToLocalCoordinates(const gfx::Point& point) const { | 860 void BrowserPluginImpl::AddMethodBinding( |
861 BrowserPluginMethodBinding* method_binding) { | |
862 bindings_->AddMethodBinding(method_binding); | |
863 } | |
864 | |
865 void BrowserPluginImpl::AddPropertyBinding( | |
866 BrowserPluginPropertyBinding* method_binding) { | |
867 bindings_->AddPropertyBinding(method_binding); | |
868 } | |
869 | |
870 bool BrowserPluginImpl::Send(IPC::Message* message) { | |
871 return browser_plugin_manager()->Send(message); | |
872 } | |
873 | |
874 void BrowserPluginImpl::RequestMessage(uint32 message_id) { | |
875 browser_plugin_manager()->RequestMessage(message_id); | |
876 } | |
877 | |
878 gfx::Point BrowserPluginImpl::ToLocalCoordinates( | |
879 const gfx::Point& point) const { | |
846 if (container_) | 880 if (container_) |
847 return container_->windowToLocalPoint(WebKit::WebPoint(point)); | 881 return container_->windowToLocalPoint(WebKit::WebPoint(point)); |
848 return gfx::Point(point.x() - plugin_rect_.x(), point.y() - plugin_rect_.y()); | 882 return gfx::Point(point.x() - plugin_rect_.x(), point.y() - plugin_rect_.y()); |
849 } | 883 } |
850 | 884 |
851 void BrowserPlugin::updateGeometry( | 885 void BrowserPluginImpl::updateGeometry( |
852 const WebRect& window_rect, | 886 const WebRect& window_rect, |
853 const WebRect& clip_rect, | 887 const WebRect& clip_rect, |
854 const WebVector<WebRect>& cut_outs_rects, | 888 const WebVector<WebRect>& cut_outs_rects, |
855 bool is_visible) { | 889 bool is_visible) { |
856 int old_width = width(); | 890 int old_width = width(); |
857 int old_height = height(); | 891 int old_height = height(); |
858 plugin_rect_ = window_rect; | 892 plugin_rect_ = window_rect; |
859 // In AutoSize mode, guests don't care when the BrowserPlugin container is | 893 // In AutoSize mode, guests don't care when the BrowserPlugin container is |
860 // resized. If |!resize_ack_received_|, then we are still waiting on a | 894 // resized. If |!resize_ack_received_|, then we are still waiting on a |
861 // previous resize to be ACK'ed and so we don't issue additional resizes | 895 // previous resize to be ACK'ed and so we don't issue additional resizes |
862 // until the previous one is ACK'ed. | 896 // until the previous one is ACK'ed. |
863 if (!navigate_src_sent_ || auto_size_ || !resize_ack_received_ || | 897 if (!navigate_src_sent_ || auto_size_ || !resize_ack_received_ || |
864 (old_width == window_rect.width && | 898 (old_width == window_rect.width && |
865 old_height == window_rect.height)) { | 899 old_height == window_rect.height)) { |
866 return; | 900 return; |
867 } | 901 } |
868 | 902 |
869 BrowserPluginHostMsg_ResizeGuest_Params params; | 903 BrowserPluginHostMsg_ResizeGuest_Params params; |
870 PopulateResizeGuestParameters(¶ms, gfx::Size(width(), height())); | 904 PopulateResizeGuestParameters(¶ms, gfx::Size(width(), height())); |
871 resize_ack_received_ = false; | 905 resize_ack_received_ = false; |
872 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( | 906 Send(new BrowserPluginHostMsg_ResizeGuest( |
873 render_view_routing_id_, | 907 render_view_routing_id_, |
874 instance_id_, | 908 instance_id_, |
875 params)); | 909 params)); |
876 } | 910 } |
877 | 911 |
878 void BrowserPlugin::SwapDamageBuffers() { | 912 void BrowserPluginImpl::SwapDamageBuffers() { |
879 current_damage_buffer_.reset(pending_damage_buffer_.release()); | 913 current_damage_buffer_.reset(pending_damage_buffer_.release()); |
880 resize_ack_received_ = true; | 914 resize_ack_received_ = true; |
881 } | 915 } |
882 | 916 |
883 void BrowserPlugin::PopulateResizeGuestParameters( | 917 void BrowserPluginImpl::PopulateResizeGuestParameters( |
884 BrowserPluginHostMsg_ResizeGuest_Params* params, | 918 BrowserPluginHostMsg_ResizeGuest_Params* params, |
885 const gfx::Size& view_size) { | 919 const gfx::Size& view_size) { |
886 params->view_size = view_size; | 920 params->view_size = view_size; |
887 params->scale_factor = GetDeviceScaleFactor(); | 921 params->scale_factor = GetDeviceScaleFactor(); |
888 | 922 |
889 // In HW compositing mode, we do not need a damage buffer. | 923 // In HW compositing mode, we do not need a damage buffer. |
890 if (compositing_enabled_) | 924 if (compositing_enabled_) |
891 return; | 925 return; |
892 | 926 |
893 const size_t stride = skia::PlatformCanvasStrideForWidth(view_size.width()); | 927 const size_t stride = skia::PlatformCanvasStrideForWidth(view_size.width()); |
894 // Make sure the size of the damage buffer is at least four bytes so that we | 928 // Make sure the size of the damage buffer is at least four bytes so that we |
895 // can fit in a magic word to verify that the memory is shared correctly. | 929 // can fit in a magic word to verify that the memory is shared correctly. |
896 size_t size = | 930 size_t size = |
897 std::max(sizeof(unsigned int), | 931 std::max(sizeof(unsigned int), |
898 static_cast<size_t>(view_size.height() * | 932 static_cast<size_t>(view_size.height() * |
899 stride * | 933 stride * |
900 GetDeviceScaleFactor() * | 934 GetDeviceScaleFactor() * |
901 GetDeviceScaleFactor())); | 935 GetDeviceScaleFactor())); |
902 | 936 |
903 params->damage_buffer_size = size; | 937 params->damage_buffer_size = size; |
904 pending_damage_buffer_.reset( | 938 pending_damage_buffer_.reset( |
905 CreateDamageBuffer(size, ¶ms->damage_buffer_handle)); | 939 CreateDamageBuffer(size, ¶ms->damage_buffer_handle)); |
906 if (!pending_damage_buffer_.get()) | 940 if (!pending_damage_buffer_.get()) |
907 NOTREACHED(); | 941 NOTREACHED(); |
908 params->damage_buffer_sequence_id = ++damage_buffer_sequence_id_; | 942 params->damage_buffer_sequence_id = ++damage_buffer_sequence_id_; |
909 } | 943 } |
910 | 944 |
911 void BrowserPlugin::GetDamageBufferWithSizeParams( | 945 void BrowserPluginImpl::GetDamageBufferWithSizeParams( |
912 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, | 946 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, |
913 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params) { | 947 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params) { |
914 PopulateAutoSizeParameters(auto_size_params); | 948 PopulateAutoSizeParameters(auto_size_params); |
915 gfx::Size view_size = auto_size_params->enable ? auto_size_params->max_size : | 949 gfx::Size view_size = auto_size_params->enable ? auto_size_params->max_size : |
916 gfx::Size(width(), height()); | 950 gfx::Size(width(), height()); |
917 if (view_size.IsEmpty()) | 951 if (view_size.IsEmpty()) |
918 return; | 952 return; |
919 resize_ack_received_ = false; | 953 resize_ack_received_ = false; |
920 PopulateResizeGuestParameters(resize_guest_params, view_size); | 954 PopulateResizeGuestParameters(resize_guest_params, view_size); |
921 } | 955 } |
922 | 956 |
923 #if defined(OS_POSIX) | 957 #if defined(OS_POSIX) |
924 base::SharedMemory* BrowserPlugin::CreateDamageBuffer( | 958 base::SharedMemory* BrowserPluginImpl::CreateDamageBuffer( |
925 const size_t size, | 959 const size_t size, |
926 base::SharedMemoryHandle* damage_buffer_handle) { | 960 base::SharedMemoryHandle* damage_buffer_handle) { |
927 scoped_ptr<base::SharedMemory> shared_buf( | 961 scoped_ptr<base::SharedMemory> shared_buf( |
928 content::RenderThread::Get()->HostAllocateSharedMemoryBuffer( | 962 content::RenderThread::Get()->HostAllocateSharedMemoryBuffer( |
929 size).release()); | 963 size).release()); |
930 | 964 |
931 if (shared_buf.get()) { | 965 if (shared_buf.get()) { |
932 if (shared_buf->Map(size)) { | 966 if (shared_buf->Map(size)) { |
933 // Insert the magic word. | 967 // Insert the magic word. |
934 *static_cast<unsigned int*>(shared_buf->memory()) = 0xdeadbeef; | 968 *static_cast<unsigned int*>(shared_buf->memory()) = 0xdeadbeef; |
935 shared_buf->ShareToProcess(base::GetCurrentProcessHandle(), | 969 shared_buf->ShareToProcess(base::GetCurrentProcessHandle(), |
936 damage_buffer_handle); | 970 damage_buffer_handle); |
937 return shared_buf.release(); | 971 return shared_buf.release(); |
938 } | 972 } |
939 } | 973 } |
940 NOTREACHED(); | 974 NOTREACHED(); |
941 return NULL; | 975 return NULL; |
942 } | 976 } |
943 #elif defined(OS_WIN) | 977 #elif defined(OS_WIN) |
944 base::SharedMemory* BrowserPlugin::CreateDamageBuffer( | 978 base::SharedMemory* BrowserPlugin::CreateDamageBuffer( |
945 const size_t size, | 979 const size_t size, |
946 base::SharedMemoryHandle* damage_buffer_handle) { | 980 base::SharedMemoryHandle* damage_buffer_handle) { |
947 scoped_ptr<base::SharedMemory> shared_buf(new base::SharedMemory()); | 981 scoped_ptr<base::SharedMemory> shared_buf(new base::SharedMemory()); |
948 | 982 |
949 if (!shared_buf->CreateAndMapAnonymous(size)) { | 983 if (!shared_buf->CreateAndMapAnonymous(size)) { |
950 NOTREACHED() << "Buffer allocation failed"; | 984 NOTREACHED() << "Buffer allocation failed"; |
951 return NULL; | 985 return NULL; |
952 } | 986 } |
953 | |
954 // Insert the magic word. | 987 // Insert the magic word. |
955 *static_cast<unsigned int*>(shared_buf->memory()) = 0xdeadbeef; | 988 *static_cast<unsigned int*>(shared_buf->memory()) = 0xdeadbeef; |
956 if (shared_buf->ShareToProcess(base::GetCurrentProcessHandle(), | 989 if (shared_buf->ShareToProcess(base::GetCurrentProcessHandle(), |
957 damage_buffer_handle)) | 990 damage_buffer_handle)) |
958 return shared_buf.release(); | 991 return shared_buf.release(); |
959 NOTREACHED(); | 992 NOTREACHED(); |
960 return NULL; | 993 return NULL; |
961 } | 994 } |
962 #endif | 995 #endif |
963 | 996 |
964 void BrowserPlugin::updateFocus(bool focused) { | 997 void BrowserPluginImpl::updateFocus(bool focused) { |
965 if (plugin_focused_ == focused) | 998 if (plugin_focused_ == focused) |
966 return; | 999 return; |
967 | 1000 |
968 bool old_guest_focus_state = ShouldGuestBeFocused(); | 1001 bool old_guest_focus_state = ShouldGuestBeFocused(); |
969 plugin_focused_ = focused; | 1002 plugin_focused_ = focused; |
970 | 1003 |
971 if (ShouldGuestBeFocused() != old_guest_focus_state) | 1004 if (ShouldGuestBeFocused() != old_guest_focus_state) |
972 UpdateGuestFocusState(); | 1005 UpdateGuestFocusState(); |
973 } | 1006 } |
974 | 1007 |
975 void BrowserPlugin::updateVisibility(bool visible) { | 1008 void BrowserPluginImpl::updateVisibility(bool visible) { |
976 if (visible_ == visible) | 1009 if (visible_ == visible) |
977 return; | 1010 return; |
978 | 1011 |
979 visible_ = visible; | 1012 visible_ = visible; |
980 if (!navigate_src_sent_) | 1013 if (!navigate_src_sent_) |
981 return; | 1014 return; |
982 | 1015 |
983 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetVisibility( | 1016 Send(new BrowserPluginHostMsg_SetVisibility( |
984 render_view_routing_id_, | 1017 render_view_routing_id_, |
985 instance_id_, | 1018 instance_id_, |
986 visible)); | 1019 visible)); |
987 } | 1020 } |
988 | 1021 |
989 bool BrowserPlugin::acceptsInputEvents() { | 1022 bool BrowserPluginImpl::acceptsInputEvents() { |
990 return true; | 1023 return true; |
991 } | 1024 } |
992 | 1025 |
993 bool BrowserPlugin::handleInputEvent(const WebKit::WebInputEvent& event, | 1026 bool BrowserPluginImpl::handleInputEvent(const WebKit::WebInputEvent& event, |
994 WebKit::WebCursorInfo& cursor_info) { | 1027 WebKit::WebCursorInfo& cursor_info) { |
995 if (guest_crashed_ || !navigate_src_sent_ || | 1028 if (guest_crashed_ || !navigate_src_sent_ || |
996 event.type == WebKit::WebInputEvent::ContextMenu) | 1029 event.type == WebKit::WebInputEvent::ContextMenu) |
997 return false; | 1030 return false; |
998 browser_plugin_manager()->Send( | 1031 Send(new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
999 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 1032 instance_id_, |
1000 instance_id_, | 1033 plugin_rect_, |
1001 plugin_rect_, | 1034 &event)); |
1002 &event)); | |
1003 cursor_.GetCursorInfo(&cursor_info); | 1035 cursor_.GetCursorInfo(&cursor_info); |
1004 return true; | 1036 return true; |
1005 } | 1037 } |
1006 | 1038 |
1007 bool BrowserPlugin::handleDragStatusUpdate(WebKit::WebDragStatus drag_status, | 1039 bool BrowserPluginImpl::handleDragStatusUpdate( |
1008 const WebKit::WebDragData& drag_data, | 1040 WebKit::WebDragStatus drag_status, |
1009 WebKit::WebDragOperationsMask mask, | 1041 const WebKit::WebDragData& drag_data, |
1010 const WebKit::WebPoint& position, | 1042 WebKit::WebDragOperationsMask mask, |
1011 const WebKit::WebPoint& screen) { | 1043 const WebKit::WebPoint& position, |
1044 const WebKit::WebPoint& screen) { | |
1012 if (guest_crashed_ || !navigate_src_sent_) | 1045 if (guest_crashed_ || !navigate_src_sent_) |
1013 return false; | 1046 return false; |
1014 browser_plugin_manager()->Send( | 1047 Send(new BrowserPluginHostMsg_DragStatusUpdate( |
1015 new BrowserPluginHostMsg_DragStatusUpdate( | 1048 render_view_routing_id_, |
1016 render_view_routing_id_, | 1049 instance_id_, |
1017 instance_id_, | 1050 drag_status, |
1018 drag_status, | 1051 WebDropData(drag_data), |
1019 WebDropData(drag_data), | 1052 mask, |
1020 mask, | 1053 position)); |
1021 position)); | |
1022 return false; | 1054 return false; |
1023 } | 1055 } |
1024 | 1056 |
1025 void BrowserPlugin::didReceiveResponse( | 1057 void BrowserPluginImpl::didReceiveResponse( |
1026 const WebKit::WebURLResponse& response) { | 1058 const WebKit::WebURLResponse& response) { |
1027 } | 1059 } |
1028 | 1060 |
1029 void BrowserPlugin::didReceiveData(const char* data, int data_length) { | 1061 void BrowserPluginImpl::didReceiveData(const char* data, int data_length) { |
1030 } | 1062 } |
1031 | 1063 |
1032 void BrowserPlugin::didFinishLoading() { | 1064 void BrowserPluginImpl::didFinishLoading() { |
1033 } | 1065 } |
1034 | 1066 |
1035 void BrowserPlugin::didFailLoading(const WebKit::WebURLError& error) { | 1067 void BrowserPluginImpl::didFailLoading(const WebKit::WebURLError& error) { |
1036 } | 1068 } |
1037 | 1069 |
1038 void BrowserPlugin::didFinishLoadingFrameRequest(const WebKit::WebURL& url, | 1070 void BrowserPluginImpl::didFinishLoadingFrameRequest(const WebKit::WebURL& url, |
1039 void* notify_data) { | 1071 void* notify_data) { |
1040 } | 1072 } |
1041 | 1073 |
1042 void BrowserPlugin::didFailLoadingFrameRequest( | 1074 void BrowserPluginImpl::didFailLoadingFrameRequest( |
1043 const WebKit::WebURL& url, | 1075 const WebKit::WebURL& url, |
1044 void* notify_data, | 1076 void* notify_data, |
1045 const WebKit::WebURLError& error) { | 1077 const WebKit::WebURLError& error) { |
1046 } | 1078 } |
1047 | 1079 |
1048 } // namespace content | 1080 } // namespace content |
OLD | NEW |