| 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 "ppapi/proxy/flash_clipboard_resource.h" | 5 #include "ppapi/proxy/flash_clipboard_resource.h" |
| 6 | 6 |
| 7 #include "base/numerics/safe_conversions.h" |
| 7 #include "ipc/ipc_message.h" | 8 #include "ipc/ipc_message.h" |
| 8 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
| 10 #include "ppapi/shared_impl/ppapi_globals.h" | 11 #include "ppapi/shared_impl/ppapi_globals.h" |
| 11 #include "ppapi/shared_impl/var.h" | 12 #include "ppapi/shared_impl/var.h" |
| 12 #include "ppapi/shared_impl/var_tracker.h" | 13 #include "ppapi/shared_impl/var_tracker.h" |
| 13 | 14 |
| 14 namespace ppapi { | 15 namespace ppapi { |
| 15 namespace proxy { | 16 namespace proxy { |
| 16 | 17 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 46 } | 47 } |
| 47 | 48 |
| 48 PP_Var ClipboardStringToPPVar(int32_t format, | 49 PP_Var ClipboardStringToPPVar(int32_t format, |
| 49 const std::string& string) { | 50 const std::string& string) { |
| 50 if (format == PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT || | 51 if (format == PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT || |
| 51 format == PP_FLASH_CLIPBOARD_FORMAT_HTML) { | 52 format == PP_FLASH_CLIPBOARD_FORMAT_HTML) { |
| 52 return StringVar::StringToPPVar(string); | 53 return StringVar::StringToPPVar(string); |
| 53 } else { | 54 } else { |
| 54 // All other formats are expected to be array buffers. | 55 // All other formats are expected to be array buffers. |
| 55 return PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( | 56 return PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
| 56 string.size(), string.data()); | 57 base::checked_cast<uint32_t>(string.size()), string.data()); |
| 57 } | 58 } |
| 58 } | 59 } |
| 59 } // namespace | 60 } // namespace |
| 60 | 61 |
| 61 FlashClipboardResource::FlashClipboardResource( | 62 FlashClipboardResource::FlashClipboardResource( |
| 62 Connection connection, PP_Instance instance) | 63 Connection connection, PP_Instance instance) |
| 63 : PluginResource(connection, instance) { | 64 : PluginResource(connection, instance) { |
| 64 SendCreate(BROWSER, PpapiHostMsg_FlashClipboard_Create()); | 65 SendCreate(BROWSER, PpapiHostMsg_FlashClipboard_Create()); |
| 65 } | 66 } |
| 66 | 67 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 int32_t result = | 160 int32_t result = |
| 160 SyncCall<PpapiPluginMsg_FlashClipboard_GetSequenceNumberReply>( | 161 SyncCall<PpapiPluginMsg_FlashClipboard_GetSequenceNumberReply>( |
| 161 BROWSER, | 162 BROWSER, |
| 162 PpapiHostMsg_FlashClipboard_GetSequenceNumber(clipboard_type), | 163 PpapiHostMsg_FlashClipboard_GetSequenceNumber(clipboard_type), |
| 163 sequence_number); | 164 sequence_number); |
| 164 return PP_FromBool(result == PP_OK); | 165 return PP_FromBool(result == PP_OK); |
| 165 } | 166 } |
| 166 | 167 |
| 167 } // namespace proxy | 168 } // namespace proxy |
| 168 } // namespace ppapi | 169 } // namespace ppapi |
| OLD | NEW |