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

Side by Side Diff: ppapi/proxy/ppb_flash_clipboard_proxy.cc

Issue 9921018: Added RTF support to pepper API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 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/c/private/ppb_flash_clipboard.h ('k') | ppapi/tests/test_flash_clipboard.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/proxy/ppb_flash_clipboard_proxy.h" 5 #include "ppapi/proxy/ppb_flash_clipboard_proxy.h"
6 6
7 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/private/ppb_flash_clipboard.h" 8 #include "ppapi/c/private/ppb_flash_clipboard.h"
9 #include "ppapi/proxy/plugin_dispatcher.h" 9 #include "ppapi/proxy/plugin_dispatcher.h"
10 #include "ppapi/proxy/ppapi_messages.h" 10 #include "ppapi/proxy/ppapi_messages.h"
(...skipping 11 matching lines...) Expand all
22 EnterFlashClipboardNoLock; 22 EnterFlashClipboardNoLock;
23 23
24 bool IsValidClipboardType(PP_Flash_Clipboard_Type clipboard_type) { 24 bool IsValidClipboardType(PP_Flash_Clipboard_Type clipboard_type) {
25 return clipboard_type == PP_FLASH_CLIPBOARD_TYPE_STANDARD || 25 return clipboard_type == PP_FLASH_CLIPBOARD_TYPE_STANDARD ||
26 clipboard_type == PP_FLASH_CLIPBOARD_TYPE_SELECTION; 26 clipboard_type == PP_FLASH_CLIPBOARD_TYPE_SELECTION;
27 } 27 }
28 28
29 bool IsValidClipboardFormat(PP_Flash_Clipboard_Format format) { 29 bool IsValidClipboardFormat(PP_Flash_Clipboard_Format format) {
30 // Purposely excludes |PP_FLASH_CLIPBOARD_FORMAT_INVALID|. 30 // Purposely excludes |PP_FLASH_CLIPBOARD_FORMAT_INVALID|.
31 return format == PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT || 31 return format == PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT ||
32 format == PP_FLASH_CLIPBOARD_FORMAT_HTML; 32 format == PP_FLASH_CLIPBOARD_FORMAT_HTML ||
33 format == PP_FLASH_CLIPBOARD_FORMAT_RTF;
33 } 34 }
34 35
35 } // namespace 36 } // namespace
36 37
37 PPB_Flash_Clipboard_Proxy::PPB_Flash_Clipboard_Proxy(Dispatcher* dispatcher) 38 PPB_Flash_Clipboard_Proxy::PPB_Flash_Clipboard_Proxy(Dispatcher* dispatcher)
38 : InterfaceProxy(dispatcher) { 39 : InterfaceProxy(dispatcher) {
39 } 40 }
40 41
41 PPB_Flash_Clipboard_Proxy::~PPB_Flash_Clipboard_Proxy() { 42 PPB_Flash_Clipboard_Proxy::~PPB_Flash_Clipboard_Proxy() {
42 } 43 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 80
80 int32_t PPB_Flash_Clipboard_Proxy::WriteData( 81 int32_t PPB_Flash_Clipboard_Proxy::WriteData(
81 PP_Instance instance, 82 PP_Instance instance,
82 PP_Flash_Clipboard_Type clipboard_type, 83 PP_Flash_Clipboard_Type clipboard_type,
83 uint32_t data_item_count, 84 uint32_t data_item_count,
84 const PP_Flash_Clipboard_Format formats[], 85 const PP_Flash_Clipboard_Format formats[],
85 const PP_Var data_items[]) { 86 const PP_Var data_items[]) {
86 if (!IsValidClipboardType(clipboard_type)) 87 if (!IsValidClipboardType(clipboard_type))
87 return PP_ERROR_BADARGUMENT; 88 return PP_ERROR_BADARGUMENT;
88 89
90 for (size_t i = 0; i < data_item_count; ++i) {
91 if (!IsValidClipboardFormat(formats[i]))
92 return PP_ERROR_BADARGUMENT;
93 }
94
89 std::vector<int> formats_vector(formats, formats + data_item_count); 95 std::vector<int> formats_vector(formats, formats + data_item_count);
90 96
91 std::vector<SerializedVar> data_items_vector; 97 std::vector<SerializedVar> data_items_vector;
92 SerializedVarSendInput::ConvertVector( 98 SerializedVarSendInput::ConvertVector(
93 dispatcher(), 99 dispatcher(),
94 data_items, 100 data_items,
95 data_item_count, 101 data_item_count,
96 &data_items_vector); 102 &data_items_vector);
97 103
98 dispatcher()->Send(new PpapiHostMsg_PPBFlashClipboard_WriteData( 104 dispatcher()->Send(new PpapiHostMsg_PPBFlashClipboard_WriteData(
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 formats_array.get(), 180 formats_array.get(),
175 data_items_array); 181 data_items_array);
176 DLOG_IF(WARNING, result != PP_OK) 182 DLOG_IF(WARNING, result != PP_OK)
177 << "Write to clipboard failed unexpectedly."; 183 << "Write to clipboard failed unexpectedly.";
178 (void)result; // Prevent warning in release mode. 184 (void)result; // Prevent warning in release mode.
179 } 185 }
180 } 186 }
181 187
182 } // namespace proxy 188 } // namespace proxy
183 } // namespace ppapi 189 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/c/private/ppb_flash_clipboard.h ('k') | ppapi/tests/test_flash_clipboard.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698