diff --git a/include/capi/cef_resource_bundle_capi.h b/include/capi/cef_resource_bundle_capi.h index 3a8887013..88e541c83 100644 --- a/include/capi/cef_resource_bundle_capi.h +++ b/include/capi/cef_resource_bundle_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=b9577b495df3990284d4e4a3db2824196175dc91$ +// $hash=b0e2b63b467c6d4e990405d948908da3546ea1c7$ // #ifndef CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_CAPI_H_ @@ -41,6 +41,7 @@ #pragma once #include "include/capi/cef_base_capi.h" +#include "include/capi/cef_values_capi.h" #ifdef __cplusplus extern "C" { @@ -70,34 +71,25 @@ typedef struct _cef_resource_bundle_t { int string_id); /// - // Retrieves the contents of the specified scale independent |resource_id|. If - // the value is found then |data| and |data_size| will be populated and this - // function will return true (1). If the value is not found then this function - // will return false (0). The returned |data| pointer will remain resident in - // memory and should not be freed. Include cef_pack_resources.h for a listing - // of valid resource ID values. + // Returns a cef_binary_value_t containing the decompressed contents of the + // specified scale independent |resource_id| or NULL if not found. Include + // cef_pack_resources.h for a listing of valid resource ID values. /// - int(CEF_CALLBACK* get_data_resource)(struct _cef_resource_bundle_t* self, - int resource_id, - void** data, - size_t* data_size); + struct _cef_binary_value_t*(CEF_CALLBACK* get_data_resource)( + struct _cef_resource_bundle_t* self, + int resource_id); /// - // Retrieves the contents of the specified |resource_id| nearest the scale - // factor |scale_factor|. Use a |scale_factor| value of SCALE_FACTOR_NONE for - // scale independent resources or call GetDataResource instead. If the value - // is found then |data| and |data_size| will be populated and this function - // will return true (1). If the value is not found then this function will - // return false (0). The returned |data| pointer will remain resident in - // memory and should not be freed. Include cef_pack_resources.h for a listing - // of valid resource ID values. + // Returns a cef_binary_value_t containing the decompressed contents of the + // specified |resource_id| nearest the scale factor |scale_factor| or NULL if + // not found. Use a |scale_factor| value of SCALE_FACTOR_NONE for scale + // independent resources or call GetDataResource instead.Include + // cef_pack_resources.h for a listing of valid resource ID values. /// - int(CEF_CALLBACK* get_data_resource_for_scale)( + struct _cef_binary_value_t*(CEF_CALLBACK* get_data_resource_for_scale)( struct _cef_resource_bundle_t* self, int resource_id, - cef_scale_factor_t scale_factor, - void** data, - size_t* data_size); + cef_scale_factor_t scale_factor); } cef_resource_bundle_t; /// diff --git a/include/cef_api_hash.h b/include/cef_api_hash.h index 9595afde0..cad2ef6b7 100644 --- a/include/cef_api_hash.h +++ b/include/cef_api_hash.h @@ -42,13 +42,13 @@ // way that may cause binary incompatibility with other builds. The universal // hash value will change if any platform is affected whereas the platform hash // values will change only if that particular platform is affected. -#define CEF_API_HASH_UNIVERSAL "385d8af3c6da76f123f3aa292d3a3308ef456297" +#define CEF_API_HASH_UNIVERSAL "7a48e7a17158593b8ac08418724954bcb84deb72" #if defined(OS_WIN) -#define CEF_API_HASH_PLATFORM "4bb528b0bb076ed5177d6581cfca12dd7b2fee04" +#define CEF_API_HASH_PLATFORM "82c3cf19d7973c473605f5d50db8fb659b2ac4fc" #elif defined(OS_MACOSX) -#define CEF_API_HASH_PLATFORM "f6580fc0858f3580b7d25e1d094dd0a336132522" +#define CEF_API_HASH_PLATFORM "8a0d8b0e87ca8226d981bd089cafc0cdcc158f02" #elif defined(OS_LINUX) -#define CEF_API_HASH_PLATFORM "83f3053840abba3b83e43ade58230f10b48591dd" +#define CEF_API_HASH_PLATFORM "b826017709228a8ccd79d4f897afa1a03f7286c7" #endif #ifdef __cplusplus diff --git a/include/cef_resource_bundle.h b/include/cef_resource_bundle.h index c08f5b089..abb605fb9 100644 --- a/include/cef_resource_bundle.h +++ b/include/cef_resource_bundle.h @@ -39,6 +39,7 @@ #pragma once #include "include/cef_base.h" +#include "include/cef_values.h" /// // Class used for retrieving resources from the resource bundle (*.pak) files @@ -67,33 +68,24 @@ class CefResourceBundle : public virtual CefBaseRefCounted { virtual CefString GetLocalizedString(int string_id) = 0; /// - // Retrieves the contents of the specified scale independent |resource_id|. - // If the value is found then |data| and |data_size| will be populated and - // this method will return true. If the value is not found then this method - // will return false. The returned |data| pointer will remain resident in - // memory and should not be freed. Include cef_pack_resources.h for a listing - // of valid resource ID values. + // Returns a CefBinaryValue containing the decompressed contents of the + // specified scale independent |resource_id| or NULL if not found. Include + // cef_pack_resources.h for a listing of valid resource ID values. /// /*--cef()--*/ - virtual bool GetDataResource(int resource_id, - void*& data, - size_t& data_size) = 0; + virtual CefRefPtr GetDataResource(int resource_id) = 0; /// - // Retrieves the contents of the specified |resource_id| nearest the scale - // factor |scale_factor|. Use a |scale_factor| value of SCALE_FACTOR_NONE for - // scale independent resources or call GetDataResource instead. If the value - // is found then |data| and |data_size| will be populated and this method will - // return true. If the value is not found then this method will return false. - // The returned |data| pointer will remain resident in memory and should not - // be freed. Include cef_pack_resources.h for a listing of valid resource ID - // values. + // Returns a CefBinaryValue containing the decompressed contents of the + // specified |resource_id| nearest the scale factor |scale_factor| or NULL if + // not found. Use a |scale_factor| value of SCALE_FACTOR_NONE for scale + // independent resources or call GetDataResource instead.Include + // cef_pack_resources.h for a listing of valid resource ID values. /// /*--cef()--*/ - virtual bool GetDataResourceForScale(int resource_id, - ScaleFactor scale_factor, - void*& data, - size_t& data_size) = 0; + virtual CefRefPtr GetDataResourceForScale( + int resource_id, + ScaleFactor scale_factor) = 0; }; #endif // CEF_INCLUDE_CEF_RESOURCE_BUNDLE_H_ diff --git a/libcef/common/resource_bundle_impl.cc b/libcef/common/resource_bundle_impl.cc index 2f4d20c0c..dff6f16e3 100644 --- a/libcef/common/resource_bundle_impl.cc +++ b/libcef/common/resource_bundle_impl.cc @@ -4,6 +4,7 @@ #include "libcef/common/resource_bundle_impl.h" +#include "base/memory/ref_counted_memory.h" #include "ui/base/resource/resource_bundle.h" CefResourceBundleImpl::CefResourceBundleImpl() {} @@ -15,29 +16,24 @@ CefString CefResourceBundleImpl::GetLocalizedString(int string_id) { return ui::ResourceBundle::GetSharedInstance().GetLocalizedString(string_id); } -bool CefResourceBundleImpl::GetDataResource(int resource_id, - void*& data, - size_t& data_size) { - return GetDataResourceForScale(resource_id, SCALE_FACTOR_NONE, data, - data_size); +CefRefPtr CefResourceBundleImpl::GetDataResource( + int resource_id) { + return GetDataResourceForScale(resource_id, SCALE_FACTOR_NONE); } -bool CefResourceBundleImpl::GetDataResourceForScale(int resource_id, - ScaleFactor scale_factor, - void*& data, - size_t& data_size) { +CefRefPtr CefResourceBundleImpl::GetDataResourceForScale( + int resource_id, + ScaleFactor scale_factor) { if (!ui::ResourceBundle::HasSharedInstance()) - return false; + return nullptr; - const base::StringPiece& result = - ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( + base::RefCountedMemory* result = + ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( resource_id, static_cast(scale_factor)); - if (result.empty()) - return false; + if (!result) + return nullptr; - data = const_cast(result.data()); - data_size = result.size(); - return true; + return CefBinaryValue::Create(result->data(), result->size()); } // static diff --git a/libcef/common/resource_bundle_impl.h b/libcef/common/resource_bundle_impl.h index cc0268214..0acf603d4 100644 --- a/libcef/common/resource_bundle_impl.h +++ b/libcef/common/resource_bundle_impl.h @@ -14,13 +14,10 @@ class CefResourceBundleImpl : public CefResourceBundle { // CefResourceBundle methods. CefString GetLocalizedString(int string_id) override; - bool GetDataResource(int resource_id, - void*& data, - size_t& data_size) override; - bool GetDataResourceForScale(int resource_id, - ScaleFactor scale_factor, - void*& data, - size_t& data_size) override; + CefRefPtr GetDataResource(int resource_id) override; + CefRefPtr GetDataResourceForScale( + int resource_id, + ScaleFactor scale_factor) override; private: IMPLEMENT_REFCOUNTING(CefResourceBundleImpl); diff --git a/libcef_dll/cpptoc/resource_bundle_cpptoc.cc b/libcef_dll/cpptoc/resource_bundle_cpptoc.cc index 3a9235cde..a3effa3fb 100644 --- a/libcef_dll/cpptoc/resource_bundle_cpptoc.cc +++ b/libcef_dll/cpptoc/resource_bundle_cpptoc.cc @@ -9,10 +9,11 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=ba0a12367019906d32dae965d7d1b5245d02b442$ +// $hash=0dc6766f75f9b051daf582009455efb08c969e9f$ // #include "libcef_dll/cpptoc/resource_bundle_cpptoc.h" +#include "libcef_dll/cpptoc/binary_value_cpptoc.h" // GLOBAL FUNCTIONS - Body may be edited by hand. @@ -47,83 +48,40 @@ resource_bundle_get_localized_string(struct _cef_resource_bundle_t* self, return _retval.DetachToUserFree(); } -int CEF_CALLBACK +struct _cef_binary_value_t* CEF_CALLBACK resource_bundle_get_data_resource(struct _cef_resource_bundle_t* self, - int resource_id, - void** data, - size_t* data_size) { + int resource_id) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) - return 0; - // Verify param: data; type: simple_byref - DCHECK(data); - if (!data) - return 0; - // Verify param: data_size; type: simple_byref - DCHECK(data_size); - if (!data_size) - return 0; - - // Translate param: data; type: simple_byref - void* dataVal = data ? *data : NULL; - // Translate param: data_size; type: simple_byref - size_t data_sizeVal = data_size ? *data_size : 0; + return NULL; // Execute - bool _retval = CefResourceBundleCppToC::Get(self)->GetDataResource( - resource_id, dataVal, data_sizeVal); + CefRefPtr _retval = + CefResourceBundleCppToC::Get(self)->GetDataResource(resource_id); - // Restore param: data; type: simple_byref - if (data) - *data = dataVal; - // Restore param: data_size; type: simple_byref - if (data_size) - *data_size = data_sizeVal; - - // Return type: bool - return _retval; + // Return type: refptr_same + return CefBinaryValueCppToC::Wrap(_retval); } -int CEF_CALLBACK +struct _cef_binary_value_t* CEF_CALLBACK resource_bundle_get_data_resource_for_scale(struct _cef_resource_bundle_t* self, int resource_id, - cef_scale_factor_t scale_factor, - void** data, - size_t* data_size) { + cef_scale_factor_t scale_factor) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) - return 0; - // Verify param: data; type: simple_byref - DCHECK(data); - if (!data) - return 0; - // Verify param: data_size; type: simple_byref - DCHECK(data_size); - if (!data_size) - return 0; - - // Translate param: data; type: simple_byref - void* dataVal = data ? *data : NULL; - // Translate param: data_size; type: simple_byref - size_t data_sizeVal = data_size ? *data_size : 0; + return NULL; // Execute - bool _retval = CefResourceBundleCppToC::Get(self)->GetDataResourceForScale( - resource_id, scale_factor, dataVal, data_sizeVal); + CefRefPtr _retval = + CefResourceBundleCppToC::Get(self)->GetDataResourceForScale(resource_id, + scale_factor); - // Restore param: data; type: simple_byref - if (data) - *data = dataVal; - // Restore param: data_size; type: simple_byref - if (data_size) - *data_size = data_sizeVal; - - // Return type: bool - return _retval; + // Return type: refptr_same + return CefBinaryValueCppToC::Wrap(_retval); } } // namespace diff --git a/libcef_dll/ctocpp/resource_bundle_ctocpp.cc b/libcef_dll/ctocpp/resource_bundle_ctocpp.cc index c4746fbce..ea4f61205 100644 --- a/libcef_dll/ctocpp/resource_bundle_ctocpp.cc +++ b/libcef_dll/ctocpp/resource_bundle_ctocpp.cc @@ -9,10 +9,11 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=026dabca1d46cfbe911d71ede9d5bb79cb7c553d$ +// $hash=12bfdabd19a9a90eb4c7b88cb0d8d225c8142115$ // #include "libcef_dll/ctocpp/resource_bundle_ctocpp.h" +#include "libcef_dll/ctocpp/binary_value_ctocpp.h" // STATIC METHODS - Body may be edited by hand. @@ -48,40 +49,38 @@ CefString CefResourceBundleCToCpp::GetLocalizedString(int string_id) { } NO_SANITIZE("cfi-icall") -bool CefResourceBundleCToCpp::GetDataResource(int resource_id, - void*& data, - size_t& data_size) { +CefRefPtr CefResourceBundleCToCpp::GetDataResource( + int resource_id) { cef_resource_bundle_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_data_resource)) - return false; + return nullptr; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - int _retval = - _struct->get_data_resource(_struct, resource_id, &data, &data_size); + cef_binary_value_t* _retval = + _struct->get_data_resource(_struct, resource_id); - // Return type: bool - return _retval ? true : false; + // Return type: refptr_same + return CefBinaryValueCToCpp::Wrap(_retval); } NO_SANITIZE("cfi-icall") -bool CefResourceBundleCToCpp::GetDataResourceForScale(int resource_id, - ScaleFactor scale_factor, - void*& data, - size_t& data_size) { +CefRefPtr CefResourceBundleCToCpp::GetDataResourceForScale( + int resource_id, + ScaleFactor scale_factor) { cef_resource_bundle_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_data_resource_for_scale)) - return false; + return nullptr; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - int _retval = _struct->get_data_resource_for_scale( - _struct, resource_id, scale_factor, &data, &data_size); + cef_binary_value_t* _retval = + _struct->get_data_resource_for_scale(_struct, resource_id, scale_factor); - // Return type: bool - return _retval ? true : false; + // Return type: refptr_same + return CefBinaryValueCToCpp::Wrap(_retval); } // CONSTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/resource_bundle_ctocpp.h b/libcef_dll/ctocpp/resource_bundle_ctocpp.h index a99cc2e8b..2d1977eb1 100644 --- a/libcef_dll/ctocpp/resource_bundle_ctocpp.h +++ b/libcef_dll/ctocpp/resource_bundle_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=c0d4e71c707c9d63a00ca1a497aaede3e429e970$ +// $hash=7668efc00e13bb790df91f26c2a5683bd74ff677$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_RESOURCE_BUNDLE_CTOCPP_H_ @@ -36,13 +36,10 @@ class CefResourceBundleCToCpp // CefResourceBundle methods. CefString GetLocalizedString(int string_id) OVERRIDE; - bool GetDataResource(int resource_id, - void*& data, - size_t& data_size) OVERRIDE; - bool GetDataResourceForScale(int resource_id, - ScaleFactor scale_factor, - void*& data, - size_t& data_size) OVERRIDE; + CefRefPtr GetDataResource(int resource_id) OVERRIDE; + CefRefPtr GetDataResourceForScale( + int resource_id, + ScaleFactor scale_factor) OVERRIDE; }; #endif // CEF_LIBCEF_DLL_CTOCPP_RESOURCE_BUNDLE_CTOCPP_H_