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

Side by Side Diff: ppapi/cpp/private/flash_clipboard.cc

Issue 915403003: Enable size_t to int truncation warnings in PPAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ppapi_unittests win x64 Created 5 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
« no previous file with comments | « ppapi/cpp/private/content_decryptor_private.cc ('k') | ppapi/examples/gamepad/gamepad.cc » ('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/cpp/private/flash_clipboard.h" 5 #include "ppapi/cpp/private/flash_clipboard.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ppapi/c/pp_bool.h" 9 #include "ppapi/c/pp_bool.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 const uint32_t* formats_ptr(NULL); 126 const uint32_t* formats_ptr(NULL);
127 const PP_Var* data_items_ptr(NULL); 127 const PP_Var* data_items_ptr(NULL);
128 if (data_items.size() > 0) { 128 if (data_items.size() > 0) {
129 formats_ptr = &formats[0]; 129 formats_ptr = &formats[0];
130 data_items_ptr = &data_items_vector[0]; 130 data_items_ptr = &data_items_vector[0];
131 } 131 }
132 132
133 rv = (get_interface<PPB_Flash_Clipboard_5_1>()->WriteData( 133 rv = (get_interface<PPB_Flash_Clipboard_5_1>()->WriteData(
134 instance.pp_instance(), 134 instance.pp_instance(),
135 clipboard_type, 135 clipboard_type,
136 data_items.size(), 136 static_cast<uint32_t>(data_items.size()),
137 formats_ptr, 137 formats_ptr,
138 data_items_ptr) == PP_OK); 138 data_items_ptr) == PP_OK);
139 } else if (has_interface<PPB_Flash_Clipboard_5_0>()) { 139 } else if (has_interface<PPB_Flash_Clipboard_5_0>()) {
140 // Convert vector of pp::Var into a vector of PP_Var. 140 // Convert vector of pp::Var into a vector of PP_Var.
141 std::vector<PP_Var> data_items_vector; 141 std::vector<PP_Var> data_items_vector;
142 for (uint32_t i = 0; i < data_items.size(); ++i) 142 for (uint32_t i = 0; i < data_items.size(); ++i)
143 data_items_vector.push_back(data_items[i].pp_var()); 143 data_items_vector.push_back(data_items[i].pp_var());
144 144
145 // Ensure that we don't dereference the memory in empty vectors. We still 145 // Ensure that we don't dereference the memory in empty vectors. We still
146 // want to call WriteData because it has the effect of clearing the 146 // want to call WriteData because it has the effect of clearing the
147 // clipboard. 147 // clipboard.
148 const uint32_t* formats_ptr(NULL); 148 const uint32_t* formats_ptr(NULL);
149 const PP_Var* data_items_ptr(NULL); 149 const PP_Var* data_items_ptr(NULL);
150 if (data_items.size() > 0) { 150 if (data_items.size() > 0) {
151 formats_ptr = &formats[0]; 151 formats_ptr = &formats[0];
152 data_items_ptr = &data_items_vector[0]; 152 data_items_ptr = &data_items_vector[0];
153 } 153 }
154 154
155 rv = (get_interface<PPB_Flash_Clipboard_5_0>()->WriteData( 155 rv = (get_interface<PPB_Flash_Clipboard_5_0>()->WriteData(
156 instance.pp_instance(), 156 instance.pp_instance(),
157 clipboard_type, 157 clipboard_type,
158 data_items.size(), 158 static_cast<uint32_t>(data_items.size()),
159 formats_ptr, 159 formats_ptr,
160 data_items_ptr) == PP_OK); 160 data_items_ptr) == PP_OK);
161 } else if (has_interface<PPB_Flash_Clipboard_4_0>()) { 161 } else if (has_interface<PPB_Flash_Clipboard_4_0>()) {
162 // Convert vector of pp::Var into a vector of PP_Var. 162 // Convert vector of pp::Var into a vector of PP_Var.
163 std::vector<PP_Var> data_items_vector; 163 std::vector<PP_Var> data_items_vector;
164 std::vector<PP_Flash_Clipboard_Format> old_formats; 164 std::vector<PP_Flash_Clipboard_Format> old_formats;
165 for (uint32_t i = 0; i < data_items.size(); ++i) { 165 for (uint32_t i = 0; i < data_items.size(); ++i) {
166 data_items_vector.push_back(data_items[i].pp_var()); 166 data_items_vector.push_back(data_items[i].pp_var());
167 old_formats.push_back(static_cast<PP_Flash_Clipboard_Format>(formats[i])); 167 old_formats.push_back(static_cast<PP_Flash_Clipboard_Format>(formats[i]));
168 } 168 }
169 169
170 // Ensure that we don't dereference the memory in empty vectors. We still 170 // Ensure that we don't dereference the memory in empty vectors. We still
171 // want to call WriteData because it has the effect of clearing the 171 // want to call WriteData because it has the effect of clearing the
172 // clipboard. 172 // clipboard.
173 const PP_Flash_Clipboard_Format* formats_ptr(NULL); 173 const PP_Flash_Clipboard_Format* formats_ptr(NULL);
174 const PP_Var* data_items_ptr(NULL); 174 const PP_Var* data_items_ptr(NULL);
175 if (data_items.size() > 0) { 175 if (data_items.size() > 0) {
176 formats_ptr = &old_formats[0]; 176 formats_ptr = &old_formats[0];
177 data_items_ptr = &data_items_vector[0]; 177 data_items_ptr = &data_items_vector[0];
178 } 178 }
179 179
180 rv = (get_interface<PPB_Flash_Clipboard_4_0>()->WriteData( 180 rv = (get_interface<PPB_Flash_Clipboard_4_0>()->WriteData(
181 instance.pp_instance(), 181 instance.pp_instance(),
182 clipboard_type, 182 clipboard_type,
183 data_items.size(), 183 static_cast<uint32_t>(data_items.size()),
184 formats_ptr, 184 formats_ptr,
185 data_items_ptr) == PP_OK); 185 data_items_ptr) == PP_OK);
186 } 186 }
187 187
188 return rv; 188 return rv;
189 } 189 }
190 190
191 // static 191 // static
192 bool Clipboard::GetSequenceNumber(const InstanceHandle& instance, 192 bool Clipboard::GetSequenceNumber(const InstanceHandle& instance,
193 PP_Flash_Clipboard_Type clipboard_type, 193 PP_Flash_Clipboard_Type clipboard_type,
194 uint64_t* sequence_number) { 194 uint64_t* sequence_number) {
195 if (has_interface<PPB_Flash_Clipboard_5_1>()) { 195 if (has_interface<PPB_Flash_Clipboard_5_1>()) {
196 return PP_ToBool( 196 return PP_ToBool(
197 get_interface<PPB_Flash_Clipboard_5_1>()->GetSequenceNumber( 197 get_interface<PPB_Flash_Clipboard_5_1>()->GetSequenceNumber(
198 instance.pp_instance(), clipboard_type, sequence_number)); 198 instance.pp_instance(), clipboard_type, sequence_number));
199 } 199 }
200 return false; 200 return false;
201 } 201 }
202 202
203 } // namespace flash 203 } // namespace flash
204 } // namespace pp 204 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/private/content_decryptor_private.cc ('k') | ppapi/examples/gamepad/gamepad.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698