Skip to content

Commit

Permalink
WebKit syncup changes
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Mar 15, 2024
1 parent 54646c1 commit 07473a7
Show file tree
Hide file tree
Showing 15 changed files with 393 additions and 241 deletions.
10 changes: 10 additions & 0 deletions WebKitBrowser/BrowserConsoleLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ class BrowserConsoleLog {
BrowserConsoleLog(const string& prefix, const string& message, const uint64_t line, const uint64_t column)
{
_text = '[' + prefix + "][" + Core::NumberType<uint64_t>(line).Text() + ',' + Core::NumberType<uint64_t>(column).Text() + ']' + message;
#ifndef USE_THUNDER_R4
const uint16_t maxStringLength = Trace::TRACINGBUFFERSIZE - 1;
#else
const uint16_t maxStringLength = Messaging::MessageUnit::DataSize - 1;
#endif

if (_text.length() > maxStringLength) {
_text = _text.substr(0, maxStringLength);
}
Expand All @@ -46,7 +51,12 @@ class BrowserConsoleLog {
BrowserConsoleLog(const string& prefix, const WKStringRef message, const uint64_t line, const uint64_t column)
{
_text = '[' + prefix + "][" + Core::NumberType<uint64_t>(line).Text() + ',' + Core::NumberType<uint64_t>(column).Text() + ']' + WebKit::Utils::WKStringToString(message);
#ifndef USE_THUNDER_R4
const uint16_t maxStringLength = Trace::TRACINGBUFFERSIZE - 1;
#else
const uint16_t maxStringLength = Messaging::MessageUnit::DataSize - 1;
#endif

if (_text.length() > maxStringLength) {
_text = _text.substr(0, maxStringLength);
}
Expand Down
33 changes: 22 additions & 11 deletions WebKitBrowser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ project(WebKitBrowser)
cmake_minimum_required(VERSION 3.3)

find_package(WPEFramework)
project_version(1.0.0)

set(PLUGIN_NAME WebKitBrowser)
#set(PLUGIN_NAME WebKitBrowser)
set(MODULE_NAME ${NAMESPACE}${PROJECT_NAME})

message("Setup ${MODULE_NAME} v${PROJECT_VERSION}")
Expand Down Expand Up @@ -344,51 +345,61 @@ else()
set(PLUGIN_YOUTUBE_WIDTH ${PLUGIN_WEBKITBROWSER_WIDTH})
endif()

write_config( ${PLUGIN_NAME} )
write_config()
#write_config( ${PLUGIN_NAME} )

# youtube configuration
if(PLUGIN_WEBKITBROWSER_YOUTUBE)
write_config( YouTube )
write_config( PLUGINS YouTube )
# write_config( YouTube )
endif()

# amazon configuration
if(PLUGIN_AMAZON_HYBRID)
write_config( Amazon )
write_config( PLUGINS Amazon )
# write_config( Amazon )
endif()

# Applications instance configuration
if(PLUGIN_WEBKITBROWSER_APPS)
write_config( Apps )
write_config( PLUGINS Apps )
# write_config( Apps )
endif()

# UX configuration
if(PLUGIN_WEBKITBROWSER_UX)
write_config( UX )
write_config( PLUGINS UX )
# write_config( UX )
endif()

# Search&Discovery configuration
if(PLUGIN_WEBKITBROWSER_SEARCH_AND_DISCOVERY_APP)
write_config( SearchAndDiscoveryApp )
write_config( PLUGINS SearchAndDiscoveryApp )
# write_config( SearchAndDiscoveryApp )
endif()

# Html App configuration
if(PLUGIN_WEBKITBROWSER_HTML_APP)
write_config( HtmlApp )
write_config( PLUGINS HtmlApp )
# write_config( HtmlApp )
endif()

# Lightning App configuration
if(PLUGIN_WEBKITBROWSER_LIGHTNING_APP)
write_config( LightningApp )
write_config( PLUGINS LightningApp )
# write_config( LightningApp )
endif()

# JSPP configuration
if(PLUGIN_WEBKITBROWSER_JSPP)
write_config( JSPP )
write_config( PLUGINS JSPP )
# write_config( JSPP )
endif()

# Resident App configuration
if(PLUGIN_WEBKITBROWSER_RESIDENT_APP)
write_config( ResidentApp )
write_config( PLUGINS ResidentApp )
# write_config( ResidentApp )
endif()

if(PLUGINS_CREATE_IPKG_TARGETS)
Expand Down
37 changes: 12 additions & 25 deletions WebKitBrowser/CookieJar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ static void deserialize(const std::string& cookies, std::vector<std::string>& re
{
std::string cookie;
std::stringstream ss(cookies);
while(ss.good())
{
while (ss.good()) {
getline(ss, cookie, '\n');
if (!cookie.empty())
result.push_back(cookie);
Expand Down Expand Up @@ -83,16 +82,14 @@ static std::vector<uint8_t> compress(const std::string& str)
{
std::vector<uint8_t> result;
size_t nbytes = str.size();
if (nbytes == 0)
{
if (nbytes == 0) {
result.resize(4, '\0');
return result;
}
const int compressionLevel = 1;
unsigned long len = nbytes + nbytes / 100 + 13;
int status;
do
{
do {
result.resize(len + 4);
status = ::compress2((unsigned char*)result.data() + 4, &len,
(const unsigned char*)str.c_str(), nbytes, compressionLevel);
Expand Down Expand Up @@ -122,10 +119,8 @@ static std::string uncompress(const std::vector<uint8_t>& in)
{
std::string result;
size_t nbytes = in.size();
if (nbytes <= 4)
{
if (nbytes < 4 || std::any_of(in.cbegin(), in.cend(), [](int v) {return v != 0;}))
{
if (nbytes <= 4) {
if (nbytes < 4 || std::any_of(in.cbegin(), in.cend(), [](int v) {return v != 0;})) {
TRACE_GLOBAL(Trace::Error,(_T("Input data is corrupted")));
}
return result;
Expand All @@ -136,8 +131,7 @@ static std::string uncompress(const std::vector<uint8_t>& in)
(data[2] << 8) | (data[3]));
unsigned long len = std::max(expectedSize, 1ul);
int status;
do
{
do {
result.resize(len);
status = ::uncompress((unsigned char*)result.data(), &len, data + 4, nbytes - 4);
switch (status)
Expand Down Expand Up @@ -172,8 +166,7 @@ static uint32_t crc_checksum(const std::string& str)
unsigned char c = 0;
const unsigned char *p = (const unsigned char*) str.data();
size_t len = str.size();
while (len--)
{
while (len--) {
c = *p++;
crc = ((crc >> 4) & 0x0fff) ^ crc_tbl[((crc ^ c) & 15)];
c >>= 4;
Expand All @@ -199,12 +192,9 @@ struct CookieJar::CookieJarPrivate

rc = _cookieJarCrypto.Encrypt(compress(serialized), version, encrypted);

if (rc != Core::ERROR_NONE)
{
if (rc != Core::ERROR_NONE) {
TRACE_GLOBAL(Trace::Error,(_T("Encryption failed, rc = %u"), rc));
}
else
{
} else {
payload = toBase64(encrypted);
}

Expand All @@ -225,17 +215,14 @@ struct CookieJar::CookieJarPrivate
else
{
std::string serialized;
int actualChecksum;
uint32_t actualChecksum;

serialized = uncompress(decrypted);
actualChecksum = crc_checksum(serialized);
if (actualChecksum != checksum)
{
if (actualChecksum != checksum) {
rc = Core::ERROR_GENERAL;
TRACE_GLOBAL(Trace::Error,(_T("Checksum does not match: actual=%d expected=%d"), actualChecksum, checksum));
}
else
{
} else {
deserialize(serialized, cookies);
}
}
Expand Down
Loading

0 comments on commit 07473a7

Please sign in to comment.