OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_char_set.h" | 5 #include "webkit/plugins/ppapi/ppb_char_set_impl.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include "base/i18n/icu_string_conversions.h" | 9 #include "base/i18n/icu_string_conversions.h" |
10 #include "ppapi/c/dev/ppb_char_set_dev.h" | 10 #include "ppapi/c/dev/ppb_char_set_dev.h" |
11 #include "unicode/ucnv.h" | 11 #include "unicode/ucnv.h" |
12 #include "unicode/ucnv_cb.h" | 12 #include "unicode/ucnv_cb.h" |
13 #include "unicode/ucnv_err.h" | 13 #include "unicode/ucnv_err.h" |
14 #include "unicode/ustring.h" | 14 #include "unicode/ustring.h" |
15 #include "webkit/glue/plugins/pepper_plugin_delegate.h" | 15 #include "webkit/plugins/ppapi/plugin_delegate.h" |
16 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 16 #include "webkit/plugins/ppapi/plugin_instance.h" |
17 #include "webkit/glue/plugins/pepper_plugin_module.h" | 17 #include "webkit/plugins/ppapi/plugin_module.h" |
18 #include "webkit/glue/plugins/pepper_var.h" | 18 #include "webkit/plugins/ppapi/var.h" |
19 | 19 |
20 namespace pepper { | 20 namespace webkit { |
| 21 namespace ppapi { |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 // Converts the given PP error handling behavior to the version in base, | 25 // Converts the given PP error handling behavior to the version in base, |
25 // placing the result in |*result| and returning true on success. Returns false | 26 // placing the result in |*result| and returning true on success. Returns false |
26 // if the enum is invalid. | 27 // if the enum is invalid. |
27 bool PPToBaseConversionError(PP_CharSet_ConversionError on_error, | 28 bool PPToBaseConversionError(PP_CharSet_ConversionError on_error, |
28 base::OnStringConversionError::Type* result) { | 29 base::OnStringConversionError::Type* result) { |
29 switch (on_error) { | 30 switch (on_error) { |
30 case PP_CHARSET_CONVERSIONERROR_FAIL: | 31 case PP_CHARSET_CONVERSIONERROR_FAIL: |
31 *result = base::OnStringConversionError::FAIL; | 32 *result = base::OnStringConversionError::FAIL; |
32 return true; | 33 return true; |
33 case PP_CHARSET_CONVERSIONERROR_SKIP: | 34 case PP_CHARSET_CONVERSIONERROR_SKIP: |
34 *result = base::OnStringConversionError::SKIP; | 35 *result = base::OnStringConversionError::SKIP; |
35 return true; | 36 return true; |
36 case PP_CHARSET_CONVERSIONERROR_SUBSTITUTE: | 37 case PP_CHARSET_CONVERSIONERROR_SUBSTITUTE: |
37 *result = base::OnStringConversionError::SUBSTITUTE; | 38 *result = base::OnStringConversionError::SUBSTITUTE; |
38 return true; | 39 return true; |
39 default: | 40 default: |
40 return false; | 41 return false; |
41 } | 42 } |
42 } | 43 } |
43 | 44 |
44 // The "substitution" behavior of this function does not match the | 45 // The "substitution" behavior of this function does not match the |
45 // implementation in base, so we partially duplicate the code from | 46 // implementation in base, so we partially duplicate the code from |
46 // icu_string_conversions.cc with the correct error handling setup required | 47 // icu_string_conversions.cc with the correct error handling setup required |
47 // by this pepper interface. | 48 // by this PPAPI interface. |
48 char* UTF16ToCharSet(const uint16_t* utf16, uint32_t utf16_len, | 49 char* UTF16ToCharSet(const uint16_t* utf16, uint32_t utf16_len, |
49 const char* output_char_set, | 50 const char* output_char_set, |
50 PP_CharSet_ConversionError on_error, | 51 PP_CharSet_ConversionError on_error, |
51 uint32_t* output_length) { | 52 uint32_t* output_length) { |
52 *output_length = 0; | 53 *output_length = 0; |
53 | 54 |
54 UErrorCode status = U_ZERO_ERROR; | 55 UErrorCode status = U_ZERO_ERROR; |
55 UConverter* converter = ucnv_open(output_char_set, &status); | 56 UConverter* converter = ucnv_open(output_char_set, &status); |
56 if (!U_SUCCESS(status)) | 57 if (!U_SUCCESS(status)) |
57 return NULL; | 58 return NULL; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 153 |
153 const PPB_CharSet_Dev ppb_charset = { | 154 const PPB_CharSet_Dev ppb_charset = { |
154 &UTF16ToCharSet, | 155 &UTF16ToCharSet, |
155 &CharSetToUTF16, | 156 &CharSetToUTF16, |
156 &GetDefaultCharSet | 157 &GetDefaultCharSet |
157 }; | 158 }; |
158 | 159 |
159 } // namespace | 160 } // namespace |
160 | 161 |
161 // static | 162 // static |
162 const struct PPB_CharSet_Dev* CharSet::GetInterface() { | 163 const struct PPB_CharSet_Dev* PPB_CharSet_Impl::GetInterface() { |
163 return &ppb_charset; | 164 return &ppb_charset; |
164 } | 165 } |
165 | 166 |
166 } // namespace pepper | 167 } // namespace ppapi |
| 168 } // namespace webkit |
| 169 |
OLD | NEW |