| 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "ppapi/c/pp_errors.h" | 6 #include "ppapi/c/pp_errors.h" |
| 7 #include "ppapi/c/private/ppb_flash_clipboard.h" | 7 #include "ppapi/c/private/ppb_flash_clipboard.h" |
| 8 #include "ppapi/thunk/enter.h" | 8 #include "ppapi/thunk/enter.h" |
| 9 #include "ppapi/thunk/ppb_flash_clipboard_api.h" | 9 #include "ppapi/thunk/ppb_flash_clipboard_api.h" |
| 10 #include "ppapi/thunk/thunk.h" | 10 #include "ppapi/thunk/thunk.h" |
| 11 | 11 |
| 12 namespace ppapi { | 12 namespace ppapi { |
| 13 namespace thunk { | 13 namespace thunk { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 uint32_t RegisterCustomFormat(PP_Instance instance, | 17 uint32_t RegisterCustomFormat(PP_Instance instance, const char* format_name) { |
| 18 const char* format_name) { | |
| 19 EnterInstanceAPI<PPB_Flash_Clipboard_API> enter(instance); | 18 EnterInstanceAPI<PPB_Flash_Clipboard_API> enter(instance); |
| 20 if (enter.failed()) | 19 if (enter.failed()) |
| 21 return PP_FALSE; | 20 return PP_FALSE; |
| 22 return enter.functions()->RegisterCustomFormat(instance, format_name); | 21 return enter.functions()->RegisterCustomFormat(instance, format_name); |
| 23 } | 22 } |
| 24 | 23 |
| 25 PP_Bool IsFormatAvailable(PP_Instance instance, | 24 PP_Bool IsFormatAvailable(PP_Instance instance, |
| 26 PP_Flash_Clipboard_Type clipboard_type, | 25 PP_Flash_Clipboard_Type clipboard_type, |
| 27 uint32_t format) { | 26 uint32_t format) { |
| 28 EnterInstanceAPI<PPB_Flash_Clipboard_API> enter(instance); | 27 EnterInstanceAPI<PPB_Flash_Clipboard_API> enter(instance); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 48 EnterInstanceAPI<PPB_Flash_Clipboard_API> enter(instance); | 47 EnterInstanceAPI<PPB_Flash_Clipboard_API> enter(instance); |
| 49 if (enter.failed()) | 48 if (enter.failed()) |
| 50 return enter.retval(); | 49 return enter.retval(); |
| 51 return enter.functions()->WriteData( | 50 return enter.functions()->WriteData( |
| 52 instance, clipboard_type, data_item_count, formats, data_items); | 51 instance, clipboard_type, data_item_count, formats, data_items); |
| 53 } | 52 } |
| 54 | 53 |
| 55 PP_Bool IsFormatAvailable_4_0(PP_Instance instance, | 54 PP_Bool IsFormatAvailable_4_0(PP_Instance instance, |
| 56 PP_Flash_Clipboard_Type clipboard_type, | 55 PP_Flash_Clipboard_Type clipboard_type, |
| 57 PP_Flash_Clipboard_Format format) { | 56 PP_Flash_Clipboard_Format format) { |
| 58 return IsFormatAvailable(instance, clipboard_type, | 57 return IsFormatAvailable( |
| 59 static_cast<uint32_t>(format)); | 58 instance, clipboard_type, static_cast<uint32_t>(format)); |
| 60 } | 59 } |
| 61 | 60 |
| 62 PP_Var ReadData_4_0(PP_Instance instance, | 61 PP_Var ReadData_4_0(PP_Instance instance, |
| 63 PP_Flash_Clipboard_Type clipboard_type, | 62 PP_Flash_Clipboard_Type clipboard_type, |
| 64 PP_Flash_Clipboard_Format format) { | 63 PP_Flash_Clipboard_Format format) { |
| 65 return ReadData(instance, clipboard_type, static_cast<uint32_t>(format)); | 64 return ReadData(instance, clipboard_type, static_cast<uint32_t>(format)); |
| 66 } | 65 } |
| 67 | 66 |
| 68 int32_t WriteData_4_0(PP_Instance instance, | 67 int32_t WriteData_4_0(PP_Instance instance, |
| 69 PP_Flash_Clipboard_Type clipboard_type, | 68 PP_Flash_Clipboard_Type clipboard_type, |
| 70 uint32_t data_item_count, | 69 uint32_t data_item_count, |
| 71 const PP_Flash_Clipboard_Format formats[], | 70 const PP_Flash_Clipboard_Format formats[], |
| 72 const PP_Var data_items[]) { | 71 const PP_Var data_items[]) { |
| 73 scoped_ptr<uint32_t[]> new_formats(new uint32_t[data_item_count]); | 72 scoped_ptr<uint32_t[]> new_formats(new uint32_t[data_item_count]); |
| 74 for (uint32_t i = 0; i < data_item_count; ++i) | 73 for (uint32_t i = 0; i < data_item_count; ++i) |
| 75 new_formats[i] = static_cast<uint32_t>(formats[i]); | 74 new_formats[i] = static_cast<uint32_t>(formats[i]); |
| 76 return WriteData(instance, clipboard_type, data_item_count, | 75 return WriteData( |
| 77 new_formats.get(), data_items); | 76 instance, clipboard_type, data_item_count, new_formats.get(), data_items); |
| 78 } | 77 } |
| 79 | 78 |
| 80 PP_Bool GetSequenceNumber(PP_Instance instance, | 79 PP_Bool GetSequenceNumber(PP_Instance instance, |
| 81 PP_Flash_Clipboard_Type clipboard_type, | 80 PP_Flash_Clipboard_Type clipboard_type, |
| 82 uint64_t* sequence_number) { | 81 uint64_t* sequence_number) { |
| 83 EnterInstanceAPI<PPB_Flash_Clipboard_API> enter(instance); | 82 EnterInstanceAPI<PPB_Flash_Clipboard_API> enter(instance); |
| 84 if (enter.failed()) | 83 if (enter.failed()) |
| 85 return PP_FALSE; | 84 return PP_FALSE; |
| 86 return enter.functions()->GetSequenceNumber(instance, clipboard_type, | 85 return enter.functions()->GetSequenceNumber( |
| 87 sequence_number); | 86 instance, clipboard_type, sequence_number); |
| 88 } | 87 } |
| 89 | 88 |
| 90 const PPB_Flash_Clipboard_4_0 g_ppb_flash_clipboard_thunk_4_0 = { | 89 const PPB_Flash_Clipboard_4_0 g_ppb_flash_clipboard_thunk_4_0 = { |
| 91 &IsFormatAvailable_4_0, | 90 &IsFormatAvailable_4_0, &ReadData_4_0, &WriteData_4_0}; |
| 92 &ReadData_4_0, | |
| 93 &WriteData_4_0 | |
| 94 }; | |
| 95 | 91 |
| 96 const PPB_Flash_Clipboard_5_0 g_ppb_flash_clipboard_thunk_5_0 = { | 92 const PPB_Flash_Clipboard_5_0 g_ppb_flash_clipboard_thunk_5_0 = { |
| 97 &RegisterCustomFormat, | 93 &RegisterCustomFormat, &IsFormatAvailable, &ReadData, &WriteData}; |
| 98 &IsFormatAvailable, | |
| 99 &ReadData, | |
| 100 &WriteData | |
| 101 }; | |
| 102 | 94 |
| 103 const PPB_Flash_Clipboard_5_1 g_ppb_flash_clipboard_thunk_5_1 = { | 95 const PPB_Flash_Clipboard_5_1 g_ppb_flash_clipboard_thunk_5_1 = { |
| 104 &RegisterCustomFormat, | 96 &RegisterCustomFormat, &IsFormatAvailable, &ReadData, &WriteData, |
| 105 &IsFormatAvailable, | 97 &GetSequenceNumber}; |
| 106 &ReadData, | |
| 107 &WriteData, | |
| 108 &GetSequenceNumber | |
| 109 }; | |
| 110 | 98 |
| 111 } // namespace | 99 } // namespace |
| 112 | 100 |
| 113 const PPB_Flash_Clipboard_4_0* GetPPB_Flash_Clipboard_4_0_Thunk() { | 101 const PPB_Flash_Clipboard_4_0* GetPPB_Flash_Clipboard_4_0_Thunk() { |
| 114 return &g_ppb_flash_clipboard_thunk_4_0; | 102 return &g_ppb_flash_clipboard_thunk_4_0; |
| 115 } | 103 } |
| 116 | 104 |
| 117 const PPB_Flash_Clipboard_5_0* GetPPB_Flash_Clipboard_5_0_Thunk() { | 105 const PPB_Flash_Clipboard_5_0* GetPPB_Flash_Clipboard_5_0_Thunk() { |
| 118 return &g_ppb_flash_clipboard_thunk_5_0; | 106 return &g_ppb_flash_clipboard_thunk_5_0; |
| 119 } | 107 } |
| 120 | 108 |
| 121 const PPB_Flash_Clipboard_5_1* GetPPB_Flash_Clipboard_5_1_Thunk() { | 109 const PPB_Flash_Clipboard_5_1* GetPPB_Flash_Clipboard_5_1_Thunk() { |
| 122 return &g_ppb_flash_clipboard_thunk_5_1; | 110 return &g_ppb_flash_clipboard_thunk_5_1; |
| 123 } | 111 } |
| 124 | 112 |
| 125 } // namespace thunk | 113 } // namespace thunk |
| 126 } // namespace ppapi | 114 } // namespace ppapi |
| OLD | NEW |