// static
void ProxyingURLLoaderEfl::Create(
- std::unique_ptr<_Ewk_Intercept_Request> intercept_request,
+ scoped_refptr<_Ewk_Intercept_Request> intercept_request,
+#if BUILDFLAG(IS_TIZEN_TV)
+ content::BrowserContextEfl::ResourceContextEfl* resource_context_efl,
+#endif
mojo::PendingReceiver<::network::mojom::URLLoader> loader,
mojo::PendingRemote<network::mojom::URLLoaderClient> client) {
+#if BUILDFLAG(IS_TIZEN_TV)
+ auto* proxying_url_loader_efl = new ProxyingURLLoaderEfl(
+ std::move(intercept_request), resource_context_efl, std::move(loader),
+ std::move(client));
+#else
auto* proxying_url_loader_efl = new ProxyingURLLoaderEfl(
std::move(intercept_request), std::move(loader), std::move(client));
+#endif
}
ProxyingURLLoaderEfl::ProxyingURLLoaderEfl(
- std::unique_ptr<_Ewk_Intercept_Request> intercept_request,
+ scoped_refptr<_Ewk_Intercept_Request> intercept_request,
+#if BUILDFLAG(IS_TIZEN_TV)
+ content::BrowserContextEfl::ResourceContextEfl* resource_context_efl,
+#endif
mojo::PendingReceiver<::network::mojom::URLLoader> loader,
mojo::PendingRemote<network::mojom::URLLoaderClient> client)
: intercept_request_(std::move(intercept_request)),
+#if BUILDFLAG(IS_TIZEN_TV)
+ resource_context_efl_(resource_context_efl),
+#endif
binding_(this),
weak_ptr_factory_(this) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
client_.Bind(std::move(client));
}
+ProxyingURLLoaderEfl::~ProxyingURLLoaderEfl() {
+#if BUILDFLAG(IS_TIZEN_TV)
+ LOG(INFO)
+ << "Destroyed ProxyingURLLoaderEfl, and notified app intercept url: "
+ << intercept_request_->request_url_get()
+ << ", resource_context_efl_: " << resource_context_efl_
+ << ", intercept_request_: " << intercept_request_.get();
+ if (resource_context_efl_ &&
+ resource_context_efl_->HasInterceptRequestCancelCallback()) {
+ resource_context_efl_->RunInterceptRequestCancelCallback(
+ intercept_request_.get());
+ }
+ intercept_request_->set_delegate(nullptr);
+#endif
+}
+
void ProxyingURLLoaderEfl::ResponseDecided() {
mojo::ScopedDataPipeProducerHandle pipe_producer_handle;
mojo::ScopedDataPipeConsumerHandle pipe_consumer_handle;
#include "mojo/public/cpp/system/data_pipe.h"
#include "private/ewk_intercept_request_private.h"
#include "services/network/public/mojom/url_loader.mojom.h"
-
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "browser_context_efl.h"
+#endif
namespace mojo {
class SimpleWatcher;
}
public _Ewk_Intercept_Request::Delegate {
public:
static void Create(
- std::unique_ptr<_Ewk_Intercept_Request> intercept_request,
+ scoped_refptr<_Ewk_Intercept_Request> intercept_request,
+#if BUILDFLAG(IS_TIZEN_TV)
+ content::BrowserContextEfl::ResourceContextEfl* resource_context_efl,
+#endif
mojo::PendingReceiver<::network::mojom::URLLoader> loader,
mojo::PendingRemote<network::mojom::URLLoaderClient> client);
- ~ProxyingURLLoaderEfl() override = default;
+ ~ProxyingURLLoaderEfl() override;
private:
// network::mojom::URLLoader:
void ChunkedReadDone() override;
ProxyingURLLoaderEfl(
- std::unique_ptr<_Ewk_Intercept_Request> intercept_request,
+ scoped_refptr<_Ewk_Intercept_Request> intercept_request,
+#if BUILDFLAG(IS_TIZEN_TV)
+ content::BrowserContextEfl::ResourceContextEfl* resource_context_efl,
+#endif
mojo::PendingReceiver<::network::mojom::URLLoader> loader,
mojo::PendingRemote<network::mojom::URLLoaderClient> client);
void OnConnectionError();
void MaybeDeleteSelf();
- std::unique_ptr<_Ewk_Intercept_Request> intercept_request_;
+ scoped_refptr<_Ewk_Intercept_Request> intercept_request_;
+#if BUILDFLAG(IS_TIZEN_TV)
+ content::BrowserContextEfl::ResourceContextEfl* resource_context_efl_;
+#endif
mojo::Receiver<network::mojom::URLLoader> binding_;
mojo::Remote<network::mojom::URLLoaderClient> client_;
params.upload = upload_data_stream.get();
}
- auto intercept_request = std::make_unique<_Ewk_Intercept_Request>(params);
- resource_context_->RunInterceptRequestCallback(intercept_request.get());
+ auto intercept_request = new _Ewk_Intercept_Request(params);
+ resource_context_->RunInterceptRequestCallback(intercept_request);
intercept_request->callback_ended();
if (intercept_request->is_ignored()) {
target_factory_->CreateLoaderAndStart(std::move(loader), request_id,
options, request, std::move(client),
traffic_annotation);
+ delete intercept_request;
return;
}
+#if BUILDFLAG(IS_TIZEN_TV)
+ ProxyingURLLoaderEfl::Create(base::WrapRefCounted(intercept_request),
+ resource_context_, std::move(loader),
+ std::move(client));
+#else
ProxyingURLLoaderEfl::Create(std::move(intercept_request), std::move(loader),
std::move(client));
+#endif
}
void ProxyingURLLoaderFactoryEfl::Clone(
}
#if BUILDFLAG(IS_TIZEN_TV)
+// On TV product, the cancel callback must always be registered.
+void DefaultCallback(Ewk_Context*, Ewk_Intercept_Request*, void*) {
+ NOTIMPLEMENTED();
+}
+
void FormatHour(long time, std::ostringstream& ost) {
static const double kMinutesPerHour = 60.0;
ost.width(2);
BrowserContextEfl::ResourceContextEfl::ResourceContextEfl(
scoped_refptr<CookieManager> cookie_manager)
: cookie_manager_(cookie_manager),
- intercept_request_callback_{nullptr, nullptr, nullptr} {}
+#if BUILDFLAG(IS_TIZEN_TV)
+ intercept_request_cancel_callback_{nullptr, DefaultCallback, nullptr},
+#endif
+ intercept_request_callback_{nullptr, nullptr, nullptr} {
+}
BrowserContextEfl::~BrowserContextEfl() {
NotifyWillBeDestroyed();
if (name.empty())
return false;
- base::AutoLock locker(http_custom_headers_lock_);
+ base::AutoLock lock(http_custom_headers_lock_);
return http_custom_headers_.insert(std::make_pair(name, value)).second;
}
bool BrowserContextEfl::ResourceContextEfl::HTTPCustomHeaderRemove(
const std::string& name) {
- base::AutoLock locker(http_custom_headers_lock_);
+ base::AutoLock lock(http_custom_headers_lock_);
return http_custom_headers_.erase(name);
}
void BrowserContextEfl::ResourceContextEfl::HTTPCustomHeaderClear() {
- base::AutoLock locker(http_custom_headers_lock_);
+ base::AutoLock lock(http_custom_headers_lock_);
http_custom_headers_.clear();
}
const HTTPCustomHeadersEflMap
BrowserContextEfl::ResourceContextEfl::GetHTTPCustomHeadersEflMap() const {
- base::AutoLock locker(http_custom_headers_lock_);
+ base::AutoLock lock(http_custom_headers_lock_);
return http_custom_headers_;
}
Ewk_Context_Intercept_Request_Callback callback,
void* user_data) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- base::AutoLock locker(intercept_request_callback_lock_);
+ base::AutoLock lock(intercept_request_callback_lock_);
intercept_request_callback_ = {ewk_context, callback, user_data};
}
bool BrowserContextEfl::ResourceContextEfl::HasInterceptRequestCallback()
const {
- base::AutoLock locker(intercept_request_callback_lock_);
+ base::AutoLock lock(intercept_request_callback_lock_);
return !!intercept_request_callback_.callback;
}
void BrowserContextEfl::ResourceContextEfl::RunInterceptRequestCallback(
_Ewk_Intercept_Request* intercept_request) const {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- base::AutoLock locker(intercept_request_callback_lock_);
+ base::AutoLock lock(intercept_request_callback_lock_);
if (intercept_request_callback_.callback)
intercept_request_callback_.Run(intercept_request);
}
+#if BUILDFLAG(IS_TIZEN_TV)
+void BrowserContextEfl::ResourceContextEfl::SetInterceptRequestCancelCallback(
+ Ewk_Context* ewk_context,
+ Ewk_Context_Intercept_Request_Callback callback,
+ void* user_data) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ base::AutoLock lock(intercept_request_cancel_callback_lock_);
+ intercept_request_cancel_callback_ = {ewk_context, callback, user_data};
+}
+
+bool BrowserContextEfl::ResourceContextEfl::HasInterceptRequestCancelCallback()
+ const {
+ base::AutoLock lock(intercept_request_cancel_callback_lock_);
+ return !!intercept_request_cancel_callback_.callback;
+}
+
+void BrowserContextEfl::ResourceContextEfl::RunInterceptRequestCancelCallback(
+ _Ewk_Intercept_Request* intercept_request) const {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ base::AutoLock lock(intercept_request_cancel_callback_lock_);
+ if (intercept_request && intercept_request_cancel_callback_.callback)
+ intercept_request_cancel_callback_.Run(intercept_request);
+}
+#endif
+
scoped_refptr<CookieManager>
BrowserContextEfl::ResourceContextEfl::GetCookieManager() const {
return cookie_manager_;
void RunInterceptRequestCallback(
_Ewk_Intercept_Request* intercept_request) const;
+#if BUILDFLAG(IS_TIZEN_TV)
+ void SetInterceptRequestCancelCallback(
+ Ewk_Context* ewk_context,
+ Ewk_Context_Intercept_Request_Callback callback,
+ void* user_data);
+ bool HasInterceptRequestCancelCallback() const;
+ void RunInterceptRequestCancelCallback(
+ _Ewk_Intercept_Request* intercept_request) const;
+#endif
+
private:
struct InterceptRequestCallbackWithData {
Ewk_Context* context;
InterceptRequestCallbackWithData intercept_request_callback_;
mutable base::Lock intercept_request_callback_lock_;
+#if BUILDFLAG(IS_TIZEN_TV)
+ InterceptRequestCallbackWithData intercept_request_cancel_callback_;
+ mutable base::Lock intercept_request_cancel_callback_lock_;
+#endif
};
BrowserContextEfl(EWebContext*, bool incognito = false);
static_cast<content::BrowserContextEfl*>(browser_context)
->GetResourceContextEfl();
+#if BUILDFLAG(IS_TIZEN_TV)
+ if (!resource_context_efl ||
+ !resource_context_efl->HasInterceptRequestCallback() ||
+ !resource_context_efl->HasInterceptRequestCancelCallback()) {
+#else
if (!resource_context_efl ||
!resource_context_efl->HasInterceptRequestCallback()) {
+#endif
return false;
}
double daylight_saving_time) {
browser_context_->SetTimeZoneOffset(time_zone_offset, daylight_saving_time);
}
+
+void EWebContext::SetInterceptRequestCancelCallback(
+ Ewk_Context* ewk_context,
+ Ewk_Context_Intercept_Request_Callback callback,
+ void* user_data) {
+ BrowserContextEfl::ResourceContextEfl* resource_context_efl =
+ browser_context_->GetResourceContextEfl();
+ if (!resource_context_efl) {
+ LOG(ERROR) << "Unable to get ResourceContextEfl.";
+ return;
+ }
+ resource_context_efl->SetInterceptRequestCancelCallback(ewk_context, callback,
+ user_data);
+}
#endif
void EWebContext::SetMaxRefreshRate(int max_refresh_rate) {
void RegisterURLSchemesAsCORSEnabled(const Eina_List* schemes_list);
void SetTimeOffset(double time_offset);
void SetTimeZoneOffset(double time_zone_offset, double daylight_saving_time);
+ void SetInterceptRequestCancelCallback(
+ Ewk_Context* ewk_context,
+ Ewk_Context_Intercept_Request_Callback callback,
+ void* user_data);
#endif
void EnableAppControl(bool enabled);
double daylight_saving_time) {
impl->SetTimeZoneOffset(time_zone_offset, daylight_saving_time);
}
+
+void Ewk_Context::SetContextInterceptRequestCancelCallback(
+ Ewk_Context_Intercept_Request_Callback callback,
+ void* user_data) {
+ impl->SetInterceptRequestCancelCallback(this, callback, user_data);
+}
#endif
void Ewk_Context::SetMaxRefreshRate(int max_refresh_rate) {
void SetTimeOffset(double time_offset);
// Sets time zone offset for HBBTV
void SetTimeZoneOffset(double time_zone_offset, double daylight_saving_time);
+ void SetContextInterceptRequestCancelCallback(
+ Ewk_Context_Intercept_Request_Callback callback,
+ void* user_data);
#endif
void EnableAppControl(bool enabled);
void _Ewk_Intercept_Request::post_response_decided() {
content::GetIOThreadTaskRunner({})->PostTask(
- FROM_HERE, base::BindRepeating(&_Ewk_Intercept_Request::response_decided,
- base::Unretained(this)));
+ FROM_HERE,
+ base::BindRepeating(&_Ewk_Intercept_Request::response_decided, this));
}
void _Ewk_Intercept_Request::put_chunk(const char* data, size_t length) {
void _Ewk_Intercept_Request::post_put_chunk(const char* data, size_t length) {
content::GetIOThreadTaskRunner({})->PostTask(
- FROM_HERE, base::BindRepeating(&_Ewk_Intercept_Request::put_chunk,
- base::Unretained(this), data, length));
+ FROM_HERE, base::BindRepeating(&_Ewk_Intercept_Request::put_chunk, this,
+ data, length));
}
void _Ewk_Intercept_Request::chunked_read_done() {
void _Ewk_Intercept_Request::post_chunked_read_done() {
content::GetIOThreadTaskRunner({})->PostTask(
- FROM_HERE, base::BindRepeating(&_Ewk_Intercept_Request::chunked_read_done,
- base::Unretained(this)));
+ FROM_HERE,
+ base::BindRepeating(&_Ewk_Intercept_Request::chunked_read_done, this));
}
const char* _Ewk_Intercept_Request::request_body_get() const {
#include <Eina.h>
#include <Evas.h>
-
+#include "base/memory/ref_counted.h"
#include "base/synchronization/atomic_flag.h"
namespace net {
struct InterceptRequestParams;
-struct _Ewk_Intercept_Request {
+struct _Ewk_Intercept_Request
+ : public base::RefCountedThreadSafe<_Ewk_Intercept_Request> {
public:
class Delegate {
public:
void ewk_context_intercept_request_cancel_callback_set(Ewk_Context* ewk_context, Ewk_Context_Intercept_Request_Cancel_Callback callback, void* user_data)
{
+#if BUILDFLAG(IS_TIZEN_TV)
+ EINA_SAFETY_ON_NULL_RETURN(ewk_context);
+ ewk_context->SetContextInterceptRequestCancelCallback(callback, user_data);
+#else
LOG_EWK_API_MOCKUP();
+#endif
}
void ewk_context_set_xwalk_extension_profile(Ewk_Context* ewk_context,