| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/pepper/ppb_nacl_private_impl.h" | 5 #include "chrome/renderer/pepper/ppb_nacl_private_impl.h" |
| 6 | 6 |
| 7 #ifndef DISABLE_NACL | 7 #ifndef DISABLE_NACL |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 331 |
| 332 if (out_fd == IPC::InvalidPlatformFileForTransit()) { | 332 if (out_fd == IPC::InvalidPlatformFileForTransit()) { |
| 333 return base::kInvalidPlatformFileValue; | 333 return base::kInvalidPlatformFileValue; |
| 334 } | 334 } |
| 335 | 335 |
| 336 base::PlatformFile handle = | 336 base::PlatformFile handle = |
| 337 IPC::PlatformFileForTransitToPlatformFile(out_fd); | 337 IPC::PlatformFileForTransitToPlatformFile(out_fd); |
| 338 return handle; | 338 return handle; |
| 339 } | 339 } |
| 340 | 340 |
| 341 WebKit::WebString EventTypeToString(PP_NaClEventType event_type) { | 341 blink::WebString EventTypeToString(PP_NaClEventType event_type) { |
| 342 switch (event_type) { | 342 switch (event_type) { |
| 343 case PP_NACL_EVENT_LOADSTART: | 343 case PP_NACL_EVENT_LOADSTART: |
| 344 return WebKit::WebString::fromUTF8("loadstart"); | 344 return blink::WebString::fromUTF8("loadstart"); |
| 345 case PP_NACL_EVENT_PROGRESS: | 345 case PP_NACL_EVENT_PROGRESS: |
| 346 return WebKit::WebString::fromUTF8("progress"); | 346 return blink::WebString::fromUTF8("progress"); |
| 347 case PP_NACL_EVENT_ERROR: | 347 case PP_NACL_EVENT_ERROR: |
| 348 return WebKit::WebString::fromUTF8("error"); | 348 return blink::WebString::fromUTF8("error"); |
| 349 case PP_NACL_EVENT_ABORT: | 349 case PP_NACL_EVENT_ABORT: |
| 350 return WebKit::WebString::fromUTF8("abort"); | 350 return blink::WebString::fromUTF8("abort"); |
| 351 case PP_NACL_EVENT_LOAD: | 351 case PP_NACL_EVENT_LOAD: |
| 352 return WebKit::WebString::fromUTF8("load"); | 352 return blink::WebString::fromUTF8("load"); |
| 353 case PP_NACL_EVENT_LOADEND: | 353 case PP_NACL_EVENT_LOADEND: |
| 354 return WebKit::WebString::fromUTF8("loadend"); | 354 return blink::WebString::fromUTF8("loadend"); |
| 355 case PP_NACL_EVENT_CRASH: | 355 case PP_NACL_EVENT_CRASH: |
| 356 return WebKit::WebString::fromUTF8("crash"); | 356 return blink::WebString::fromUTF8("crash"); |
| 357 } | 357 } |
| 358 NOTIMPLEMENTED(); | 358 NOTIMPLEMENTED(); |
| 359 return WebKit::WebString(); | 359 return blink::WebString(); |
| 360 } | 360 } |
| 361 | 361 |
| 362 void DispatchEvent(PP_Instance instance, | 362 void DispatchEvent(PP_Instance instance, |
| 363 PP_NaClEventType event_type, | 363 PP_NaClEventType event_type, |
| 364 struct PP_Var resource_url, | 364 struct PP_Var resource_url, |
| 365 PP_Bool length_is_computable, | 365 PP_Bool length_is_computable, |
| 366 uint64_t loaded_bytes, | 366 uint64_t loaded_bytes, |
| 367 uint64_t total_bytes) { | 367 uint64_t total_bytes) { |
| 368 content::PepperPluginInstance* plugin_instance = | 368 content::PepperPluginInstance* plugin_instance = |
| 369 content::PepperPluginInstance::Get(instance); | 369 content::PepperPluginInstance::Get(instance); |
| 370 if (!plugin_instance) { | 370 if (!plugin_instance) { |
| 371 NOTREACHED(); | 371 NOTREACHED(); |
| 372 return; | 372 return; |
| 373 } | 373 } |
| 374 WebKit::WebPluginContainer* container = plugin_instance->GetContainer(); | 374 blink::WebPluginContainer* container = plugin_instance->GetContainer(); |
| 375 // It's possible that container() is NULL if the plugin has been removed from | 375 // It's possible that container() is NULL if the plugin has been removed from |
| 376 // the DOM (but the PluginInstance is not destroyed yet). | 376 // the DOM (but the PluginInstance is not destroyed yet). |
| 377 if (!container) | 377 if (!container) |
| 378 return; | 378 return; |
| 379 WebKit::WebFrame* frame = container->element().document().frame(); | 379 blink::WebFrame* frame = container->element().document().frame(); |
| 380 if (!frame) | 380 if (!frame) |
| 381 return; | 381 return; |
| 382 v8::HandleScope handle_scope(plugin_instance->GetIsolate()); | 382 v8::HandleScope handle_scope(plugin_instance->GetIsolate()); |
| 383 v8::Local<v8::Context> context( | 383 v8::Local<v8::Context> context( |
| 384 plugin_instance->GetIsolate()->GetCurrentContext()); | 384 plugin_instance->GetIsolate()->GetCurrentContext()); |
| 385 if (context.IsEmpty()) { | 385 if (context.IsEmpty()) { |
| 386 // If there's no JavaScript on the stack, we have to make a new Context. | 386 // If there's no JavaScript on the stack, we have to make a new Context. |
| 387 context = v8::Context::New(plugin_instance->GetIsolate()); | 387 context = v8::Context::New(plugin_instance->GetIsolate()); |
| 388 } | 388 } |
| 389 v8::Context::Scope context_scope(context); | 389 v8::Context::Scope context_scope(context); |
| 390 | 390 |
| 391 ppapi::StringVar* url_var = ppapi::StringVar::FromPPVar(resource_url); | 391 ppapi::StringVar* url_var = ppapi::StringVar::FromPPVar(resource_url); |
| 392 if (url_var) { | 392 if (url_var) { |
| 393 WebKit::WebString url_string = WebKit::WebString::fromUTF8( | 393 blink::WebString url_string = blink::WebString::fromUTF8( |
| 394 url_var->value().data(), url_var->value().size()); | 394 url_var->value().data(), url_var->value().size()); |
| 395 WebKit::WebDOMResourceProgressEvent event(EventTypeToString(event_type), | 395 blink::WebDOMResourceProgressEvent event(EventTypeToString(event_type), |
| 396 PP_ToBool(length_is_computable), | 396 PP_ToBool(length_is_computable), |
| 397 loaded_bytes, | 397 loaded_bytes, |
| 398 total_bytes, | 398 total_bytes, |
| 399 url_string); | 399 url_string); |
| 400 container->element().dispatchEvent(event); | 400 container->element().dispatchEvent(event); |
| 401 } else { | 401 } else { |
| 402 WebKit::WebDOMProgressEvent event(EventTypeToString(event_type), | 402 blink::WebDOMProgressEvent event(EventTypeToString(event_type), |
| 403 PP_ToBool(length_is_computable), | 403 PP_ToBool(length_is_computable), |
| 404 loaded_bytes, | 404 loaded_bytes, |
| 405 total_bytes); | 405 total_bytes); |
| 406 container->element().dispatchEvent(event); | 406 container->element().dispatchEvent(event); |
| 407 } | 407 } |
| 408 } | 408 } |
| 409 | 409 |
| 410 const PPB_NaCl_Private nacl_interface = { | 410 const PPB_NaCl_Private nacl_interface = { |
| 411 &LaunchSelLdr, | 411 &LaunchSelLdr, |
| 412 &StartPpapiProxy, | 412 &StartPpapiProxy, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 423 &DispatchEvent | 423 &DispatchEvent |
| 424 }; | 424 }; |
| 425 | 425 |
| 426 } // namespace | 426 } // namespace |
| 427 | 427 |
| 428 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { | 428 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { |
| 429 return &nacl_interface; | 429 return &nacl_interface; |
| 430 } | 430 } |
| 431 | 431 |
| 432 #endif // DISABLE_NACL | 432 #endif // DISABLE_NACL |
| OLD | NEW |