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/pepper/pepper_webplugin_impl.h" | 5 #include "content/renderer/pepper/pepper_webplugin_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 MessageChannel* message_channel = instance_->message_channel(); | 176 MessageChannel* message_channel = instance_->message_channel(); |
177 if (message_channel) | 177 if (message_channel) |
178 message_channel->SetPassthroughObject(object_var->GetHandle()); | 178 message_channel->SetPassthroughObject(object_var->GetHandle()); |
179 } | 179 } |
180 | 180 |
181 v8::Local<v8::Object> result = instance_->GetMessageChannelObject(); | 181 v8::Local<v8::Object> result = instance_->GetMessageChannelObject(); |
182 return result; | 182 return result; |
183 } | 183 } |
184 | 184 |
185 void PepperWebPluginImpl::Paint(WebCanvas* canvas, const WebRect& rect) { | 185 void PepperWebPluginImpl::Paint(WebCanvas* canvas, const WebRect& rect) { |
186 if (!instance_->FlashIsFullscreenOrPending()) | 186 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 187 // is fully initialized. See: crbug.com/715747. |
| 188 if (instance_ && !instance_->FlashIsFullscreenOrPending()) |
187 instance_->Paint(canvas, plugin_rect_, rect); | 189 instance_->Paint(canvas, plugin_rect_, rect); |
188 } | 190 } |
189 | 191 |
190 void PepperWebPluginImpl::UpdateGeometry( | 192 void PepperWebPluginImpl::UpdateGeometry( |
191 const WebRect& window_rect, | 193 const WebRect& window_rect, |
192 const WebRect& clip_rect, | 194 const WebRect& clip_rect, |
193 const WebRect& unobscured_rect, | 195 const WebRect& unobscured_rect, |
194 const WebVector<WebRect>& cut_outs_rects, | 196 const WebVector<WebRect>& cut_outs_rects, |
195 bool is_visible) { | 197 bool is_visible) { |
196 plugin_rect_ = window_rect; | 198 plugin_rect_ = window_rect; |
197 if (instance_ && !instance_->FlashIsFullscreenOrPending()) | 199 if (instance_ && !instance_->FlashIsFullscreenOrPending()) |
198 instance_->ViewChanged(plugin_rect_, clip_rect, unobscured_rect); | 200 instance_->ViewChanged(plugin_rect_, clip_rect, unobscured_rect); |
199 } | 201 } |
200 | 202 |
201 void PepperWebPluginImpl::UpdateFocus(bool focused, | 203 void PepperWebPluginImpl::UpdateFocus(bool focused, |
202 blink::WebFocusType focus_type) { | 204 blink::WebFocusType focus_type) { |
203 instance_->SetWebKitFocus(focused); | 205 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 206 // is fully initialized. See: crbug.com/715747. |
| 207 if (instance_) |
| 208 instance_->SetWebKitFocus(focused); |
204 } | 209 } |
205 | 210 |
206 void PepperWebPluginImpl::UpdateVisibility(bool visible) {} | 211 void PepperWebPluginImpl::UpdateVisibility(bool visible) {} |
207 | 212 |
208 blink::WebInputEventResult PepperWebPluginImpl::HandleInputEvent( | 213 blink::WebInputEventResult PepperWebPluginImpl::HandleInputEvent( |
209 const blink::WebInputEvent& event, | 214 const blink::WebInputEvent& event, |
210 blink::WebCursorInfo& cursor_info) { | 215 blink::WebCursorInfo& cursor_info) { |
211 if (instance_->FlashIsFullscreenOrPending()) | 216 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 217 // is fully initialized. See: crbug.com/715747. |
| 218 if (!instance_ || instance_->FlashIsFullscreenOrPending()) |
212 return blink::WebInputEventResult::kNotHandled; | 219 return blink::WebInputEventResult::kNotHandled; |
213 return instance_->HandleInputEvent(event, &cursor_info) | 220 return instance_->HandleInputEvent(event, &cursor_info) |
214 ? blink::WebInputEventResult::kHandledApplication | 221 ? blink::WebInputEventResult::kHandledApplication |
215 : blink::WebInputEventResult::kNotHandled; | 222 : blink::WebInputEventResult::kNotHandled; |
216 } | 223 } |
217 | 224 |
218 void PepperWebPluginImpl::DidReceiveResponse( | 225 void PepperWebPluginImpl::DidReceiveResponse( |
219 const blink::WebURLResponse& response) { | 226 const blink::WebURLResponse& response) { |
| 227 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 228 // is fully initialized. See: crbug.com/715747. |
| 229 if (!instance_) |
| 230 return; |
220 DCHECK(!instance_->document_loader()); | 231 DCHECK(!instance_->document_loader()); |
221 instance_->HandleDocumentLoad(response); | 232 instance_->HandleDocumentLoad(response); |
222 } | 233 } |
223 | 234 |
224 void PepperWebPluginImpl::DidReceiveData(const char* data, int data_length) { | 235 void PepperWebPluginImpl::DidReceiveData(const char* data, int data_length) { |
| 236 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 237 // is fully initialized. See: crbug.com/715747. |
| 238 if (!instance_) |
| 239 return; |
225 blink::WebAssociatedURLLoaderClient* document_loader = | 240 blink::WebAssociatedURLLoaderClient* document_loader = |
226 instance_->document_loader(); | 241 instance_->document_loader(); |
227 if (document_loader) | 242 if (document_loader) |
228 document_loader->DidReceiveData(data, data_length); | 243 document_loader->DidReceiveData(data, data_length); |
229 } | 244 } |
230 | 245 |
231 void PepperWebPluginImpl::DidFinishLoading() { | 246 void PepperWebPluginImpl::DidFinishLoading() { |
| 247 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 248 // is fully initialized. See: crbug.com/715747. |
| 249 if (!instance_) |
| 250 return; |
232 blink::WebAssociatedURLLoaderClient* document_loader = | 251 blink::WebAssociatedURLLoaderClient* document_loader = |
233 instance_->document_loader(); | 252 instance_->document_loader(); |
234 if (document_loader) | 253 if (document_loader) |
235 document_loader->DidFinishLoading(0.0); | 254 document_loader->DidFinishLoading(0.0); |
236 } | 255 } |
237 | 256 |
238 void PepperWebPluginImpl::DidFailLoading(const blink::WebURLError& error) { | 257 void PepperWebPluginImpl::DidFailLoading(const blink::WebURLError& error) { |
| 258 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 259 // is fully initialized. See: crbug.com/715747. |
| 260 if (!instance_) |
| 261 return; |
239 blink::WebAssociatedURLLoaderClient* document_loader = | 262 blink::WebAssociatedURLLoaderClient* document_loader = |
240 instance_->document_loader(); | 263 instance_->document_loader(); |
241 if (document_loader) | 264 if (document_loader) |
242 document_loader->DidFail(error); | 265 document_loader->DidFail(error); |
243 } | 266 } |
244 | 267 |
245 bool PepperWebPluginImpl::HasSelection() const { | 268 bool PepperWebPluginImpl::HasSelection() const { |
246 return !SelectionAsText().IsEmpty(); | 269 return !SelectionAsText().IsEmpty(); |
247 } | 270 } |
248 | 271 |
249 WebString PepperWebPluginImpl::SelectionAsText() const { | 272 WebString PepperWebPluginImpl::SelectionAsText() const { |
| 273 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 274 // is fully initialized. See: crbug.com/715747. |
| 275 if (!instance_) |
| 276 return WebString(); |
250 return WebString::FromUTF16(instance_->GetSelectedText(false)); | 277 return WebString::FromUTF16(instance_->GetSelectedText(false)); |
251 } | 278 } |
252 | 279 |
253 WebString PepperWebPluginImpl::SelectionAsMarkup() const { | 280 WebString PepperWebPluginImpl::SelectionAsMarkup() const { |
| 281 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 282 // is fully initialized. See: crbug.com/715747. |
| 283 if (!instance_) |
| 284 return WebString(); |
254 return WebString::FromUTF16(instance_->GetSelectedText(true)); | 285 return WebString::FromUTF16(instance_->GetSelectedText(true)); |
255 } | 286 } |
256 | 287 |
257 WebURL PepperWebPluginImpl::LinkAtPosition(const WebPoint& position) const { | 288 WebURL PepperWebPluginImpl::LinkAtPosition(const WebPoint& position) const { |
| 289 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 290 // is fully initialized. See: crbug.com/715747. |
| 291 if (!instance_) |
| 292 return GURL(); |
258 return GURL(instance_->GetLinkAtPosition(position)); | 293 return GURL(instance_->GetLinkAtPosition(position)); |
259 } | 294 } |
260 | 295 |
261 bool PepperWebPluginImpl::StartFind(const blink::WebString& search_text, | 296 bool PepperWebPluginImpl::StartFind(const blink::WebString& search_text, |
262 bool case_sensitive, | 297 bool case_sensitive, |
263 int identifier) { | 298 int identifier) { |
| 299 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 300 // is fully initialized. See: crbug.com/715747. |
| 301 if (!instance_) |
| 302 return false; |
264 return instance_->StartFind(search_text.Utf8(), case_sensitive, identifier); | 303 return instance_->StartFind(search_text.Utf8(), case_sensitive, identifier); |
265 } | 304 } |
266 | 305 |
267 void PepperWebPluginImpl::SelectFindResult(bool forward, int identifier) { | 306 void PepperWebPluginImpl::SelectFindResult(bool forward, int identifier) { |
268 instance_->SelectFindResult(forward, identifier); | 307 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 308 // is fully initialized. See: crbug.com/715747. |
| 309 if (instance_) |
| 310 instance_->SelectFindResult(forward, identifier); |
269 } | 311 } |
270 | 312 |
271 void PepperWebPluginImpl::StopFind() { | 313 void PepperWebPluginImpl::StopFind() { |
272 instance_->StopFind(); | 314 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 315 // is fully initialized. See: crbug.com/715747. |
| 316 if (instance_) |
| 317 instance_->StopFind(); |
273 } | 318 } |
274 | 319 |
275 bool PepperWebPluginImpl::SupportsPaginatedPrint() { | 320 bool PepperWebPluginImpl::SupportsPaginatedPrint() { |
| 321 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 322 // is fully initialized. See: crbug.com/715747. |
| 323 if (!instance_) |
| 324 return false; |
276 return instance_->SupportsPrintInterface(); | 325 return instance_->SupportsPrintInterface(); |
277 } | 326 } |
278 | 327 |
279 bool PepperWebPluginImpl::IsPrintScalingDisabled() { | 328 bool PepperWebPluginImpl::IsPrintScalingDisabled() { |
| 329 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 330 // is fully initialized. See: crbug.com/715747. |
| 331 if (!instance_) |
| 332 return false; |
280 return instance_->IsPrintScalingDisabled(); | 333 return instance_->IsPrintScalingDisabled(); |
281 } | 334 } |
282 | 335 |
283 int PepperWebPluginImpl::PrintBegin(const WebPrintParams& print_params) { | 336 int PepperWebPluginImpl::PrintBegin(const WebPrintParams& print_params) { |
| 337 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 338 // is fully initialized. See: crbug.com/715747. |
| 339 if (!instance_) |
| 340 return 0; |
284 return instance_->PrintBegin(print_params); | 341 return instance_->PrintBegin(print_params); |
285 } | 342 } |
286 | 343 |
287 void PepperWebPluginImpl::PrintPage(int page_number, blink::WebCanvas* canvas) { | 344 void PepperWebPluginImpl::PrintPage(int page_number, blink::WebCanvas* canvas) { |
288 instance_->PrintPage(page_number, canvas); | 345 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 346 // is fully initialized. See: crbug.com/715747. |
| 347 if (instance_) |
| 348 instance_->PrintPage(page_number, canvas); |
289 } | 349 } |
290 | 350 |
291 void PepperWebPluginImpl::PrintEnd() { | 351 void PepperWebPluginImpl::PrintEnd() { |
292 instance_->PrintEnd(); | 352 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 353 // is fully initialized. See: crbug.com/715747. |
| 354 if (instance_) |
| 355 instance_->PrintEnd(); |
293 } | 356 } |
294 | 357 |
295 bool PepperWebPluginImpl::GetPrintPresetOptionsFromDocument( | 358 bool PepperWebPluginImpl::GetPrintPresetOptionsFromDocument( |
296 blink::WebPrintPresetOptions* preset_options) { | 359 blink::WebPrintPresetOptions* preset_options) { |
| 360 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 361 // is fully initialized. See: crbug.com/715747. |
| 362 if (!instance_) |
| 363 return false; |
297 return instance_->GetPrintPresetOptionsFromDocument(preset_options); | 364 return instance_->GetPrintPresetOptionsFromDocument(preset_options); |
298 } | 365 } |
299 | 366 |
300 bool PepperWebPluginImpl::CanRotateView() { | 367 bool PepperWebPluginImpl::CanRotateView() { |
| 368 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 369 // is fully initialized. See: crbug.com/715747. |
| 370 if (!instance_) |
| 371 return false; |
301 return instance_->CanRotateView(); | 372 return instance_->CanRotateView(); |
302 } | 373 } |
303 | 374 |
304 void PepperWebPluginImpl::RotateView(RotationType type) { | 375 void PepperWebPluginImpl::RotateView(RotationType type) { |
305 instance_->RotateView(type); | 376 // Re-entrancy may cause JS to try to execute script on the plugin before it |
| 377 // is fully initialized. See: crbug.com/715747. |
| 378 if (instance_) |
| 379 instance_->RotateView(type); |
306 } | 380 } |
307 | 381 |
308 bool PepperWebPluginImpl::IsPlaceholder() { | 382 bool PepperWebPluginImpl::IsPlaceholder() { |
309 return false; | 383 return false; |
310 } | 384 } |
311 | 385 |
312 } // namespace content | 386 } // namespace content |
OLD | NEW |