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 "ipc/ipc_message_utils.h" | 5 #include "ipc/ipc_message_utils.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/nullable_string16.h" | 10 #include "base/nullable_string16.h" |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 std::string* l) { | 482 std::string* l) { |
483 if (p.auto_close) { | 483 if (p.auto_close) { |
484 l->append(StringPrintf("FD(%d auto-close)", p.fd)); | 484 l->append(StringPrintf("FD(%d auto-close)", p.fd)); |
485 } else { | 485 } else { |
486 l->append(StringPrintf("FD(%d)", p.fd)); | 486 l->append(StringPrintf("FD(%d)", p.fd)); |
487 } | 487 } |
488 } | 488 } |
489 #endif // defined(OS_POSIX) | 489 #endif // defined(OS_POSIX) |
490 | 490 |
491 void ParamTraits<FilePath>::Write(Message* m, const param_type& p) { | 491 void ParamTraits<FilePath>::Write(Message* m, const param_type& p) { |
492 ParamTraits<FilePath::StringType>::Write(m, p.value()); | 492 p.WriteToPickle(m); |
493 } | 493 } |
494 | 494 |
495 bool ParamTraits<FilePath>::Read(const Message* m, | 495 bool ParamTraits<FilePath>::Read(const Message* m, |
496 PickleIterator* iter, | 496 PickleIterator* iter, |
497 param_type* r) { | 497 param_type* r) { |
498 FilePath::StringType value; | 498 return r->ReadFromPickle(iter); |
499 if (!ParamTraits<FilePath::StringType>::Read(m, iter, &value)) | |
500 return false; | |
501 // Reject embedded NULs as they can cause security checks to go awry. | |
502 if (value.find(FILE_PATH_LITERAL('\0')) != FilePath::StringType::npos) | |
503 return false; | |
504 *r = FilePath(value); | |
505 return true; | |
506 } | 499 } |
507 | 500 |
508 void ParamTraits<FilePath>::Log(const param_type& p, std::string* l) { | 501 void ParamTraits<FilePath>::Log(const param_type& p, std::string* l) { |
509 ParamTraits<FilePath::StringType>::Log(p.value(), l); | 502 ParamTraits<FilePath::StringType>::Log(p.value(), l); |
510 } | 503 } |
511 | 504 |
512 void ParamTraits<ListValue>::Write(Message* m, const param_type& p) { | 505 void ParamTraits<ListValue>::Write(Message* m, const param_type& p) { |
513 WriteValue(m, &p, 0); | 506 WriteValue(m, &p, 0); |
514 } | 507 } |
515 | 508 |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 return result; | 814 return result; |
822 } | 815 } |
823 | 816 |
824 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { | 817 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { |
825 l->append("<MSG>"); | 818 l->append("<MSG>"); |
826 } | 819 } |
827 | 820 |
828 #endif // OS_WIN | 821 #endif // OS_WIN |
829 | 822 |
830 } // namespace IPC | 823 } // namespace IPC |
OLD | NEW |