| 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 "content/common/mac/attributed_string_coder.h" | 5 #include "content/common/mac/attributed_string_coder.h" |
| 6 | 6 |
| 7 #include <AppKit/AppKit.h> | 7 #include <AppKit/AppKit.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 115 |
| 116 } // namespace mac | 116 } // namespace mac |
| 117 | 117 |
| 118 // IPC ParamTraits specialization ////////////////////////////////////////////// | 118 // IPC ParamTraits specialization ////////////////////////////////////////////// |
| 119 | 119 |
| 120 namespace IPC { | 120 namespace IPC { |
| 121 | 121 |
| 122 using mac::AttributedStringCoder; | 122 using mac::AttributedStringCoder; |
| 123 | 123 |
| 124 void ParamTraits<AttributedStringCoder::EncodedString>::Write( | 124 void ParamTraits<AttributedStringCoder::EncodedString>::Write( |
| 125 Message* m, const param_type& p) { | 125 base::Pickle* m, |
| 126 const param_type& p) { |
| 126 WriteParam(m, p.string()); | 127 WriteParam(m, p.string()); |
| 127 WriteParam(m, p.attributes()); | 128 WriteParam(m, p.attributes()); |
| 128 } | 129 } |
| 129 | 130 |
| 130 bool ParamTraits<AttributedStringCoder::EncodedString>::Read( | 131 bool ParamTraits<AttributedStringCoder::EncodedString>::Read( |
| 131 const Message* m, | 132 const base::Pickle* m, |
| 132 base::PickleIterator* iter, | 133 base::PickleIterator* iter, |
| 133 param_type* p) { | 134 param_type* p) { |
| 134 bool success = true; | 135 bool success = true; |
| 135 | 136 |
| 136 base::string16 result; | 137 base::string16 result; |
| 137 success &= ReadParam(m, iter, &result); | 138 success &= ReadParam(m, iter, &result); |
| 138 *p = AttributedStringCoder::EncodedString(result); | 139 *p = AttributedStringCoder::EncodedString(result); |
| 139 | 140 |
| 140 success &= ReadParam(m, iter, p->attributes()); | 141 success &= ReadParam(m, iter, p->attributes()); |
| 141 return success; | 142 return success; |
| 142 } | 143 } |
| 143 | 144 |
| 144 void ParamTraits<AttributedStringCoder::EncodedString>::Log( | 145 void ParamTraits<AttributedStringCoder::EncodedString>::Log( |
| 145 const param_type& p, std::string* l) { | 146 const param_type& p, std::string* l) { |
| 146 l->append(base::UTF16ToUTF8(p.string())); | 147 l->append(base::UTF16ToUTF8(p.string())); |
| 147 } | 148 } |
| 148 | 149 |
| 149 void ParamTraits<AttributedStringCoder::FontAttribute>::Write( | 150 void ParamTraits<AttributedStringCoder::FontAttribute>::Write( |
| 150 Message* m, const param_type& p) { | 151 base::Pickle* m, |
| 152 const param_type& p) { |
| 151 WriteParam(m, p.font_descriptor()); | 153 WriteParam(m, p.font_descriptor()); |
| 152 WriteParam(m, p.effective_range()); | 154 WriteParam(m, p.effective_range()); |
| 153 } | 155 } |
| 154 | 156 |
| 155 bool ParamTraits<AttributedStringCoder::FontAttribute>::Read( | 157 bool ParamTraits<AttributedStringCoder::FontAttribute>::Read( |
| 156 const Message* m, | 158 const base::Pickle* m, |
| 157 base::PickleIterator* iter, | 159 base::PickleIterator* iter, |
| 158 param_type* p) { | 160 param_type* p) { |
| 159 bool success = true; | 161 bool success = true; |
| 160 | 162 |
| 161 FontDescriptor font; | 163 FontDescriptor font; |
| 162 success &= ReadParam(m, iter, &font); | 164 success &= ReadParam(m, iter, &font); |
| 163 | 165 |
| 164 gfx::Range range; | 166 gfx::Range range; |
| 165 success &= ReadParam(m, iter, &range); | 167 success &= ReadParam(m, iter, &range); |
| 166 | 168 |
| 167 if (success) { | 169 if (success) { |
| 168 *p = AttributedStringCoder::FontAttribute(font, range); | 170 *p = AttributedStringCoder::FontAttribute(font, range); |
| 169 } | 171 } |
| 170 return success; | 172 return success; |
| 171 } | 173 } |
| 172 | 174 |
| 173 void ParamTraits<AttributedStringCoder::FontAttribute>::Log( | 175 void ParamTraits<AttributedStringCoder::FontAttribute>::Log( |
| 174 const param_type& p, std::string* l) { | 176 const param_type& p, std::string* l) { |
| 175 } | 177 } |
| 176 | 178 |
| 177 } // namespace IPC | 179 } // namespace IPC |
| OLD | NEW |