Skip to content

Commit 645a1a0

Browse files
WebKitBrowser: syncup : [AAMP] support for custom http headers from rdkservices (#152)
1 parent dcda4b2 commit 645a1a0

File tree

6 files changed

+37
-0
lines changed

6 files changed

+37
-0
lines changed

WebKitBrowser/Extension/AAMPJSBindings.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
extern "C" {
2626
void aamp_LoadJSController(JSGlobalContextRef context);
2727
void aamp_UnloadJSController(JSGlobalContextRef context);
28+
void aamp_SetPageHttpHeaders(const char* headers);
2829
JSGlobalContextRef jscContextGetJSContext(JSCContext*);
2930
}
3031

@@ -93,6 +94,12 @@ void UnloadJSBindings(WebKitScriptWorld* world, WebKitFrame* frame) {
9394
g_object_unref(jsContext);
9495
}
9596

97+
// Just pass headers json to aamp plugin. SetHttpHeaders Called from RequestHeaders.cpp
98+
void SetHttpHeaders(const char * headerJson)
99+
{
100+
aamp_SetPageHttpHeaders(headerJson);
101+
}
102+
96103
} // namespace AAMP
97104
} // namespace JavaScript
98105
} // namespace WPEFramework

WebKitBrowser/Extension/AAMPJSBindings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace AAMP {
2727

2828
void LoadJSBindings(WebKitScriptWorld* world, WebKitFrame* frame);
2929
void UnloadJSBindings(WebKitScriptWorld* world, WebKitFrame* frame);
30+
void SetHttpHeaders(const char * headerJson);
3031

3132
} // namespace AAMP
3233
} // namespace JavaScript

WebKitBrowser/Extension/RequestHeaders.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424

2525
#include <core/JSON.h>
2626

27+
#if defined(ENABLE_AAMP_JSBINDINGS)
28+
#include "AAMPJSBindings.h"
29+
#endif
30+
2731
namespace WPEFramework {
2832
namespace WebKit {
2933

@@ -75,6 +79,12 @@ void SetRequestHeaders(WebKitWebPage* page, WebKitUserMessage* message)
7579
}
7680
g_variant_get(parameters, "&s", &headersPtr);
7781
string headersStr = headersPtr;
82+
83+
#if defined(ENABLE_AAMP_JSBINDINGS)
84+
// Pass on HTTP headers to AAMP , if empty, AAMP should clear previose headers set
85+
JavaScript::AAMP::SetHttpHeaders(headersStr.c_str());
86+
#endif
87+
7888
if (headersStr.empty()) {
7989
RemoveRequestHeaders(page);
8090
return;

WebKitBrowser/InjectedBundle/AAMPJSBindings.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
extern "C" {
2424
void aamp_LoadJSController(JSGlobalContextRef context);
2525
void aamp_UnloadJSController(JSGlobalContextRef context);
26+
void aamp_SetPageHttpHeaders(const char* headers);
2627
}
2728

2829
namespace WPEFramework {
@@ -75,6 +76,12 @@ void UnloadJSBindings(WKBundleFrameRef frame) {
7576
}
7677
}
7778

79+
// Just pass headers json to aamp plugin. SetHttpHeaders Called from RequestHeaders.cpp
80+
void SetHttpHeaders(const char * headerJson)
81+
{
82+
aamp_SetPageHttpHeaders(headerJson);
83+
}
84+
7885
} // namespace AAMP
7986
} // namespace JavaScript
8087
} // namespace WPEFramework

WebKitBrowser/InjectedBundle/AAMPJSBindings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ void LoadJSBindings(WKBundleFrameRef frame);
3030

3131
void UnloadJSBindings(WKBundleFrameRef frame);
3232

33+
void SetHttpHeaders(const char * headerJson);
34+
3335
} // namespace AAMP
3436
} // namespace JavaScript
3537
} // namespace WPEFramework

WebKitBrowser/InjectedBundle/RequestHeaders.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929

3030
#include <core/JSON.h>
3131

32+
#if defined(ENABLE_AAMP_JSBINDINGS)
33+
#include "AAMPJSBindings.h"
34+
#endif
35+
3236
#include "Utils.h"
3337

3438
namespace WPEFramework {
@@ -77,6 +81,12 @@ void SetRequestHeaders(WKBundlePageRef page, WKTypeRef messageBody)
7781
return;
7882

7983
string message = WPEFramework::WebKit::Utils::WKStringToString(static_cast<WKStringRef>(messageBody));
84+
85+
#if defined(ENABLE_AAMP_JSBINDINGS)
86+
// Pass on HTTP headers to AAMP , if empty, AAMP should clear previose headers set
87+
JavaScript::AAMP::SetHttpHeaders(message.c_str());
88+
#endif
89+
8090
if (message.empty()) {
8191
RemoveRequestHeaders(page);
8292
return;

0 commit comments

Comments
 (0)