#include "common/render_messages_ewk.h"
#include "content/public/browser/browser_message_filter.h"
#include "content/public/browser/render_process_host.h"
-#include "content/public/browser/resource_request_info.h"
#include "ipc/ipc_message_macros.h"
+#include "ipc_message_start_ewk.h"
#include "net/url_request/url_request.h"
-#include "tizen_webview/public/tw_wrt.h"
#include "url/gurl.h"
namespace {
// TODO(z.kostrzewa) I would prefer not make it a singleton, check out
// if it can't be a member of ContentMainDelegateEfl (but keep the static
// getter, maybe?).
-base::LazyInstance<scoped_ptr<WrtWidgetHost> > g_wrt_widget_host =
+base::LazyInstance<std::unique_ptr<WrtWidgetHost> > g_wrt_widget_host =
LAZY_INSTANCE_INITIALIZER;
bool SendToAllRenderers(IPC::Message* message) {
content::RenderProcessHost::iterator it =
content::RenderProcessHost::AllHostsIterator();
while (!it.IsAtEnd()) {
- if (it.GetCurrentValue()->Send(message))
+ if (it.GetCurrentValue()->Send(new IPC::Message(*message)))
result = true;
it.Advance();
}
+ delete message;
return result;
}
bool SendToRenderer(int renderer_id, IPC::Message* message) {
- return content::RenderProcessHost::FromID(renderer_id)->Send(message);
+ content::RenderProcessHost* host =
+ content::RenderProcessHost::FromID(renderer_id);
+ if (!host)
+ return false;
+
+ return host->Send(message);
}
}
WrtWidgetHostMessageFilter::WrtWidgetHostMessageFilter(
WrtWidgetHost* wrt_widget_host)
- : content::BrowserMessageFilter(ChromeMsgStart),
+ : content::BrowserMessageFilter(EwkMsgStart),
wrt_widget_host_(wrt_widget_host) {
}
WrtWidgetHost* WrtWidgetHost::Get() {
// TODO(z.kostrzewa) LazyInstance is thread-safe but creating
// WrtWidgetHost is not - make it thread-safe.
+#if !defined(EWK_BRINGUP) // FIXME: m67 bringup
+ // FIXME: ‘New’ is not a member of
+ // ‘base::internal::ErrorMustSelectLazyOrDestructorAtExitForLazyInstance<std::unique_ptr<WrtWidgetHost>
+ // >’
if (!g_wrt_widget_host.Get().get())
g_wrt_widget_host.Get().reset(new WrtWidgetHost);
return g_wrt_widget_host.Get().get();
+#else
+ return nullptr;
+#endif
}
WrtWidgetHost::WrtWidgetHost()
- : message_filter_(new WrtWidgetHostMessageFilter(this)),
- in_wrt_(false),
- widget_id_(0) {
+ : message_filter_(new WrtWidgetHostMessageFilter(this)) {
}
void WrtWidgetHost::GetUrlForRequest(
net::URLRequest* request,
- base::Callback<void(const GURL&)> callback) {
+ base::OnceCallback<void(const GURL&)> callback) {
// TODO(z.kostrzewa) Check on which thread(s) callbacks_ is touched
// and provide synchronization if required (either via a lock or
// by assuring that it is referenced only on one thread)
int callback_id = callback_id_generator_.GetNext();
- callbacks_[callback_id] = callback;
+ callbacks_[callback_id] = std::move(callback);
+#if !defined(EWK_BRINGUP) // FIXME: m85 bringup
int renderer_id, frame_id;
if (content::ResourceRequestInfo::GetRenderFrameForRequest(request, &renderer_id,
&frame_id))
if (SendToRenderer(renderer_id, new WrtMsg_ParseUrl(callback_id, request->url())))
return;
+#endif
+ std::move(callbacks_[callback_id]).Run(GURL());
callbacks_.erase(callback_id);
- callback.Run(GURL());
-}
-
-void WrtWidgetHost::SetWidgetInfo(int widget_id,
- double scale,
- const std::string& theme,
- const std::string& encoded_bundle) {
- // TODO shouldn't it be confirmed by WRT that this is really a launch
- // of the widget identified by widget_id?
- if (SendToAllRenderers(
- new WrtMsg_SetWidgetInfo(widget_id, scale, theme, encoded_bundle))) {
- // TODO(z.kostrzewa) This should be determined (somehow) on application
- // startup. Can it be done via Application Framework/Package Manager?
- in_wrt_ = true;
- widget_id_ = widget_id;
- }
}
void WrtWidgetHost::SendWrtMessage(
- const tizen_webview::WrtIpcMessageData& message) {
+ const Ewk_Wrt_Message_Data& message) {
SendToAllRenderers(new WrtMsg_SendWrtMessage(message));
}
+// It's only used by the wrt_file_protocol_handler which is not going to be used in the future
+// Candidate for deletion.
bool WrtWidgetHost::InWrt() const {
- return in_wrt_;
+ return false;
}
-int WrtWidgetHost::WidgetId() const {
- return widget_id_;
+// It's only used by the wrt_file_protocol_handler which is not going to be used in the future
+// Candidate for deletion.
+std::string WrtWidgetHost::TizenAppId() const {
+ return std::string();
}
void WrtWidgetHost::OnUrlRetrieved(int callback_id, const GURL& url) {
- callbacks_type::iterator it = callbacks_.find(callback_id);
+ auto it = callbacks_.find(callback_id);
if (callbacks_.end() == it)
return;
- callbacks_type::mapped_type callback = it->second;
- callbacks_.erase(callback_id);
- callback.Run(url);
+ std::move(it->second).Run(url);
+ callbacks_.erase(it);
}