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 999f8a2
Show file tree
Hide file tree
Showing 13 changed files with 188 additions and 212 deletions.
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
2 changes: 2 additions & 0 deletions WebKitBrowser/Extension/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ set_target_properties(${MODULE_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES)

target_compile_options (${MODULE_NAME} PRIVATE -Wno-psabi)

target_link_libraries(${MODULE_NAME}
PRIVATE
Expand All @@ -89,5 +90,6 @@ target_link_libraries(${MODULE_NAME}
target_compile_definitions(${MODULE_NAME} PRIVATE WEBKIT_GLIB_API)

install(TARGETS ${MODULE_NAME}
PERMISSIONS OWNER_READ GROUP_READ
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${NAMESPACE}/WebKitBrowser/${PLUGIN_WEBKITBROWSER_EXTENSION_DIRECTORY}
COMPONENT ${PROJECT_NAME})
10 changes: 10 additions & 0 deletions WebKitBrowser/Extension/IIdentifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ void InjectJS(WebKitScriptWorld* world, WebKitFrame* frame, Core::ProxyType<RPC:
IIdentifierData& identifierData = *static_cast<IIdentifierData*>(userData);

PluginHost::IShell* controller = std::get<0>(identifierData);
ASSERT(controller != nullptr);
const PluginHost::ISubSystem* subsysInterface = std::get<1>(identifierData);
ASSERT(subsysInterface != nullptr);
const PluginHost::ISubSystem::IIdentifier* identifierInterface = std::get<2>(identifierData);
ASSERT(identifierInterface != nullptr);

identifierInterface->Release();
subsysInterface->Release();
Expand All @@ -61,9 +64,12 @@ void InjectJS(WebKitScriptWorld* world, WebKitFrame* frame, Core::ProxyType<RPC:
nullptr,
GCallback(+[](gpointer userData) -> gpointer {
Core::ProxyType<RPC::CommunicatorClient>& comClient = *static_cast<Core::ProxyType<RPC::CommunicatorClient>*>(userData);
ASSERT(comClient != nullptr);

PluginHost::IShell* controller = comClient->Acquire<PluginHost::IShell>(10000, _T("Controller"), ~0);
ASSERT(controller != nullptr);
const PluginHost::ISubSystem* subsysInterface = controller->SubSystems();
ASSERT(subsysInterface != nullptr);
const PluginHost::ISubSystem::IIdentifier* identifierInterface = subsysInterface->Get<PluginHost::ISubSystem::IIdentifier>();

auto* identifierData = new IIdentifierData(controller, subsysInterface, identifierInterface);
Expand All @@ -84,6 +90,7 @@ void InjectJS(WebKitScriptWorld* world, WebKitFrame* frame, Core::ProxyType<RPC:
G_CALLBACK(+[](gpointer userData) -> char* {
IIdentifierData& identifierData = *static_cast<IIdentifierData*>(userData);
const PluginHost::ISubSystem::IIdentifier* identifierInterface = std::get<2>(identifierData);
ASSERT(identifierInterface != nullptr);

uint8_t buffer[64] = {};
buffer[0] = identifierInterface->Identifier(sizeof(buffer) - 1, &(buffer[1]));
Expand All @@ -106,6 +113,7 @@ void InjectJS(WebKitScriptWorld* world, WebKitFrame* frame, Core::ProxyType<RPC:
G_CALLBACK(+[](gpointer userData) -> char* {
IIdentifierData& identifierData = *static_cast<IIdentifierData*>(userData);
const PluginHost::ISubSystem::IIdentifier* identifierInterface = std::get<2>(identifierData);
ASSERT(identifierInterface != nullptr);

string architecture = identifierInterface->Architecture();
if (architecture.length() > 0) {
Expand All @@ -126,6 +134,7 @@ void InjectJS(WebKitScriptWorld* world, WebKitFrame* frame, Core::ProxyType<RPC:
G_CALLBACK(+[](gpointer userData) -> char* {
IIdentifierData& identifierData = *static_cast<IIdentifierData*>(userData);
const PluginHost::ISubSystem::IIdentifier* identifierInterface = std::get<2>(identifierData);
ASSERT(identifierInterface != nullptr);

string chipset = identifierInterface->Chipset();
if (chipset.length() > 0) {
Expand All @@ -146,6 +155,7 @@ void InjectJS(WebKitScriptWorld* world, WebKitFrame* frame, Core::ProxyType<RPC:
G_CALLBACK(+[](gpointer userData) -> char* {
IIdentifierData& identifierData = *static_cast<IIdentifierData*>(userData);
const PluginHost::ISubSystem::IIdentifier* identifierInterface = std::get<2>(identifierData);
ASSERT(identifierInterface != nullptr);

string firmwareVersion = identifierInterface->FirmwareVersion();
if (firmwareVersion.length() > 0) {
Expand Down
50 changes: 0 additions & 50 deletions WebKitBrowser/Extension/ProcessInfo.cpp

This file was deleted.

30 changes: 0 additions & 30 deletions WebKitBrowser/Extension/ProcessInfo.h

This file was deleted.

8 changes: 7 additions & 1 deletion WebKitBrowser/Extension/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ static class PluginHost {
PluginHost()
: _engine(Core::ProxyType<RPC::InvokeServerType<2, 0, 4>>::Create())
, _comClient(Core::ProxyType<RPC::CommunicatorClient>::Create(GetConnectionNode(), Core::ProxyType<Core::IIPCServer>(_engine)))
, _extension(nullptr)
{
#ifndef USE_THUNDER_R4
_engine->Announcements(_comClient->Announcement());
#endif
}
~PluginHost()
{
Expand All @@ -85,6 +88,7 @@ static class PluginHost {
public:
void Initialize(WebKitWebExtension* extension, const void* userData)
{
ASSERT(_comClient.IsValid() == true);
// We have something to report back, do so...
uint32_t result = _comClient->Open(RPC::CommunicationTimeOut);
if (result != Core::ERROR_NONE) {
Expand Down Expand Up @@ -160,7 +164,7 @@ static class PluginHost {
}

private:
static void windowObjectClearedCallback(WebKitScriptWorld* world, WebKitWebPage* page, WebKitFrame* frame)
static void windowObjectClearedCallback(WebKitScriptWorld* world, WebKitWebPage* page)
{
JavaScript::Milestone::InjectJS(world, frame);
JavaScript::NotifyWPEFramework::InjectJS(world, frame);
Expand All @@ -186,6 +190,7 @@ static class PluginHost {
WebKitWebPage* page,
PluginHost* host)
{
ASSERT(host != nullptr);
if (host->_logToSystemConsoleEnabled) {
g_signal_connect(page, "console-message-sent",
G_CALLBACK(consoleMessageSentCallback), host);
Expand All @@ -202,6 +207,7 @@ static class PluginHost {
}
static void consoleMessageSentCallback(VARIABLE_IS_NOT_USED WebKitWebPage* page, WebKitConsoleMessage* message, PluginHost* host)
{
ASSERT(host != nullptr);
string messageString = Core::ToString(webkit_console_message_get_text(message));
uint64_t line = static_cast<uint64_t>(webkit_console_message_get_line(message));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ namespace WebKit {
string jsonString = WebKit::Utils::WKStringToString(returnedString);

unique_ptr<WhiteListedOriginDomainsList> whiteList(new WhiteListedOriginDomainsList());
ASSERT(whiteList != nullptr);
ParseWhiteList(jsonString, whiteList->_whiteMap);

WKRelease(returnData);
Expand Down
Loading

0 comments on commit 999f8a2

Please sign in to comment.