| 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 "webkit/plugins/ppapi/ppb_flash_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_flash_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 #endif | 516 #endif |
| 517 size_t size = name.size() + 1; | 517 size_t size = name.size() + 1; |
| 518 char* name_copy = new char[size]; | 518 char* name_copy = new char[size]; |
| 519 memcpy(name_copy, name.c_str(), size); | 519 memcpy(name_copy, name.c_str(), size); |
| 520 entry.name = name_copy; | 520 entry.name = name_copy; |
| 521 entry.is_dir = BoolToPPBool(pepper_contents[i].is_dir); | 521 entry.is_dir = BoolToPPBool(pepper_contents[i].is_dir); |
| 522 } | 522 } |
| 523 return PP_OK; | 523 return PP_OK; |
| 524 } | 524 } |
| 525 | 525 |
| 526 int32_t PPB_Flash_Impl::CreateTemporaryFile(PP_Instance instance, |
| 527 const char* dir_path, |
| 528 PP_FileHandle* file, |
| 529 std::string* file_name) { |
| 530 if (!dir_path || !file || !file_name) |
| 531 return PP_ERROR_BADARGUMENT; |
| 532 |
| 533 PluginInstance* plugin_instance = HostGlobals::Get()->GetInstance(instance); |
| 534 if (!plugin_instance) { |
| 535 *file = PP_kInvalidFileHandle; |
| 536 file_name->clear(); |
| 537 return PP_ERROR_FAILED; |
| 538 } |
| 539 |
| 540 base::PlatformFile temp_file = base::kInvalidPlatformFileValue; |
| 541 base::PlatformFileError result = |
| 542 plugin_instance->delegate()->CreateTemporaryFile( |
| 543 ::ppapi::PepperFilePath::MakeModuleLocal( |
| 544 plugin_instance->module()->name(), dir_path), |
| 545 &temp_file, file_name); |
| 546 *file = temp_file; |
| 547 return ::ppapi::PlatformFileErrorToPepperError(result); |
| 548 } |
| 549 |
| 526 int32_t PPB_Flash_Impl::OpenFileRef(PP_Instance pp_instance, | 550 int32_t PPB_Flash_Impl::OpenFileRef(PP_Instance pp_instance, |
| 527 PP_Resource file_ref_id, | 551 PP_Resource file_ref_id, |
| 528 int32_t mode, | 552 int32_t mode, |
| 529 PP_FileHandle* file) { | 553 PP_FileHandle* file) { |
| 530 int flags = 0; | 554 int flags = 0; |
| 531 if (!::ppapi::PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || !file) | 555 if (!::ppapi::PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || !file) |
| 532 return PP_ERROR_BADARGUMENT; | 556 return PP_ERROR_BADARGUMENT; |
| 533 | 557 |
| 534 EnterResourceNoLock<PPB_FileRef_API> enter(file_ref_id, true); | 558 EnterResourceNoLock<PPB_FileRef_API> enter(file_ref_id, true); |
| 535 if (enter.failed()) | 559 if (enter.failed()) |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 } | 673 } |
| 650 case PP_FLASH_CLIPBOARD_FORMAT_INVALID: | 674 case PP_FLASH_CLIPBOARD_FORMAT_INVALID: |
| 651 break; | 675 break; |
| 652 } | 676 } |
| 653 | 677 |
| 654 return PP_ERROR_BADARGUMENT; | 678 return PP_ERROR_BADARGUMENT; |
| 655 } | 679 } |
| 656 | 680 |
| 657 } // namespace ppapi | 681 } // namespace ppapi |
| 658 } // namespace webkit | 682 } // namespace webkit |
| OLD | NEW |