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

Side by Side Diff: content/browser/web_contents/web_contents_view_aura.cc

Issue 1154283003: Change most uses of Pickle to base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
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 "content/browser/web_contents/web_contents_view_aura.h" 5 #include "content/browser/web_contents/web_contents_view_aura.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 static const char kFormatString[] = "chromium/x-file-system-files"; 222 static const char kFormatString[] = "chromium/x-file-system-files";
223 CR_DEFINE_STATIC_LOCAL(ui::OSExchangeData::CustomFormat, 223 CR_DEFINE_STATIC_LOCAL(ui::OSExchangeData::CustomFormat,
224 format, 224 format,
225 (ui::Clipboard::GetFormatType(kFormatString))); 225 (ui::Clipboard::GetFormatType(kFormatString)));
226 return format; 226 return format;
227 } 227 }
228 228
229 // Writes file system files to the pickle. 229 // Writes file system files to the pickle.
230 void WriteFileSystemFilesToPickle( 230 void WriteFileSystemFilesToPickle(
231 const std::vector<DropData::FileSystemFileInfo>& file_system_files, 231 const std::vector<DropData::FileSystemFileInfo>& file_system_files,
232 Pickle* pickle) { 232 base::Pickle* pickle) {
233 pickle->WriteSizeT(file_system_files.size()); 233 pickle->WriteSizeT(file_system_files.size());
234 for (size_t i = 0; i < file_system_files.size(); ++i) { 234 for (size_t i = 0; i < file_system_files.size(); ++i) {
235 pickle->WriteString(file_system_files[i].url.spec()); 235 pickle->WriteString(file_system_files[i].url.spec());
236 pickle->WriteInt64(file_system_files[i].size); 236 pickle->WriteInt64(file_system_files[i].size);
237 } 237 }
238 } 238 }
239 239
240 // Reads file system files from the pickle. 240 // Reads file system files from the pickle.
241 bool ReadFileSystemFilesFromPickle( 241 bool ReadFileSystemFilesFromPickle(
242 const Pickle& pickle, 242 const base::Pickle& pickle,
243 std::vector<DropData::FileSystemFileInfo>* file_system_files) { 243 std::vector<DropData::FileSystemFileInfo>* file_system_files) {
244 PickleIterator iter(pickle); 244 base::PickleIterator iter(pickle);
245 245
246 size_t num_files = 0; 246 size_t num_files = 0;
247 if (!iter.ReadSizeT(&num_files)) 247 if (!iter.ReadSizeT(&num_files))
248 return false; 248 return false;
249 file_system_files->resize(num_files); 249 file_system_files->resize(num_files);
250 250
251 for (size_t i = 0; i < num_files; ++i) { 251 for (size_t i = 0; i < num_files; ++i) {
252 std::string url_string; 252 std::string url_string;
253 int64 size = 0; 253 int64 size = 0;
254 if (!iter.ReadString(&url_string) || !iter.ReadInt64(&size)) 254 if (!iter.ReadString(&url_string) || !iter.ReadInt64(&size))
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // exists. 288 // exists.
289 if (!drop_data.text.string().empty()) 289 if (!drop_data.text.string().empty())
290 provider->SetString(drop_data.text.string()); 290 provider->SetString(drop_data.text.string());
291 if (drop_data.url.is_valid()) 291 if (drop_data.url.is_valid())
292 provider->SetURL(drop_data.url, drop_data.url_title); 292 provider->SetURL(drop_data.url, drop_data.url_title);
293 if (!drop_data.html.string().empty()) 293 if (!drop_data.html.string().empty())
294 provider->SetHtml(drop_data.html.string(), drop_data.html_base_url); 294 provider->SetHtml(drop_data.html.string(), drop_data.html_base_url);
295 if (!drop_data.filenames.empty()) 295 if (!drop_data.filenames.empty())
296 provider->SetFilenames(drop_data.filenames); 296 provider->SetFilenames(drop_data.filenames);
297 if (!drop_data.file_system_files.empty()) { 297 if (!drop_data.file_system_files.empty()) {
298 Pickle pickle; 298 base::Pickle pickle;
299 WriteFileSystemFilesToPickle(drop_data.file_system_files, &pickle); 299 WriteFileSystemFilesToPickle(drop_data.file_system_files, &pickle);
300 provider->SetPickledData(GetFileSystemFileCustomFormat(), pickle); 300 provider->SetPickledData(GetFileSystemFileCustomFormat(), pickle);
301 } 301 }
302 if (!drop_data.custom_data.empty()) { 302 if (!drop_data.custom_data.empty()) {
303 Pickle pickle; 303 base::Pickle pickle;
304 ui::WriteCustomDataToPickle(drop_data.custom_data, &pickle); 304 ui::WriteCustomDataToPickle(drop_data.custom_data, &pickle);
305 provider->SetPickledData(ui::Clipboard::GetWebCustomDataFormatType(), 305 provider->SetPickledData(ui::Clipboard::GetWebCustomDataFormatType(),
306 pickle); 306 pickle);
307 } 307 }
308 } 308 }
309 309
310 // Utility to fill a DropData object from ui::OSExchangeData. 310 // Utility to fill a DropData object from ui::OSExchangeData.
311 void PrepareDropData(DropData* drop_data, const ui::OSExchangeData& data) { 311 void PrepareDropData(DropData* drop_data, const ui::OSExchangeData& data) {
312 drop_data->did_originate_from_renderer = data.DidOriginateFromRenderer(); 312 drop_data->did_originate_from_renderer = data.DidOriginateFromRenderer();
313 313
(...skipping 14 matching lines...) Expand all
328 base::string16 html; 328 base::string16 html;
329 GURL html_base_url; 329 GURL html_base_url;
330 data.GetHtml(&html, &html_base_url); 330 data.GetHtml(&html, &html_base_url);
331 if (!html.empty()) 331 if (!html.empty())
332 drop_data->html = base::NullableString16(html, false); 332 drop_data->html = base::NullableString16(html, false);
333 if (html_base_url.is_valid()) 333 if (html_base_url.is_valid())
334 drop_data->html_base_url = html_base_url; 334 drop_data->html_base_url = html_base_url;
335 335
336 data.GetFilenames(&drop_data->filenames); 336 data.GetFilenames(&drop_data->filenames);
337 337
338 Pickle pickle; 338 base::Pickle pickle;
339 std::vector<DropData::FileSystemFileInfo> file_system_files; 339 std::vector<DropData::FileSystemFileInfo> file_system_files;
340 if (data.GetPickledData(GetFileSystemFileCustomFormat(), &pickle) && 340 if (data.GetPickledData(GetFileSystemFileCustomFormat(), &pickle) &&
341 ReadFileSystemFilesFromPickle(pickle, &file_system_files)) 341 ReadFileSystemFilesFromPickle(pickle, &file_system_files))
342 drop_data->file_system_files = file_system_files; 342 drop_data->file_system_files = file_system_files;
343 343
344 if (data.GetPickledData(ui::Clipboard::GetWebCustomDataFormatType(), &pickle)) 344 if (data.GetPickledData(ui::Clipboard::GetWebCustomDataFormatType(), &pickle))
345 ui::ReadCustomDataIntoMap( 345 ui::ReadCustomDataIntoMap(
346 pickle.data(), pickle.size(), &drop_data->custom_data); 346 pickle.data(), pickle.size(), &drop_data->custom_data);
347 } 347 }
348 348
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 if (visible) { 1324 if (visible) {
1325 if (!web_contents_->should_normally_be_visible()) 1325 if (!web_contents_->should_normally_be_visible())
1326 web_contents_->WasShown(); 1326 web_contents_->WasShown();
1327 } else { 1327 } else {
1328 if (web_contents_->should_normally_be_visible()) 1328 if (web_contents_->should_normally_be_visible())
1329 web_contents_->WasHidden(); 1329 web_contents_->WasHidden();
1330 } 1330 }
1331 } 1331 }
1332 1332
1333 } // namespace content 1333 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/sandbox_ipc_linux.cc ('k') | content/browser/web_contents/web_drag_source_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698