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 #ifndef CONTENT_COMMON_MAC_ATTRIBUTED_STRING_CODER_H_ | 5 #ifndef CONTENT_COMMON_MAC_ATTRIBUTED_STRING_CODER_H_ |
6 #define CONTENT_COMMON_MAC_ATTRIBUTED_STRING_CODER_H_ | 6 #define CONTENT_COMMON_MAC_ATTRIBUTED_STRING_CODER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "content/common/mac/font_descriptor.h" | 12 #include "content/common/mac/font_descriptor.h" |
13 #include "ipc/ipc_message_utils.h" | 13 #include "ipc/ipc_message_utils.h" |
14 #include "ui/gfx/range/range.h" | 14 #include "ui/gfx/range/range.h" |
15 | 15 |
16 #if __OBJC__ | 16 #if __OBJC__ |
17 @class NSAttributedString; | 17 @class NSAttributedString; |
18 @class NSDictionary; | 18 @class NSDictionary; |
19 #else | 19 #else |
20 class NSAttributedString; | 20 class NSAttributedString; |
21 class NSDictionary; | 21 class NSDictionary; |
22 #endif | 22 #endif |
23 | 23 |
| 24 namespace base { |
| 25 class Pickle; |
| 26 class PickleIterator; |
| 27 } |
| 28 |
24 namespace mac { | 29 namespace mac { |
25 | 30 |
26 // This class will serialize the font information of an NSAttributedString so | 31 // This class will serialize the font information of an NSAttributedString so |
27 // that it can be sent over IPC. This class only stores the information of the | 32 // that it can be sent over IPC. This class only stores the information of the |
28 // NSFontAttributeName. The motive is that of security: using NSArchiver and | 33 // NSFontAttributeName. The motive is that of security: using NSArchiver and |
29 // friends to send objects from the renderer to the browser could lead to | 34 // friends to send objects from the renderer to the browser could lead to |
30 // deserialization of arbitrary objects. This class restricts serialization to | 35 // deserialization of arbitrary objects. This class restricts serialization to |
31 // a specific object class and specific attributes of that object. | 36 // a specific object class and specific attributes of that object. |
32 class CONTENT_EXPORT AttributedStringCoder { | 37 class CONTENT_EXPORT AttributedStringCoder { |
33 public: | 38 public: |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 98 |
94 } // namespace mac | 99 } // namespace mac |
95 | 100 |
96 // IPC ParamTraits specialization ////////////////////////////////////////////// | 101 // IPC ParamTraits specialization ////////////////////////////////////////////// |
97 | 102 |
98 namespace IPC { | 103 namespace IPC { |
99 | 104 |
100 template <> | 105 template <> |
101 struct ParamTraits<mac::AttributedStringCoder::EncodedString> { | 106 struct ParamTraits<mac::AttributedStringCoder::EncodedString> { |
102 typedef mac::AttributedStringCoder::EncodedString param_type; | 107 typedef mac::AttributedStringCoder::EncodedString param_type; |
103 static void Write(Message* m, const param_type& p); | 108 static void Write(base::Pickle* m, const param_type& p); |
104 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); | 109 static bool Read(const base::Pickle* m, |
| 110 base::PickleIterator* iter, |
| 111 param_type* r); |
105 static void Log(const param_type& p, std::string* l); | 112 static void Log(const param_type& p, std::string* l); |
106 }; | 113 }; |
107 | 114 |
108 template <> | 115 template <> |
109 struct ParamTraits<mac::AttributedStringCoder::FontAttribute> { | 116 struct ParamTraits<mac::AttributedStringCoder::FontAttribute> { |
110 typedef mac::AttributedStringCoder::FontAttribute param_type; | 117 typedef mac::AttributedStringCoder::FontAttribute param_type; |
111 static void Write(Message* m, const param_type& p); | 118 static void Write(base::Pickle* m, const param_type& p); |
112 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); | 119 static bool Read(const base::Pickle* m, |
| 120 base::PickleIterator* iter, |
| 121 param_type* r); |
113 static void Log(const param_type& p, std::string* l); | 122 static void Log(const param_type& p, std::string* l); |
114 }; | 123 }; |
115 | 124 |
116 } // namespace IPC | 125 } // namespace IPC |
117 | 126 |
118 #endif // CONTENT_COMMON_MAC_ATTRIBUTED_STRING_CODER_H_ | 127 #endif // CONTENT_COMMON_MAC_ATTRIBUTED_STRING_CODER_H_ |
OLD | NEW |