| 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 plugins { |
| 22 namespace ppapi { |
| 21 | 23 |
| 22 namespace { | 24 namespace { |
| 23 | 25 |
| 24 // Converts the given PP error handling behavior to the version in base, | 26 // 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 | 27 // placing the result in |*result| and returning true on success. Returns false |
| 26 // if the enum is invalid. | 28 // if the enum is invalid. |
| 27 bool PPToBaseConversionError(PP_CharSet_ConversionError on_error, | 29 bool PPToBaseConversionError(PP_CharSet_ConversionError on_error, |
| 28 base::OnStringConversionError::Type* result) { | 30 base::OnStringConversionError::Type* result) { |
| 29 switch (on_error) { | 31 switch (on_error) { |
| 30 case PP_CHARSET_CONVERSIONERROR_FAIL: | 32 case PP_CHARSET_CONVERSIONERROR_FAIL: |
| 31 *result = base::OnStringConversionError::FAIL; | 33 *result = base::OnStringConversionError::FAIL; |
| 32 return true; | 34 return true; |
| 33 case PP_CHARSET_CONVERSIONERROR_SKIP: | 35 case PP_CHARSET_CONVERSIONERROR_SKIP: |
| 34 *result = base::OnStringConversionError::SKIP; | 36 *result = base::OnStringConversionError::SKIP; |
| 35 return true; | 37 return true; |
| 36 case PP_CHARSET_CONVERSIONERROR_SUBSTITUTE: | 38 case PP_CHARSET_CONVERSIONERROR_SUBSTITUTE: |
| 37 *result = base::OnStringConversionError::SUBSTITUTE; | 39 *result = base::OnStringConversionError::SUBSTITUTE; |
| 38 return true; | 40 return true; |
| 39 default: | 41 default: |
| 40 return false; | 42 return false; |
| 41 } | 43 } |
| 42 } | 44 } |
| 43 | 45 |
| 44 // The "substitution" behavior of this function does not match the | 46 // The "substitution" behavior of this function does not match the |
| 45 // implementation in base, so we partially duplicate the code from | 47 // implementation in base, so we partially duplicate the code from |
| 46 // icu_string_conversions.cc with the correct error handling setup required | 48 // icu_string_conversions.cc with the correct error handling setup required |
| 47 // by this pepper interface. | 49 // by this PPAPI interface. |
| 48 char* UTF16ToCharSet(const uint16_t* utf16, uint32_t utf16_len, | 50 char* UTF16ToCharSet(const uint16_t* utf16, uint32_t utf16_len, |
| 49 const char* output_char_set, | 51 const char* output_char_set, |
| 50 PP_CharSet_ConversionError on_error, | 52 PP_CharSet_ConversionError on_error, |
| 51 uint32_t* output_length) { | 53 uint32_t* output_length) { |
| 52 *output_length = 0; | 54 *output_length = 0; |
| 53 | 55 |
| 54 UErrorCode status = U_ZERO_ERROR; | 56 UErrorCode status = U_ZERO_ERROR; |
| 55 UConverter* converter = ucnv_open(output_char_set, &status); | 57 UConverter* converter = ucnv_open(output_char_set, &status); |
| 56 if (!U_SUCCESS(status)) | 58 if (!U_SUCCESS(status)) |
| 57 return NULL; | 59 return NULL; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 154 |
| 153 const PPB_CharSet_Dev ppb_charset = { | 155 const PPB_CharSet_Dev ppb_charset = { |
| 154 &UTF16ToCharSet, | 156 &UTF16ToCharSet, |
| 155 &CharSetToUTF16, | 157 &CharSetToUTF16, |
| 156 &GetDefaultCharSet | 158 &GetDefaultCharSet |
| 157 }; | 159 }; |
| 158 | 160 |
| 159 } // namespace | 161 } // namespace |
| 160 | 162 |
| 161 // static | 163 // static |
| 162 const struct PPB_CharSet_Dev* CharSet::GetInterface() { | 164 const struct PPB_CharSet_Dev* PPB_CharSet_Impl::GetInterface() { |
| 163 return &ppb_charset; | 165 return &ppb_charset; |
| 164 } | 166 } |
| 165 | 167 |
| 166 } // namespace pepper | 168 } // namespace ppapi |
| 169 } // namespace plugins |
| 170 } // namespace webkit |
| 171 |
| OLD | NEW |