Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 225903006: PPAPI: Run clang_format.py on content/renderer/pepper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_plugin_instance_impl.h" 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 using blink::WebURLRequest; 176 using blink::WebURLRequest;
177 using blink::WebURLResponse; 177 using blink::WebURLResponse;
178 using blink::WebUserGestureIndicator; 178 using blink::WebUserGestureIndicator;
179 using blink::WebUserGestureToken; 179 using blink::WebUserGestureToken;
180 using blink::WebView; 180 using blink::WebView;
181 181
182 namespace content { 182 namespace content {
183 183
184 #if defined(OS_WIN) 184 #if defined(OS_WIN)
185 // Exported by pdf.dll 185 // Exported by pdf.dll
186 typedef bool (*RenderPDFPageToDCProc)( 186 typedef bool (*RenderPDFPageToDCProc)(const unsigned char* pdf_buffer,
187 const unsigned char* pdf_buffer, int buffer_size, int page_number, HDC dc, 187 int buffer_size,
188 int dpi_x, int dpi_y, int bounds_origin_x, int bounds_origin_y, 188 int page_number,
189 int bounds_width, int bounds_height, bool fit_to_bounds, 189 HDC dc,
190 bool stretch_to_bounds, bool keep_aspect_ratio, bool center_in_bounds, 190 int dpi_x,
191 bool autorotate); 191 int dpi_y,
192 int bounds_origin_x,
193 int bounds_origin_y,
194 int bounds_width,
195 int bounds_height,
196 bool fit_to_bounds,
197 bool stretch_to_bounds,
198 bool keep_aspect_ratio,
199 bool center_in_bounds,
200 bool autorotate);
192 201
193 void DrawEmptyRectangle(HDC dc) { 202 void DrawEmptyRectangle(HDC dc) {
194 // TODO(sanjeevr): This is a temporary hack. If we output a JPEG 203 // TODO(sanjeevr): This is a temporary hack. If we output a JPEG
195 // to the EMF, the EnumEnhMetaFile call fails in the browser 204 // to the EMF, the EnumEnhMetaFile call fails in the browser
196 // process. The failure also happens if we output nothing here. 205 // process. The failure also happens if we output nothing here.
197 // We need to investigate the reason for this failure and fix it. 206 // We need to investigate the reason for this failure and fix it.
198 // In the meantime this temporary hack of drawing an empty 207 // In the meantime this temporary hack of drawing an empty
199 // rectangle in the DC gets us by. 208 // rectangle in the DC gets us by.
200 Rectangle(dc, 0, 0, 0, 0); 209 Rectangle(dc, 0, 0, 0, 0);
201 } 210 }
202 #endif // defined(OS_WIN) 211 #endif // defined(OS_WIN)
203 212
204 namespace { 213 namespace {
205 214
206 // Check PP_TextInput_Type and ui::TextInputType are kept in sync. 215 // Check PP_TextInput_Type and ui::TextInputType are kept in sync.
207 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NONE) == \ 216 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NONE) == int(PP_TEXTINPUT_TYPE_NONE),
208 int(PP_TEXTINPUT_TYPE_NONE), mismatching_enums); 217 mismatching_enums);
209 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TEXT) == \ 218 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TEXT) == int(PP_TEXTINPUT_TYPE_TEXT),
210 int(PP_TEXTINPUT_TYPE_TEXT), mismatching_enums); 219 mismatching_enums);
211 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_PASSWORD) == \ 220 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_PASSWORD) ==
212 int(PP_TEXTINPUT_TYPE_PASSWORD), mismatching_enums); 221 int(PP_TEXTINPUT_TYPE_PASSWORD),
213 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_SEARCH) == \ 222 mismatching_enums);
214 int(PP_TEXTINPUT_TYPE_SEARCH), mismatching_enums); 223 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_SEARCH) == int(PP_TEXTINPUT_TYPE_SEARCH),
215 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_EMAIL) == \ 224 mismatching_enums);
216 int(PP_TEXTINPUT_TYPE_EMAIL), mismatching_enums); 225 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_EMAIL) == int(PP_TEXTINPUT_TYPE_EMAIL),
217 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NUMBER) == \ 226 mismatching_enums);
218 int(PP_TEXTINPUT_TYPE_NUMBER), mismatching_enums); 227 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NUMBER) == int(PP_TEXTINPUT_TYPE_NUMBER),
219 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TELEPHONE) == \ 228 mismatching_enums);
220 int(PP_TEXTINPUT_TYPE_TELEPHONE), mismatching_enums); 229 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TELEPHONE) ==
221 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_URL) == \ 230 int(PP_TEXTINPUT_TYPE_TELEPHONE),
222 int(PP_TEXTINPUT_TYPE_URL), mismatching_enums); 231 mismatching_enums);
232 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_URL) == int(PP_TEXTINPUT_TYPE_URL),
233 mismatching_enums);
223 234
224 // The default text input type is to regard the plugin always accept text input. 235 // The default text input type is to regard the plugin always accept text input.
225 // This is for allowing users to use input methods even on completely-IME- 236 // This is for allowing users to use input methods even on completely-IME-
226 // unaware plugins (e.g., PPAPI Flash or PDF plugin for M16). 237 // unaware plugins (e.g., PPAPI Flash or PDF plugin for M16).
227 // Plugins need to explicitly opt out the text input mode if they know 238 // Plugins need to explicitly opt out the text input mode if they know
228 // that they don't accept texts. 239 // that they don't accept texts.
229 const ui::TextInputType kPluginDefaultTextInputType = ui::TEXT_INPUT_TYPE_TEXT; 240 const ui::TextInputType kPluginDefaultTextInputType = ui::TEXT_INPUT_TYPE_TEXT;
230 241
231 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \ 242 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \
232 COMPILE_ASSERT(static_cast<int>(WebCursorInfo::webkit_name) \ 243 COMPILE_ASSERT(static_cast<int>(WebCursorInfo::webkit_name) == \
233 == static_cast<int>(np_name), \ 244 static_cast<int>(np_name), \
234 mismatching_enums) 245 mismatching_enums)
235 246
236 #define COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(webkit_name, pp_name) \ 247 #define COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(webkit_name, pp_name) \
237 COMPILE_ASSERT(static_cast<int>(webkit_name) \ 248 COMPILE_ASSERT(static_cast<int>(webkit_name) == static_cast<int>(pp_name), \
238 == static_cast<int>(pp_name), \ 249 mismatching_enums)
239 mismatching_enums)
240 250
241 // <embed>/<object> attributes. 251 // <embed>/<object> attributes.
242 const char kWidth[] = "width"; 252 const char kWidth[] = "width";
243 const char kHeight[] = "height"; 253 const char kHeight[] = "height";
244 const char kBorder[] = "border"; // According to w3c, deprecated. 254 const char kBorder[] = "border"; // According to w3c, deprecated.
245 const char kStyle[] = "style"; 255 const char kStyle[] = "style";
246 256
247 COMPILE_ASSERT_MATCHING_ENUM(TypePointer, PP_MOUSECURSOR_TYPE_POINTER); 257 COMPILE_ASSERT_MATCHING_ENUM(TypePointer, PP_MOUSECURSOR_TYPE_POINTER);
248 COMPILE_ASSERT_MATCHING_ENUM(TypeCross, PP_MOUSECURSOR_TYPE_CROSS); 258 COMPILE_ASSERT_MATCHING_ENUM(TypeCross, PP_MOUSECURSOR_TYPE_CROSS);
249 COMPILE_ASSERT_MATCHING_ENUM(TypeHand, PP_MOUSECURSOR_TYPE_HAND); 259 COMPILE_ASSERT_MATCHING_ENUM(TypeHand, PP_MOUSECURSOR_TYPE_HAND);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_MOUSECURSOR_TYPE_GRABBING); 316 COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_MOUSECURSOR_TYPE_GRABBING);
307 // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM; 317 // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM;
308 // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types. 318 // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types.
309 319
310 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(blink::WebPrintScalingOptionNone, 320 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(blink::WebPrintScalingOptionNone,
311 PP_PRINTSCALINGOPTION_NONE); 321 PP_PRINTSCALINGOPTION_NONE);
312 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM( 322 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(
313 blink::WebPrintScalingOptionFitToPrintableArea, 323 blink::WebPrintScalingOptionFitToPrintableArea,
314 PP_PRINTSCALINGOPTION_FIT_TO_PRINTABLE_AREA); 324 PP_PRINTSCALINGOPTION_FIT_TO_PRINTABLE_AREA);
315 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM( 325 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(
316 blink::WebPrintScalingOptionSourceSize, PP_PRINTSCALINGOPTION_SOURCE_SIZE); 326 blink::WebPrintScalingOptionSourceSize,
327 PP_PRINTSCALINGOPTION_SOURCE_SIZE);
317 328
318 // Sets |*security_origin| to be the WebKit security origin associated with the 329 // Sets |*security_origin| to be the WebKit security origin associated with the
319 // document containing the given plugin instance. On success, returns true. If 330 // document containing the given plugin instance. On success, returns true. If
320 // the instance is invalid, returns false and |*security_origin| will be 331 // the instance is invalid, returns false and |*security_origin| will be
321 // unchanged. 332 // unchanged.
322 bool SecurityOriginForInstance(PP_Instance instance_id, 333 bool SecurityOriginForInstance(PP_Instance instance_id,
323 blink::WebSecurityOrigin* security_origin) { 334 blink::WebSecurityOrigin* security_origin) {
324 PepperPluginInstanceImpl* instance = 335 PepperPluginInstanceImpl* instance =
325 HostGlobals::Get()->GetInstance(instance_id); 336 HostGlobals::Get()->GetInstance(instance_id);
326 if (!instance) 337 if (!instance)
327 return false; 338 return false;
328 339
329 WebElement plugin_element = instance->container()->element(); 340 WebElement plugin_element = instance->container()->element();
330 *security_origin = plugin_element.document().securityOrigin(); 341 *security_origin = plugin_element.document().securityOrigin();
331 return true; 342 return true;
332 } 343 }
333 344
334 // Convert the given vector to an array of C-strings. The strings in the 345 // Convert the given vector to an array of C-strings. The strings in the
335 // returned vector are only guaranteed valid so long as the vector of strings 346 // returned vector are only guaranteed valid so long as the vector of strings
336 // is not modified. 347 // is not modified.
337 scoped_ptr<const char*[]> StringVectorToArgArray( 348 scoped_ptr<const char* []> StringVectorToArgArray(
338 const std::vector<std::string>& vector) { 349 const std::vector<std::string>& vector) {
339 scoped_ptr<const char*[]> array(new const char*[vector.size()]); 350 scoped_ptr<const char * []> array(new const char* [vector.size()]);
340 for (size_t i = 0; i < vector.size(); ++i) 351 for (size_t i = 0; i < vector.size(); ++i)
341 array[i] = vector[i].c_str(); 352 array[i] = vector[i].c_str();
342 return array.Pass(); 353 return array.Pass();
343 } 354 }
344 355
345 // Returns true if this is a "system reserved" key which should not be sent to 356 // Returns true if this is a "system reserved" key which should not be sent to
346 // a plugin. Some poorly behaving plugins (like Flash) incorrectly report that 357 // a plugin. Some poorly behaving plugins (like Flash) incorrectly report that
347 // they handle all keys sent to them. This can prevent keystrokes from working 358 // they handle all keys sent to them. This can prevent keystrokes from working
348 // for things like screen brightness and volume control. 359 // for things like screen brightness and volume control.
349 bool IsReservedSystemInputEvent(const blink::WebInputEvent& event) { 360 bool IsReservedSystemInputEvent(const blink::WebInputEvent& event) {
(...skipping 21 matching lines...) Expand all
371 382
372 class PluginInstanceLockTarget : public MouseLockDispatcher::LockTarget { 383 class PluginInstanceLockTarget : public MouseLockDispatcher::LockTarget {
373 public: 384 public:
374 PluginInstanceLockTarget(PepperPluginInstanceImpl* plugin) 385 PluginInstanceLockTarget(PepperPluginInstanceImpl* plugin)
375 : plugin_(plugin) {} 386 : plugin_(plugin) {}
376 387
377 virtual void OnLockMouseACK(bool succeeded) OVERRIDE { 388 virtual void OnLockMouseACK(bool succeeded) OVERRIDE {
378 plugin_->OnLockMouseACK(succeeded); 389 plugin_->OnLockMouseACK(succeeded);
379 } 390 }
380 391
381 virtual void OnMouseLockLost() OVERRIDE { 392 virtual void OnMouseLockLost() OVERRIDE { plugin_->OnMouseLockLost(); }
382 plugin_->OnMouseLockLost();
383 }
384 393
385 virtual bool HandleMouseLockedInputEvent( 394 virtual bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event)
386 const blink::WebMouseEvent &event) OVERRIDE { 395 OVERRIDE {
387 plugin_->HandleMouseLockedInputEvent(event); 396 plugin_->HandleMouseLockedInputEvent(event);
388 return true; 397 return true;
389 } 398 }
390 399
391 private: 400 private:
392 PepperPluginInstanceImpl* plugin_; 401 PepperPluginInstanceImpl* plugin_;
393 }; 402 };
394 403
395
396 } // namespace 404 } // namespace
397 405
398 // static 406 // static
399 PepperPluginInstanceImpl* PepperPluginInstanceImpl::Create( 407 PepperPluginInstanceImpl* PepperPluginInstanceImpl::Create(
400 RenderFrameImpl* render_frame, 408 RenderFrameImpl* render_frame,
401 PluginModule* module, 409 PluginModule* module,
402 WebPluginContainer* container, 410 WebPluginContainer* container,
403 const GURL& plugin_url) { 411 const GURL& plugin_url) {
404 base::Callback<const void*(const char*)> get_plugin_interface_func = 412 base::Callback<const void*(const char*)> get_plugin_interface_func =
405 base::Bind(&PluginModule::GetPluginInterface, module); 413 base::Bind(&PluginModule::GetPluginInterface, module);
406 PPP_Instance_Combined* ppp_instance_combined = 414 PPP_Instance_Combined* ppp_instance_combined =
407 PPP_Instance_Combined::Create(get_plugin_interface_func); 415 PPP_Instance_Combined::Create(get_plugin_interface_func);
408 if (!ppp_instance_combined) 416 if (!ppp_instance_combined)
409 return NULL; 417 return NULL;
410 return new PepperPluginInstanceImpl(render_frame, module, 418 return new PepperPluginInstanceImpl(
411 ppp_instance_combined, container, 419 render_frame, module, ppp_instance_combined, container, plugin_url);
412 plugin_url);
413 } 420 }
414 421
415 PepperPluginInstanceImpl::ExternalDocumentLoader::ExternalDocumentLoader() 422 PepperPluginInstanceImpl::ExternalDocumentLoader::ExternalDocumentLoader()
416 : finished_loading_(false) { 423 : finished_loading_(false) {}
417 }
418 424
419 PepperPluginInstanceImpl::ExternalDocumentLoader::~ExternalDocumentLoader() { 425 PepperPluginInstanceImpl::ExternalDocumentLoader::~ExternalDocumentLoader() {}
420 }
421 426
422 void PepperPluginInstanceImpl::ExternalDocumentLoader::ReplayReceivedData( 427 void PepperPluginInstanceImpl::ExternalDocumentLoader::ReplayReceivedData(
423 WebURLLoaderClient* document_loader) { 428 WebURLLoaderClient* document_loader) {
424 for (std::list<std::string>::iterator it = data_.begin(); 429 for (std::list<std::string>::iterator it = data_.begin(); it != data_.end();
425 it != data_.end(); ++it) { 430 ++it) {
426 document_loader->didReceiveData(NULL, it->c_str(), it->length(), 431 document_loader->didReceiveData(
427 0 /* encoded_data_length */); 432 NULL, it->c_str(), it->length(), 0 /* encoded_data_length */);
428 } 433 }
429 if (finished_loading_) { 434 if (finished_loading_) {
430 document_loader->didFinishLoading(NULL, 0 /* finish_time */, 435 document_loader->didFinishLoading(
436 NULL,
437 0 /* finish_time */,
431 blink::WebURLLoaderClient::kUnknownEncodedDataLength); 438 blink::WebURLLoaderClient::kUnknownEncodedDataLength);
432 } 439 }
433 if (error_.get()) { 440 if (error_.get()) {
434 document_loader->didFail(NULL, *error_); 441 document_loader->didFail(NULL, *error_);
435 } 442 }
436 } 443 }
437 444
438 void PepperPluginInstanceImpl::ExternalDocumentLoader::didReceiveData( 445 void PepperPluginInstanceImpl::ExternalDocumentLoader::didReceiveData(
439 WebURLLoader* loader, 446 WebURLLoader* loader,
440 const char* data, 447 const char* data,
(...skipping 11 matching lines...) Expand all
452 } 459 }
453 460
454 void PepperPluginInstanceImpl::ExternalDocumentLoader::didFail( 461 void PepperPluginInstanceImpl::ExternalDocumentLoader::didFail(
455 WebURLLoader* loader, 462 WebURLLoader* loader,
456 const WebURLError& error) { 463 const WebURLError& error) {
457 DCHECK(!error_.get()); 464 DCHECK(!error_.get());
458 error_.reset(new WebURLError(error)); 465 error_.reset(new WebURLError(error));
459 } 466 }
460 467
461 PepperPluginInstanceImpl::GamepadImpl::GamepadImpl() 468 PepperPluginInstanceImpl::GamepadImpl::GamepadImpl()
462 : Resource(ppapi::Resource::Untracked()) { 469 : Resource(ppapi::Resource::Untracked()) {}
463 }
464 470
465 PepperPluginInstanceImpl::GamepadImpl::~GamepadImpl() { 471 PepperPluginInstanceImpl::GamepadImpl::~GamepadImpl() {}
466 }
467 472
468 PPB_Gamepad_API* PepperPluginInstanceImpl::GamepadImpl::AsPPB_Gamepad_API() { 473 PPB_Gamepad_API* PepperPluginInstanceImpl::GamepadImpl::AsPPB_Gamepad_API() {
469 return this; 474 return this;
470 } 475 }
471 476
472 void PepperPluginInstanceImpl::GamepadImpl::Sample( 477 void PepperPluginInstanceImpl::GamepadImpl::Sample(
473 PP_Instance instance, 478 PP_Instance instance,
474 PP_GamepadsSampleData* data) { 479 PP_GamepadsSampleData* data) {
475 blink::WebGamepads webkit_data; 480 blink::WebGamepads webkit_data;
476 RenderThreadImpl::current()->SampleGamepads(&webkit_data); 481 RenderThreadImpl::current()->SampleGamepads(&webkit_data);
477 ConvertWebKitGamepadData( 482 ConvertWebKitGamepadData(bit_cast<ppapi::WebKitGamepads>(webkit_data), data);
478 bit_cast<ppapi::WebKitGamepads>(webkit_data), data);
479 } 483 }
480 484
481 PepperPluginInstanceImpl::PepperPluginInstanceImpl( 485 PepperPluginInstanceImpl::PepperPluginInstanceImpl(
482 RenderFrameImpl* render_frame, 486 RenderFrameImpl* render_frame,
483 PluginModule* module, 487 PluginModule* module,
484 ppapi::PPP_Instance_Combined* instance_interface, 488 ppapi::PPP_Instance_Combined* instance_interface,
485 WebPluginContainer* container, 489 WebPluginContainer* container,
486 const GURL& plugin_url) 490 const GURL& plugin_url)
487 : RenderFrameObserver(render_frame), 491 : RenderFrameObserver(render_frame),
488 render_frame_(render_frame), 492 render_frame_(render_frame),
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 DCHECK(!fullscreen_container_); 594 DCHECK(!fullscreen_container_);
591 595
592 // Free all the plugin objects. This will automatically clear the back- 596 // Free all the plugin objects. This will automatically clear the back-
593 // pointer from the NPObject so WebKit can't call into the plugin any more. 597 // pointer from the NPObject so WebKit can't call into the plugin any more.
594 // 598 //
595 // Swap out the set so we can delete from it (the objects will try to 599 // Swap out the set so we can delete from it (the objects will try to
596 // unregister themselves inside the delete call). 600 // unregister themselves inside the delete call).
597 PluginObjectSet plugin_object_copy; 601 PluginObjectSet plugin_object_copy;
598 live_plugin_objects_.swap(plugin_object_copy); 602 live_plugin_objects_.swap(plugin_object_copy);
599 for (PluginObjectSet::iterator i = plugin_object_copy.begin(); 603 for (PluginObjectSet::iterator i = plugin_object_copy.begin();
600 i != plugin_object_copy.end(); ++i) 604 i != plugin_object_copy.end();
605 ++i)
601 delete *i; 606 delete *i;
602 607
603 if (TrackedCallback::IsPending(lock_mouse_callback_)) 608 if (TrackedCallback::IsPending(lock_mouse_callback_))
604 lock_mouse_callback_->Abort(); 609 lock_mouse_callback_->Abort();
605 610
606 if (!instance_deleted_callback_.is_null()) 611 if (!instance_deleted_callback_.is_null())
607 instance_deleted_callback_.Run(); 612 instance_deleted_callback_.Run();
608 613
609 if (!module_->IsProxied() && render_frame_) { 614 if (!module_->IsProxied() && render_frame_) {
610 PepperBrowserConnection* browser_connection = 615 PepperBrowserConnection* browser_connection =
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 fullscreen_container_ = NULL; 665 fullscreen_container_ = NULL;
661 } 666 }
662 667
663 // Force-unbind any Graphics. In the case of Graphics2D, if the plugin 668 // Force-unbind any Graphics. In the case of Graphics2D, if the plugin
664 // leaks the graphics 2D, it may actually get cleaned up after our 669 // leaks the graphics 2D, it may actually get cleaned up after our
665 // destruction, so we need its pointers to be up-to-date. 670 // destruction, so we need its pointers to be up-to-date.
666 BindGraphics(pp_instance(), 0); 671 BindGraphics(pp_instance(), 0);
667 container_ = NULL; 672 container_ = NULL;
668 } 673 }
669 674
670 bool PepperPluginInstanceImpl::is_deleted() const { 675 bool PepperPluginInstanceImpl::is_deleted() const { return is_deleted_; }
671 return is_deleted_;
672 }
673 676
674 void PepperPluginInstanceImpl::Paint(WebCanvas* canvas, 677 void PepperPluginInstanceImpl::Paint(WebCanvas* canvas,
675 const gfx::Rect& plugin_rect, 678 const gfx::Rect& plugin_rect,
676 const gfx::Rect& paint_rect) { 679 const gfx::Rect& paint_rect) {
677 TRACE_EVENT0("ppapi", "PluginInstance::Paint"); 680 TRACE_EVENT0("ppapi", "PluginInstance::Paint");
678 if (module()->is_crashed()) { 681 if (module()->is_crashed()) {
679 // Crashed plugin painting. 682 // Crashed plugin painting.
680 if (!sad_plugin_) // Lazily initialize bitmap. 683 if (!sad_plugin_) // Lazily initialize bitmap.
681 sad_plugin_ = GetContentClient()->renderer()->GetSadPluginBitmap(); 684 sad_plugin_ = GetContentClient()->renderer()->GetSadPluginBitmap();
682 if (sad_plugin_) 685 if (sad_plugin_)
683 PaintSadPlugin(canvas, plugin_rect, *sad_plugin_); 686 PaintSadPlugin(canvas, plugin_rect, *sad_plugin_);
684 return; 687 return;
685 } 688 }
686 689
687 if (bound_graphics_2d_platform_) 690 if (bound_graphics_2d_platform_)
688 bound_graphics_2d_platform_->Paint(canvas, plugin_rect, paint_rect); 691 bound_graphics_2d_platform_->Paint(canvas, plugin_rect, paint_rect);
689 } 692 }
690 693
691 void PepperPluginInstanceImpl::InvalidateRect(const gfx::Rect& rect) { 694 void PepperPluginInstanceImpl::InvalidateRect(const gfx::Rect& rect) {
692 if (fullscreen_container_) { 695 if (fullscreen_container_) {
693 if (rect.IsEmpty()) 696 if (rect.IsEmpty())
694 fullscreen_container_->Invalidate(); 697 fullscreen_container_->Invalidate();
695 else 698 else
696 fullscreen_container_->InvalidateRect(rect); 699 fullscreen_container_->InvalidateRect(rect);
697 } else { 700 } else {
698 if (!container_ || 701 if (!container_ || view_data_.rect.size.width == 0 ||
699 view_data_.rect.size.width == 0 || view_data_.rect.size.height == 0) 702 view_data_.rect.size.height == 0)
700 return; // Nothing to do. 703 return; // Nothing to do.
701 if (rect.IsEmpty()) 704 if (rect.IsEmpty())
702 container_->invalidate(); 705 container_->invalidate();
703 else 706 else
704 container_->invalidateRect(rect); 707 container_->invalidateRect(rect);
705 } 708 }
706 if (texture_layer_) { 709 if (texture_layer_) {
707 if (rect.IsEmpty()) { 710 if (rect.IsEmpty()) {
708 texture_layer_->SetNeedsDisplay(); 711 texture_layer_->SetNeedsDisplay();
709 } else { 712 } else {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 } 765 }
763 766
764 if (render_frame_) 767 if (render_frame_)
765 render_frame_->PluginCrashed(module_->path(), module_->GetPeerProcessId()); 768 render_frame_->PluginCrashed(module_->path(), module_->GetPeerProcessId());
766 UnSetAndDeleteLockTargetAdapter(); 769 UnSetAndDeleteLockTargetAdapter();
767 } 770 }
768 771
769 static void SetGPUHistogram(const ppapi::Preferences& prefs, 772 static void SetGPUHistogram(const ppapi::Preferences& prefs,
770 const std::vector<std::string>& arg_names, 773 const std::vector<std::string>& arg_names,
771 const std::vector<std::string>& arg_values) { 774 const std::vector<std::string>& arg_values) {
772 // Calculate a histogram to let us determine how likely people are to try to 775 // Calculate a histogram to let us determine how likely people are to try to
773 // run Stage3D content on machines that have it blacklisted. 776 // run Stage3D content on machines that have it blacklisted.
774 #if defined(OS_WIN) 777 #if defined(OS_WIN)
775 bool needs_gpu = false; 778 bool needs_gpu = false;
776 bool is_xp = base::win::GetVersion() <= base::win::VERSION_XP; 779 bool is_xp = base::win::GetVersion() <= base::win::VERSION_XP;
777 780
778 for (size_t i = 0; i < arg_names.size(); i++) { 781 for (size_t i = 0; i < arg_names.size(); i++) {
779 if (arg_names[i] == "wmode") { 782 if (arg_names[i] == "wmode") {
780 // In theory content other than Flash could have a "wmode" argument, 783 // In theory content other than Flash could have a "wmode" argument,
781 // but that's pretty unlikely. 784 // but that's pretty unlikely.
782 if (arg_values[i] == "direct" || arg_values[i] == "gpu") 785 if (arg_values[i] == "direct" || arg_values[i] == "gpu")
783 needs_gpu = true; 786 needs_gpu = true;
784 break; 787 break;
785 } 788 }
786 } 789 }
787 // 0 : No 3D content and GPU is blacklisted 790 // 0 : No 3D content and GPU is blacklisted
788 // 1 : No 3D content and GPU is not blacklisted 791 // 1 : No 3D content and GPU is not blacklisted
789 // 2 : 3D content but GPU is blacklisted 792 // 2 : 3D content but GPU is blacklisted
790 // 3 : 3D content and GPU is not blacklisted 793 // 3 : 3D content and GPU is not blacklisted
791 // 4 : No 3D content and GPU is blacklisted on XP 794 // 4 : No 3D content and GPU is blacklisted on XP
792 // 5 : No 3D content and GPU is not blacklisted on XP 795 // 5 : No 3D content and GPU is not blacklisted on XP
793 // 6 : 3D content but GPU is blacklisted on XP 796 // 6 : 3D content but GPU is blacklisted on XP
794 // 7 : 3D content and GPU is not blacklisted on XP 797 // 7 : 3D content and GPU is not blacklisted on XP
795 UMA_HISTOGRAM_ENUMERATION("Flash.UsesGPU", 798 UMA_HISTOGRAM_ENUMERATION(
796 is_xp * 4 + needs_gpu * 2 + prefs.is_webgl_supported, 8); 799 "Flash.UsesGPU", is_xp * 4 + needs_gpu * 2 + prefs.is_webgl_supported, 8);
797 #endif 800 #endif
798 } 801 }
799 802
800 bool PepperPluginInstanceImpl::Initialize( 803 bool PepperPluginInstanceImpl::Initialize(
801 const std::vector<std::string>& arg_names, 804 const std::vector<std::string>& arg_names,
802 const std::vector<std::string>& arg_values, 805 const std::vector<std::string>& arg_values,
803 bool full_frame) { 806 bool full_frame) {
804 if (!render_frame_) 807 if (!render_frame_)
805 return false; 808 return false;
806 message_channel_.reset(new MessageChannel(this)); 809 message_channel_.reset(new MessageChannel(this));
807 810
808 full_frame_ = full_frame; 811 full_frame_ = full_frame;
809 812
810 UpdateTouchEventRequest(); 813 UpdateTouchEventRequest();
811 container_->setWantsWheelEvents(IsAcceptingWheelEvents()); 814 container_->setWantsWheelEvents(IsAcceptingWheelEvents());
812 815
813 SetGPUHistogram(ppapi::Preferences( 816 SetGPUHistogram(
814 render_frame_->render_view()->webkit_preferences()), 817 ppapi::Preferences(render_frame_->render_view()->webkit_preferences()),
815 arg_names, arg_values); 818 arg_names,
819 arg_values);
816 820
817 argn_ = arg_names; 821 argn_ = arg_names;
818 argv_ = arg_values; 822 argv_ = arg_values;
819 scoped_ptr<const char*[]> argn_array(StringVectorToArgArray(argn_)); 823 scoped_ptr<const char * []> argn_array(StringVectorToArgArray(argn_));
820 scoped_ptr<const char*[]> argv_array(StringVectorToArgArray(argv_)); 824 scoped_ptr<const char * []> argv_array(StringVectorToArgArray(argv_));
821 bool success = PP_ToBool(instance_interface_->DidCreate(pp_instance(), 825 bool success = PP_ToBool(instance_interface_->DidCreate(
822 argn_.size(), 826 pp_instance(), argn_.size(), argn_array.get(), argv_array.get()));
823 argn_array.get(),
824 argv_array.get()));
825 if (success) 827 if (success)
826 message_channel_->StopQueueingJavaScriptMessages(); 828 message_channel_->StopQueueingJavaScriptMessages();
827 return success; 829 return success;
828 } 830 }
829 831
830 bool PepperPluginInstanceImpl::HandleDocumentLoad( 832 bool PepperPluginInstanceImpl::HandleDocumentLoad(
831 const blink::WebURLResponse& response) { 833 const blink::WebURLResponse& response) {
832 DCHECK(!document_loader_); 834 DCHECK(!document_loader_);
833 if (external_document_load_) { 835 if (external_document_load_) {
834 // The external proxy isn't available, so save the response and record 836 // The external proxy isn't available, so save the response and record
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 response, 878 response,
877 pending_host_id)); 879 pending_host_id));
878 880
879 // If the load was not abandoned, document_loader_ will now be set. It's 881 // If the load was not abandoned, document_loader_ will now be set. It's
880 // possible that the load was canceled by now and document_loader_ was 882 // possible that the load was canceled by now and document_loader_ was
881 // already nulled out. 883 // already nulled out.
882 return true; 884 return true;
883 } 885 }
884 886
885 bool PepperPluginInstanceImpl::SendCompositionEventToPlugin( 887 bool PepperPluginInstanceImpl::SendCompositionEventToPlugin(
886 PP_InputEvent_Type type, const base::string16& text) { 888 PP_InputEvent_Type type,
889 const base::string16& text) {
887 std::vector<blink::WebCompositionUnderline> empty; 890 std::vector<blink::WebCompositionUnderline> empty;
888 return SendCompositionEventWithUnderlineInformationToPlugin( 891 return SendCompositionEventWithUnderlineInformationToPlugin(
889 type, text, empty, static_cast<int>(text.size()), 892 type,
893 text,
894 empty,
895 static_cast<int>(text.size()),
890 static_cast<int>(text.size())); 896 static_cast<int>(text.size()));
891 } 897 }
892 898
893 bool PepperPluginInstanceImpl:: 899 bool
894 SendCompositionEventWithUnderlineInformationToPlugin( 900 PepperPluginInstanceImpl::SendCompositionEventWithUnderlineInformationToPlugin(
895 PP_InputEvent_Type type, 901 PP_InputEvent_Type type,
896 const base::string16& text, 902 const base::string16& text,
897 const std::vector<blink::WebCompositionUnderline>& underlines, 903 const std::vector<blink::WebCompositionUnderline>& underlines,
898 int selection_start, 904 int selection_start,
899 int selection_end) { 905 int selection_end) {
900 // Keep a reference on the stack. See NOTE above. 906 // Keep a reference on the stack. See NOTE above.
901 scoped_refptr<PepperPluginInstanceImpl> ref(this); 907 scoped_refptr<PepperPluginInstanceImpl> ref(this);
902 908
903 if (!LoadInputEventInterface()) 909 if (!LoadInputEventInterface())
904 return false; 910 return false;
905 911
906 PP_InputEvent_Class event_class = PP_INPUTEVENT_CLASS_IME; 912 PP_InputEvent_Class event_class = PP_INPUTEVENT_CLASS_IME;
907 if (!(filtered_input_event_mask_ & event_class) && 913 if (!(filtered_input_event_mask_ & event_class) &&
908 !(input_event_mask_ & event_class)) 914 !(input_event_mask_ & event_class))
909 return false; 915 return false;
910 916
911 ppapi::InputEventData event; 917 ppapi::InputEventData event;
912 event.event_type = type; 918 event.event_type = type;
913 event.event_time_stamp = ppapi::TimeTicksToPPTimeTicks( 919 event.event_time_stamp =
914 base::TimeTicks::Now()); 920 ppapi::TimeTicksToPPTimeTicks(base::TimeTicks::Now());
915 921
916 // Convert UTF16 text to UTF8 with offset conversion. 922 // Convert UTF16 text to UTF8 with offset conversion.
917 std::vector<size_t> utf16_offsets; 923 std::vector<size_t> utf16_offsets;
918 utf16_offsets.push_back(selection_start); 924 utf16_offsets.push_back(selection_start);
919 utf16_offsets.push_back(selection_end); 925 utf16_offsets.push_back(selection_end);
920 for (size_t i = 0; i < underlines.size(); ++i) { 926 for (size_t i = 0; i < underlines.size(); ++i) {
921 utf16_offsets.push_back(underlines[i].startOffset); 927 utf16_offsets.push_back(underlines[i].startOffset);
922 utf16_offsets.push_back(underlines[i].endOffset); 928 utf16_offsets.push_back(underlines[i].endOffset);
923 } 929 }
924 std::vector<size_t> utf8_offsets(utf16_offsets); 930 std::vector<size_t> utf8_offsets(utf16_offsets);
925 event.character_text = base::UTF16ToUTF8AndAdjustOffsets(text, &utf8_offsets); 931 event.character_text = base::UTF16ToUTF8AndAdjustOffsets(text, &utf8_offsets);
926 932
927 // Set the converted selection range. 933 // Set the converted selection range.
928 event.composition_selection_start = (utf8_offsets[0] == std::string::npos ? 934 event.composition_selection_start =
929 event.character_text.size() : utf8_offsets[0]); 935 (utf8_offsets[0] == std::string::npos ? event.character_text.size()
930 event.composition_selection_end = (utf8_offsets[1] == std::string::npos ? 936 : utf8_offsets[0]);
931 event.character_text.size() : utf8_offsets[1]); 937 event.composition_selection_end =
938 (utf8_offsets[1] == std::string::npos ? event.character_text.size()
939 : utf8_offsets[1]);
932 940
933 // Set the converted segmentation points. 941 // Set the converted segmentation points.
934 // Be sure to add 0 and size(), and remove duplication or errors. 942 // Be sure to add 0 and size(), and remove duplication or errors.
935 std::set<size_t> offset_set(utf8_offsets.begin()+2, utf8_offsets.end()); 943 std::set<size_t> offset_set(utf8_offsets.begin() + 2, utf8_offsets.end());
936 offset_set.insert(0); 944 offset_set.insert(0);
937 offset_set.insert(event.character_text.size()); 945 offset_set.insert(event.character_text.size());
938 offset_set.erase(std::string::npos); 946 offset_set.erase(std::string::npos);
939 event.composition_segment_offsets.assign(offset_set.begin(), 947 event.composition_segment_offsets.assign(offset_set.begin(),
940 offset_set.end()); 948 offset_set.end());
941 949
942 // Set the composition target. 950 // Set the composition target.
943 for (size_t i = 0; i < underlines.size(); ++i) { 951 for (size_t i = 0; i < underlines.size(); ++i) {
944 if (underlines[i].thick) { 952 if (underlines[i].thick) {
945 std::vector<uint32_t>::iterator it = 953 std::vector<uint32_t>::iterator it =
946 std::find(event.composition_segment_offsets.begin(), 954 std::find(event.composition_segment_offsets.begin(),
947 event.composition_segment_offsets.end(), 955 event.composition_segment_offsets.end(),
948 utf8_offsets[2*i+2]); 956 utf8_offsets[2 * i + 2]);
949 if (it != event.composition_segment_offsets.end()) { 957 if (it != event.composition_segment_offsets.end()) {
950 event.composition_target_segment = 958 event.composition_target_segment =
951 it - event.composition_segment_offsets.begin(); 959 it - event.composition_segment_offsets.begin();
952 break; 960 break;
953 } 961 }
954 } 962 }
955 } 963 }
956 964
957 // Send the event. 965 // Send the event.
958 bool handled = false; 966 bool handled = false;
(...skipping 22 matching lines...) Expand all
981 text); 989 text);
982 } 990 }
983 991
984 bool PepperPluginInstanceImpl::HandleCompositionUpdate( 992 bool PepperPluginInstanceImpl::HandleCompositionUpdate(
985 const base::string16& text, 993 const base::string16& text,
986 const std::vector<blink::WebCompositionUnderline>& underlines, 994 const std::vector<blink::WebCompositionUnderline>& underlines,
987 int selection_start, 995 int selection_start,
988 int selection_end) { 996 int selection_end) {
989 return SendCompositionEventWithUnderlineInformationToPlugin( 997 return SendCompositionEventWithUnderlineInformationToPlugin(
990 PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE, 998 PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE,
991 text, underlines, selection_start, selection_end); 999 text,
1000 underlines,
1001 selection_start,
1002 selection_end);
992 } 1003 }
993 1004
994 bool PepperPluginInstanceImpl::HandleCompositionEnd( 1005 bool PepperPluginInstanceImpl::HandleCompositionEnd(
995 const base::string16& text) { 1006 const base::string16& text) {
996 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_COMPOSITION_END, 1007 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_COMPOSITION_END,
997 text); 1008 text);
998 } 1009 }
999 1010
1000 bool PepperPluginInstanceImpl::HandleTextInput(const base::string16& text) { 1011 bool PepperPluginInstanceImpl::HandleTextInput(const base::string16& text) {
1001 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_TEXT, 1012 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_TEXT, text);
1002 text);
1003 } 1013 }
1004 1014
1005 void PepperPluginInstanceImpl::GetSurroundingText(base::string16* text, 1015 void PepperPluginInstanceImpl::GetSurroundingText(base::string16* text,
1006 gfx::Range* range) const { 1016 gfx::Range* range) const {
1007 std::vector<size_t> offsets; 1017 std::vector<size_t> offsets;
1008 offsets.push_back(selection_anchor_); 1018 offsets.push_back(selection_anchor_);
1009 offsets.push_back(selection_caret_); 1019 offsets.push_back(selection_caret_);
1010 *text = base::UTF8ToUTF16AndAdjustOffsets(surrounding_text_, &offsets); 1020 *text = base::UTF8ToUTF16AndAdjustOffsets(surrounding_text_, &offsets);
1011 range->set_start(offsets[0] == base::string16::npos ? text->size() 1021 range->set_start(offsets[0] == base::string16::npos ? text->size()
1012 : offsets[0]); 1022 : offsets[0]);
1013 range->set_end(offsets[1] == base::string16::npos ? text->size() 1023 range->set_end(offsets[1] == base::string16::npos ? text->size()
1014 : offsets[1]); 1024 : offsets[1]);
1015 } 1025 }
1016 1026
1017 bool PepperPluginInstanceImpl::IsPluginAcceptingCompositionEvents() const { 1027 bool PepperPluginInstanceImpl::IsPluginAcceptingCompositionEvents() const {
1018 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_IME) || 1028 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_IME) ||
1019 (input_event_mask_ & PP_INPUTEVENT_CLASS_IME); 1029 (input_event_mask_ & PP_INPUTEVENT_CLASS_IME);
1020 } 1030 }
1021 1031
1022 gfx::Rect PepperPluginInstanceImpl::GetCaretBounds() const { 1032 gfx::Rect PepperPluginInstanceImpl::GetCaretBounds() const {
1023 if (!text_input_caret_set_) { 1033 if (!text_input_caret_set_) {
1024 // If it is never set by the plugin, use the bottom left corner. 1034 // If it is never set by the plugin, use the bottom left corner.
1025 return gfx::Rect(view_data_.rect.point.x, 1035 return gfx::Rect(view_data_.rect.point.x,
1026 view_data_.rect.point.y + view_data_.rect.size.height, 1036 view_data_.rect.point.y + view_data_.rect.size.height,
1027 0, 0); 1037 0,
1038 0);
1028 } 1039 }
1029 1040
1030 // TODO(kinaba) Take CSS transformation into accont. 1041 // TODO(kinaba) Take CSS transformation into accont.
1031 // TODO(kinaba) Take bounding_box into account. On some platforms, an 1042 // TODO(kinaba) Take bounding_box into account. On some platforms, an
1032 // "exclude rectangle" where candidate window must avoid the region can be 1043 // "exclude rectangle" where candidate window must avoid the region can be
1033 // passed to IME. Currently, we pass only the caret rectangle because 1044 // passed to IME. Currently, we pass only the caret rectangle because
1034 // it is the only information supported uniformly in Chromium. 1045 // it is the only information supported uniformly in Chromium.
1035 gfx::Rect caret(text_input_caret_); 1046 gfx::Rect caret(text_input_caret_);
1036 caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y); 1047 caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y);
1037 return caret; 1048 return caret;
(...skipping 23 matching lines...) Expand all
1061 1072
1062 bool rv = false; 1073 bool rv = false;
1063 if (LoadInputEventInterface()) { 1074 if (LoadInputEventInterface()) {
1064 PP_InputEvent_Class event_class = ClassifyInputEvent(event.type); 1075 PP_InputEvent_Class event_class = ClassifyInputEvent(event.type);
1065 if (!event_class) 1076 if (!event_class)
1066 return false; 1077 return false;
1067 1078
1068 if ((filtered_input_event_mask_ & event_class) || 1079 if ((filtered_input_event_mask_ & event_class) ||
1069 (input_event_mask_ & event_class)) { 1080 (input_event_mask_ & event_class)) {
1070 // Actually send the event. 1081 // Actually send the event.
1071 std::vector< ppapi::InputEventData > events; 1082 std::vector<ppapi::InputEventData> events;
1072 CreateInputEventData(event, &events); 1083 CreateInputEventData(event, &events);
1073 1084
1074 // Allow the user gesture to be pending after the plugin handles the 1085 // Allow the user gesture to be pending after the plugin handles the
1075 // event. This allows out-of-process plugins to respond to the user 1086 // event. This allows out-of-process plugins to respond to the user
1076 // gesture after processing has finished here. 1087 // gesture after processing has finished here.
1077 if (WebUserGestureIndicator::isProcessingUserGesture()) { 1088 if (WebUserGestureIndicator::isProcessingUserGesture()) {
1078 pending_user_gesture_ = 1089 pending_user_gesture_ =
1079 ppapi::EventTimeToPPTimeTicks(event.timeStampSeconds); 1090 ppapi::EventTimeToPPTimeTicks(event.timeStampSeconds);
1080 pending_user_gesture_token_ = 1091 pending_user_gesture_token_ =
1081 WebUserGestureIndicator::currentUserGestureToken(); 1092 WebUserGestureIndicator::currentUserGestureToken();
1082 pending_user_gesture_token_.setOutOfProcess(); 1093 pending_user_gesture_token_.setOutOfProcess();
1083 } 1094 }
1084 1095
1085 // Each input event may generate more than one PP_InputEvent. 1096 // Each input event may generate more than one PP_InputEvent.
1086 for (size_t i = 0; i < events.size(); i++) { 1097 for (size_t i = 0; i < events.size(); i++) {
1087 if (filtered_input_event_mask_ & event_class) 1098 if (filtered_input_event_mask_ & event_class)
1088 events[i].is_filtered = true; 1099 events[i].is_filtered = true;
1089 else 1100 else
1090 rv = true; // Unfiltered events are assumed to be handled. 1101 rv = true; // Unfiltered events are assumed to be handled.
1091 scoped_refptr<PPB_InputEvent_Shared> event_resource( 1102 scoped_refptr<PPB_InputEvent_Shared> event_resource(
1092 new PPB_InputEvent_Shared(ppapi::OBJECT_IS_IMPL, 1103 new PPB_InputEvent_Shared(
1093 pp_instance(), events[i])); 1104 ppapi::OBJECT_IS_IMPL, pp_instance(), events[i]));
1094 1105
1095 rv |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( 1106 rv |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent(
1096 pp_instance(), event_resource->pp_resource())); 1107 pp_instance(), event_resource->pp_resource()));
1097 } 1108 }
1098 } 1109 }
1099 } 1110 }
1100 1111
1101 if (cursor_) 1112 if (cursor_)
1102 *cursor_info = *cursor_; 1113 *cursor_info = *cursor_;
1103 return rv; 1114 return rv;
(...skipping 29 matching lines...) Expand all
1133 // in the "everything is clipped" case. 1144 // in the "everything is clipped" case.
1134 gfx::Rect new_clip; 1145 gfx::Rect new_clip;
1135 if (!clip.IsEmpty()) 1146 if (!clip.IsEmpty())
1136 new_clip = clip; 1147 new_clip = clip;
1137 1148
1138 cut_outs_rects_ = cut_outs_rects; 1149 cut_outs_rects_ = cut_outs_rects;
1139 1150
1140 view_data_.rect = PP_FromGfxRect(position); 1151 view_data_.rect = PP_FromGfxRect(position);
1141 view_data_.clip_rect = PP_FromGfxRect(clip); 1152 view_data_.clip_rect = PP_FromGfxRect(clip);
1142 view_data_.device_scale = container_->deviceScaleFactor(); 1153 view_data_.device_scale = container_->deviceScaleFactor();
1143 view_data_.css_scale = container_->pageZoomFactor() * 1154 view_data_.css_scale =
1144 container_->pageScaleFactor(); 1155 container_->pageZoomFactor() * container_->pageScaleFactor();
1145 1156
1146 if (desired_fullscreen_state_ || view_data_.is_fullscreen) { 1157 if (desired_fullscreen_state_ || view_data_.is_fullscreen) {
1147 WebElement element = container_->element(); 1158 WebElement element = container_->element();
1148 WebDocument document = element.document(); 1159 WebDocument document = element.document();
1149 bool is_fullscreen_element = (element == document.fullScreenElement()); 1160 bool is_fullscreen_element = (element == document.fullScreenElement());
1150 if (!view_data_.is_fullscreen && desired_fullscreen_state_ && 1161 if (!view_data_.is_fullscreen && desired_fullscreen_state_ &&
1151 render_frame()->GetRenderWidget()->is_fullscreen() && 1162 render_frame()->GetRenderWidget()->is_fullscreen() &&
1152 is_fullscreen_element) { 1163 is_fullscreen_element) {
1153 // Entered fullscreen. Only possible via SetFullscreen(). 1164 // Entered fullscreen. Only possible via SetFullscreen().
1154 view_data_.is_fullscreen = true; 1165 view_data_.is_fullscreen = true;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 1312
1302 bool PepperPluginInstanceImpl::StartFind(const base::string16& search_text, 1313 bool PepperPluginInstanceImpl::StartFind(const base::string16& search_text,
1303 bool case_sensitive, 1314 bool case_sensitive,
1304 int identifier) { 1315 int identifier) {
1305 // Keep a reference on the stack. See NOTE above. 1316 // Keep a reference on the stack. See NOTE above.
1306 scoped_refptr<PepperPluginInstanceImpl> ref(this); 1317 scoped_refptr<PepperPluginInstanceImpl> ref(this);
1307 if (!LoadFindInterface()) 1318 if (!LoadFindInterface())
1308 return false; 1319 return false;
1309 find_identifier_ = identifier; 1320 find_identifier_ = identifier;
1310 return PP_ToBool( 1321 return PP_ToBool(
1311 plugin_find_interface_->StartFind( 1322 plugin_find_interface_->StartFind(pp_instance(),
1312 pp_instance(), 1323 base::UTF16ToUTF8(search_text).c_str(),
1313 base::UTF16ToUTF8(search_text).c_str(), 1324 PP_FromBool(case_sensitive)));
1314 PP_FromBool(case_sensitive)));
1315 } 1325 }
1316 1326
1317 void PepperPluginInstanceImpl::SelectFindResult(bool forward) { 1327 void PepperPluginInstanceImpl::SelectFindResult(bool forward) {
1318 // Keep a reference on the stack. See NOTE above. 1328 // Keep a reference on the stack. See NOTE above.
1319 scoped_refptr<PepperPluginInstanceImpl> ref(this); 1329 scoped_refptr<PepperPluginInstanceImpl> ref(this);
1320 if (LoadFindInterface()) 1330 if (LoadFindInterface())
1321 plugin_find_interface_->SelectFindResult(pp_instance(), 1331 plugin_find_interface_->SelectFindResult(pp_instance(),
1322 PP_FromBool(forward)); 1332 PP_FromBool(forward));
1323 } 1333 }
1324 1334
1325 void PepperPluginInstanceImpl::StopFind() { 1335 void PepperPluginInstanceImpl::StopFind() {
1326 // Keep a reference on the stack. See NOTE above. 1336 // Keep a reference on the stack. See NOTE above.
1327 scoped_refptr<PepperPluginInstanceImpl> ref(this); 1337 scoped_refptr<PepperPluginInstanceImpl> ref(this);
1328 if (!LoadFindInterface()) 1338 if (!LoadFindInterface())
1329 return; 1339 return;
1330 find_identifier_ = -1; 1340 find_identifier_ = -1;
1331 plugin_find_interface_->StopFind(pp_instance()); 1341 plugin_find_interface_->StopFind(pp_instance());
1332 } 1342 }
1333 1343
1334 bool PepperPluginInstanceImpl::LoadFindInterface() { 1344 bool PepperPluginInstanceImpl::LoadFindInterface() {
1335 if (!module_->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) 1345 if (!module_->permissions().HasPermission(ppapi::PERMISSION_PRIVATE))
1336 return false; 1346 return false;
1337 if (!plugin_find_interface_) { 1347 if (!plugin_find_interface_) {
1338 plugin_find_interface_ = 1348 plugin_find_interface_ = static_cast<const PPP_Find_Private*>(
1339 static_cast<const PPP_Find_Private*>(module_->GetPluginInterface( 1349 module_->GetPluginInterface(PPP_FIND_PRIVATE_INTERFACE));
1340 PPP_FIND_PRIVATE_INTERFACE));
1341 } 1350 }
1342 1351
1343 return !!plugin_find_interface_; 1352 return !!plugin_find_interface_;
1344 } 1353 }
1345 1354
1346 bool PepperPluginInstanceImpl::LoadInputEventInterface() { 1355 bool PepperPluginInstanceImpl::LoadInputEventInterface() {
1347 if (!checked_for_plugin_input_event_interface_) { 1356 if (!checked_for_plugin_input_event_interface_) {
1348 checked_for_plugin_input_event_interface_ = true; 1357 checked_for_plugin_input_event_interface_ = true;
1349 plugin_input_event_interface_ = 1358 plugin_input_event_interface_ = static_cast<const PPP_InputEvent*>(
1350 static_cast<const PPP_InputEvent*>(module_->GetPluginInterface( 1359 module_->GetPluginInterface(PPP_INPUT_EVENT_INTERFACE));
1351 PPP_INPUT_EVENT_INTERFACE));
1352 } 1360 }
1353 return !!plugin_input_event_interface_; 1361 return !!plugin_input_event_interface_;
1354 } 1362 }
1355 1363
1356 bool PepperPluginInstanceImpl::LoadMessagingInterface() { 1364 bool PepperPluginInstanceImpl::LoadMessagingInterface() {
1357 if (!checked_for_plugin_messaging_interface_) { 1365 if (!checked_for_plugin_messaging_interface_) {
1358 checked_for_plugin_messaging_interface_ = true; 1366 checked_for_plugin_messaging_interface_ = true;
1359 plugin_messaging_interface_ = 1367 plugin_messaging_interface_ = static_cast<const PPP_Messaging*>(
1360 static_cast<const PPP_Messaging*>(module_->GetPluginInterface( 1368 module_->GetPluginInterface(PPP_MESSAGING_INTERFACE));
1361 PPP_MESSAGING_INTERFACE));
1362 } 1369 }
1363 return !!plugin_messaging_interface_; 1370 return !!plugin_messaging_interface_;
1364 } 1371 }
1365 1372
1366 bool PepperPluginInstanceImpl::LoadMouseLockInterface() { 1373 bool PepperPluginInstanceImpl::LoadMouseLockInterface() {
1367 if (!plugin_mouse_lock_interface_) { 1374 if (!plugin_mouse_lock_interface_) {
1368 plugin_mouse_lock_interface_ = 1375 plugin_mouse_lock_interface_ = static_cast<const PPP_MouseLock*>(
1369 static_cast<const PPP_MouseLock*>(module_->GetPluginInterface( 1376 module_->GetPluginInterface(PPP_MOUSELOCK_INTERFACE));
1370 PPP_MOUSELOCK_INTERFACE));
1371 } 1377 }
1372 1378
1373 return !!plugin_mouse_lock_interface_; 1379 return !!plugin_mouse_lock_interface_;
1374 } 1380 }
1375 1381
1376 bool PepperPluginInstanceImpl::LoadPdfInterface() { 1382 bool PepperPluginInstanceImpl::LoadPdfInterface() {
1377 if (!checked_for_plugin_pdf_interface_) { 1383 if (!checked_for_plugin_pdf_interface_) {
1378 checked_for_plugin_pdf_interface_ = true; 1384 checked_for_plugin_pdf_interface_ = true;
1379 plugin_pdf_interface_ = 1385 plugin_pdf_interface_ = static_cast<const PPP_Pdf_1*>(
1380 static_cast<const PPP_Pdf_1*>(module_->GetPluginInterface( 1386 module_->GetPluginInterface(PPP_PDF_INTERFACE_1));
1381 PPP_PDF_INTERFACE_1));
1382 } 1387 }
1383 1388
1384 return !!plugin_pdf_interface_; 1389 return !!plugin_pdf_interface_;
1385 } 1390 }
1386 1391
1387 bool PepperPluginInstanceImpl::LoadPrintInterface() { 1392 bool PepperPluginInstanceImpl::LoadPrintInterface() {
1388 // Only check for the interface if the plugin has dev permission. 1393 // Only check for the interface if the plugin has dev permission.
1389 if (!module_->permissions().HasPermission(ppapi::PERMISSION_DEV)) 1394 if (!module_->permissions().HasPermission(ppapi::PERMISSION_DEV))
1390 return false; 1395 return false;
1391 if (!plugin_print_interface_) { 1396 if (!plugin_print_interface_) {
1392 plugin_print_interface_ = static_cast<const PPP_Printing_Dev*>( 1397 plugin_print_interface_ = static_cast<const PPP_Printing_Dev*>(
1393 module_->GetPluginInterface(PPP_PRINTING_DEV_INTERFACE)); 1398 module_->GetPluginInterface(PPP_PRINTING_DEV_INTERFACE));
1394 } 1399 }
1395 return !!plugin_print_interface_; 1400 return !!plugin_print_interface_;
1396 } 1401 }
1397 1402
1398 bool PepperPluginInstanceImpl::LoadPrivateInterface() { 1403 bool PepperPluginInstanceImpl::LoadPrivateInterface() {
1399 // If this is a NaCl app, we want to talk to the trusted NaCl plugin to 1404 // If this is a NaCl app, we want to talk to the trusted NaCl plugin to
1400 // call GetInstanceObject. This is necessary to ensure that the properties 1405 // call GetInstanceObject. This is necessary to ensure that the properties
1401 // the trusted plugin exposes (readyState and lastError) work properly. Note 1406 // the trusted plugin exposes (readyState and lastError) work properly. Note
1402 // that untrusted NaCl apps are not allowed to provide PPP_InstancePrivate, 1407 // that untrusted NaCl apps are not allowed to provide PPP_InstancePrivate,
1403 // so it's correct to never look up PPP_InstancePrivate for them. 1408 // so it's correct to never look up PPP_InstancePrivate for them.
1404 // 1409 //
1405 // If this is *not* a NaCl plugin, original_module_ will never be set; we talk 1410 // If this is *not* a NaCl plugin, original_module_ will never be set; we talk
1406 // to the "real" module. 1411 // to the "real" module.
1407 scoped_refptr<PluginModule> module = original_module_ ? original_module_ : 1412 scoped_refptr<PluginModule> module =
1408 module_; 1413 original_module_ ? original_module_ : module_;
1409 // Only check for the interface if the plugin has private permission. 1414 // Only check for the interface if the plugin has private permission.
1410 if (!module->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) 1415 if (!module->permissions().HasPermission(ppapi::PERMISSION_PRIVATE))
1411 return false; 1416 return false;
1412 if (!plugin_private_interface_) { 1417 if (!plugin_private_interface_) {
1413 plugin_private_interface_ = static_cast<const PPP_Instance_Private*>( 1418 plugin_private_interface_ = static_cast<const PPP_Instance_Private*>(
1414 module->GetPluginInterface(PPP_INSTANCE_PRIVATE_INTERFACE)); 1419 module->GetPluginInterface(PPP_INSTANCE_PRIVATE_INTERFACE));
1415 } 1420 }
1416 1421
1417 return !!plugin_private_interface_; 1422 return !!plugin_private_interface_;
1418 } 1423 }
1419 1424
1420 bool PepperPluginInstanceImpl::LoadSelectionInterface() { 1425 bool PepperPluginInstanceImpl::LoadSelectionInterface() {
1421 if (!plugin_selection_interface_) { 1426 if (!plugin_selection_interface_) {
1422 plugin_selection_interface_ = 1427 plugin_selection_interface_ = static_cast<const PPP_Selection_Dev*>(
1423 static_cast<const PPP_Selection_Dev*>(module_->GetPluginInterface( 1428 module_->GetPluginInterface(PPP_SELECTION_DEV_INTERFACE));
1424 PPP_SELECTION_DEV_INTERFACE));
1425 } 1429 }
1426 return !!plugin_selection_interface_; 1430 return !!plugin_selection_interface_;
1427 } 1431 }
1428 1432
1429 bool PepperPluginInstanceImpl::LoadTextInputInterface() { 1433 bool PepperPluginInstanceImpl::LoadTextInputInterface() {
1430 if (!plugin_textinput_interface_) { 1434 if (!plugin_textinput_interface_) {
1431 plugin_textinput_interface_ = 1435 plugin_textinput_interface_ = static_cast<const PPP_TextInput_Dev*>(
1432 static_cast<const PPP_TextInput_Dev*>(module_->GetPluginInterface( 1436 module_->GetPluginInterface(PPP_TEXTINPUT_DEV_INTERFACE));
1433 PPP_TEXTINPUT_DEV_INTERFACE));
1434 } 1437 }
1435 1438
1436 return !!plugin_textinput_interface_; 1439 return !!plugin_textinput_interface_;
1437 } 1440 }
1438 1441
1439 bool PepperPluginInstanceImpl::LoadZoomInterface() { 1442 bool PepperPluginInstanceImpl::LoadZoomInterface() {
1440 if (!plugin_zoom_interface_) { 1443 if (!plugin_zoom_interface_) {
1441 plugin_zoom_interface_ = 1444 plugin_zoom_interface_ = static_cast<const PPP_Zoom_Dev*>(
1442 static_cast<const PPP_Zoom_Dev*>(module_->GetPluginInterface( 1445 module_->GetPluginInterface(PPP_ZOOM_DEV_INTERFACE));
1443 PPP_ZOOM_DEV_INTERFACE));
1444 } 1446 }
1445 1447
1446 return !!plugin_zoom_interface_; 1448 return !!plugin_zoom_interface_;
1447 } 1449 }
1448 1450
1449 void PepperPluginInstanceImpl::UpdateLayerTransform() { 1451 void PepperPluginInstanceImpl::UpdateLayerTransform() {
1450 if (!bound_graphics_2d_platform_ || !texture_layer_) { 1452 if (!bound_graphics_2d_platform_ || !texture_layer_) {
1451 // Currently the transform is only applied for Graphics2D. 1453 // Currently the transform is only applied for Graphics2D.
1452 return; 1454 return;
1453 } 1455 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 1493
1492 // instance_interface_ may have been cleared in Delete() if the 1494 // instance_interface_ may have been cleared in Delete() if the
1493 // PepperWebPluginImpl is destroyed. 1495 // PepperWebPluginImpl is destroyed.
1494 if (instance_interface_) 1496 if (instance_interface_)
1495 instance_interface_->DidChangeFocus(pp_instance(), PP_FromBool(has_focus)); 1497 instance_interface_->DidChangeFocus(pp_instance(), PP_FromBool(has_focus));
1496 } 1498 }
1497 1499
1498 void PepperPluginInstanceImpl::UpdateTouchEventRequest() { 1500 void PepperPluginInstanceImpl::UpdateTouchEventRequest() {
1499 bool raw_touch = (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH) || 1501 bool raw_touch = (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH) ||
1500 (input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH); 1502 (input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH);
1501 container_->requestTouchEventType(raw_touch ? 1503 container_->requestTouchEventType(
1502 blink::WebPluginContainer::TouchEventRequestTypeRaw : 1504 raw_touch
1503 blink::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse); 1505 ? blink::WebPluginContainer::TouchEventRequestTypeRaw
1506 : blink::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse);
1504 } 1507 }
1505 1508
1506 bool PepperPluginInstanceImpl::IsAcceptingWheelEvents() const { 1509 bool PepperPluginInstanceImpl::IsAcceptingWheelEvents() const {
1507 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL) || 1510 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL) ||
1508 (input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL); 1511 (input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL);
1509 } 1512 }
1510 1513
1511 void PepperPluginInstanceImpl::ScheduleAsyncDidChangeView() { 1514 void PepperPluginInstanceImpl::ScheduleAsyncDidChangeView() {
1512 if (view_change_weak_ptr_factory_.HasWeakPtrs()) 1515 if (view_change_weak_ptr_factory_.HasWeakPtrs())
1513 return; // Already scheduled. 1516 return; // Already scheduled.
1514 base::MessageLoop::current()->PostTask( 1517 base::MessageLoop::current()->PostTask(
1515 FROM_HERE, 1518 FROM_HERE,
1516 base::Bind(&PepperPluginInstanceImpl::SendAsyncDidChangeView, 1519 base::Bind(&PepperPluginInstanceImpl::SendAsyncDidChangeView,
1517 view_change_weak_ptr_factory_.GetWeakPtr())); 1520 view_change_weak_ptr_factory_.GetWeakPtr()));
1518 } 1521 }
(...skipping 15 matching lines...) Expand all
1534 1537
1535 if (view_change_weak_ptr_factory_.HasWeakPtrs() || 1538 if (view_change_weak_ptr_factory_.HasWeakPtrs() ||
1536 (sent_initial_did_change_view_ && 1539 (sent_initial_did_change_view_ &&
1537 last_sent_view_data_.Equals(view_data_))) 1540 last_sent_view_data_.Equals(view_data_)))
1538 return; // Nothing to update. 1541 return; // Nothing to update.
1539 1542
1540 sent_initial_did_change_view_ = true; 1543 sent_initial_did_change_view_ = true;
1541 last_sent_view_data_ = view_data_; 1544 last_sent_view_data_ = view_data_;
1542 ScopedPPResource resource( 1545 ScopedPPResource resource(
1543 ScopedPPResource::PassRef(), 1546 ScopedPPResource::PassRef(),
1544 (new PPB_View_Shared(ppapi::OBJECT_IS_IMPL, 1547 (new PPB_View_Shared(ppapi::OBJECT_IS_IMPL, pp_instance(), view_data_))
1545 pp_instance(), view_data_))->GetReference()); 1548 ->GetReference());
1546 1549
1547 UpdateLayerTransform(); 1550 UpdateLayerTransform();
1548 1551
1549 // It's possible that Delete() has been called but the renderer hasn't 1552 // It's possible that Delete() has been called but the renderer hasn't
1550 // released its reference to this object yet. 1553 // released its reference to this object yet.
1551 if (instance_interface_) { 1554 if (instance_interface_) {
1552 instance_interface_->DidChangeView(pp_instance(), resource, 1555 instance_interface_->DidChangeView(
1553 &view_data_.rect, 1556 pp_instance(), resource, &view_data_.rect, &view_data_.clip_rect);
1554 &view_data_.clip_rect);
1555 } 1557 }
1556 } 1558 }
1557 1559
1558 void PepperPluginInstanceImpl::ReportGeometry() { 1560 void PepperPluginInstanceImpl::ReportGeometry() {
1559 // If this call was delayed, we may have transitioned back to fullscreen in 1561 // If this call was delayed, we may have transitioned back to fullscreen in
1560 // the mean time, so only report the geometry if we are actually in normal 1562 // the mean time, so only report the geometry if we are actually in normal
1561 // mode. 1563 // mode.
1562 if (container_ && !fullscreen_container_ && !flash_fullscreen_) 1564 if (container_ && !fullscreen_container_ && !flash_fullscreen_)
1563 container_->reportGeometry(); 1565 container_->reportGeometry();
1564 } 1566 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 return 0; 1603 return 0;
1602 } 1604 }
1603 int num_pages = 0; 1605 int num_pages = 0;
1604 PP_PrintSettings_Dev print_settings; 1606 PP_PrintSettings_Dev print_settings;
1605 print_settings.printable_area = PP_FromGfxRect(print_params.printableArea); 1607 print_settings.printable_area = PP_FromGfxRect(print_params.printableArea);
1606 print_settings.content_area = PP_FromGfxRect(print_params.printContentArea); 1608 print_settings.content_area = PP_FromGfxRect(print_params.printContentArea);
1607 print_settings.paper_size = PP_FromGfxSize(print_params.paperSize); 1609 print_settings.paper_size = PP_FromGfxSize(print_params.paperSize);
1608 print_settings.dpi = print_params.printerDPI; 1610 print_settings.dpi = print_params.printerDPI;
1609 print_settings.orientation = PP_PRINTORIENTATION_NORMAL; 1611 print_settings.orientation = PP_PRINTORIENTATION_NORMAL;
1610 print_settings.grayscale = PP_FALSE; 1612 print_settings.grayscale = PP_FALSE;
1611 print_settings.print_scaling_option = static_cast<PP_PrintScalingOption_Dev>( 1613 print_settings.print_scaling_option =
1612 print_params.printScalingOption); 1614 static_cast<PP_PrintScalingOption_Dev>(print_params.printScalingOption);
1613 print_settings.format = format; 1615 print_settings.format = format;
1614 num_pages = plugin_print_interface_->Begin(pp_instance(), 1616 num_pages = plugin_print_interface_->Begin(pp_instance(), &print_settings);
1615 &print_settings);
1616 if (!num_pages) 1617 if (!num_pages)
1617 return 0; 1618 return 0;
1618 current_print_settings_ = print_settings; 1619 current_print_settings_ = print_settings;
1619 canvas_.clear(); 1620 canvas_.clear();
1620 ranges_.clear(); 1621 ranges_.clear();
1621 return num_pages; 1622 return num_pages;
1622 } 1623 }
1623 1624
1624 bool PepperPluginInstanceImpl::PrintPage(int page_number, 1625 bool PepperPluginInstanceImpl::PrintPage(int page_number,
1625 blink::WebCanvas* canvas) { 1626 blink::WebCanvas* canvas) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1692 if (!LoadPdfInterface()) 1693 if (!LoadPdfInterface())
1693 return false; 1694 return false;
1694 1695
1695 return true; 1696 return true;
1696 } 1697 }
1697 1698
1698 void PepperPluginInstanceImpl::RotateView(WebPlugin::RotationType type) { 1699 void PepperPluginInstanceImpl::RotateView(WebPlugin::RotationType type) {
1699 if (!LoadPdfInterface()) 1700 if (!LoadPdfInterface())
1700 return; 1701 return;
1701 PP_PrivatePageTransformType transform_type = 1702 PP_PrivatePageTransformType transform_type =
1702 type == WebPlugin::RotationType90Clockwise ? 1703 type == WebPlugin::RotationType90Clockwise
1703 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : 1704 ? PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW
1704 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; 1705 : PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW;
1705 plugin_pdf_interface_->Transform(pp_instance(), transform_type); 1706 plugin_pdf_interface_->Transform(pp_instance(), transform_type);
1706 // NOTE: plugin instance may have been deleted. 1707 // NOTE: plugin instance may have been deleted.
1707 } 1708 }
1708 1709
1709 bool PepperPluginInstanceImpl::FlashIsFullscreenOrPending() { 1710 bool PepperPluginInstanceImpl::FlashIsFullscreenOrPending() {
1710 return fullscreen_container_ != NULL; 1711 return fullscreen_container_ != NULL;
1711 } 1712 }
1712 1713
1713 bool PepperPluginInstanceImpl::IsFullscreenOrPending() { 1714 bool PepperPluginInstanceImpl::IsFullscreenOrPending() {
1714 return desired_fullscreen_state_; 1715 return desired_fullscreen_state_;
1715 } 1716 }
1716 1717
1717 bool PepperPluginInstanceImpl::SetFullscreen(bool fullscreen) { 1718 bool PepperPluginInstanceImpl::SetFullscreen(bool fullscreen) {
1718 // Keep a reference on the stack. See NOTE above. 1719 // Keep a reference on the stack. See NOTE above.
1719 scoped_refptr<PepperPluginInstanceImpl> ref(this); 1720 scoped_refptr<PepperPluginInstanceImpl> ref(this);
1720 1721
1721 // Check whether we are trying to switch to the state we're already going 1722 // Check whether we are trying to switch to the state we're already going
1722 // to (i.e. if we're already switching to fullscreen but the fullscreen 1723 // to (i.e. if we're already switching to fullscreen but the fullscreen
1723 // container isn't ready yet, don't do anything more). 1724 // container isn't ready yet, don't do anything more).
1724 if (fullscreen == IsFullscreenOrPending()) 1725 if (fullscreen == IsFullscreenOrPending())
1725 return false; 1726 return false;
1726 1727
1727 if (!render_frame_) 1728 if (!render_frame_)
1728 return false; 1729 return false;
1729 if (fullscreen && 1730 if (fullscreen && !render_frame_->render_view()
1730 !render_frame_->render_view()->renderer_preferences(). 1731 ->renderer_preferences()
1731 plugin_fullscreen_allowed) 1732 .plugin_fullscreen_allowed)
1732 return false; 1733 return false;
1733 1734
1734 // Check whether we are trying to switch while the state is in transition. 1735 // Check whether we are trying to switch while the state is in transition.
1735 // The 2nd request gets dropped while messing up the internal state, so 1736 // The 2nd request gets dropped while messing up the internal state, so
1736 // disallow this. 1737 // disallow this.
1737 if (view_data_.is_fullscreen != desired_fullscreen_state_) 1738 if (view_data_.is_fullscreen != desired_fullscreen_state_)
1738 return false; 1739 return false;
1739 1740
1740 if (fullscreen && !IsProcessingUserGesture()) 1741 if (fullscreen && !IsProcessingUserGesture())
1741 return false; 1742 return false;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 BufferAutoMapper mapper(enter.object()); 1816 BufferAutoMapper mapper(enter.object());
1816 if (!mapper.data() || !mapper.size()) { 1817 if (!mapper.data() || !mapper.size()) {
1817 NOTREACHED(); 1818 NOTREACHED();
1818 return false; 1819 return false;
1819 } 1820 }
1820 #if defined(OS_WIN) 1821 #if defined(OS_WIN)
1821 // For Windows, we need the PDF DLL to render the output PDF to a DC. 1822 // For Windows, we need the PDF DLL to render the output PDF to a DC.
1822 HMODULE pdf_module = GetModuleHandle(L"pdf.dll"); 1823 HMODULE pdf_module = GetModuleHandle(L"pdf.dll");
1823 if (!pdf_module) 1824 if (!pdf_module)
1824 return false; 1825 return false;
1825 RenderPDFPageToDCProc render_proc = 1826 RenderPDFPageToDCProc render_proc = reinterpret_cast<RenderPDFPageToDCProc>(
1826 reinterpret_cast<RenderPDFPageToDCProc>( 1827 GetProcAddress(pdf_module, "RenderPDFPageToDC"));
1827 GetProcAddress(pdf_module, "RenderPDFPageToDC"));
1828 if (!render_proc) 1828 if (!render_proc)
1829 return false; 1829 return false;
1830 #endif // defined(OS_WIN) 1830 #endif // defined(OS_WIN)
1831 1831
1832 bool ret = false; 1832 bool ret = false;
1833 #if defined(OS_POSIX) && !defined(OS_ANDROID) 1833 #if defined(OS_POSIX) && !defined(OS_ANDROID)
1834 // On Linux we just set the final bits in the native metafile 1834 // On Linux we just set the final bits in the native metafile
1835 // (NativeMetafile and PreviewMetafile must have compatible formats, 1835 // (NativeMetafile and PreviewMetafile must have compatible formats,
1836 // i.e. both PDF for this to work). 1836 // i.e. both PDF for this to work).
1837 printing::Metafile* metafile = 1837 printing::Metafile* metafile =
1838 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); 1838 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas);
1839 DCHECK(metafile != NULL); 1839 DCHECK(metafile != NULL);
1840 if (metafile) 1840 if (metafile)
1841 ret = metafile->InitFromData(mapper.data(), mapper.size()); 1841 ret = metafile->InitFromData(mapper.data(), mapper.size());
1842 #elif defined(OS_WIN) 1842 #elif defined(OS_WIN)
1843 printing::Metafile* metafile = 1843 printing::Metafile* metafile =
1844 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); 1844 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas);
1845 if (metafile) { 1845 if (metafile) {
1846 // We only have a metafile when doing print preview, so we just want to 1846 // We only have a metafile when doing print preview, so we just want to
1847 // pass the PDF off to preview. 1847 // pass the PDF off to preview.
1848 ret = metafile->InitFromData(mapper.data(), mapper.size()); 1848 ret = metafile->InitFromData(mapper.data(), mapper.size());
1849 } else { 1849 } else {
1850 // On Windows, we now need to render the PDF to the DC that backs the 1850 // On Windows, we now need to render the PDF to the DC that backs the
1851 // supplied canvas. 1851 // supplied canvas.
1852 HDC dc = skia::BeginPlatformPaint(canvas); 1852 HDC dc = skia::BeginPlatformPaint(canvas);
1853 DrawEmptyRectangle(dc); 1853 DrawEmptyRectangle(dc);
1854 gfx::Size size_in_pixels; 1854 gfx::Size size_in_pixels;
1855 size_in_pixels.set_width(printing::ConvertUnit( 1855 size_in_pixels.set_width(
1856 current_print_settings_.printable_area.size.width, 1856 printing::ConvertUnit(current_print_settings_.printable_area.size.width,
1857 static_cast<int>(printing::kPointsPerInch), 1857 static_cast<int>(printing::kPointsPerInch),
1858 current_print_settings_.dpi)); 1858 current_print_settings_.dpi));
1859 size_in_pixels.set_height(printing::ConvertUnit( 1859 size_in_pixels.set_height(printing::ConvertUnit(
1860 current_print_settings_.printable_area.size.height, 1860 current_print_settings_.printable_area.size.height,
1861 static_cast<int>(printing::kPointsPerInch), 1861 static_cast<int>(printing::kPointsPerInch),
1862 current_print_settings_.dpi)); 1862 current_print_settings_.dpi));
1863 // We need to scale down DC to fit an entire page into DC available area. 1863 // We need to scale down DC to fit an entire page into DC available area.
1864 // First, we'll try to use default scaling based on the 72dpi that is 1864 // First, we'll try to use default scaling based on the 72dpi that is
1865 // used in webkit for printing. 1865 // used in webkit for printing.
1866 // If default scaling is not enough to fit the entire PDF without 1866 // If default scaling is not enough to fit the entire PDF without
1867 // Current metafile is based on screen DC and have current screen size. 1867 // Current metafile is based on screen DC and have current screen size.
1868 // Writing outside of those boundaries will result in the cut-off output. 1868 // Writing outside of those boundaries will result in the cut-off output.
1869 // On metafiles (this is the case here), scaling down will still record 1869 // On metafiles (this is the case here), scaling down will still record
1870 // original coordinates and we'll be able to print in full resolution. 1870 // original coordinates and we'll be able to print in full resolution.
1871 // Before playback we'll need to counter the scaling up that will happen 1871 // Before playback we'll need to counter the scaling up that will happen
1872 // in the browser (printed_document_win.cc). 1872 // in the browser (printed_document_win.cc).
1873 double dynamic_scale = gfx::CalculatePageScale(dc, size_in_pixels.width(), 1873 double dynamic_scale = gfx::CalculatePageScale(
1874 size_in_pixels.height()); 1874 dc, size_in_pixels.width(), size_in_pixels.height());
1875 double page_scale = static_cast<double>(printing::kPointsPerInch) / 1875 double page_scale = static_cast<double>(printing::kPointsPerInch) /
1876 static_cast<double>(current_print_settings_.dpi); 1876 static_cast<double>(current_print_settings_.dpi);
1877 1877
1878 if (dynamic_scale < page_scale) { 1878 if (dynamic_scale < page_scale) {
1879 page_scale = dynamic_scale; 1879 page_scale = dynamic_scale;
1880 printing::MetafileSkiaWrapper::SetCustomScaleOnCanvas(*canvas, 1880 printing::MetafileSkiaWrapper::SetCustomScaleOnCanvas(*canvas,
1881 page_scale); 1881 page_scale);
1882 } 1882 }
1883 1883
1884 gfx::ScaleDC(dc, page_scale); 1884 gfx::ScaleDC(dc, page_scale);
1885 1885
1886 ret = render_proc(static_cast<unsigned char*>(mapper.data()), mapper.size(), 1886 ret = render_proc(static_cast<unsigned char*>(mapper.data()),
1887 0, dc, current_print_settings_.dpi, 1887 mapper.size(),
1888 current_print_settings_.dpi, 0, 0, size_in_pixels.width(), 1888 0,
1889 size_in_pixels.height(), true, false, true, true, true); 1889 dc,
1890 current_print_settings_.dpi,
1891 current_print_settings_.dpi,
1892 0,
1893 0,
1894 size_in_pixels.width(),
1895 size_in_pixels.height(),
1896 true,
1897 false,
1898 true,
1899 true,
1900 true);
1890 skia::EndPlatformPaint(canvas); 1901 skia::EndPlatformPaint(canvas);
1891 } 1902 }
1892 #endif // defined(OS_WIN) 1903 #endif // defined(OS_WIN)
1893 1904
1894 return ret; 1905 return ret;
1895 #else // defined(ENABLE_FULL_PRINTING) 1906 #else // defined(ENABLE_FULL_PRINTING)
1896 return false; 1907 return false;
1897 #endif 1908 #endif
1898 } 1909 }
1899 1910
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 layer_is_hardware_ = want_3d_layer; 1971 layer_is_hardware_ = want_3d_layer;
1961 UpdateLayerTransform(); 1972 UpdateLayerTransform();
1962 } 1973 }
1963 1974
1964 bool PepperPluginInstanceImpl::PrepareTextureMailbox( 1975 bool PepperPluginInstanceImpl::PrepareTextureMailbox(
1965 cc::TextureMailbox* mailbox, 1976 cc::TextureMailbox* mailbox,
1966 scoped_ptr<cc::SingleReleaseCallback>* release_callback, 1977 scoped_ptr<cc::SingleReleaseCallback>* release_callback,
1967 bool use_shared_memory) { 1978 bool use_shared_memory) {
1968 if (!bound_graphics_2d_platform_) 1979 if (!bound_graphics_2d_platform_)
1969 return false; 1980 return false;
1970 return bound_graphics_2d_platform_->PrepareTextureMailbox( 1981 return bound_graphics_2d_platform_->PrepareTextureMailbox(mailbox,
1971 mailbox, release_callback); 1982 release_callback);
1972 } 1983 }
1973 1984
1974 void PepperPluginInstanceImpl::OnDestruct() { 1985 void PepperPluginInstanceImpl::OnDestruct() { render_frame_ = NULL; }
1975 render_frame_ = NULL;
1976 }
1977 1986
1978 void PepperPluginInstanceImpl::AddPluginObject(PluginObject* plugin_object) { 1987 void PepperPluginInstanceImpl::AddPluginObject(PluginObject* plugin_object) {
1979 DCHECK(live_plugin_objects_.find(plugin_object) == 1988 DCHECK(live_plugin_objects_.find(plugin_object) ==
1980 live_plugin_objects_.end()); 1989 live_plugin_objects_.end());
1981 live_plugin_objects_.insert(plugin_object); 1990 live_plugin_objects_.insert(plugin_object);
1982 } 1991 }
1983 1992
1984 void PepperPluginInstanceImpl::RemovePluginObject(PluginObject* plugin_object) { 1993 void PepperPluginInstanceImpl::RemovePluginObject(PluginObject* plugin_object) {
1985 // Don't actually verify that the object is in the set since during module 1994 // Don't actually verify that the object is in the set since during module
1986 // deletion we'll be in the process of freeing them. 1995 // deletion we'll be in the process of freeing them.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2029 bool handled = SimulateIMEEvent(input_event); 2038 bool handled = SimulateIMEEvent(input_event);
2030 if (handled) 2039 if (handled)
2031 return; 2040 return;
2032 2041
2033 std::vector<linked_ptr<WebInputEvent> > events = 2042 std::vector<linked_ptr<WebInputEvent> > events =
2034 CreateSimulatedWebInputEvents( 2043 CreateSimulatedWebInputEvents(
2035 input_event, 2044 input_event,
2036 view_data_.rect.point.x + view_data_.rect.size.width / 2, 2045 view_data_.rect.point.x + view_data_.rect.size.width / 2,
2037 view_data_.rect.point.y + view_data_.rect.size.height / 2); 2046 view_data_.rect.point.y + view_data_.rect.size.height / 2);
2038 for (std::vector<linked_ptr<WebInputEvent> >::iterator it = events.begin(); 2047 for (std::vector<linked_ptr<WebInputEvent> >::iterator it = events.begin();
2039 it != events.end(); ++it) { 2048 it != events.end();
2049 ++it) {
2040 web_view->handleInputEvent(*it->get()); 2050 web_view->handleInputEvent(*it->get());
2041 } 2051 }
2042 } 2052 }
2043 2053
2044 bool PepperPluginInstanceImpl::SimulateIMEEvent( 2054 bool PepperPluginInstanceImpl::SimulateIMEEvent(
2045 const InputEventData& input_event) { 2055 const InputEventData& input_event) {
2046 switch (input_event.event_type) { 2056 switch (input_event.event_type) {
2047 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_START: 2057 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_START:
2048 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE: 2058 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE:
2049 SimulateImeSetCompositionEvent(input_event); 2059 SimulateImeSetCompositionEvent(input_event);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 if (input_event.composition_target_segment == static_cast<int32_t>(i - 2)) 2097 if (input_event.composition_target_segment == static_cast<int32_t>(i - 2))
2088 underline.thick = true; 2098 underline.thick = true;
2089 underlines.push_back(underline); 2099 underlines.push_back(underline);
2090 } 2100 }
2091 2101
2092 render_frame_->SimulateImeSetComposition( 2102 render_frame_->SimulateImeSetComposition(
2093 utf16_text, underlines, offsets[0], offsets[1]); 2103 utf16_text, underlines, offsets[0], offsets[1]);
2094 } 2104 }
2095 2105
2096 ContentDecryptorDelegate* 2106 ContentDecryptorDelegate*
2097 PepperPluginInstanceImpl::GetContentDecryptorDelegate() { 2107 PepperPluginInstanceImpl::GetContentDecryptorDelegate() {
2098 if (content_decryptor_delegate_) 2108 if (content_decryptor_delegate_)
2099 return content_decryptor_delegate_.get(); 2109 return content_decryptor_delegate_.get();
2100 2110
2101 const PPP_ContentDecryptor_Private* plugin_decryption_interface = 2111 const PPP_ContentDecryptor_Private* plugin_decryption_interface =
2102 static_cast<const PPP_ContentDecryptor_Private*>( 2112 static_cast<const PPP_ContentDecryptor_Private*>(
2103 module_->GetPluginInterface( 2113 module_->GetPluginInterface(PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE));
2104 PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE));
2105 if (!plugin_decryption_interface) 2114 if (!plugin_decryption_interface)
2106 return NULL; 2115 return NULL;
2107 2116
2108 content_decryptor_delegate_.reset( 2117 content_decryptor_delegate_.reset(
2109 new ContentDecryptorDelegate(pp_instance_, plugin_decryption_interface)); 2118 new ContentDecryptorDelegate(pp_instance_, plugin_decryption_interface));
2110 return content_decryptor_delegate_.get(); 2119 return content_decryptor_delegate_.get();
2111 } 2120 }
2112 2121
2113 PP_Bool PepperPluginInstanceImpl::BindGraphics(PP_Instance instance, 2122 PP_Bool PepperPluginInstanceImpl::BindGraphics(PP_Instance instance,
2114 PP_Resource device) { 2123 PP_Resource device) {
(...skipping 27 matching lines...) Expand all
2142 RendererPpapiHost::GetForPPInstance(instance)->GetPpapiHost(); 2151 RendererPpapiHost::GetForPPInstance(instance)->GetPpapiHost();
2143 ppapi::host::ResourceHost* host = ppapi_host->GetResourceHost(device); 2152 ppapi::host::ResourceHost* host = ppapi_host->GetResourceHost(device);
2144 PepperGraphics2DHost* graphics_2d = NULL; 2153 PepperGraphics2DHost* graphics_2d = NULL;
2145 if (host) { 2154 if (host) {
2146 if (host->IsGraphics2DHost()) 2155 if (host->IsGraphics2DHost())
2147 graphics_2d = static_cast<PepperGraphics2DHost*>(host); 2156 graphics_2d = static_cast<PepperGraphics2DHost*>(host);
2148 DLOG_IF(ERROR, !graphics_2d) << "Resource is not PepperGraphics2DHost."; 2157 DLOG_IF(ERROR, !graphics_2d) << "Resource is not PepperGraphics2DHost.";
2149 } 2158 }
2150 2159
2151 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); 2160 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false);
2152 PPB_Graphics3D_Impl* graphics_3d = enter_3d.succeeded() ? 2161 PPB_Graphics3D_Impl* graphics_3d =
2153 static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) : NULL; 2162 enter_3d.succeeded()
2163 ? static_cast<PPB_Graphics3D_Impl*>(enter_3d.object())
2164 : NULL;
2154 2165
2155 if (graphics_2d) { 2166 if (graphics_2d) {
2156 if (graphics_2d->BindToInstance(this)) { 2167 if (graphics_2d->BindToInstance(this)) {
2157 bound_graphics_2d_platform_ = graphics_2d; 2168 bound_graphics_2d_platform_ = graphics_2d;
2158 UpdateLayer(); 2169 UpdateLayer();
2159 return PP_TRUE; 2170 return PP_TRUE;
2160 } 2171 }
2161 } else if (graphics_3d) { 2172 } else if (graphics_3d) {
2162 // Make sure graphics can only be bound to the instance it is 2173 // Make sure graphics can only be bound to the instance it is
2163 // associated with. 2174 // associated with.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2227 WebFrame* frame = container_->element().document().frame(); 2238 WebFrame* frame = container_->element().document().frame();
2228 if (!frame) { 2239 if (!frame) {
2229 try_catch.SetException("No frame to execute script in."); 2240 try_catch.SetException("No frame to execute script in.");
2230 return PP_MakeUndefined(); 2241 return PP_MakeUndefined();
2231 } 2242 }
2232 2243
2233 NPVariant result; 2244 NPVariant result;
2234 bool ok = false; 2245 bool ok = false;
2235 if (IsProcessingUserGesture()) { 2246 if (IsProcessingUserGesture()) {
2236 blink::WebScopedUserGesture user_gesture(CurrentUserGestureToken()); 2247 blink::WebScopedUserGesture user_gesture(CurrentUserGestureToken());
2237 ok = WebBindings::evaluate(NULL, frame->windowObject(), &np_script, 2248 ok =
2238 &result); 2249 WebBindings::evaluate(NULL, frame->windowObject(), &np_script, &result);
2239 } else { 2250 } else {
2240 ok = WebBindings::evaluate(NULL, frame->windowObject(), &np_script, 2251 ok =
2241 &result); 2252 WebBindings::evaluate(NULL, frame->windowObject(), &np_script, &result);
2242 } 2253 }
2243 if (!ok) { 2254 if (!ok) {
2244 // TryCatch doesn't catch the exceptions properly. Since this is only for 2255 // TryCatch doesn't catch the exceptions properly. Since this is only for
2245 // a trusted API, just set to a general exception message. 2256 // a trusted API, just set to a general exception message.
2246 try_catch.SetException("Exception caught"); 2257 try_catch.SetException("Exception caught");
2247 WebBindings::releaseVariantValue(&result); 2258 WebBindings::releaseVariantValue(&result);
2248 return PP_MakeUndefined(); 2259 return PP_MakeUndefined();
2249 } 2260 }
2250 2261
2251 PP_Var ret = NPVariantToPPVar(this, &result); 2262 PP_Var ret = NPVariantToPPVar(this, &result);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 request_id); 2343 request_id);
2333 } 2344 }
2334 2345
2335 void PepperPluginInstanceImpl::DecoderResetDone( 2346 void PepperPluginInstanceImpl::DecoderResetDone(
2336 PP_Instance instance, 2347 PP_Instance instance,
2337 PP_DecryptorStreamType decoder_type, 2348 PP_DecryptorStreamType decoder_type,
2338 uint32_t request_id) { 2349 uint32_t request_id) {
2339 content_decryptor_delegate_->DecoderResetDone(decoder_type, request_id); 2350 content_decryptor_delegate_->DecoderResetDone(decoder_type, request_id);
2340 } 2351 }
2341 2352
2342
2343 void PepperPluginInstanceImpl::DeliverFrame( 2353 void PepperPluginInstanceImpl::DeliverFrame(
2344 PP_Instance instance, 2354 PP_Instance instance,
2345 PP_Resource decrypted_frame, 2355 PP_Resource decrypted_frame,
2346 const PP_DecryptedFrameInfo* frame_info) { 2356 const PP_DecryptedFrameInfo* frame_info) {
2347 content_decryptor_delegate_->DeliverFrame(decrypted_frame, frame_info); 2357 content_decryptor_delegate_->DeliverFrame(decrypted_frame, frame_info);
2348 } 2358 }
2349 2359
2350 void PepperPluginInstanceImpl::DeliverSamples( 2360 void PepperPluginInstanceImpl::DeliverSamples(
2351 PP_Instance instance, 2361 PP_Instance instance,
2352 PP_Resource audio_frames, 2362 PP_Resource audio_frames,
2353 const PP_DecryptedSampleInfo* sample_info) { 2363 const PP_DecryptedSampleInfo* sample_info) {
2354 content_decryptor_delegate_->DeliverSamples(audio_frames, sample_info); 2364 content_decryptor_delegate_->DeliverSamples(audio_frames, sample_info);
2355 } 2365 }
2356 2366
2357 void PepperPluginInstanceImpl::SetPluginToHandleFindRequests( 2367 void PepperPluginInstanceImpl::SetPluginToHandleFindRequests(
2358 PP_Instance instance) { 2368 PP_Instance instance) {
2359 if (!LoadFindInterface()) 2369 if (!LoadFindInterface())
2360 return; 2370 return;
2361 bool is_main_frame = render_frame_ && 2371 bool is_main_frame =
2372 render_frame_ &&
2362 render_frame_->GetRenderView()->GetMainRenderFrame() == render_frame_; 2373 render_frame_->GetRenderView()->GetMainRenderFrame() == render_frame_;
2363 if (!is_main_frame) 2374 if (!is_main_frame)
2364 return; 2375 return;
2365 render_frame_->render_view()->set_plugin_find_handler(this); 2376 render_frame_->render_view()->set_plugin_find_handler(this);
2366 } 2377 }
2367 2378
2368 void PepperPluginInstanceImpl::NumberOfFindResultsChanged( 2379 void PepperPluginInstanceImpl::NumberOfFindResultsChanged(
2369 PP_Instance instance, 2380 PP_Instance instance,
2370 int32_t total, 2381 int32_t total,
2371 PP_Bool final_result) { 2382 PP_Bool final_result) {
(...skipping 18 matching lines...) Expand all
2390 uint32_t count) { 2401 uint32_t count) {
2391 if (!render_frame_ || !render_frame_->GetWebFrame()) 2402 if (!render_frame_ || !render_frame_->GetWebFrame())
2392 return; 2403 return;
2393 2404
2394 blink::WebVector<blink::WebRect> tickmarks_converted( 2405 blink::WebVector<blink::WebRect> tickmarks_converted(
2395 static_cast<size_t>(count)); 2406 static_cast<size_t>(count));
2396 for (uint32 i = 0; i < count; ++i) { 2407 for (uint32 i = 0; i < count; ++i) {
2397 tickmarks_converted[i] = blink::WebRect(tickmarks[i].point.x, 2408 tickmarks_converted[i] = blink::WebRect(tickmarks[i].point.x,
2398 tickmarks[i].point.y, 2409 tickmarks[i].point.y,
2399 tickmarks[i].size.width, 2410 tickmarks[i].size.width,
2400 tickmarks[i].size.height);; 2411 tickmarks[i].size.height);
2412 ;
2401 } 2413 }
2402 blink::WebFrame* frame = render_frame_->GetWebFrame(); 2414 blink::WebFrame* frame = render_frame_->GetWebFrame();
2403 frame->setTickmarks(tickmarks_converted); 2415 frame->setTickmarks(tickmarks_converted);
2404 } 2416 }
2405 2417
2406 PP_Bool PepperPluginInstanceImpl::IsFullscreen(PP_Instance instance) { 2418 PP_Bool PepperPluginInstanceImpl::IsFullscreen(PP_Instance instance) {
2407 return PP_FromBool(view_data_.is_fullscreen); 2419 return PP_FromBool(view_data_.is_fullscreen);
2408 } 2420 }
2409 2421
2410 PP_Bool PepperPluginInstanceImpl::SetFullscreen(PP_Instance instance, 2422 PP_Bool PepperPluginInstanceImpl::SetFullscreen(PP_Instance instance,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2494 double minimum_factor, 2506 double minimum_factor,
2495 double maximum_factor) { 2507 double maximum_factor) {
2496 if (!render_frame_) 2508 if (!render_frame_)
2497 return; 2509 return;
2498 if (minimum_factor > maximum_factor) { 2510 if (minimum_factor > maximum_factor) {
2499 NOTREACHED(); 2511 NOTREACHED();
2500 return; 2512 return;
2501 } 2513 }
2502 double minimum_level = ZoomFactorToZoomLevel(minimum_factor); 2514 double minimum_level = ZoomFactorToZoomLevel(minimum_factor);
2503 double maximum_level = ZoomFactorToZoomLevel(maximum_factor); 2515 double maximum_level = ZoomFactorToZoomLevel(maximum_factor);
2504 render_frame_->render_view()->webview()->zoomLimitsChanged( 2516 render_frame_->render_view()->webview()->zoomLimitsChanged(minimum_level,
2505 minimum_level, maximum_level); 2517 maximum_level);
2506 } 2518 }
2507 2519
2508 void PepperPluginInstanceImpl::PostMessage(PP_Instance instance, 2520 void PepperPluginInstanceImpl::PostMessage(PP_Instance instance,
2509 PP_Var message) { 2521 PP_Var message) {
2510 message_channel_->PostMessageToJavaScript(message); 2522 message_channel_->PostMessageToJavaScript(message);
2511 } 2523 }
2512 2524
2513 PP_Bool PepperPluginInstanceImpl::SetCursor(PP_Instance instance, 2525 PP_Bool PepperPluginInstanceImpl::SetCursor(PP_Instance instance,
2514 PP_MouseCursor_Type type, 2526 PP_MouseCursor_Type type,
2515 PP_Resource image, 2527 PP_Resource image,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2642 PP_Instance instance, 2654 PP_Instance instance,
2643 PP_Var relative, 2655 PP_Var relative,
2644 PP_URLComponents_Dev* components) { 2656 PP_URLComponents_Dev* components) {
2645 StringVar* relative_string = StringVar::FromPPVar(relative); 2657 StringVar* relative_string = StringVar::FromPPVar(relative);
2646 if (!relative_string) 2658 if (!relative_string)
2647 return PP_MakeNull(); 2659 return PP_MakeNull();
2648 2660
2649 WebElement plugin_element = container()->element(); 2661 WebElement plugin_element = container()->element();
2650 GURL document_url = plugin_element.document().baseURL(); 2662 GURL document_url = plugin_element.document().baseURL();
2651 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn( 2663 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(
2652 document_url.Resolve(relative_string->value()), 2664 document_url.Resolve(relative_string->value()), components);
2653 components);
2654 } 2665 }
2655 2666
2656 PP_Bool PepperPluginInstanceImpl::DocumentCanRequest(PP_Instance instance, 2667 PP_Bool PepperPluginInstanceImpl::DocumentCanRequest(PP_Instance instance,
2657 PP_Var url) { 2668 PP_Var url) {
2658 StringVar* url_string = StringVar::FromPPVar(url); 2669 StringVar* url_string = StringVar::FromPPVar(url);
2659 if (!url_string) 2670 if (!url_string)
2660 return PP_FALSE; 2671 return PP_FALSE;
2661 2672
2662 blink::WebSecurityOrigin security_origin; 2673 blink::WebSecurityOrigin security_origin;
2663 if (!SecurityOriginForInstance(instance, &security_origin)) 2674 if (!SecurityOriginForInstance(instance, &security_origin))
(...skipping 24 matching lines...) Expand all
2688 PP_Instance instance, 2699 PP_Instance instance,
2689 PP_URLComponents_Dev* components) { 2700 PP_URLComponents_Dev* components) {
2690 blink::WebDocument document = container()->element().document(); 2701 blink::WebDocument document = container()->element().document();
2691 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(document.url(), 2702 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(document.url(),
2692 components); 2703 components);
2693 } 2704 }
2694 2705
2695 PP_Var PepperPluginInstanceImpl::GetPluginInstanceURL( 2706 PP_Var PepperPluginInstanceImpl::GetPluginInstanceURL(
2696 PP_Instance instance, 2707 PP_Instance instance,
2697 PP_URLComponents_Dev* components) { 2708 PP_URLComponents_Dev* components) {
2698 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(plugin_url_, 2709 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(plugin_url_, components);
2699 components);
2700 } 2710 }
2701 2711
2702 PP_Var PepperPluginInstanceImpl::GetPluginReferrerURL( 2712 PP_Var PepperPluginInstanceImpl::GetPluginReferrerURL(
2703 PP_Instance instance, 2713 PP_Instance instance,
2704 PP_URLComponents_Dev* components) { 2714 PP_URLComponents_Dev* components) {
2705 blink::WebDocument document = container()->element().document(); 2715 blink::WebDocument document = container()->element().document();
2706 if (!full_frame_) 2716 if (!full_frame_)
2707 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(document.url(), 2717 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(document.url(),
2708 components); 2718 components);
2709 WebFrame* frame = document.frame(); 2719 WebFrame* frame = document.frame();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2752 checked_for_plugin_messaging_interface_ = false; 2762 checked_for_plugin_messaging_interface_ = false;
2753 plugin_mouse_lock_interface_ = NULL; 2763 plugin_mouse_lock_interface_ = NULL;
2754 plugin_pdf_interface_ = NULL; 2764 plugin_pdf_interface_ = NULL;
2755 checked_for_plugin_pdf_interface_ = false; 2765 checked_for_plugin_pdf_interface_ = false;
2756 plugin_private_interface_ = NULL; 2766 plugin_private_interface_ = NULL;
2757 plugin_selection_interface_ = NULL; 2767 plugin_selection_interface_ = NULL;
2758 plugin_textinput_interface_ = NULL; 2768 plugin_textinput_interface_ = NULL;
2759 plugin_zoom_interface_ = NULL; 2769 plugin_zoom_interface_ = NULL;
2760 2770
2761 // Re-send the DidCreate event via the proxy. 2771 // Re-send the DidCreate event via the proxy.
2762 scoped_ptr<const char*[]> argn_array(StringVectorToArgArray(argn_)); 2772 scoped_ptr<const char * []> argn_array(StringVectorToArgArray(argn_));
2763 scoped_ptr<const char*[]> argv_array(StringVectorToArgArray(argv_)); 2773 scoped_ptr<const char * []> argv_array(StringVectorToArgArray(argv_));
2764 if (!instance_interface_->DidCreate(pp_instance(), argn_.size(), 2774 if (!instance_interface_->DidCreate(
2765 argn_array.get(), argv_array.get())) 2775 pp_instance(), argn_.size(), argn_array.get(), argv_array.get()))
2766 return PP_EXTERNAL_PLUGIN_ERROR_INSTANCE; 2776 return PP_EXTERNAL_PLUGIN_ERROR_INSTANCE;
2767 message_channel_->StopQueueingJavaScriptMessages(); 2777 message_channel_->StopQueueingJavaScriptMessages();
2768 2778
2769 // Clear sent_initial_did_change_view_ and cancel any pending DidChangeView 2779 // Clear sent_initial_did_change_view_ and cancel any pending DidChangeView
2770 // event. This way, SendDidChangeView will send the "current" view 2780 // event. This way, SendDidChangeView will send the "current" view
2771 // immediately (before other events like HandleDocumentLoad). 2781 // immediately (before other events like HandleDocumentLoad).
2772 sent_initial_did_change_view_ = false; 2782 sent_initial_did_change_view_ = false;
2773 view_change_weak_ptr_factory_.InvalidateWeakPtrs(); 2783 view_change_weak_ptr_factory_.InvalidateWeakPtrs();
2774 SendDidChangeView(); 2784 SendDidChangeView();
2775 2785
2776 DCHECK(external_document_load_); 2786 DCHECK(external_document_load_);
2777 external_document_load_ = false; 2787 external_document_load_ = false;
2778 if (!external_document_response_.isNull()) { 2788 if (!external_document_response_.isNull()) {
2779 document_loader_ = NULL; 2789 document_loader_ = NULL;
2780 // Pass the response to the new proxy. 2790 // Pass the response to the new proxy.
2781 HandleDocumentLoad(external_document_response_); 2791 HandleDocumentLoad(external_document_response_);
2782 external_document_response_ = blink::WebURLResponse(); 2792 external_document_response_ = blink::WebURLResponse();
2783 // Replay any document load events we've received to the real loader. 2793 // Replay any document load events we've received to the real loader.
2784 external_document_loader_->ReplayReceivedData(document_loader_); 2794 external_document_loader_->ReplayReceivedData(document_loader_);
2785 external_document_loader_.reset(NULL); 2795 external_document_loader_.reset(NULL);
2786 } 2796 }
2787 2797
2788 return PP_EXTERNAL_PLUGIN_OK; 2798 return PP_EXTERNAL_PLUGIN_OK;
2789 } 2799 }
2790 2800
2791 bool PepperPluginInstanceImpl::IsValidInstanceOf(PluginModule* module) { 2801 bool PepperPluginInstanceImpl::IsValidInstanceOf(PluginModule* module) {
2792 DCHECK(module); 2802 DCHECK(module);
2793 return module == module_.get() || 2803 return module == module_.get() || module == original_module_.get();
2794 module == original_module_.get();
2795 } 2804 }
2796 2805
2797 NPP PepperPluginInstanceImpl::instanceNPP() { 2806 NPP PepperPluginInstanceImpl::instanceNPP() { return npp_.get(); }
2798 return npp_.get();
2799 }
2800 2807
2801 PepperPluginInstance* PepperPluginInstance::Get(PP_Instance instance_id) { 2808 PepperPluginInstance* PepperPluginInstance::Get(PP_Instance instance_id) {
2802 return HostGlobals::Get()->GetInstance(instance_id); 2809 return HostGlobals::Get()->GetInstance(instance_id);
2803 } 2810 }
2804 2811
2805 RenderView* PepperPluginInstanceImpl::GetRenderView() { 2812 RenderView* PepperPluginInstanceImpl::GetRenderView() {
2806 return render_frame_ ? render_frame_->render_view() : NULL; 2813 return render_frame_ ? render_frame_->render_view() : NULL;
2807 } 2814 }
2808 2815
2809 blink::WebPluginContainer* PepperPluginInstanceImpl::GetContainer() { 2816 blink::WebPluginContainer* PepperPluginInstanceImpl::GetContainer() {
2810 return container_; 2817 return container_;
2811 } 2818 }
2812 2819
2813 v8::Isolate* PepperPluginInstanceImpl::GetIsolate() const { 2820 v8::Isolate* PepperPluginInstanceImpl::GetIsolate() const { return isolate_; }
2814 return isolate_;
2815 }
2816 2821
2817 ppapi::VarTracker* PepperPluginInstanceImpl::GetVarTracker() { 2822 ppapi::VarTracker* PepperPluginInstanceImpl::GetVarTracker() {
2818 return HostGlobals::Get()->GetVarTracker(); 2823 return HostGlobals::Get()->GetVarTracker();
2819 } 2824 }
2820 2825
2821 const GURL& PepperPluginInstanceImpl::GetPluginURL() { 2826 const GURL& PepperPluginInstanceImpl::GetPluginURL() { return plugin_url_; }
2822 return plugin_url_;
2823 }
2824 2827
2825 base::FilePath PepperPluginInstanceImpl::GetModulePath() { 2828 base::FilePath PepperPluginInstanceImpl::GetModulePath() {
2826 return module_->path(); 2829 return module_->path();
2827 } 2830 }
2828 2831
2829 PP_Resource PepperPluginInstanceImpl::CreateImage(gfx::ImageSkia* source_image, 2832 PP_Resource PepperPluginInstanceImpl::CreateImage(gfx::ImageSkia* source_image,
2830 float scale) { 2833 float scale) {
2831 gfx::ImageSkiaRep image_skia_rep = source_image->GetRepresentation(scale); 2834 gfx::ImageSkiaRep image_skia_rep = source_image->GetRepresentation(scale);
2832 2835
2833 if (image_skia_rep.is_null() || image_skia_rep.scale() != scale) 2836 if (image_skia_rep.is_null() || image_skia_rep.scale() != scale)
2834 return 0; 2837 return 0;
2835 2838
2836 scoped_refptr<PPB_ImageData_Impl> image_data(new PPB_ImageData_Impl( 2839 scoped_refptr<PPB_ImageData_Impl> image_data(
2837 pp_instance(), 2840 new PPB_ImageData_Impl(pp_instance(), PPB_ImageData_Impl::PLATFORM));
2838 PPB_ImageData_Impl::PLATFORM)); 2841 if (!image_data->Init(PPB_ImageData_Impl::GetNativeImageDataFormat(),
2839 if (!image_data->Init( 2842 image_skia_rep.pixel_width(),
2840 PPB_ImageData_Impl::GetNativeImageDataFormat(), 2843 image_skia_rep.pixel_height(),
2841 image_skia_rep.pixel_width(), 2844 false)) {
2842 image_skia_rep.pixel_height(),
2843 false)) {
2844 return 0; 2845 return 0;
2845 } 2846 }
2846 2847
2847 ImageDataAutoMapper mapper(image_data.get()); 2848 ImageDataAutoMapper mapper(image_data.get());
2848 if (!mapper.is_valid()) 2849 if (!mapper.is_valid())
2849 return 0; 2850 return 0;
2850 2851
2851 skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas(); 2852 skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas();
2852 // Note: Do not SkBitmap::copyTo the canvas bitmap directly because it will 2853 // Note: Do not SkBitmap::copyTo the canvas bitmap directly because it will
2853 // ignore the allocated pixels in shared memory and re-allocate a new buffer. 2854 // ignore the allocated pixels in shared memory and re-allocate a new buffer.
2854 canvas->writePixels(image_skia_rep.sk_bitmap(), 0, 0); 2855 canvas->writePixels(image_skia_rep.sk_bitmap(), 0, 0);
2855 2856
2856 return image_data->GetReference(); 2857 return image_data->GetReference();
2857 } 2858 }
2858 2859
2859 PP_ExternalPluginResult PepperPluginInstanceImpl::SwitchToOutOfProcessProxy( 2860 PP_ExternalPluginResult PepperPluginInstanceImpl::SwitchToOutOfProcessProxy(
2860 const base::FilePath& file_path, 2861 const base::FilePath& file_path,
2861 ppapi::PpapiPermissions permissions, 2862 ppapi::PpapiPermissions permissions,
2862 const IPC::ChannelHandle& channel_handle, 2863 const IPC::ChannelHandle& channel_handle,
2863 base::ProcessId plugin_pid, 2864 base::ProcessId plugin_pid,
2864 int plugin_child_id) { 2865 int plugin_child_id) {
2865 // Create a new module for each instance of the external plugin that is using 2866 // Create a new module for each instance of the external plugin that is using
2866 // the IPC based out-of-process proxy. We can't use the existing module, 2867 // the IPC based out-of-process proxy. We can't use the existing module,
2867 // because it is configured for the in-process plugin, and we must keep it 2868 // because it is configured for the in-process plugin, and we must keep it
2868 // that way to allow the page to create other instances. 2869 // that way to allow the page to create other instances.
2869 scoped_refptr<PluginModule> external_plugin_module( 2870 scoped_refptr<PluginModule> external_plugin_module(
2870 module_->CreateModuleForExternalPluginInstance()); 2871 module_->CreateModuleForExternalPluginInstance());
2871 2872
2872 RendererPpapiHostImpl* renderer_ppapi_host = 2873 RendererPpapiHostImpl* renderer_ppapi_host =
2873 external_plugin_module->CreateOutOfProcessModule( 2874 external_plugin_module->CreateOutOfProcessModule(render_frame_,
2874 render_frame_, 2875 file_path,
2875 file_path, 2876 permissions,
2876 permissions, 2877 channel_handle,
2877 channel_handle, 2878 plugin_pid,
2878 plugin_pid, 2879 plugin_child_id,
2879 plugin_child_id, 2880 true);
2880 true);
2881 if (!renderer_ppapi_host) { 2881 if (!renderer_ppapi_host) {
2882 DLOG(ERROR) << "CreateExternalPluginModule() failed"; 2882 DLOG(ERROR) << "CreateExternalPluginModule() failed";
2883 return PP_EXTERNAL_PLUGIN_ERROR_MODULE; 2883 return PP_EXTERNAL_PLUGIN_ERROR_MODULE;
2884 } 2884 }
2885 2885
2886 // Finally, switch the instance to the proxy. 2886 // Finally, switch the instance to the proxy.
2887 return external_plugin_module->InitAsProxiedExternalPlugin(this); 2887 return external_plugin_module->InitAsProxiedExternalPlugin(this);
2888 } 2888 }
2889 2889
2890 void PepperPluginInstanceImpl::SetAlwaysOnTop(bool on_top) { 2890 void PepperPluginInstanceImpl::SetAlwaysOnTop(bool on_top) {
(...skipping 21 matching lines...) Expand all
2912 scoped_refptr<PepperPluginInstanceImpl> ref(this); 2912 scoped_refptr<PepperPluginInstanceImpl> ref(this);
2913 2913
2914 // We check whether we are trying to switch to the state we're already going 2914 // We check whether we are trying to switch to the state we're already going
2915 // to (i.e. if we're already switching to fullscreen but the fullscreen 2915 // to (i.e. if we're already switching to fullscreen but the fullscreen
2916 // container isn't ready yet, don't do anything more). 2916 // container isn't ready yet, don't do anything more).
2917 if (fullscreen == FlashIsFullscreenOrPending()) 2917 if (fullscreen == FlashIsFullscreenOrPending())
2918 return true; 2918 return true;
2919 2919
2920 if (!render_frame_) 2920 if (!render_frame_)
2921 return false; 2921 return false;
2922 if (fullscreen && 2922 if (fullscreen && !render_frame_->render_view()
2923 !render_frame_->render_view()->renderer_preferences(). 2923 ->renderer_preferences()
2924 plugin_fullscreen_allowed) 2924 .plugin_fullscreen_allowed)
2925 return false; 2925 return false;
2926 2926
2927 // Unbind current 2D or 3D graphics context. 2927 // Unbind current 2D or 3D graphics context.
2928 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); 2928 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off");
2929 if (fullscreen) { 2929 if (fullscreen) {
2930 DCHECK(!fullscreen_container_); 2930 DCHECK(!fullscreen_container_);
2931 fullscreen_container_ = 2931 fullscreen_container_ =
2932 render_frame_->CreatePepperFullscreenContainer(this); 2932 render_frame_->CreatePepperFullscreenContainer(this);
2933 UpdateLayer(); 2933 UpdateLayer();
2934 } else { 2934 } else {
(...skipping 28 matching lines...) Expand all
2963 return PP_ERROR_FAILED; 2963 return PP_ERROR_FAILED;
2964 2964
2965 WebDocument document = container_->element().document(); 2965 WebDocument document = container_->element().document();
2966 WebFrame* frame = document.frame(); 2966 WebFrame* frame = document.frame();
2967 if (!frame) 2967 if (!frame)
2968 return PP_ERROR_FAILED; 2968 return PP_ERROR_FAILED;
2969 2969
2970 ppapi::URLRequestInfoData completed_request = request; 2970 ppapi::URLRequestInfoData completed_request = request;
2971 2971
2972 WebURLRequest web_request; 2972 WebURLRequest web_request;
2973 if (!CreateWebURLRequest(pp_instance_, 2973 if (!CreateWebURLRequest(
2974 &completed_request, 2974 pp_instance_, &completed_request, frame, &web_request)) {
2975 frame,
2976 &web_request)) {
2977 return PP_ERROR_FAILED; 2975 return PP_ERROR_FAILED;
2978 } 2976 }
2979 web_request.setFirstPartyForCookies(document.firstPartyForCookies()); 2977 web_request.setFirstPartyForCookies(document.firstPartyForCookies());
2980 web_request.setHasUserGesture(from_user_action); 2978 web_request.setHasUserGesture(from_user_action);
2981 2979
2982 GURL gurl(web_request.url()); 2980 GURL gurl(web_request.url());
2983 if (gurl.SchemeIs("javascript")) { 2981 if (gurl.SchemeIs("javascript")) {
2984 // In imitation of the NPAPI implementation, only |target_frame == frame| is 2982 // In imitation of the NPAPI implementation, only |target_frame == frame| is
2985 // allowed for security reasons. 2983 // allowed for security reasons.
2986 WebFrame* target_frame = 2984 WebFrame* target_frame =
2987 frame->view()->findFrameByName(WebString::fromUTF8(target), frame); 2985 frame->view()->findFrameByName(WebString::fromUTF8(target), frame);
2988 if (target_frame != frame) 2986 if (target_frame != frame)
2989 return PP_ERROR_NOACCESS; 2987 return PP_ERROR_NOACCESS;
2990 2988
2991 // TODO(viettrungluu): NPAPI sends the result back to the plugin -- do we 2989 // TODO(viettrungluu): NPAPI sends the result back to the plugin -- do we
2992 // need that? 2990 // need that?
2993 WebString result = container_->executeScriptURL(gurl, from_user_action); 2991 WebString result = container_->executeScriptURL(gurl, from_user_action);
2994 return result.isNull() ? PP_ERROR_FAILED : PP_OK; 2992 return result.isNull() ? PP_ERROR_FAILED : PP_OK;
2995 } 2993 }
2996 2994
2997 // Only GETs and POSTs are supported. 2995 // Only GETs and POSTs are supported.
2998 if (web_request.httpMethod() != "GET" && 2996 if (web_request.httpMethod() != "GET" && web_request.httpMethod() != "POST")
2999 web_request.httpMethod() != "POST")
3000 return PP_ERROR_BADARGUMENT; 2997 return PP_ERROR_BADARGUMENT;
3001 2998
3002 WebString target_str = WebString::fromUTF8(target); 2999 WebString target_str = WebString::fromUTF8(target);
3003 container_->loadFrameRequest(web_request, target_str, false, NULL); 3000 container_->loadFrameRequest(web_request, target_str, false, NULL);
3004 return PP_OK; 3001 return PP_OK;
3005 } 3002 }
3006 3003
3007 int PepperPluginInstanceImpl::MakePendingFileRefRendererHost( 3004 int PepperPluginInstanceImpl::MakePendingFileRefRendererHost(
3008 const base::FilePath& path) { 3005 const base::FilePath& path) {
3009 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); 3006 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host();
3010 PepperFileRefRendererHost* file_ref_host( 3007 PepperFileRefRendererHost* file_ref_host(
3011 new PepperFileRefRendererHost(host_impl, pp_instance(), 0, path)); 3008 new PepperFileRefRendererHost(host_impl, pp_instance(), 0, path));
3012 return host_impl->GetPpapiHost()->AddPendingResourceHost( 3009 return host_impl->GetPpapiHost()->AddPendingResourceHost(
3013 scoped_ptr<ppapi::host::ResourceHost>(file_ref_host)); 3010 scoped_ptr<ppapi::host::ResourceHost>(file_ref_host));
3014 } 3011 }
3015 3012
3016 void PepperPluginInstanceImpl::SetEmbedProperty(PP_Var key, 3013 void PepperPluginInstanceImpl::SetEmbedProperty(PP_Var key, PP_Var value) {
3017 PP_Var value) {
3018 message_channel_->SetReadOnlyProperty(key, value); 3014 message_channel_->SetReadOnlyProperty(key, value);
3019 } 3015 }
3020 3016
3021 bool PepperPluginInstanceImpl::CanAccessMainFrame() const { 3017 bool PepperPluginInstanceImpl::CanAccessMainFrame() const {
3022 if (!container_) 3018 if (!container_)
3023 return false; 3019 return false;
3024 blink::WebDocument containing_document = container_->element().document(); 3020 blink::WebDocument containing_document = container_->element().document();
3025 3021
3026 if (!containing_document.frame() || 3022 if (!containing_document.frame() || !containing_document.frame()->view() ||
3027 !containing_document.frame()->view() ||
3028 !containing_document.frame()->view()->mainFrame()) { 3023 !containing_document.frame()->view()->mainFrame()) {
3029 return false; 3024 return false;
3030 } 3025 }
3031 blink::WebDocument main_document = 3026 blink::WebDocument main_document =
3032 containing_document.frame()->view()->mainFrame()->document(); 3027 containing_document.frame()->view()->mainFrame()->document();
3033 3028
3034 return containing_document.securityOrigin().canAccess( 3029 return containing_document.securityOrigin().canAccess(
3035 main_document.securityOrigin()); 3030 main_document.securityOrigin());
3036 } 3031 }
3037 3032
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3083 bool PepperPluginInstanceImpl::IsMouseLocked() { 3078 bool PepperPluginInstanceImpl::IsMouseLocked() {
3084 return GetMouseLockDispatcher()->IsMouseLockedTo( 3079 return GetMouseLockDispatcher()->IsMouseLockedTo(
3085 GetOrCreateLockTargetAdapter()); 3080 GetOrCreateLockTargetAdapter());
3086 } 3081 }
3087 3082
3088 bool PepperPluginInstanceImpl::LockMouse() { 3083 bool PepperPluginInstanceImpl::LockMouse() {
3089 return GetMouseLockDispatcher()->LockMouse(GetOrCreateLockTargetAdapter()); 3084 return GetMouseLockDispatcher()->LockMouse(GetOrCreateLockTargetAdapter());
3090 } 3085 }
3091 3086
3092 MouseLockDispatcher::LockTarget* 3087 MouseLockDispatcher::LockTarget*
3093 PepperPluginInstanceImpl::GetOrCreateLockTargetAdapter() { 3088 PepperPluginInstanceImpl::GetOrCreateLockTargetAdapter() {
3094 if (!lock_target_.get()) { 3089 if (!lock_target_.get()) {
3095 lock_target_.reset(new PluginInstanceLockTarget(this)); 3090 lock_target_.reset(new PluginInstanceLockTarget(this));
3096 } 3091 }
3097 return lock_target_.get(); 3092 return lock_target_.get();
3098 } 3093 }
3099 3094
3100 MouseLockDispatcher* PepperPluginInstanceImpl::GetMouseLockDispatcher() { 3095 MouseLockDispatcher* PepperPluginInstanceImpl::GetMouseLockDispatcher() {
3101 if (flash_fullscreen_) { 3096 if (flash_fullscreen_) {
3102 RenderWidgetFullscreenPepper* container = 3097 RenderWidgetFullscreenPepper* container =
3103 static_cast<RenderWidgetFullscreenPepper*>(fullscreen_container_); 3098 static_cast<RenderWidgetFullscreenPepper*>(fullscreen_container_);
(...skipping 16 matching lines...) Expand all
3120 int pending_host_id, 3115 int pending_host_id,
3121 const ppapi::URLResponseInfoData& data) { 3116 const ppapi::URLResponseInfoData& data) {
3122 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); 3117 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host();
3123 3118
3124 if (host_impl->in_process_router()) { 3119 if (host_impl->in_process_router()) {
3125 // Running in-process, we can just create the resource and call the 3120 // Running in-process, we can just create the resource and call the
3126 // PPP_Instance function directly. 3121 // PPP_Instance function directly.
3127 scoped_refptr<ppapi::proxy::URLLoaderResource> loader_resource( 3122 scoped_refptr<ppapi::proxy::URLLoaderResource> loader_resource(
3128 new ppapi::proxy::URLLoaderResource( 3123 new ppapi::proxy::URLLoaderResource(
3129 host_impl->in_process_router()->GetPluginConnection(pp_instance()), 3124 host_impl->in_process_router()->GetPluginConnection(pp_instance()),
3130 pp_instance(), pending_host_id, data)); 3125 pp_instance(),
3126 pending_host_id,
3127 data));
3131 3128
3132 PP_Resource loader_pp_resource = loader_resource->GetReference(); 3129 PP_Resource loader_pp_resource = loader_resource->GetReference();
3133 if (!instance_interface_->HandleDocumentLoad( 3130 if (!instance_interface_->HandleDocumentLoad(pp_instance(),
3134 pp_instance(), loader_pp_resource)) 3131 loader_pp_resource))
3135 loader_resource->Close(); 3132 loader_resource->Close();
3136 // We don't pass a ref into the plugin, if it wants one, it will have taken 3133 // We don't pass a ref into the plugin, if it wants one, it will have taken
3137 // an additional one. 3134 // an additional one.
3138 ppapi::PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource( 3135 ppapi::PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(
3139 loader_pp_resource); 3136 loader_pp_resource);
3140 } else { 3137 } else {
3141 // Running out-of-process. Initiate an IPC call to notify the plugin 3138 // Running out-of-process. Initiate an IPC call to notify the plugin
3142 // process. 3139 // process.
3143 ppapi::proxy::HostDispatcher* dispatcher = 3140 ppapi::proxy::HostDispatcher* dispatcher =
3144 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); 3141 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance());
3145 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( 3142 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad(
3146 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); 3143 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data));
3147 } 3144 }
3148 } 3145 }
3149 3146
3150 } // namespace content 3147 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.h ('k') | content/renderer/pepper/pepper_plugin_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698