Add Tizen-platform implementation of ContentMainDelegate, of ResourceDispatcherHostDe...
authorArnaud Renevier <a.renevier@samsung.com>
Wed, 28 May 2014 17:47:12 +0000 (10:47 -0700)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Change-Id: I7b691acae88bd3b9ed625ed84a7848d2fdd047cf

tizen_src/impl/chromium-efl.gyp
tizen_src/impl/content_browser_client_efl.cc [new file with mode: 0644]
tizen_src/impl/content_browser_client_efl.h [new file with mode: 0644]
tizen_src/impl/content_main_delegate_efl.cc [new file with mode: 0644]
tizen_src/impl/content_main_delegate_efl.h [new file with mode: 0644]
tizen_src/impl/resource_dispatcher_host_delegate_efl.cc [new file with mode: 0644]
tizen_src/impl/resource_dispatcher_host_delegate_efl.h [new file with mode: 0644]

index d20dfd6..9e210f4 100644 (file)
       'components/editing/content/common/editing_messages.h',
       'components/editing/content/renderer/editorclient_agent.cc',
       'components/editing/content/renderer/editorclient_agent.h',
+      'content_browser_client_efl.cc',
+      'content_browser_client_efl.h',
+      'content_main_delegate_efl.cc',
+      'content_main_delegate_efl.h',
       'context_menu_controller_efl.cc',
       'context_menu_controller_efl.h',
       'cookie_manager.cc',
       'renderer/render_view_observer_efl.h',
       'resource/JavaScriptPopup.edc',
       'resource/Magnifier.edc',
+      'resource_dispatcher_host_delegate_efl.cc',
+      'resource_dispatcher_host_delegate_efl.h',
       'screen_efl.cc',
       'screen_efl.h',
       'selection_box_efl.cc',
diff --git a/tizen_src/impl/content_browser_client_efl.cc b/tizen_src/impl/content_browser_client_efl.cc
new file mode 100644 (file)
index 0000000..3e7b795
--- /dev/null
@@ -0,0 +1,236 @@
+/*
+   Copyright (C) 2014 Samsung Electronics
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "content_browser_client_efl.h"
+
+#include "command_line_efl.h"
+#include "browser_main_parts_efl.h"
+#include "browser_context_efl.h"
+#include "web_contents_delegate_efl.h"
+#include "resource_dispatcher_host_delegate_efl.h"
+#include "browser/web_contents/web_contents_view_efl.h"
+#include "browser/geolocation/access_token_store_efl.h"
+#include "browser/renderer_host/render_message_filter_efl.h"
+#include "browser/vibration/vibration_message_filter.h"
+#include "content/public/browser/resource_dispatcher_host.h"
+#include "content/public/browser/web_contents.h"
+#include "common/web_contents_utils.h"
+#include "components/editing/content/browser/editor_client_observer.h"
+
+using web_contents_utils::WebContentsFromFrameID;
+
+namespace content {
+
+ContentBrowserClientEfl::ContentBrowserClientEfl()
+  : browser_main_parts_efl_(NULL) {
+}
+
+BrowserMainParts* ContentBrowserClientEfl::CreateBrowserMainParts(
+    const MainFunctionParams& parameters) {
+  browser_main_parts_efl_ = new BrowserMainPartsEfl();
+  return browser_main_parts_efl_;
+}
+
+WebContentsView* ContentBrowserClientEfl::OverrideCreateWebContentsView(
+    WebContents* web_contents,
+    RenderViewHostDelegateView** delegate_view) {
+  WebContentsViewEfl* view = new WebContentsViewEfl(web_contents);
+  *delegate_view = view;
+  return view;
+}
+
+net::URLRequestContextGetter* ContentBrowserClientEfl::CreateRequestContext(
+    BrowserContext* browser_context, ProtocolHandlerMap* protocol_handlers) {
+  if (browser_context->IsOffTheRecord()) {
+    LOG(ERROR) << "off the record browser context not implemented";
+    return NULL;
+  }
+
+  return static_cast<BrowserContextEfl*>(browser_context)->
+      CreateRequestContext(protocol_handlers);
+}
+
+AccessTokenStore* ContentBrowserClientEfl::CreateAccessTokenStore() {
+  return new AccessTokenStoreEfl();
+}
+
+#if defined(OS_TIZEN)
+LocationProvider* ContentBrowserClientEfl::OverrideSystemLocationProvider() {
+  return LocationProviderEfl::Create();
+}
+#endif
+
+void ContentBrowserClientEfl::AppendExtraCommandLineSwitches(CommandLine* command_line,
+    int child_process_id) {
+  CommandLineEfl::AppendProcessSpecificArgs(*command_line);
+}
+
+void ContentBrowserClientEfl::ResourceDispatcherHostCreated() {
+  ResourceDispatcherHost* host = ResourceDispatcherHost::Get();
+  resource_disp_host_del_efl_.reset(new ResourceDispatcherHostDelegateEfl());
+  host->SetDelegate(resource_disp_host_del_efl_.get());
+}
+
+void ContentBrowserClientEfl::AllowCertificateError(
+    int render_process_id, int render_frame_id, int cert_error,
+    const net::SSLInfo& ssl_info, const GURL& request_url,
+    ResourceType::Type resource_type, bool overridable,
+    bool strict_enforcement, const base::Callback<void(bool)>& callback,
+    CertificateRequestResultType* result) {
+
+  WebContents* web_contents = WebContentsFromFrameID(render_process_id, render_frame_id);
+  if (!web_contents) {
+    NOTREACHED();
+    return;
+  }
+  WebContentsDelegate * delegate = web_contents->GetDelegate();
+  if (!delegate) {
+    callback.Run(NULL);
+    return;
+  }
+  static_cast<content::WebContentsDelegateEfl*>(delegate)->
+     RequestCertificateConfirm(web_contents, cert_error, ssl_info, request_url,
+         resource_type, overridable, strict_enforcement, callback, result);
+}
+
+void ContentBrowserClientEfl::RequestDesktopNotificationPermission(
+    const GURL& source_origin, int callback_context,
+    int render_process_id, int render_view_id) {
+#if defined(ENABLE_NOTIFICATIONS)
+  WebContents* web_contents = WebContentsFromViewID(render_process_id,
+                                                    render_view_id);
+  if (!web_contents)
+    return;
+
+  WebContentsDelegateEfl* delegate =
+       static_cast<WebContentsDelegateEfl*>(web_contents->GetDelegate());
+  if (!delegate)
+    return;
+
+  BrowserContextEfl* browser_context =
+      static_cast<BrowserContextEfl*>(web_contents->GetBrowserContext());
+  Ewk_Notification_Permission_Request* notification_permission =
+       new Ewk_Notification_Permission_Request(
+         delegate->web_view()->evas_object(), callback_context, source_origin);
+
+  if (browser_context->GetNotificationController()->
+        IsDefaultAllowed(notification_permission->origin->host)) {
+    browser_context->GetNotificationController()->
+        SetPermissionForNotification(notification_permission, true);
+    delete notification_permission;
+  } else {
+    delegate->web_view()->
+      SmartCallback<EWebViewCallbacks::NotificationPermissionRequest>()
+        .call(notification_permission);
+  }
+#else
+  NOTIMPLEMENTED();
+#endif
+}
+
+void ContentBrowserClientEfl::ShowDesktopNotification(
+    const ShowDesktopNotificationHostMsgParams& params,
+    int render_process_id, int render_view_id, bool /*worker*/) {
+#if defined(ENABLE_NOTIFICATIONS)
+  WebContents* web_contents = WebContentsFromViewID(render_process_id, render_view_id);
+  if (!web_contents)
+    return;
+
+  WebContentsDelegateEfl* delegate =
+      static_cast<WebContentsDelegateEfl*>(web_contents->GetDelegate());
+  if (!delegate)
+    return;
+
+  BrowserContextEfl* browser_context =
+      static_cast<BrowserContextEfl*>(web_contents->GetBrowserContext());
+  uint64_t old_notification_id = 0;
+
+  if (!params.replace_id.empty() && browser_context->GetNotificationController()->
+      IsNotificationPresent(params.replace_id, old_notification_id))
+    CancelDesktopNotification(render_process_id, render_view_id, old_notification_id);
+
+  browser_context->GetNotificationController()->
+      AddNotification(params.notification_id, render_process_id,
+                      render_view_id, params.replace_id);
+  Ewk_Notification* notification = new Ewk_Notification(params);
+  delegate->web_view()->
+      SmartCallback<EWebViewCallbacks::NotificationShow>().call(notification);
+#else
+  NOTIMPLEMENTED();
+#endif
+}
+
+bool ContentBrowserClientEfl::AllowGetCookie(const GURL& url,
+                                             const GURL& first_party,
+                                             const net::CookieList& cookie_list,
+                                             content::ResourceContext* context,
+                                             int render_process_id,
+                                             int render_frame_id) {
+  if (!web_context_)
+      return false;
+
+  CookieManager* cookie_manager = web_context_->cookieManager();
+  if (!cookie_manager)
+    return false;
+
+  return cookie_manager->AllowGetCookie(url,
+                                        first_party,
+                                        cookie_list,
+                                        context,
+                                        render_process_id,
+                                        render_frame_id);
+}
+
+bool ContentBrowserClientEfl::AllowSetCookie(const GURL& url,
+                                             const GURL& first_party,
+                                             const std::string& cookie_line,
+                                             content::ResourceContext* context,
+                                             int render_process_id,
+                                             int render_frame_id,
+                                             net::CookieOptions* options) {
+  if (!web_context_)
+    return false;
+
+  CookieManager* cookie_manager = web_context_->cookieManager();
+  if (!cookie_manager)
+    return false;
+
+  return cookie_manager->AllowSetCookie(url,
+                                        first_party,
+                                        cookie_line,
+                                        context,
+                                        render_process_id,
+                                        render_frame_id,
+                                        options);
+}
+
+void ContentBrowserClientEfl::RenderProcessWillLaunch(
+    content::RenderProcessHost* host) {
+
+  BrowserContextEfl* browser_context = static_cast<BrowserContextEfl*>(
+                                          host->GetBrowserContext());
+  if (browser_context)
+    web_context_ = browser_context->WebContext();
+
+  host->AddFilter(new RenderMessageFilterEfl(host->GetID()));
+  host->AddFilter(new VibrationMessageFilter());
+  host->AddFilter(new editing::EditorClientObserver(host->GetID()));
+}
+
+}
diff --git a/tizen_src/impl/content_browser_client_efl.h b/tizen_src/impl/content_browser_client_efl.h
new file mode 100644 (file)
index 0000000..605a117
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+   Copyright (C) 2014 Samsung Electronics
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef CONTENT_BROWSER_CLIENT_EFL
+#define CONTENT_BROWSER_CLIENT_EFL
+
+#include "content/public/browser/content_browser_client.h"
+
+namespace base {
+class CommandLine;
+}
+
+class EWebContext;
+
+namespace content {
+
+class ResourceDispatcherHostDelegateEfl;
+class BrowserMainPartsEfl;
+class RenderViewHostDelegateView;
+class WebContents;
+class WebContentsView;
+
+class ContentBrowserClientEfl: public ContentBrowserClient {
+ public:
+  ContentBrowserClientEfl();
+
+  virtual BrowserMainParts* CreateBrowserMainParts(
+      const MainFunctionParams& parameters) OVERRIDE;
+
+  virtual WebContentsView* OverrideCreateWebContentsView(
+      WebContents* web_contents,
+      RenderViewHostDelegateView** delegate_view) OVERRIDE;
+
+  virtual net::URLRequestContextGetter* CreateRequestContext(
+      content::BrowserContext* browser_context,
+      content::ProtocolHandlerMap* protocol_handlers) OVERRIDE;
+
+  virtual AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
+#if defined(OS_TIZEN)
+  virtual LocationProvider* OverrideSystemLocationProvider() OVERRIDE;
+#endif
+
+  // Allows the embedder to pass extra command line flags.
+  // switches::kProcessType will already be set at this point.
+  virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
+                                              int child_process_id) OVERRIDE;
+
+  virtual void ResourceDispatcherHostCreated() OVERRIDE;
+
+  virtual void AllowCertificateError(int render_process_id,
+                                     int render_frame_id,
+                                     int cert_error,
+                                     const net::SSLInfo& ssl_info,
+                                     const GURL& request_url,
+                                     ResourceType::Type resource_type,
+                                     bool overridable,
+                                     bool strict_enforcement,
+                                     const base::Callback<void(bool)>& callback,
+                                     CertificateRequestResultType* result) OVERRIDE;
+
+  // Asks permission to show desktop notifications.
+  virtual void RequestDesktopNotificationPermission(const GURL& source_origin,
+                                                    int callback_context,
+                                                    int render_process_id,
+                                                    int render_view_id) OVERRIDE;
+
+  // Show a desktop notification.  If |worker| is true, the request came from an
+  // HTML5 web worker, otherwise, it came from a renderer.
+  virtual void ShowDesktopNotification(const ShowDesktopNotificationHostMsgParams& params,
+                                       int render_process_id,
+                                       int render_view_id,
+                                       bool worker) OVERRIDE;
+
+  virtual bool AllowGetCookie(const GURL& url,
+                              const GURL& first_party,
+                              const net::CookieList& cookie_list,
+                              content::ResourceContext* context,
+                              int render_process_id,
+                              int render_frame_id) OVERRIDE;
+
+  virtual bool AllowSetCookie(const GURL& url,
+                              const GURL& first_party,
+                              const std::string& cookie_line,
+                              content::ResourceContext* context,
+                              int render_process_id,
+                              int render_frame_id,
+                              net::CookieOptions* options) OVERRIDE;
+
+  virtual void RenderProcessWillLaunch(content::RenderProcessHost* host) OVERRIDE;
+
+ private:
+  scoped_ptr<ResourceDispatcherHostDelegateEfl> resource_disp_host_del_efl_;
+  EWebContext* web_context_;
+  BrowserMainPartsEfl* browser_main_parts_efl_;
+
+  DISALLOW_COPY_AND_ASSIGN(ContentBrowserClientEfl);
+};
+
+}
+
+#endif // CONTENT_BROWSER_CLIENT_EFL
diff --git a/tizen_src/impl/content_main_delegate_efl.cc b/tizen_src/impl/content_main_delegate_efl.cc
new file mode 100644 (file)
index 0000000..6134089
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+   Copyright (C) 2014 Samsung Electronics
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "content_main_delegate_efl.h"
+
+#include "paths_efl.h"
+#include "command_line_efl.h"
+#include "content_browser_client_efl.h"
+#include "base/path_service.h"
+#include "content/browser/gpu/gpu_process_host.h"
+#include "content/gpu/in_process_gpu_thread.h"
+#include "content/public/common/content_switches.h"
+
+namespace content {
+
+std::string SubProcessPath() {
+  static std::string result;
+  if (!result.empty())
+    return result;
+
+  char* path_from_env = getenv("EFL_WEBPROCESS_PATH");
+  if (path_from_env) {
+    result = std::string(path_from_env);
+    return result;
+  }
+
+  base::FilePath pak_dir;
+  base::FilePath pak_file;
+  PathService::Get(base::DIR_EXE, &pak_dir);
+  pak_file = pak_dir.Append(FILE_PATH_LITERAL("efl_webprocess"));
+
+  return pak_file.AsUTF8Unsafe();
+}
+
+void ContentMainDelegateEfl::PreSandboxStartup() {
+  PathService::Override(base::FILE_EXE, base::FilePath(SubProcessPath()));
+
+  // needed for gpu process
+  CommandLine::ForCurrentProcess()->AppendSwitchPath(
+      switches::kBrowserSubprocessPath, base::FilePath(SubProcessPath()));
+
+  // needed for gpu thread
+  GpuProcessHost::RegisterGpuMainThreadFactory(CreateInProcessGpuThread);
+}
+
+ContentBrowserClient* ContentMainDelegateEfl::CreateContentBrowserClient() {
+  client_.reset(new ContentBrowserClientEfl);
+  return client_.get();
+}
+
+bool ContentMainDelegateEfl::BasicStartupComplete(int* /*exit_code*/) {
+  content::SetContentClient(&content_client_);
+  PathsEfl::Register();
+  return false;
+}
+
+} // namespace content
diff --git a/tizen_src/impl/content_main_delegate_efl.h b/tizen_src/impl/content_main_delegate_efl.h
new file mode 100644 (file)
index 0000000..84b6f68
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+   Copyright (C) 2014 Samsung Electronics
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef CONTENT_MAIN_DELEGATE
+#define CONTENT_MAIN_DELEGATE
+
+#include "content/public/app/content_main_delegate.h"
+
+#include "base/compiler_specific.h"
+#include "content/public/browser/content_browser_client.h"
+#include "common/content_client_efl.h"
+
+class EWebContext;
+
+namespace content {
+
+class ContentMainDelegateEfl
+    : public ContentMainDelegate {
+ public:
+  ContentMainDelegateEfl() {}
+  // Tells the embedder that the absolute basic startup has been done, i.e.
+  // it's now safe to create singletons and check the command line. Return true
+  // if the process should exit afterwards, and if so, |exit_code| should be
+  // set. This is the place for embedder to do the things that must happen at
+  // the start. Most of its startup code should be in the methods below.
+  virtual bool BasicStartupComplete(int* exit_code) OVERRIDE;
+  virtual void PreSandboxStartup() OVERRIDE;
+  virtual ContentBrowserClient* CreateContentBrowserClient() OVERRIDE;
+
+ private:
+  scoped_ptr<ContentBrowserClient> client_;
+  ContentClientEfl content_client_;
+  DISALLOW_COPY_AND_ASSIGN(ContentMainDelegateEfl);
+};
+
+}
+
+#endif
diff --git a/tizen_src/impl/resource_dispatcher_host_delegate_efl.cc b/tizen_src/impl/resource_dispatcher_host_delegate_efl.cc
new file mode 100644 (file)
index 0000000..8454b15
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+   Copyright (C) 2014 Samsung Electronics
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "resource_dispatcher_host_delegate_efl.h"
+
+#include "eweb_context.h"
+#include "browser_context_efl.h"
+#include "browser/login_delegate_efl.h"
+#include "common/web_contents_utils.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/resource_request_info.h"
+
+using web_contents_utils::WebContentsFromFrameID;
+
+namespace content {
+
+namespace {
+
+void TriggerNewDownloadStartCallbackOnUIThread(
+    EwkDidStartDownloadCallback* start_download_callback,
+    const GURL& url,
+    const std::string& /*user_agent*/,
+    const std::string& /*content_disposition*/,
+    const std::string& /*mime_type*/,
+    int64 /*content_length*/) {
+  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  start_download_callback->TriggerCallback(url.spec());
+}
+
+}
+
+void ResourceDispatcherHostDelegateEfl::RequestBeginning(
+    net::URLRequest* request,
+    ResourceContext* resource_context,
+    appcache::AppCacheService* appcache_service,
+    ResourceType::Type resource_type,
+    int child_id,
+    int route_id,
+    ScopedVector<ResourceThrottle>* throttles) {
+
+  BrowserContextEfl::ResourceContextEfl *resource_context_efl =
+      static_cast<BrowserContextEfl::ResourceContextEfl*>(resource_context);
+  if(!resource_context_efl)
+    return;
+
+  BrowserContextEfl *browser_context = resource_context_efl->getBrowserContext();
+  if(!browser_context)
+    return;
+
+  EWebContext* eweb_context = browser_context->WebContext();
+  if(!eweb_context)
+    return;
+
+  HTTPCustomHeadersEflMap header_map = eweb_context->GetHTTPCustomHeadersEflMap();
+  for (HTTPCustomHeadersEflMap::iterator it = header_map.begin();
+       it != header_map.end();
+       ++it)
+    request->SetExtraRequestHeaderByName(it->first, it->second, true);
+}
+
+ResourceDispatcherHostLoginDelegate*
+ResourceDispatcherHostDelegateEfl::CreateLoginDelegate(
+        net::AuthChallengeInfo* auth_info,
+        net::URLRequest* request) {
+  return new LoginDelegateEfl(auth_info, request);
+}
+
+void ResourceDispatcherHostDelegateEfl::DownloadStarting(
+    net::URLRequest* request,
+    content::ResourceContext* resource_context,
+    int child_id,
+    int route_id,
+    int request_id,
+    bool is_content_initiated,
+    bool must_download,
+    ScopedVector<content::ResourceThrottle>* throttles) {
+
+  std::string user_agent;
+  std::string content_disposition;
+  std::string mime_type;
+  int64 content_length = request->GetExpectedContentSize();
+
+  request->GetResponseHeaderByName("content-disposition", &content_disposition);
+  request->extra_request_headers().GetHeader(
+      net::HttpRequestHeaders::kUserAgent, &user_agent);
+  request->GetMimeType(&mime_type);
+
+  request->Cancel();
+  // POST request cannot be repeated in general, so prevent client from
+  // retrying the same request, even if it is with a GET.
+  if ("GET" == request->method()) {
+    TriggerNewDownloadStartCallback(request,
+                user_agent,
+                content_disposition,
+                mime_type,
+                content_length);
+  }
+}
+
+void ResourceDispatcherHostDelegateEfl::TriggerNewDownloadStartCallback(
+    net::URLRequest* request,
+    const std::string& user_agent,
+    const std::string& content_disposition,
+    const std::string& mime_type,
+    int64 content_length) {
+
+  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+  int render_process_id = -1;
+  int render_frame_id = -1;
+  if (!ResourceRequestInfo::GetRenderFrameForRequest(request, &render_process_id, &render_frame_id))
+    return;
+
+  if (render_process_id == -1 || render_frame_id == -1)
+    return;
+
+  WebContents* web_contents = WebContentsFromFrameID(render_process_id, render_frame_id);
+  if (!web_contents)
+    return;
+
+  BrowserContextEfl* browser_context = static_cast<BrowserContextEfl*>(web_contents->GetBrowserContext());
+  if (!browser_context)
+    return;
+
+  EwkDidStartDownloadCallback* start_download_callback = browser_context->WebContext()->DidStartDownloadCallback();
+  if (!start_download_callback)
+    return;
+
+  //Since called by IO thread callback trigger needs to be posted to UI thread so that IO thread is unblocked
+  BrowserThread::PostTask(
+    BrowserThread::UI, FROM_HERE,
+    base::Bind(TriggerNewDownloadStartCallbackOnUIThread,
+               start_download_callback,
+               request->url(),
+               user_agent,
+               content_disposition,
+               mime_type,
+               content_length));
+}
+
+} // namespace content
diff --git a/tizen_src/impl/resource_dispatcher_host_delegate_efl.h b/tizen_src/impl/resource_dispatcher_host_delegate_efl.h
new file mode 100644 (file)
index 0000000..b82af97
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+   Copyright (C) 2014 Samsung Electronics
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef RESOURCE_DISPATCHER_HOST_DELEGATE_EFL_H
+#define RESOURCE_DISPATCHER_HOST_DELEGATE_EFL_H
+
+#include "content/public/browser/resource_dispatcher_host_delegate.h"
+
+namespace content {
+
+class ResourceDispatcherHostDelegateEfl
+    : public ResourceDispatcherHostDelegate {
+ public:
+  ResourceDispatcherHostDelegateEfl() {}
+
+  // Called after ShouldBeginRequest to allow the embedder to add resource
+  // throttles.
+  virtual void RequestBeginning(
+      net::URLRequest* request,
+      ResourceContext* resource_context,
+      appcache::AppCacheService* appcache_service,
+      ResourceType::Type resource_type,
+      int child_id,
+      int route_id,
+      ScopedVector<ResourceThrottle>* throttles) OVERRIDE;
+
+  virtual ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
+      net::AuthChallengeInfo* auth_info,
+      net::URLRequest* request) OVERRIDE;
+
+  virtual void DownloadStarting(
+      net::URLRequest* request,
+      content::ResourceContext* resource_context,
+      int child_id,
+      int route_id,
+      int request_id,
+      bool is_content_initiated,
+      bool must_download,
+      ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE;
+
+ private:
+  void TriggerNewDownloadStartCallback(net::URLRequest* request,
+                                       const std::string& user_agent,
+                                       const std::string& content_disposition,
+                                       const std::string& mime_type,
+                                       int64 content_length);
+
+};
+
+}
+
+#endif // RESOURCE_DISPATCHER_HOST_DELEGETE_EFL_H