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, |
18 const char* format_name) { | 18 const char* format_name) { |
19 EnterInstance enter(instance); | 19 EnterInstanceAPI<PPB_Flash_Clipboard_API> enter(instance, |
20 FLASH_CLIPBOARD_SINGLETON_ID); | |
raymes
2012/11/20 21:14:59
Note that we could make this even easier by associ
raymes
2012/11/20 23:30:23
Done.
| |
20 if (enter.failed()) | 21 if (enter.failed()) |
21 return PP_FALSE; | 22 return PP_FALSE; |
22 return enter.functions()->GetFlashClipboardAPI( | 23 return enter.functions()->RegisterCustomFormat(instance, format_name); |
23 instance)->RegisterCustomFormat(instance, format_name); | |
24 } | 24 } |
25 | 25 |
26 PP_Bool IsFormatAvailable(PP_Instance instance, | 26 PP_Bool IsFormatAvailable(PP_Instance instance, |
27 PP_Flash_Clipboard_Type clipboard_type, | 27 PP_Flash_Clipboard_Type clipboard_type, |
28 uint32_t format) { | 28 uint32_t format) { |
29 EnterInstance enter(instance); | 29 EnterInstanceAPI<PPB_Flash_Clipboard_API> enter(instance, |
30 FLASH_CLIPBOARD_SINGLETON_ID); | |
30 if (enter.failed()) | 31 if (enter.failed()) |
31 return PP_FALSE; | 32 return PP_FALSE; |
32 return enter.functions()->GetFlashClipboardAPI( | 33 return enter.functions()->IsFormatAvailable(instance, clipboard_type, format); |
33 instance)->IsFormatAvailable(instance, clipboard_type, format); | |
34 } | 34 } |
35 | 35 |
36 PP_Var ReadData(PP_Instance instance, | 36 PP_Var ReadData(PP_Instance instance, |
37 PP_Flash_Clipboard_Type clipboard_type, | 37 PP_Flash_Clipboard_Type clipboard_type, |
38 uint32_t format) { | 38 uint32_t format) { |
39 EnterInstance enter(instance); | 39 EnterInstanceAPI<PPB_Flash_Clipboard_API> enter(instance, |
40 FLASH_CLIPBOARD_SINGLETON_ID); | |
40 if (enter.failed()) | 41 if (enter.failed()) |
41 return PP_MakeUndefined(); | 42 return PP_MakeUndefined(); |
42 return enter.functions()->GetFlashClipboardAPI(instance)->ReadData( | 43 return enter.functions()->ReadData(instance, clipboard_type, format); |
43 instance, clipboard_type, format); | |
44 } | 44 } |
45 | 45 |
46 int32_t WriteData(PP_Instance instance, | 46 int32_t WriteData(PP_Instance instance, |
47 PP_Flash_Clipboard_Type clipboard_type, | 47 PP_Flash_Clipboard_Type clipboard_type, |
48 uint32_t data_item_count, | 48 uint32_t data_item_count, |
49 const uint32_t formats[], | 49 const uint32_t formats[], |
50 const PP_Var data_items[]) { | 50 const PP_Var data_items[]) { |
51 EnterInstance enter(instance); | 51 EnterInstanceAPI<PPB_Flash_Clipboard_API> enter(instance, |
52 FLASH_CLIPBOARD_SINGLETON_ID); | |
52 if (enter.failed()) | 53 if (enter.failed()) |
53 return enter.retval(); | 54 return enter.retval(); |
54 return enter.functions()->GetFlashClipboardAPI(instance)->WriteData( | 55 return enter.functions()->WriteData( |
55 instance, clipboard_type, data_item_count, formats, data_items); | 56 instance, clipboard_type, data_item_count, formats, data_items); |
56 } | 57 } |
57 | 58 |
58 PP_Bool IsFormatAvailable_4_0(PP_Instance instance, | 59 PP_Bool IsFormatAvailable_4_0(PP_Instance instance, |
59 PP_Flash_Clipboard_Type clipboard_type, | 60 PP_Flash_Clipboard_Type clipboard_type, |
60 PP_Flash_Clipboard_Format format) { | 61 PP_Flash_Clipboard_Format format) { |
61 return IsFormatAvailable(instance, clipboard_type, | 62 return IsFormatAvailable(instance, clipboard_type, |
62 static_cast<uint32_t>(format)); | 63 static_cast<uint32_t>(format)); |
63 } | 64 } |
64 | 65 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 const PPB_Flash_Clipboard_4_0* GetPPB_Flash_Clipboard_4_0_Thunk() { | 99 const PPB_Flash_Clipboard_4_0* GetPPB_Flash_Clipboard_4_0_Thunk() { |
99 return &g_ppb_flash_clipboard_thunk_4_0; | 100 return &g_ppb_flash_clipboard_thunk_4_0; |
100 } | 101 } |
101 | 102 |
102 const PPB_Flash_Clipboard_5_0* GetPPB_Flash_Clipboard_5_0_Thunk() { | 103 const PPB_Flash_Clipboard_5_0* GetPPB_Flash_Clipboard_5_0_Thunk() { |
103 return &g_ppb_flash_clipboard_thunk_5_0; | 104 return &g_ppb_flash_clipboard_thunk_5_0; |
104 } | 105 } |
105 | 106 |
106 } // namespace thunk | 107 } // namespace thunk |
107 } // namespace ppapi | 108 } // namespace ppapi |
OLD | NEW |