diff --git a/WebKitBrowser/Extension/AAMPJSBindings.cpp b/WebKitBrowser/Extension/AAMPJSBindings.cpp index 9f5a885780..876b1e7a39 100644 --- a/WebKitBrowser/Extension/AAMPJSBindings.cpp +++ b/WebKitBrowser/Extension/AAMPJSBindings.cpp @@ -25,6 +25,7 @@ extern "C" { void aamp_LoadJSController(JSGlobalContextRef context); void aamp_UnloadJSController(JSGlobalContextRef context); + void aamp_SetPageHttpHeaders(const char* headers); JSGlobalContextRef jscContextGetJSContext(JSCContext*); } @@ -93,6 +94,12 @@ void UnloadJSBindings(WebKitScriptWorld* world, WebKitFrame* frame) { g_object_unref(jsContext); } +// Just pass headers json to aamp plugin. SetHttpHeaders Called from RequestHeaders.cpp +void SetHttpHeaders(const char * headerJson) +{ + aamp_SetPageHttpHeaders(headerJson); +} + } // namespace AAMP } // namespace JavaScript } // namespace WPEFramework diff --git a/WebKitBrowser/Extension/AAMPJSBindings.h b/WebKitBrowser/Extension/AAMPJSBindings.h index 72e9c371d0..a4976929fe 100644 --- a/WebKitBrowser/Extension/AAMPJSBindings.h +++ b/WebKitBrowser/Extension/AAMPJSBindings.h @@ -27,6 +27,7 @@ namespace AAMP { void LoadJSBindings(WebKitScriptWorld* world, WebKitFrame* frame); void UnloadJSBindings(WebKitScriptWorld* world, WebKitFrame* frame); +void SetHttpHeaders(const char * headerJson); } // namespace AAMP } // namespace JavaScript diff --git a/WebKitBrowser/Extension/RequestHeaders.cpp b/WebKitBrowser/Extension/RequestHeaders.cpp index 609260ca02..257d9d7f08 100644 --- a/WebKitBrowser/Extension/RequestHeaders.cpp +++ b/WebKitBrowser/Extension/RequestHeaders.cpp @@ -24,6 +24,10 @@ #include +#if defined(ENABLE_AAMP_JSBINDINGS) +#include "AAMPJSBindings.h" +#endif + namespace WPEFramework { namespace WebKit { @@ -75,6 +79,12 @@ void SetRequestHeaders(WebKitWebPage* page, WebKitUserMessage* message) } g_variant_get(parameters, "&s", &headersPtr); string headersStr = headersPtr; + +#if defined(ENABLE_AAMP_JSBINDINGS) + // Pass on HTTP headers to AAMP , if empty, AAMP should clear previose headers set + JavaScript::AAMP::SetHttpHeaders(headersStr.c_str()); +#endif + if (headersStr.empty()) { RemoveRequestHeaders(page); return; diff --git a/WebKitBrowser/InjectedBundle/AAMPJSBindings.cpp b/WebKitBrowser/InjectedBundle/AAMPJSBindings.cpp index 99b39a692a..a790b3be2a 100644 --- a/WebKitBrowser/InjectedBundle/AAMPJSBindings.cpp +++ b/WebKitBrowser/InjectedBundle/AAMPJSBindings.cpp @@ -23,6 +23,7 @@ extern "C" { void aamp_LoadJSController(JSGlobalContextRef context); void aamp_UnloadJSController(JSGlobalContextRef context); + void aamp_SetPageHttpHeaders(const char* headers); } namespace WPEFramework { @@ -75,6 +76,12 @@ void UnloadJSBindings(WKBundleFrameRef frame) { } } +// Just pass headers json to aamp plugin. SetHttpHeaders Called from RequestHeaders.cpp +void SetHttpHeaders(const char * headerJson) +{ + aamp_SetPageHttpHeaders(headerJson); +} + } // namespace AAMP } // namespace JavaScript } // namespace WPEFramework diff --git a/WebKitBrowser/InjectedBundle/AAMPJSBindings.h b/WebKitBrowser/InjectedBundle/AAMPJSBindings.h index f6adae9fb8..8a792168a7 100644 --- a/WebKitBrowser/InjectedBundle/AAMPJSBindings.h +++ b/WebKitBrowser/InjectedBundle/AAMPJSBindings.h @@ -30,6 +30,8 @@ void LoadJSBindings(WKBundleFrameRef frame); void UnloadJSBindings(WKBundleFrameRef frame); +void SetHttpHeaders(const char * headerJson); + } // namespace AAMP } // namespace JavaScript } // namespace WPEFramework diff --git a/WebKitBrowser/InjectedBundle/RequestHeaders.cpp b/WebKitBrowser/InjectedBundle/RequestHeaders.cpp index f58736e97e..7f1c70395a 100644 --- a/WebKitBrowser/InjectedBundle/RequestHeaders.cpp +++ b/WebKitBrowser/InjectedBundle/RequestHeaders.cpp @@ -29,6 +29,10 @@ #include +#if defined(ENABLE_AAMP_JSBINDINGS) +#include "AAMPJSBindings.h" +#endif + #include "Utils.h" namespace WPEFramework { @@ -77,6 +81,12 @@ void SetRequestHeaders(WKBundlePageRef page, WKTypeRef messageBody) return; string message = WPEFramework::WebKit::Utils::WKStringToString(static_cast(messageBody)); + +#if defined(ENABLE_AAMP_JSBINDINGS) + // Pass on HTTP headers to AAMP , if empty, AAMP should clear previose headers set + JavaScript::AAMP::SetHttpHeaders(message.c_str()); +#endif + if (message.empty()) { RemoveRequestHeaders(page); return;