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

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
« no previous file with comments | « ppapi/thunk/ppb_flash_clipboard_api.h ('k') | ppapi/thunk/thunk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 PP_Flash_Clipboard_Format formats[],
40 const PP_Var data_items[]) {
41 EnterFlashClipboard enter(instance, true);
42 if (enter.failed())
43 return enter.retval();
44 return enter.functions()->WriteData(instance,
45 clipboard_type,
46 data_item_count,
47 formats,
48 data_items);
49 }
50
27 PP_Var ReadPlainText(PP_Instance instance, 51 PP_Var ReadPlainText(PP_Instance instance,
28 PP_Flash_Clipboard_Type clipboard_type) { 52 PP_Flash_Clipboard_Type clipboard_type) {
29 EnterFlashClipboard enter(instance, true); 53 return ReadData(instance,
30 if (enter.failed()) 54 clipboard_type,
31 return PP_MakeUndefined(); 55 PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT);
32 return enter.functions()->ReadPlainText(instance, clipboard_type);
33 } 56 }
34 57
35 int32_t WritePlainText(PP_Instance instance, 58 int32_t WritePlainText(PP_Instance instance,
36 PP_Flash_Clipboard_Type clipboard_type, 59 PP_Flash_Clipboard_Type clipboard_type,
37 PP_Var text) { 60 PP_Var text) {
38 EnterFlashClipboard enter(instance, true); 61 PP_Flash_Clipboard_Format format = PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT;
39 if (enter.failed()) 62 return WriteData(instance, clipboard_type, 1, &format, &text);
40 return enter.retval();
41 return enter.functions()->WritePlainText(instance, clipboard_type, text);
42 } 63 }
43 64
44 const PPB_Flash_Clipboard g_ppb_flash_clipboard_thunk = { 65 const PPB_Flash_Clipboard_3_0 g_ppb_flash_clipboard_thunk_3_0 = {
45 &IsFormatAvailable, 66 &IsFormatAvailable,
46 &ReadPlainText, 67 &ReadPlainText,
47 &WritePlainText 68 &WritePlainText
48 }; 69 };
49 70
71 const PPB_Flash_Clipboard_4_0 g_ppb_flash_clipboard_thunk_4_0 = {
72 &IsFormatAvailable,
73 &ReadData,
74 &WriteData
75 };
76
50 } // namespace 77 } // namespace
51 78
52 const PPB_Flash_Clipboard_3_0* GetPPB_Flash_Clipboard_3_0_Thunk() { 79 const PPB_Flash_Clipboard_3_0* GetPPB_Flash_Clipboard_3_0_Thunk() {
53 return &g_ppb_flash_clipboard_thunk; 80 return &g_ppb_flash_clipboard_thunk_3_0;
81 }
82
83 const PPB_Flash_Clipboard_4_0* GetPPB_Flash_Clipboard_4_0_Thunk() {
84 return &g_ppb_flash_clipboard_thunk_4_0;
54 } 85 }
55 86
56 } // namespace thunk 87 } // namespace thunk
57 } // namespace ppapi 88 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_flash_clipboard_api.h ('k') | ppapi/thunk/thunk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698