Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: ppapi/thunk/ppb_flash_clipboard_thunk.cc

Issue 9212066: Modified the flash cipboard interface to add html clipboard support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ppapi/c/pp_errors.h" 5 #include "ppapi/c/pp_errors.h"
6 #include "ppapi/c/private/ppb_flash_clipboard.h" 6 #include "ppapi/c/private/ppb_flash_clipboard.h"
7 #include "ppapi/thunk/enter.h" 7 #include "ppapi/thunk/enter.h"
8 #include "ppapi/thunk/thunk.h" 8 #include "ppapi/thunk/thunk.h"
9 #include "ppapi/thunk/ppb_flash_clipboard_api.h" 9 #include "ppapi/thunk/ppb_flash_clipboard_api.h"
10 10
11 namespace ppapi { 11 namespace ppapi {
12 namespace thunk { 12 namespace thunk {
13 13
14 namespace { 14 namespace {
15 15
16 typedef EnterFunction<PPB_Flash_Clipboard_FunctionAPI> EnterFlashClipboard; 16 typedef EnterFunction<PPB_Flash_Clipboard_FunctionAPI> EnterFlashClipboard;
17 17
18 PP_Bool IsFormatAvailable(PP_Instance instance, 18 PP_Bool IsFormatAvailable(PP_Instance instance,
19 PP_Flash_Clipboard_Type clipboard_type, 19 PP_Flash_Clipboard_Type clipboard_type,
20 PP_Flash_Clipboard_Format format) { 20 PP_Flash_Clipboard_Format format) {
21 EnterFlashClipboard enter(instance, true); 21 EnterFlashClipboard enter(instance, true);
22 if (enter.failed()) 22 if (enter.failed())
23 return PP_FALSE; 23 return PP_FALSE;
24 return enter.functions()->IsFormatAvailable(instance, clipboard_type, format); 24 return enter.functions()->IsFormatAvailable(instance, clipboard_type, format);
25 } 25 }
26 26
27 PP_Var ReadData(PP_Instance instance,
28 PP_Flash_Clipboard_Type clipboard_type,
29 PP_Flash_Clipboard_Format format) {
30 EnterFlashClipboard enter(instance, true);
31 if (enter.failed())
32 return PP_MakeUndefined();
33 return enter.functions()->ReadData(instance, clipboard_type, format);
34 }
35
36 int32_t WriteData(PP_Instance instance,
37 PP_Flash_Clipboard_Type clipboard_type,
38 uint32_t data_item_count,
39 const struct PP_Flash_Clipboard_Data_Item data_items[]) {
40 EnterFlashClipboard enter(instance, true);
41 if (enter.failed())
42 return PP_ERROR_NOINTERFACE;
43 return enter.functions()->WriteData(instance, clipboard_type, data_item_count,
44 data_items);
45 }
46
27 PP_Var ReadPlainText(PP_Instance instance, 47 PP_Var ReadPlainText(PP_Instance instance,
28 PP_Flash_Clipboard_Type clipboard_type) { 48 PP_Flash_Clipboard_Type clipboard_type) {
29 EnterFlashClipboard enter(instance, true); 49 return ReadData(instance, clipboard_type,
30 if (enter.failed()) 50 PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT);
31 return PP_MakeUndefined();
32 return enter.functions()->ReadPlainText(instance, clipboard_type);
33 } 51 }
34 52
35 int32_t WritePlainText(PP_Instance instance, 53 int32_t WritePlainText(PP_Instance instance,
36 PP_Flash_Clipboard_Type clipboard_type, 54 PP_Flash_Clipboard_Type clipboard_type,
37 PP_Var text) { 55 PP_Var text) {
38 EnterFlashClipboard enter(instance, true); 56 PP_Flash_Clipboard_Data_Item data_item =
39 if (enter.failed()) 57 { PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT, text };
40 return PP_ERROR_NOINTERFACE; 58 return WriteData(instance, clipboard_type, 1, &data_item);
41 return enter.functions()->WritePlainText(instance, clipboard_type, text);
42 } 59 }
43 60
44 const PPB_Flash_Clipboard g_ppb_flash_clipboard_thunk = { 61 const PPB_Flash_Clipboard_3_0 g_ppb_flash_clipboard_thunk_3_0 = {
45 &IsFormatAvailable, 62 &IsFormatAvailable,
46 &ReadPlainText, 63 &ReadPlainText,
47 &WritePlainText 64 &WritePlainText
48 }; 65 };
49 66
67 const PPB_Flash_Clipboard_4_0 g_ppb_flash_clipboard_thunk_4_0 = {
68 &IsFormatAvailable,
69 &ReadData,
70 &WriteData
71 };
72
50 } // namespace 73 } // namespace
51 74
52 const PPB_Flash_Clipboard_3_0* GetPPB_Flash_Clipboard_3_0_Thunk() { 75 const PPB_Flash_Clipboard_3_0* GetPPB_Flash_Clipboard_3_0_Thunk() {
53 return &g_ppb_flash_clipboard_thunk; 76 return &g_ppb_flash_clipboard_thunk_3_0;
77 }
78
79 const PPB_Flash_Clipboard_4_0* GetPPB_Flash_Clipboard_4_0_Thunk() {
80 return &g_ppb_flash_clipboard_thunk_4_0;
54 } 81 }
55 82
56 } // namespace thunk 83 } // namespace thunk
57 } // namespace ppapi 84 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698