Unify ContentMainDelegateEfl and WebProcessContentMainDelegateEfl
authorAntonio Gomes <a1.gomes@samsung.com>
Wed, 20 Jan 2016 23:13:59 +0000 (19:13 -0400)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 07:55:23 +0000 (07:55 +0000)
Both classes are EWK delegates to the main process kick off routines.
It turns out though that chromium-efl is the only content-based
app that has two different delegates for browser and renderer processes.
Chrome (ChromeMainDelegate) and ContentShell (ShellMainDelegate) for
instance have this class unified.

That said, patch merges WebProcessContentMainDelegateEfl into
ContentMainDelegateEfl, simplifying our logic.
WebProcessContentMainDelegateEfl's main method PreSandboxStartup
was merged into ContentMainDelegateEfl counterpart.

Original beta/m47 patch:
- http://165.213.202.130/gerrit/#/c/105265/

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=14350

Reviewed by: djmix.kim, sns.park

Change-Id: Idff02ac417b8247d0fd498db7d99cf3a60b60fb7
Signed-off-by: Antonio Gomes <a1.gomes@samsung.com>
tizen_src/ewk/efl_integration/content_main_delegate_efl.cc
tizen_src/ewk/efl_integration/content_main_delegate_efl.h
tizen_src/ewk/efl_integration/efl_integration.gypi
tizen_src/ewk/efl_integration/efl_webprocess_main.cc
tizen_src/ewk/efl_integration/web_process_content_main_delegate_efl.cc [deleted file]
tizen_src/ewk/efl_integration/web_process_content_main_delegate_efl.h [deleted file]

index 029faea..9b86696 100644 (file)
@@ -5,14 +5,16 @@
 #include "content_main_delegate_efl.h"
 
 #include "base/path_service.h"
+#include "browser/resource_dispatcher_host_delegate_efl.h"
+#include "command_line_efl.h"
 #include "content/browser/gpu/gpu_process_host.h"
 #include "content/common/paths_efl.h"
 #include "content/gpu/in_process_gpu_thread.h"
 #include "content/public/common/content_switches.h"
-#include "browser/resource_dispatcher_host_delegate_efl.h"
-#include "command_line_efl.h"
 #include "content_browser_client_efl.h"
 #include "locale_efl.h"
+#include "renderer/content_renderer_client_efl.h"
+#include "ui/base/resource/resource_bundle.h"
 
 namespace content {
 
@@ -67,7 +69,7 @@ void InitializeDiskCacheDir() {
 }
 } // namespace
 
-void ContentMainDelegateEfl::PreSandboxStartup() {
+void ContentMainDelegateEfl::PreSandboxStartupBrowser() {
   PathService::Override(base::FILE_EXE, base::FilePath(SubProcessPath()));
 
   InitializeUserDataDir();
@@ -81,9 +83,30 @@ void ContentMainDelegateEfl::PreSandboxStartup() {
   GpuProcessHost::RegisterGpuMainThreadFactory(CreateInProcessGpuThread);
 }
 
+void ContentMainDelegateEfl::PreSandboxStartup() {
+  base::FilePath pak_dir;
+  base::FilePath pak_file;
+  PathService::Get(base::DIR_EXE, &pak_dir);
+  pak_file = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak"));
+  ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
+
+  const base::CommandLine& command_line =
+      *base::CommandLine::ForCurrentProcess();
+  std::string process_type =
+      command_line.GetSwitchValueASCII(switches::kProcessType);
+  if (process_type.empty()) { // browser process
+    PreSandboxStartupBrowser();
+  }
+}
+
+ContentRendererClient* ContentMainDelegateEfl::CreateContentRendererClient() {
+  renderer_client_.reset(new ContentRendererClientEfl);
+  return renderer_client_.get();
+}
+
 ContentBrowserClient* ContentMainDelegateEfl::CreateContentBrowserClient() {
-  client_.reset(new ContentBrowserClientEfl);
-  return client_.get();
+  browser_client_.reset(new ContentBrowserClientEfl);
+  return browser_client_.get();
 }
 
 bool ContentMainDelegateEfl::BasicStartupComplete(int* /*exit_code*/) {
@@ -94,7 +117,7 @@ bool ContentMainDelegateEfl::BasicStartupComplete(int* /*exit_code*/) {
 }
 
 ContentBrowserClient* ContentMainDelegateEfl::GetContentBrowserClient() const {
-  return client_.get();
+  return browser_client_.get();
 }
 
 } // namespace content
index ca7de67..4ed5843 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "base/compiler_specific.h"
 #include "content/public/browser/content_browser_client.h"
+#include "content/public/renderer/content_renderer_client.h"
 #include "common/content_client_efl.h"
 
 namespace content {
@@ -25,11 +26,15 @@ class ContentMainDelegateEfl
   virtual bool BasicStartupComplete(int* exit_code) override;
   virtual void PreSandboxStartup() override;
   virtual ContentBrowserClient* CreateContentBrowserClient() override;
+  virtual ContentRendererClient* CreateContentRendererClient() override;
 
   ContentBrowserClient* GetContentBrowserClient() const;
 
  private:
-  scoped_ptr<ContentBrowserClient> client_;
+  void PreSandboxStartupBrowser();
+
+  scoped_ptr<ContentBrowserClient> browser_client_;
+  scoped_ptr<ContentRendererClient> renderer_client_;
   ContentClientEfl content_client_;
   DISALLOW_COPY_AND_ASSIGN(ContentMainDelegateEfl);
 };
index 47780d0..5e1dc8f 100644 (file)
       'web_contents_view_delegate_ewk.h',
       'web_contents_view_efl_delegate_ewk.cc',
       'web_contents_view_efl_delegate_ewk.h',
-      'web_process_content_main_delegate_efl.cc',
-      'web_process_content_main_delegate_efl.h',
 
       'browser/browsing_data_remover_efl.cc',
       'browser/browsing_data_remover_efl.h',
index c3373a0..b4ec37a 100644 (file)
@@ -5,12 +5,13 @@
 #include "efl_webprocess_main.h"
 
 #include "base/logging.h"
-#include "web_process_content_main_delegate_efl.h"
+#include "content_main_delegate_efl.h"
+#include "content/public/app/content_main.h"
 
 int efl_webprocess_main(int argc, const char **argv) {
   LOG(INFO) << "web process launching...";
 
-  content::WebProcessContentMainDelegateEfl content_main_delegate;
+  content::ContentMainDelegateEfl content_main_delegate;
   content::ContentMainParams params(&content_main_delegate);
 
   params.argc = argc;
diff --git a/tizen_src/ewk/efl_integration/web_process_content_main_delegate_efl.cc b/tizen_src/ewk/efl_integration/web_process_content_main_delegate_efl.cc
deleted file mode 100644 (file)
index 6e963a9..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2014 Samsung Electronics. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "web_process_content_main_delegate_efl.h"
-
-#include "base/files/file_path.h"
-#include "base/path_service.h"
-#include "content/common/paths_efl.h"
-#include "content/public/common/referrer.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "renderer/content_renderer_client_efl.h"
-#include "common/content_client_efl.h"
-#include "locale_efl.h"
-
-namespace content {
-
-// static
-ContentRendererClient* WebProcessContentMainDelegateEfl::CreateContentRendererClient() {
-  return new ContentRendererClientEfl();
-}
-
-// ContentMainDelegate implementation:
-void WebProcessContentMainDelegateEfl::PreSandboxStartup() {
-  base::FilePath pak_dir;
-  base::FilePath pak_file;
-  PathService::Get(base::DIR_EXE, &pak_dir);
-  pak_file = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak"));
-  ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
-  LocaleEfl::Initialize();
-}
-
-bool WebProcessContentMainDelegateEfl::BasicStartupComplete(int* exit_code) {
-  PathsEfl::Register();
-
-  ContentClientEfl* content_client = new ContentClientEfl();
-  content::SetContentClient(content_client);
-  return false;
-}
-
-} // namespace content
diff --git a/tizen_src/ewk/efl_integration/web_process_content_main_delegate_efl.h b/tizen_src/ewk/efl_integration/web_process_content_main_delegate_efl.h
deleted file mode 100644 (file)
index d361fa4..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2014 Samsung Electronics. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef WEB_PROCESS_CONTENT_MAIN_DELEGATE_H
-#define WEB_PROCESS_CONTENT_MAIN_DELEGATE_H
-
-#include "base/compiler_specific.h"
-#include "content/public/app/content_main.h"
-#include "content/public/app/content_main_delegate.h"
-
-namespace content {
-
-class WebProcessContentMainDelegateEfl: public content::ContentMainDelegate {
- public:
-  virtual void PreSandboxStartup() override;
-  virtual bool BasicStartupComplete(int* exit_code) override;
-  virtual ContentRendererClient* CreateContentRendererClient() override;
-};
-
-} // namespace content
-
-#endif // WEB_PROCESS_CONTENT_MAIN_DELEGATE_H