| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/plugin_module.h" | 5 #include "webkit/plugins/ppapi/plugin_module.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 plugin_instance->SimulateInputEvent(input_event_data); | 240 plugin_instance->SimulateInputEvent(input_event_data); |
| 241 } | 241 } |
| 242 | 242 |
| 243 PP_Var GetDocumentURL(PP_Instance instance, PP_URLComponents_Dev* components) { | 243 PP_Var GetDocumentURL(PP_Instance instance, PP_URLComponents_Dev* components) { |
| 244 PluginInstance* plugin_instance = host_globals->GetInstance(instance); | 244 PluginInstance* plugin_instance = host_globals->GetInstance(instance); |
| 245 if (!plugin_instance) | 245 if (!plugin_instance) |
| 246 return PP_MakeUndefined(); | 246 return PP_MakeUndefined(); |
| 247 return plugin_instance->GetDocumentURL(instance, components); | 247 return plugin_instance->GetDocumentURL(instance, components); |
| 248 } | 248 } |
| 249 | 249 |
| 250 uint32_t GetLiveVars(PP_Var live_vars[], uint32_t array_size) { |
| 251 std::vector<PP_Var> vars = |
| 252 PpapiGlobals::Get()->GetVarTracker()->GetLiveVars(); |
| 253 for (size_t i = 0u; |
| 254 i < std::min(static_cast<size_t>(array_size), vars.size()); |
| 255 ++i) |
| 256 live_vars[i] = vars[i]; |
| 257 return vars.size(); |
| 258 } |
| 259 |
| 250 const PPB_Testing_Dev testing_interface = { | 260 const PPB_Testing_Dev testing_interface = { |
| 251 &ReadImageData, | 261 &ReadImageData, |
| 252 &RunMessageLoop, | 262 &RunMessageLoop, |
| 253 &QuitMessageLoop, | 263 &QuitMessageLoop, |
| 254 &GetLiveObjectsForInstance, | 264 &GetLiveObjectsForInstance, |
| 255 &IsOutOfProcess, | 265 &IsOutOfProcess, |
| 256 &SimulateInputEvent, | 266 &SimulateInputEvent, |
| 257 &GetDocumentURL | 267 &GetDocumentURL, |
| 268 &GetLiveVars |
| 258 }; | 269 }; |
| 259 | 270 |
| 260 // GetInterface ---------------------------------------------------------------- | 271 // GetInterface ---------------------------------------------------------------- |
| 261 | 272 |
| 262 const void* GetInterface(const char* name) { | 273 const void* GetInterface(const char* name) { |
| 263 // All interfaces should be used on the main thread. | 274 // All interfaces should be used on the main thread. |
| 264 CHECK(IsMainThread()); | 275 CHECK(IsMainThread()); |
| 265 | 276 |
| 266 // Allow custom interface factories first stab at the GetInterface call. | 277 // Allow custom interface factories first stab at the GetInterface call. |
| 267 const void* custom_interface = | 278 const void* custom_interface = |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 if (strcmp(name, PPB_FLASH_NETCONNECTOR_INTERFACE) == 0) | 355 if (strcmp(name, PPB_FLASH_NETCONNECTOR_INTERFACE) == 0) |
| 345 return ::ppapi::thunk::GetPPB_Flash_NetConnector_Thunk(); | 356 return ::ppapi::thunk::GetPPB_Flash_NetConnector_Thunk(); |
| 346 #endif // ENABLE_FLAPPER_HACKS | 357 #endif // ENABLE_FLAPPER_HACKS |
| 347 | 358 |
| 348 // Only support the testing interface when the command line switch is | 359 // Only support the testing interface when the command line switch is |
| 349 // specified. This allows us to prevent people from (ab)using this interface | 360 // specified. This allows us to prevent people from (ab)using this interface |
| 350 // in production code. | 361 // in production code. |
| 351 if (CommandLine::ForCurrentProcess()->HasSwitch( | 362 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 352 switches::kEnablePepperTesting)) { | 363 switches::kEnablePepperTesting)) { |
| 353 if (strcmp(name, PPB_TESTING_DEV_INTERFACE) == 0 || | 364 if (strcmp(name, PPB_TESTING_DEV_INTERFACE) == 0 || |
| 354 strcmp(name, PPB_TESTING_DEV_INTERFACE_0_7) == 0 || | 365 strcmp(name, PPB_TESTING_DEV_INTERFACE_0_9) == 0) { |
| 355 strcmp(name, PPB_TESTING_DEV_INTERFACE_0_8) == 0) { | |
| 356 return &testing_interface; | 366 return &testing_interface; |
| 357 } | 367 } |
| 358 } | 368 } |
| 359 return NULL; | 369 return NULL; |
| 360 } | 370 } |
| 361 | 371 |
| 362 // Gets the PPAPI entry points from the given library and places them into the | 372 // Gets the PPAPI entry points from the given library and places them into the |
| 363 // given structure. Returns true on success. | 373 // given structure. Returns true on success. |
| 364 bool LoadEntryPointsFromLibrary(const base::NativeLibrary& library, | 374 bool LoadEntryPointsFromLibrary(const base::NativeLibrary& library, |
| 365 PluginModule::EntryPoints* entry_points) { | 375 PluginModule::EntryPoints* entry_points) { |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 int retval = entry_points.initialize_module(pp_module(), &GetInterface); | 598 int retval = entry_points.initialize_module(pp_module(), &GetInterface); |
| 589 if (retval != 0) { | 599 if (retval != 0) { |
| 590 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; | 600 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; |
| 591 return false; | 601 return false; |
| 592 } | 602 } |
| 593 return true; | 603 return true; |
| 594 } | 604 } |
| 595 | 605 |
| 596 } // namespace ppapi | 606 } // namespace ppapi |
| 597 } // namespace webkit | 607 } // namespace webkit |
| OLD | NEW |