Offsreen Rendering support based on Ozone EFL 15/284815/9
authorGajendra N <gajendra.n@samsung.com>
Thu, 24 Nov 2022 04:54:13 +0000 (10:24 +0530)
committerGajendra N <gajendra.n@samsung.com>
Mon, 12 Dec 2022 11:55:18 +0000 (17:25 +0530)
Major changes:
1) Gets evas smart object created from ewk api and sets the same to
   GLSharedContextEfl to initialize evas gl context and surface.
2) Instantiates WindowTreeHost (Platform Window Delegate) in efl layer
   for adding webcontents native view as child of aura root window.
3) Initializes ScreenOzone in EwkGlobalData.
4) Adds runtime flag --enable-offscreen-rendering to enable offscreen flow.
5) Adds necessary command line flags to CommandLineEfl.
6) Fixes exit/shutdown crash while closing browsers (ewa/ubrowser).

Launch commands:
Desktop EFL : ./out.x64/efl_webview_app.sh
TM1 / TV    : /usr/apps/org.tizen.chromium-efl/bin/ubrowser

References:
1) [M94 Migration] Offscreen rendering with ozone-platform=efl
   https://review.tizen.org/gerrit/269556

2) Move ownership of aura::ScreenOzone to EwkGlobalData
   https://review.tizen.org/gerrit/277890

3) Avoid crash during cleanup and memory exceed
   https://review.tizen.org/gerrit/274512

Change-Id: I1ff270931af8e47011aca37e4f84e68e6d280db4
Signed-off-by: Gajendra N <gajendra.n@samsung.com>
38 files changed:
base/base_switches.cc
base/base_switches.h
base/task/sequence_manager/sequence_manager_impl.cc
base/task/sequence_manager/thread_controller.h
base/task/sequence_manager/thread_controller_impl.cc
base/task/sequence_manager/thread_controller_impl.h
base/task/sequence_manager/thread_controller_with_message_pump_impl.cc
base/task/sequence_manager/thread_controller_with_message_pump_impl.h
content/browser/renderer_host/render_widget_host_view_aura.cc
content/browser/renderer_host/render_widget_host_view_aura.h
content/browser/web_contents/web_contents_impl.cc
content/browser/web_contents/web_contents_impl.h
content/browser/web_contents/web_contents_view_aura.cc
tizen_src/chromium_impl/content/browser/browser_efl.gni
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc [new file with mode: 0644]
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h [new file with mode: 0644]
tizen_src/chromium_impl/content/gpu/in_process_gpu_thread_efl.cc
tizen_src/chromium_impl/efl/init.cc
tizen_src/chromium_impl/ui/ozone/platform/efl/efl_window.cc
tizen_src/chromium_impl/ui/ozone/platform/efl/efl_window.h
tizen_src/ewk/efl_integration/BUILD.gn
tizen_src/ewk/efl_integration/browser_context_efl.cc
tizen_src/ewk/efl_integration/command_line_efl.cc
tizen_src/ewk/efl_integration/common/content_client_efl.cc
tizen_src/ewk/efl_integration/common/content_client_efl.h
tizen_src/ewk/efl_integration/common/version_info.cc
tizen_src/ewk/efl_integration/content_browser_client_efl.cc
tizen_src/ewk/efl_integration/content_browser_client_efl.h
tizen_src/ewk/efl_integration/content_main_delegate_efl.cc
tizen_src/ewk/efl_integration/eweb_context.cc
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/eweb_view.h
tizen_src/ewk/efl_integration/ewk_global_data.cc
tizen_src/ewk/efl_integration/ewk_global_data.h
tizen_src/ewk/efl_integration/permission_controller_delegate_efl.cc
tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc
tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.h [changed mode: 0644->0755]
ui/gl/gl_context_egl.cc

index 28fdb35..b87ad61 100644 (file)
@@ -147,6 +147,7 @@ const char kDisableDevShmUsage[] = "disable-dev-shm-usage";
 // Used for limiting memory allocations in MessagePumpForUIEfl.
 const char kLimitMemoryAllocationInScheduleDelayedWork[] =
     "limit-memory-allocation-in-schedule-delayed-work";
+const char kEnableOffscreenRendering[] = "enable-offscreen-rendering";
 #endif
 
 #if BUILDFLAG(IS_POSIX)
index 75d2b3c..642e5b5 100644 (file)
@@ -50,6 +50,7 @@ extern const char kDisableDevShmUsage[];
 
 #if defined(USE_EFL)
 extern const char kLimitMemoryAllocationInScheduleDelayedWork[];
+extern const char kEnableOffscreenRendering[];
 #endif
 
 #if BUILDFLAG(IS_POSIX)
index afa8f38..cf3c8aa 100644 (file)
@@ -379,7 +379,7 @@ void SequenceManagerImpl::BindToMessagePump(std::unique_ptr<MessagePump> pump) {
 #endif
 
   // On iOS/EFL attach to the native loop when there is one.
-#if BUILDFLAG(IS_IOS)
+#if BUILDFLAG(IS_IOS) || defined(USE_EFL)
   if (settings_.message_loop_type == MessagePumpType::UI) {
     controller_->AttachToMessagePump();
   }
index aa12d8f..a26f848 100644 (file)
@@ -131,7 +131,7 @@ class BASE_EXPORT ThreadController {
   // Returns true if the current run loop should quit when idle.
   virtual bool ShouldQuitRunLoopWhenIdle() = 0;
 
-#if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_ANDROID)
+#if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_ANDROID) || defined(USE_EFL)
   // On iOS, the main message loop cannot be Run().  Instead call
   // AttachToMessagePump(), which connects this ThreadController to the
   // UI thread's CFRunLoop and allows PostTask() to work.
index 9e56b5f..415b6b2 100644 (file)
@@ -361,7 +361,7 @@ MessagePump* ThreadControllerImpl::GetBoundMessagePump() const {
   return nullptr;
 }
 
-#if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_ANDROID)
+#if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_ANDROID) || defined(USE_EFL)
 void ThreadControllerImpl::AttachToMessagePump() {
   NOTREACHED();
 }
index a6664c0..4fc321d 100644 (file)
@@ -61,7 +61,7 @@ class BASE_EXPORT ThreadControllerImpl : public ThreadController,
   void SetTaskExecutionAllowed(bool allowed) override;
   bool IsTaskExecutionAllowed() const override;
   MessagePump* GetBoundMessagePump() const override;
-#if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_ANDROID)
+#if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_ANDROID) || defined(USE_EFL)
   void AttachToMessagePump() override;
 #endif
 #if BUILDFLAG(IS_IOS)
index 55d9675..067d631 100644 (file)
@@ -29,6 +29,8 @@
 #include "base/message_loop/message_pump_mac.h"
 #elif BUILDFLAG(IS_ANDROID)
 #include "base/message_loop/message_pump_android.h"
+#elif defined(USE_EFL)
+#include "base/message_loop/message_pump_for_ui_efl.h"
 #endif
 
 namespace base {
@@ -689,6 +691,10 @@ void ThreadControllerWithMessagePumpImpl::DetachFromMessagePump() {
 void ThreadControllerWithMessagePumpImpl::AttachToMessagePump() {
   static_cast<MessagePumpForUI*>(pump_.get())->Attach(this);
 }
+#elif defined(USE_EFL)
+void ThreadControllerWithMessagePumpImpl::AttachToMessagePump() {
+  static_cast<MessagePumpForUIEfl*>(pump_.get())->Attach(this);
+}
 #endif
 
 base::TimeDelta ThreadControllerWithMessagePumpImpl::GetAlternationInterval() {
index 66208c8..8fcdb84 100644 (file)
@@ -77,7 +77,7 @@ class BASE_EXPORT ThreadControllerWithMessagePumpImpl
   MessagePump* GetBoundMessagePump() const override;
   void PrioritizeYieldingToNative(base::TimeTicks prioritize_until) override;
   void EnablePeriodicYieldingToNative(base::TimeDelta delta) override;
-#if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_ANDROID)
+#if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_ANDROID) || defined(USE_EFL)
   void AttachToMessagePump() override;
 #endif
 #if BUILDFLAG(IS_IOS)
index 8b712a2..14d5617 100644 (file)
 #include "ui/base/ime/mojom/virtual_keyboard_types.mojom.h"
 #endif
 
+#if defined(USE_EFL)
+#include "base/base_switches.h"
+#endif
+
 using gfx::RectToSkIRect;
 using gfx::SkIRectToRect;
 
@@ -249,7 +253,8 @@ class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver {
 // RenderWidgetHostViewAura, public:
 
 RenderWidgetHostViewAura::RenderWidgetHostViewAura(
-    RenderWidgetHost* widget_host)
+    RenderWidgetHost* widget_host,
+    WebContents& web_contents)
     : RenderWidgetHostViewBase(widget_host),
       window_(nullptr),
       in_shutdown_(false),
@@ -302,6 +307,14 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(
   }
 
   host()->render_frame_metadata_provider()->AddObserver(this);
+
+#if defined(USE_EFL)
+  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kEnableOffscreenRendering)) {
+    offscreen_helper_ =
+        std::make_unique<RWHVAuraOffscreenHelperEfl>(this, &web_contents);
+  }
+#endif
 }
 
 ////////////////////////////////////////////////////////////////////////////////
index 9688a16..776aac9 100644 (file)
 #include "content/browser/renderer_host/virtual_keyboard_controller_win.h"
 #endif
 
+#if defined(USE_EFL)
+#include "content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h"
+#endif
+
 namespace aura_extra {
 class WindowPositionInRootMonitor;
 }
@@ -102,7 +106,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
       public aura::client::FocusChangeObserver,
       public aura::client::CursorClientObserver {
  public:
-  explicit RenderWidgetHostViewAura(RenderWidgetHost* host);
+  explicit RenderWidgetHostViewAura(RenderWidgetHost* host,
+                                    WebContents& web_contents);
   RenderWidgetHostViewAura(const RenderWidgetHostViewAura&) = delete;
   RenderWidgetHostViewAura& operator=(const RenderWidgetHostViewAura&) = delete;
 
@@ -399,11 +404,20 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
 
   ui::Compositor* GetCompositor() override;
 
+#if defined(USE_EFL)
+  aura::Window* window() { return window_; }
+  RWHVAuraOffscreenHelperEfl* offscreen_helper() {
+    return offscreen_helper_.get();
+  }
+#endif
+
  protected:
   ~RenderWidgetHostViewAura() override;
 
+#if !defined(USE_EFL)
   // Exposed for tests.
   aura::Window* window() { return window_; }
+#endif
 
   DelegatedFrameHost* GetDelegatedFrameHost() const {
     return delegated_frame_host_.get();
@@ -786,6 +800,10 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
 
   absl::optional<display::ScopedDisplayObserver> display_observer_;
 
+#if defined(USE_EFL)
+  std::unique_ptr<RWHVAuraOffscreenHelperEfl> offscreen_helper_;
+#endif
+
   base::WeakPtrFactory<RenderWidgetHostViewAura> weak_ptr_factory_{this};
 };
 
index 04bd451..327ac57 100644 (file)
 #include "ui/aura/window.h"
 #endif
 
+#if defined(USE_EFL)
+#include <Elementary.h>
+
+#include "base/base_switches.h"
+#include "base/path_service.h"
+#include "tizen_src/chromium_impl/content/common/paths_efl.h"
+#include "tizen_src/chromium_impl/efl/window_factory.h"
+#include "tizen_src/chromium_impl/ui/ozone/platform/efl/efl_screen.h"
+#include "ui/gl/gl_shared_context_efl.h"
+#endif
+
 namespace content {
 
 namespace {
@@ -9567,4 +9578,20 @@ std::pair<int, int> WebContentsImpl::GetAvailablePointerAndHoverTypes() {
   return ui::GetAvailablePointerAndHoverTypes();
 }
 
+#if defined(USE_EFL)
+void WebContentsImpl::CreateEflNativeView() {
+  Evas_Object* root_window = efl::WindowFactory::GetHostWindow(this);
+  efl_native_view_ = elm_layout_add(root_window);
+
+  base::FilePath edj_dir;
+  base::PathService::Get(PathsEfl::EDJE_RESOURCE_DIR, &edj_dir);
+
+  base::FilePath main_edj = edj_dir.Append(FILE_PATH_LITERAL("MainLayout.edj"));
+  elm_layout_file_set(efl_native_view_, main_edj.AsUTF8Unsafe().c_str(),
+                      "main_layout");
+
+  GLSharedContextEfl::Initialize(root_window);
+}
+#endif
+
 }  // namespace content
index faf8938..738061d 100644 (file)
 #include "content/public/browser/android/child_process_importance.h"
 #endif
 
+#if defined(USE_EFL)
+#include <Evas.h>
+#endif
+
 namespace base {
 class FilePath;
 }  // namespace base
@@ -219,6 +223,11 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
   virtual void Init(const WebContents::CreateParams& params,
                     blink::FramePolicy primary_main_frame_policy);
 
+#if defined(USE_EFL)
+  void CreateEflNativeView();
+  Evas_Object* GetEflNativeView() const { return efl_native_view_; }
+#endif
+
   // Returns the SavePackage which manages the page saving job. May be NULL.
   SavePackage* save_package() const { return save_package_.get(); }
 
@@ -2375,6 +2384,10 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
 
   bool prerender2_disabled_ = false;
 
+#if defined(USE_EFL)
+  Evas_Object* efl_native_view_ = nullptr;
+#endif
+
   base::WeakPtrFactory<WebContentsImpl> loading_weak_factory_{this};
   base::WeakPtrFactory<WebContentsImpl> weak_factory_{this};
 };
index 7a7f170..c134cfb 100644 (file)
 #include "ui/gfx/image/image_skia.h"
 #include "ui/touch_selection/touch_selection_controller.h"
 
+#if defined(USE_EFL)
+#include "base/base_switches.h"
+#endif
+
 namespace content {
 
 std::unique_ptr<WebContentsView> CreateWebContentsView(
@@ -1044,6 +1048,13 @@ Visibility WebContentsViewAura::GetVisibility() const {
 // WebContentsViewAura, WebContentsView implementation:
 
 void WebContentsViewAura::CreateView(gfx::NativeView context) {
+#if defined(USE_EFL)
+  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kEnableOffscreenRendering)) {
+    web_contents_->CreateEflNativeView();
+  }
+#endif
+
   CreateAuraWindow(context);
 
   // delegate_->GetDragDestDelegate() creates a new delegate on every call.
@@ -1069,7 +1080,7 @@ RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget(
   RenderWidgetHostViewAura* view =
       g_create_render_widget_host_view
           ? g_create_render_widget_host_view(render_widget_host)
-          : new RenderWidgetHostViewAura(render_widget_host);
+          : new RenderWidgetHostViewAura(render_widget_host, *web_contents_);
   view->InitAsChild(GetRenderWidgetHostViewParent());
 
   RenderWidgetHostImpl* host_impl =
@@ -1092,7 +1103,7 @@ RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget(
 
 RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForChildWidget(
     RenderWidgetHost* render_widget_host) {
-  return new RenderWidgetHostViewAura(render_widget_host);
+  return new RenderWidgetHostViewAura(render_widget_host, *web_contents_);
 }
 
 void WebContentsViewAura::SetPageTitle(const std::u16string& title) {
index c7dafea..ed7da40 100644 (file)
@@ -72,6 +72,8 @@ external_content_browser_efl_sources = [
   "//tizen_src/chromium_impl/content/browser/public/browser/web_contents_view_efl_delegate.h",
   "//tizen_src/chromium_impl/content/browser/renderer_host/edge_effect.cc",
   "//tizen_src/chromium_impl/content/browser/renderer_host/edge_effect.h",
+  "//tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc",
+  "//tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h",
   "//tizen_src/chromium_impl/content/browser/screen_orientation/screen_orientation_delegate_efl.cc",
   "//tizen_src/chromium_impl/content/browser/screen_orientation/screen_orientation_delegate_efl.h",
   "//tizen_src/chromium_impl/content/browser/selection/selection_box_efl.cc",
diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc
new file mode 100644 (file)
index 0000000..efedfa5
--- /dev/null
@@ -0,0 +1,549 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h"
+
+#include <Ecore_Evas.h>
+#include <Elementary.h>
+
+#include "base/base_switches.h"
+#include "content/browser/renderer_host/render_widget_host_view_aura.h"
+#include "content/browser/web_contents/web_contents_impl.h"
+#include "content/browser/web_contents/web_contents_view_aura.h"
+#include "content/public/browser/web_contents_delegate.h"
+#include "gpu/command_buffer/service/texture_base.h"
+#include "skia/ext/image_operations.h"
+#include "tizen/system_info.h"
+#include "ui/aura/client/focus_client.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_tree_host_platform.h"
+#include "ui/display/screen.h"
+#include "ui/events/gestures/gesture_types.h"
+#include "ui/gfx/geometry/dip_util.h"
+#include "ui/gfx/skbitmap_operations.h"
+#include "ui/gl/gl_share_group.h"
+#include "ui/gl/gl_shared_context_efl.h"
+#include "ui/platform_window/platform_window.h"
+
+#define MAX_SURFACE_WIDTH_EGL 4096   // max supported Framebuffer width
+#define MAX_SURFACE_HEIGHT_EGL 4096  // max supported Framebuffer height
+
+// These two constants are redefinitions of the original constants defined
+// in evas_common.c. These are not supposed to be used directly by apps,
+// but we do this because of chromium uses fbo for direct rendering.
+#define EVAS_GL_OPTIONS_DIRECT_MEMORY_OPTIMIZE (1 << 12)
+#define EVAS_GL_OPTIONS_DIRECT_OVERRIDE (1 << 13)
+
+namespace content {
+
+// Defined in gl_current_context_efl.cc because of conflicts of
+// texture_manager.h with efl GL API wrappers.
+extern GLuint GetTextureIdFromTexture(gpu::TextureBase* texture);
+
+RWHVAuraOffscreenHelperEfl::RWHVAuraOffscreenHelperEfl(
+    RenderWidgetHostViewAura* rwhva,
+    WebContents* web_contents)
+    : rwhv_aura_(rwhva), web_contents_(web_contents) {
+  Initialize();
+}
+
+RWHVAuraOffscreenHelperEfl::~RWHVAuraOffscreenHelperEfl() {
+  if (evas_gl_surface_) {
+    if (!MakeCurrent())
+      LOG(WARNING) << "Failed to bind gl context";
+    evas_object_image_native_surface_set(content_image_, nullptr);
+    evas_gl_surface_destroy(evas_gl_, evas_gl_surface_);
+  }
+
+  if (!ClearCurrent())
+    LOG(WARNING) << "Failed to unbind gl context";
+
+  if (evas_gl_context_)
+    evas_gl_context_destroy(evas_gl_, evas_gl_context_);
+  if (evas_gl_config_)
+    evas_gl_config_free(evas_gl_config_);
+  if (evas_gl_)
+    evas_gl_free(evas_gl_);
+
+  elm_object_part_content_unset(content_image_elm_host_, "overlay");
+  evas_object_event_callback_del(content_image_, EVAS_CALLBACK_FOCUS_IN,
+                                 OnFocusIn);
+  evas_object_event_callback_del(content_image_, EVAS_CALLBACK_FOCUS_OUT,
+                                 OnFocusOut);
+  evas_object_del(content_image_elm_host_);
+  evas_object_del(content_image_);
+
+  content_image_elm_host_ = nullptr;
+  content_image_ = nullptr;
+  parent_view_ = nullptr;
+}
+
+void RWHVAuraOffscreenHelperEfl::Initialize() {
+  parent_view_ =
+      static_cast<WebContentsImpl*>(web_contents_)->GetEflNativeView();
+  evas_ = evas_object_evas_get(parent_view_);
+
+  InitEvasGL();
+  InitializeProgram();
+  evas_object_event_callback_add(parent_view_, EVAS_CALLBACK_RESIZE,
+                                 OnParentViewResize, this);
+  evas_object_show(content_image_);
+
+  device_scale_factor_ =
+      display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
+}
+
+void RWHVAuraOffscreenHelperEfl::SetParentNativeView(
+    gfx::NativeView parent_view) {
+  parent_native_view_ = parent_view;
+}
+
+void RWHVAuraOffscreenHelperEfl::AuraChildWindowAdded() {
+  // Add FOCUS_{IN,OUT} callbacks only after child aura window is created.
+  evas_object_event_callback_add(content_image_, EVAS_CALLBACK_FOCUS_IN,
+                                 OnFocusIn, this);
+  evas_object_event_callback_add(content_image_, EVAS_CALLBACK_FOCUS_OUT,
+                                 OnFocusOut, this);
+}
+
+// static
+void RWHVAuraOffscreenHelperEfl::OnParentViewResize(void* data,
+                                                    Evas*,
+                                                    Evas_Object* obj,
+                                                    void*) {
+  RWHVAuraOffscreenHelperEfl* thiz =
+      static_cast<RWHVAuraOffscreenHelperEfl*>(data);
+  gfx::Rect new_bounds(thiz->CreateNativeSurface());
+  aura::WindowTreeHost* window_host = thiz->rwhv_aura_->window()->GetHost();
+  if (window_host)
+    window_host->SetBoundsInPixels(new_bounds);
+
+  aura::Window* parent_window = thiz->parent_native_view_;
+  if (parent_window)
+    parent_window->SetBounds(new_bounds);
+}
+
+bool RWHVAuraOffscreenHelperEfl::ClearCurrent() {
+  return evas_gl_make_current(evas_gl_, 0, 0);
+}
+
+bool RWHVAuraOffscreenHelperEfl::MakeCurrent() {
+  return evas_gl_make_current(evas_gl_, evas_gl_surface_, evas_gl_context_);
+}
+
+void RWHVAuraOffscreenHelperEfl::ClearBrowserFrame() {
+  DCHECK(evas_gl_api_);
+  evas_gl_api_->glClearColor(1.0, 1.0, 1.0, 1.0);
+  evas_gl_api_->glClear(GL_COLOR_BUFFER_BIT);
+}
+
+static const char kVertexShaderSourceSimple[] =
+    "attribute vec4 a_position;                                        \n"
+    "attribute vec2 a_texCoord;                                        \n"
+    "varying vec2 v_texCoord;                                          \n"
+    "uniform vec2 u_rotation;                                          \n"
+    "void main() {                                                     \n"
+    "  gl_Position = vec4(                                             \n"
+    "    (a_position.x * u_rotation.y + a_position.y * u_rotation.x),  \n"
+    "    (a_position.y * u_rotation.y - a_position.x * u_rotation.x),  \n"
+    "     0, 1);                                                       \n"
+    "  v_texCoord = a_texCoord;                                        \n"
+    "}                                                                 \n";
+
+static const char kFragmentShaderSourceSimple[] =
+    "precision mediump float;                            \n"
+    "varying vec2 v_texCoord;                            \n"
+    "uniform sampler2D s_texture;                        \n"
+    "void main() {                                       \n"
+    "  gl_FragColor = texture2D( s_texture, v_texCoord );\n"
+    "}                                                   \n";
+
+static void GLCheckProgramHelper(Evas_GL_API* api,
+                                 GLuint program,
+                                 const char* file,
+                                 int line) {
+  GLint status;
+  api->glGetProgramiv(program, GL_LINK_STATUS, &status);
+  if (status)
+    return;
+
+  const GLsizei buf_length = 2048;
+  std::unique_ptr<GLchar[]> log(new GLchar[buf_length]);
+  GLsizei length = 0;
+  api->glGetProgramInfoLog(program, buf_length, &length, log.get());
+  LOG(ERROR) << "GL program link failed in: " << file << ":" << line << ":"
+             << log.get();
+  api->glDeleteProgram(program);
+}
+
+#define GLCheckProgram(api, program) \
+  GLCheckProgramHelper(api, program, __FILE__, __LINE__)
+
+static void GLCheckShaderHelper(Evas_GL_API* api,
+                                GLuint shader,
+                                const char* file,
+                                int line) {
+  GLint status;
+  api->glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
+  if (status)
+    return;
+
+  const GLsizei buf_length = 2048;
+  std::unique_ptr<GLchar[]> log(new GLchar[buf_length]);
+  GLsizei length = 0;
+  api->glGetShaderInfoLog(shader, buf_length, &length, log.get());
+  LOG(ERROR) << "GL shader compile failed in " << file << ":" << line << ":"
+             << log.get();
+  api->glDeleteShader(shader);
+}
+
+#define GLCheckShader(api, shader) \
+  GLCheckShaderHelper((api), (shader), __FILE__, __LINE__)
+
+void RWHVAuraOffscreenHelperEfl::InitializeProgram() {
+  evas_gl_make_current(evas_gl_, evas_gl_surface_, evas_gl_context_);
+
+  //  GL_CHECK_STATUS("GL Error before program initialization");
+
+  const char* vertexShaderSourceProgram = kVertexShaderSourceSimple;
+  const char* fragmentShaderSourceProgram = kFragmentShaderSourceSimple;
+  GLuint vertexShader = evas_gl_api_->glCreateShader(GL_VERTEX_SHADER);
+  // GL_CHECK_STATUS("vertex shader");
+  GLuint fragmentShader = evas_gl_api_->glCreateShader(GL_FRAGMENT_SHADER);
+  // GL_CHECK_STATUS("fragment shader");
+
+  const GLfloat vertex_attributes[] = {
+      -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f,  0.0f, 0.0f, 1.0f,
+      1.0f,  1.0f,  0.0f, 1.0f, 1.0f, 1.0f,  -1.0f, 0.0f, 1.0f, 0.0f};
+
+  evas_gl_api_->glGenBuffers(1, &vertex_buffer_obj_);
+  evas_gl_api_->glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_obj_);
+  evas_gl_api_->glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_attributes),
+                             vertex_attributes, GL_STATIC_DRAW);
+
+  const GLushort index_attributes[] = {0, 1, 2, 0, 2, 3};
+  evas_gl_api_->glGenBuffers(1, &index_buffer_obj_);
+  evas_gl_api_->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer_obj_);
+  evas_gl_api_->glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(index_attributes),
+                             index_attributes, GL_STATIC_DRAW);
+
+  evas_gl_api_->glShaderSource(vertexShader, 1, &vertexShaderSourceProgram, 0);
+  evas_gl_api_->glShaderSource(fragmentShader, 1, &fragmentShaderSourceProgram,
+                               0);
+  program_id_ = evas_gl_api_->glCreateProgram();
+  evas_gl_api_->glCompileShader(vertexShader);
+  GLCheckShader(evas_gl_api_, vertexShader);
+  evas_gl_api_->glCompileShader(fragmentShader);
+  GLCheckShader(evas_gl_api_, fragmentShader);
+  evas_gl_api_->glAttachShader(program_id_, vertexShader);
+  evas_gl_api_->glAttachShader(program_id_, fragmentShader);
+  evas_gl_api_->glLinkProgram(program_id_);
+  GLCheckProgram(evas_gl_api_, program_id_);
+  evas_gl_api_->glDetachShader(program_id_, vertexShader);
+  evas_gl_api_->glDetachShader(program_id_, fragmentShader);
+  evas_gl_api_->glDeleteShader(vertexShader);
+  evas_gl_api_->glDeleteShader(fragmentShader);
+
+  position_attrib_ =
+      evas_gl_api_->glGetAttribLocation(program_id_, "a_position");
+  texcoord_attrib_ =
+      evas_gl_api_->glGetAttribLocation(program_id_, "a_texCoord");
+  source_texture_location_ =
+      evas_gl_api_->glGetUniformLocation(program_id_, "s_texture");
+  rotate_position_attrib_ =
+      evas_gl_api_->glGetUniformLocation(program_id_, "u_rotation");
+  evas_gl_make_current(evas_gl_, 0, 0);
+}
+
+void RWHVAuraOffscreenHelperEfl::PaintTextureToSurface(GLuint texture_id) {
+  int x, y, width = 0, height = 0;
+  evas_object_geometry_get(parent_view_, &x, &y, &width, &height);
+
+  evas_gl_make_current(evas_gl_, evas_gl_surface_, evas_gl_context_);
+  evas_gl_api_->glViewport(0, 0, width, height);
+  evas_gl_api_->glClearColor(1.0, 1.0, 1.0, 1.0);
+  evas_gl_api_->glClear(GL_COLOR_BUFFER_BIT);
+  evas_gl_api_->glUseProgram(program_id_);
+
+  evas_gl_api_->glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_obj_);
+
+  evas_gl_api_->glEnableVertexAttribArray(position_attrib_);
+  // Below 5 * sizeof(GLfloat) value specifies the size of a vertex
+  // attribute (x, y, z, u, v).
+  evas_gl_api_->glVertexAttribPointer(position_attrib_, 3, GL_FLOAT, GL_FALSE,
+                                      5 * sizeof(GLfloat), NULL);
+  evas_gl_api_->glEnableVertexAttribArray(texcoord_attrib_);
+  // Below 3 * sizeof(GLfloat) value specifies the location of texture
+  // coordinate in the vertex.
+  evas_gl_api_->glVertexAttribPointer(texcoord_attrib_, 2, GL_FLOAT, GL_FALSE,
+                                      5 * sizeof(GLfloat),
+                                      (void*)(3 * sizeof(GLfloat)));
+  evas_gl_api_->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer_obj_);
+
+  evas_gl_api_->glActiveTexture(GL_TEXTURE0);
+  evas_gl_api_->glBindTexture(GL_TEXTURE_2D, texture_id);
+  evas_gl_api_->glUniform1i(source_texture_location_, 0);
+  if (rotation_ == 0) {
+    evas_gl_api_->glUniform2f(rotate_position_attrib_, 0, 1);
+  } else if (rotation_ == 90) {
+    evas_gl_api_->glUniform2f(rotate_position_attrib_, -1, 0);
+  } else if (rotation_ == 180) {
+    evas_gl_api_->glUniform2f(rotate_position_attrib_, 0, -1);
+  } else if (rotation_ == 270) {
+    evas_gl_api_->glUniform2f(rotate_position_attrib_, 1, 0);
+  }
+  evas_gl_api_->glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, NULL);
+
+  evas_gl_api_->glBindTexture(GL_TEXTURE_2D, 0);
+  evas_gl_make_current(evas_gl_, 0, 0);
+}
+
+void RWHVAuraOffscreenHelperEfl::InitEvasGL() {
+  evas_gl_config_ = evas_gl_config_new();
+  evas_gl_config_->options_bits =
+      (Evas_GL_Options_Bits)(EVAS_GL_OPTIONS_DIRECT |
+                             EVAS_GL_OPTIONS_DIRECT_MEMORY_OPTIMIZE |
+                             EVAS_GL_OPTIONS_DIRECT_OVERRIDE |
+                             EVAS_GL_OPTIONS_CLIENT_SIDE_ROTATION);
+  evas_gl_config_->color_format = EVAS_GL_RGBA_8888;
+  evas_gl_config_->depth_bits = EVAS_GL_DEPTH_BIT_24;
+  evas_gl_config_->stencil_bits = EVAS_GL_STENCIL_BIT_8;
+
+  evas_gl_ = evas_gl_new(evas_);
+
+  Evas_GL_Context_Version context_version = EVAS_GL_GLES_2_X;
+
+  evas_gl_context_ = evas_gl_context_version_create(
+      evas_gl_, GLSharedContextEfl::GetEvasGLContext(), context_version);
+
+  if (!evas_gl_context_)
+    LOG(FATAL) << "Failed to create evas gl context";
+
+  evas_gl_api_ = evas_gl_context_api_get(evas_gl_, evas_gl_context_);
+
+  CreateNativeSurface();
+
+  MakeCurrent();
+}
+
+gfx::Size RWHVAuraOffscreenHelperEfl::CreateNativeSurface() {
+  int x, y, width = 0, height = 0;
+  evas_object_geometry_get(parent_view_, &x, &y, &width, &height);
+  if (width == 0 || height == 0)
+    width = height = 1;
+  if (width > MAX_SURFACE_WIDTH_EGL)
+    width = MAX_SURFACE_WIDTH_EGL;
+  if (height > MAX_SURFACE_HEIGHT_EGL)
+    height = MAX_SURFACE_HEIGHT_EGL;
+
+  if (!content_image_) {
+    content_image_ = evas_object_image_filled_add(evas_);
+
+    // elm host for focus handling
+    content_image_elm_host_ = elm_bg_add(parent_view_);
+    elm_object_part_content_set(parent_view_, "content",
+                                content_image_elm_host_);
+    elm_object_part_content_set(content_image_elm_host_, "overlay",
+                                content_image_);
+    elm_object_focus_allow_set(content_image_elm_host_, EINA_TRUE);
+    evas_object_smart_callback_add(content_image_elm_host_, "focused",
+                                   OnHostFocusIn, this);
+    evas_object_smart_callback_add(content_image_elm_host_, "unfocused",
+                                   OnHostFocusOut, this);
+    evas_object_show(content_image_elm_host_);
+  }
+
+  evas_object_image_size_set(content_image_, width, height);
+  evas_object_geometry_set(content_image_, x, y, width, height);
+  evas_object_geometry_set(content_image_elm_host_, x, y, width, height);
+
+  if (evas_gl_surface_) {
+    evas_object_image_native_surface_set(content_image_, NULL);
+    evas_gl_surface_destroy(evas_gl_, evas_gl_surface_);
+    ClearCurrent();
+  }
+
+  evas_gl_surface_ =
+      evas_gl_surface_create(evas_gl_, evas_gl_config_, width, height);
+  if (!evas_gl_surface_)
+    LOG(FATAL) << "Failed to create evas gl surface";
+
+  Evas_Native_Surface nativeSurface;
+  if (evas_gl_native_surface_get(evas_gl_, evas_gl_surface_, &nativeSurface)) {
+    evas_object_image_native_surface_set(content_image_, &nativeSurface);
+    evas_object_image_pixels_get_callback_set(
+        content_image_, EvasObjectImagePixelsGetCallback, this);
+    evas_object_image_pixels_dirty_set(content_image_, true);
+  } else {
+    LOG(FATAL) << "Failed to get native surface";
+  }
+
+  return gfx::Size(width, height);
+}
+
+// static
+void RWHVAuraOffscreenHelperEfl::EvasObjectImagePixelsGetCallback(
+    void* data,
+    Evas_Object* obj) {
+  RWHVAuraOffscreenHelperEfl* rwhv_helper =
+      reinterpret_cast<RWHVAuraOffscreenHelperEfl*>(data);
+  rwhv_helper->MakeCurrent();
+  rwhv_helper->ClearBrowserFrame();
+  rwhv_helper->ClearCurrent();
+  if (rwhv_helper->texture_id_)
+    rwhv_helper->PaintTextureToSurface(rwhv_helper->texture_id_);
+}
+
+void RWHVAuraOffscreenHelperEfl::NotifySwap(const uint32_t texture_id) {
+  if (texture_id <= 0) {
+    LOG(ERROR) << __FUNCTION__ << " invalid texture id ";
+    return;
+  }
+  texture_id_ = texture_id;
+  evas_object_image_pixels_dirty_set(content_image_, true);
+}
+
+void RWHVAuraOffscreenHelperEfl::Focus(bool focus) {
+  elm_object_focus_set(content_image_elm_host_, focus);
+  evas_object_focus_set(content_image_, focus);
+}
+
+bool RWHVAuraOffscreenHelperEfl::HasFocus() {
+  return evas_object_focus_get(content_image_);
+}
+
+void RWHVAuraOffscreenHelperEfl::OnFocusIn(void* data,
+                                           Evas* evas,
+                                           Evas_Object* obj,
+                                           void* event_info) {
+  RWHVAuraOffscreenHelperEfl* thiz =
+      static_cast<RWHVAuraOffscreenHelperEfl*>(data);
+  thiz->FocusRWHVA();
+}
+
+void RWHVAuraOffscreenHelperEfl::OnFocusOut(void* data,
+                                            Evas* evas,
+                                            Evas_Object* obj,
+                                            void* event_info) {
+  RWHVAuraOffscreenHelperEfl* thiz =
+      static_cast<RWHVAuraOffscreenHelperEfl*>(data);
+  aura::WindowTreeHost* window_host = thiz->rwhv_aura_->window()->GetHost();
+  if (!window_host || !window_host->window())
+    return;
+
+  aura::Window* focused_window =
+      aura::client::GetFocusClient(window_host->window())->GetFocusedWindow();
+#if 0
+  if (focused_window)
+    focused_window->LostFocus();
+#endif
+}
+
+void RWHVAuraOffscreenHelperEfl::OnHostFocusIn(void* data,
+                                               Evas_Object*,
+                                               void*) {
+  RWHVAuraOffscreenHelperEfl* thiz =
+      static_cast<RWHVAuraOffscreenHelperEfl*>(data);
+  thiz->Focus(true);
+}
+
+void RWHVAuraOffscreenHelperEfl::OnHostFocusOut(void* data,
+                                                Evas_Object*,
+                                                void*) {
+  RWHVAuraOffscreenHelperEfl* thiz =
+      static_cast<RWHVAuraOffscreenHelperEfl*>(data);
+  thiz->GetRenderWidgetHostImpl()->Blur();
+}
+
+void RWHVAuraOffscreenHelperEfl::OnMouseOrTouchEvent(ui::Event* event) {
+  if (event->type() == ui::ET_MOUSE_PRESSED ||
+      event->type() == ui::ET_TOUCH_PRESSED) {
+    FocusRWHVA();
+  }
+}
+
+void RWHVAuraOffscreenHelperEfl::EvasToBlinkCords(int x,
+                                                  int y,
+                                                  int* view_x,
+                                                  int* view_y) {
+  gfx::Rect view_bounds = GetViewBoundsInPix();
+  if (view_x) {
+    *view_x = x - view_bounds.x();
+    *view_x /= device_scale_factor_;
+  }
+  if (view_y) {
+    *view_y = y - view_bounds.y();
+    *view_y /= device_scale_factor_;
+  }
+}
+
+void RWHVAuraOffscreenHelperEfl::FocusRWHVA() {
+  if (!rwhv_aura_->HasFocus())
+    rwhv_aura_->Focus();
+}
+
+void RWHVAuraOffscreenHelperEfl::Show() {
+  evas_object_show(content_image_elm_host_);
+}
+
+void RWHVAuraOffscreenHelperEfl::Hide() {
+  evas_object_hide(content_image_elm_host_);
+}
+
+void RWHVAuraOffscreenHelperEfl::SetCustomViewportSize(const gfx::Size& size) {
+  if (custom_viewport_size_ != size) {
+    custom_viewport_size_ = size;
+    // Take the view port change into account.
+    rwhv_aura_->host()->SynchronizeVisualProperties();
+  }
+}
+
+gfx::Size RWHVAuraOffscreenHelperEfl::GetVisibleViewportSize() {
+  if (!custom_viewport_size_.IsEmpty())
+    return custom_viewport_size_;
+  return GetViewBounds().size();
+}
+
+gfx::Rect RWHVAuraOffscreenHelperEfl::GetViewBounds() {
+  return gfx::ToEnclosingRect(
+      gfx::ConvertRectToDips(GetViewBoundsInPix(), device_scale_factor_));
+}
+
+void RWHVAuraOffscreenHelperEfl::SetPageVisibility(bool visible) {
+  LOG(INFO) << __FUNCTION__ << ", visible : " << visible;
+  if (visible) {
+    // Triggers RWHVA::ShowWithVisibility followed by RWHVAHelperEfl::Show
+    web_contents_->WasShown();
+  } else {
+    // Triggers RWHVA::Hide followed by RWHVAHelperEfl::Hide
+    web_contents_->WasHidden();
+  }
+}
+
+RenderWidgetHostImpl* RWHVAuraOffscreenHelperEfl::GetRenderWidgetHostImpl() {
+  return rwhv_aura_->host();
+}
+
+gfx::NativeView RWHVAuraOffscreenHelperEfl::GetNativeView() {
+  return rwhv_aura_->GetNativeView();
+}
+
+gfx::Point RWHVAuraOffscreenHelperEfl::ConvertPointInViewPix(gfx::Point point) {
+  return gfx::ToFlooredPoint(
+      gfx::ScalePoint(gfx::PointF(point), device_scale_factor_));
+}
+
+gfx::Size RWHVAuraOffscreenHelperEfl::GetPhysicalBackingSize() const {
+  int w, h;
+  evas_object_geometry_get(content_image_elm_host_, nullptr, nullptr, &w, &h);
+  return gfx::Size(w, h);
+}
+
+int RWHVAuraOffscreenHelperEfl::GetTopControlsHeight() {
+  int y = 0;
+  evas_object_geometry_get(content_image_, nullptr, &y, nullptr, nullptr);
+  return y;
+}
+
+}  // namespace content
diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h
new file mode 100644 (file)
index 0000000..02bd471
--- /dev/null
@@ -0,0 +1,122 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_RENDERER_HOST_RWHV_AURA_OFFSCREEN_HELPER_EFL_H_
+#define CONTENT_BROWSER_RENDERER_HOST_RWHV_AURA_OFFSCREEN_HELPER_EFL_H_
+
+#include <list>
+
+#include <Evas.h>
+#include <Evas_GL.h>
+
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+#include <Ecore_Input.h>
+#include <Elementary.h>
+#include "ecore_x_wayland_wrapper.h"
+
+#include "base/callback.h"
+#include "base/containers/id_map.h"
+#include "base/timer/timer.h"
+#include "content/common/cursors/webcursor.h"
+#include "ui/base/ime/mojom/text_input_state.mojom-forward.h"
+#include "ui/events/event.h"
+#include "ui/gfx/geometry/size_f.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace content {
+
+class RenderWidgetHostImpl;
+class RenderWidgetHostViewAura;
+class WebContents;
+class WebContentsDelegate;
+
+class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl {
+ public:
+  RWHVAuraOffscreenHelperEfl(RenderWidgetHostViewAura* rwhva,
+                             WebContents* web_contents);
+  ~RWHVAuraOffscreenHelperEfl();
+
+  void SetParentNativeView(gfx::NativeView parent_view);
+  void AuraChildWindowAdded();
+  void NotifySwap(const uint32_t texture_id);
+  void Show();
+  void Hide();
+
+  gfx::Size GetVisibleViewportSize();
+  gfx::Rect GetViewBounds();
+  void SetCustomViewportSize(const gfx::Size& size);
+  gfx::Size GetPhysicalBackingSize() const;
+  gfx::Rect GetViewBoundsInPix() const;
+  int GetTopControlsHeight();
+
+  void Focus(bool focus);
+  bool HasFocus();
+  void SetPageVisibility(bool visible);
+  void TextInputStateChanged(const ui::mojom::TextInputState& params);
+
+  RenderWidgetHostViewAura* rwhva() { return rwhv_aura_; }
+  void OnMouseOrTouchEvent(ui::Event* event);
+  void EvasToBlinkCords(int x, int y, int* view_x, int* view_y);
+
+  Evas_Object* content_image() const { return content_image_; }
+  Evas_Object* content_image_elm_host() const {
+    return content_image_elm_host_;
+  }
+  gfx::Point ConvertPointInViewPix(gfx::Point point);
+  RenderWidgetHostImpl* GetRenderWidgetHostImpl();
+  gfx::NativeView GetNativeView();
+  WebContents* GetWebContents() { return web_contents_; }
+
+ private:
+  static void OnParentViewResize(void* data, Evas*, Evas_Object*, void*);
+  static void EvasObjectImagePixelsGetCallback(void*, Evas_Object*);
+  static void OnFocusIn(void* data, Evas*, Evas_Object*, void*);
+  static void OnFocusOut(void* data, Evas*, Evas_Object*, void*);
+  static void OnHostFocusIn(void* data, Evas_Object*, void*);
+  static void OnHostFocusOut(void* data, Evas_Object*, void*);
+
+  void Initialize();
+  void InitializeProgram();
+  void PaintTextureToSurface(GLuint texture_id);
+  void FocusRWHVA();
+
+  void InitEvasGL();
+  gfx::Size CreateNativeSurface();
+  bool ClearCurrent();
+  bool MakeCurrent();
+  void ClearBrowserFrame();
+
+  Evas* evas_ = nullptr;
+  Evas_GL* evas_gl_ = nullptr;
+  Evas_GL_API* evas_gl_api_ = nullptr;
+  Evas_GL_Config* evas_gl_config_ = nullptr;
+  Evas_GL_Context* evas_gl_context_ = nullptr;
+  Evas_GL_Surface* evas_gl_surface_ = nullptr;
+  Evas_Object* content_image_ = nullptr;
+  Evas_Object* parent_view_ = nullptr;
+  Evas_Object* content_image_elm_host_ = nullptr;
+
+  GLuint program_id_;
+  GLint source_texture_location_;
+  GLuint position_attrib_;
+  GLuint rotate_position_attrib_;
+  GLuint texcoord_attrib_;
+  GLuint texture_id_ = 0;
+  GLuint vertex_buffer_obj_;
+  GLuint index_buffer_obj_;
+  gfx::NativeView parent_native_view_ = nullptr;
+
+  int rotation_ = 0;
+  float device_scale_factor_ = 1.0f;
+  gfx::SizeF scaled_contents_size_;
+  gfx::Size custom_viewport_size_;
+
+  RenderWidgetHostViewAura* rwhv_aura_ = nullptr;
+  WebContents* web_contents_ = nullptr;
+};
+
+}  // namespace content
+
+#endif
index 27c94af..b436398 100644 (file)
@@ -31,10 +31,6 @@ struct GpuChildThreadEfl : public content::GpuChildThread {
     GpuChildThread::SetGpuServiceConnection(gpu_service);
     gpu_service->gpu_channel_manager()->share_group_ =
         GLSharedContextEfl::GetShareGroup();
-#if !defined(USE_AURA)
-    SharedMailboxManager::SetMailboxManager(
-        gpu_service->gpu_channel_manager()->mailbox_manager());
-#endif
   }
 };
 
index e1e4c69..20cf940 100644 (file)
@@ -76,7 +76,6 @@ int Initialize(int argc, const char* argv[]) {
 
 void AppendPortParams(base::CommandLine& cmdline) {
   cmdline.AppendSwitchASCII(switches::kUseGL, gl::kGLImplementationEGLName);
-  cmdline.AppendSwitch(switches::kInProcessGPU);
 
 #if !defined(EWK_BRINGUP)  // FIXME: m67 bringup
 // [M44_2403] Temporary disabling the codes for switching to new chromium
@@ -92,10 +91,6 @@ void AppendPortParams(base::CommandLine& cmdline) {
     cmdline.AppendSwitch(switches::kDisableGpuRasterization);
 #endif
 #endif  // EWK_BRINGUP
-
-#if !defined(OS_TIZEN)
-  cmdline.AppendSwitch(switches::kIgnoreGpuBlocklist);
-#endif
 }
 
 }  // namespace efl
index 09929e0..c5ffdb3 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "ui/ozone/platform/efl/efl_window.h"
 
+#include "base/base_switches.h"
+#include "base/command_line.h"
 #include "base/logging.h"
 #include "base/memory/scoped_refptr.h"
 #include "base/notreached.h"
@@ -18,6 +20,10 @@ EflWindow::EflWindow(PlatformWindowDelegate* delegate,
 }
 
 EflWindow::~EflWindow() {
+  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kEnableOffscreenRendering))
+    return;
+
 #if defined(USE_WAYLAND)
   if (wl2_egl_window_) {
     ecore_wl2_egl_window_destroy(wl2_egl_window_);
@@ -29,10 +35,18 @@ EflWindow::~EflWindow() {
 }
 
 void EflWindow::Show(bool inactive) {
+  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kEnableOffscreenRendering))
+    return;
+
   ecore_evas_show(ee_);
 }
 
 void EflWindow::Hide() {
+  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kEnableOffscreenRendering))
+    return;
+
   ecore_evas_hide(ee_);
 }
 
@@ -51,11 +65,14 @@ void EflWindow::PrepareForShutdown() {
 
 void EflWindow::SetBoundsInPixels(const gfx::Rect& bounds) {
 #if defined(USE_WAYLAND)
-  ecore_wl2_egl_window_resize_with_rotation(wl2_egl_window_, bounds.x(),
-                                            bounds.y(), bounds.width(),
-                                            bounds.height(), 0);
+  if (wl2_egl_window_) {
+    ecore_wl2_egl_window_resize_with_rotation(wl2_egl_window_, bounds.x(),
+                                              bounds.y(), bounds.width(),
+                                              bounds.height(), 0);
+  }
 #else
-  ecore_evas_resize(ee_, bounds.width(), bounds.height());
+  if (ee_)
+    ecore_evas_resize(ee_, bounds.width(), bounds.height());
 #endif
   bool origin_changed = bounds_.origin() != bounds.origin();
   bounds_ = bounds;
@@ -168,11 +185,17 @@ uint32_t EflWindow::DispatchEvent(const PlatformEvent& event) {
   return POST_DISPATCH_NONE;
 }
 
-bool EflWindow::Initialize(const PlatformWindowInitProperties& properties) {
+void EflWindow::Initialize(const PlatformWindowInitProperties& properties) {
   bounds_ = properties.bounds;
   opacity_ = properties.opacity;
   type_ = properties.type;
 
+  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kEnableOffscreenRendering)) {
+    delegate_->OnAcceleratedWidgetAvailable(gfx::kNullAcceleratedWidget);
+    return;
+  }
+
   ecore_evas_init();
 
 #if defined(USE_WAYLAND)
@@ -185,27 +208,27 @@ bool EflWindow::Initialize(const PlatformWindowInitProperties& properties) {
 
   if (!ee_) {
     LOG(ERROR) << "Failed to create ecore evas.";
-    return false;
+    return;
   }
 
 #if defined(USE_WAYLAND)
   Ecore_Wl2_Window* ww = ecore_evas_wayland2_window_get(ee_);
   if (!ww) {
     LOG(ERROR) << "Failed to get Wl2 window";
-    return false;
+    return;
   }
 
   wl2_egl_window_ =
       ecore_wl2_egl_window_create(ww, bounds_.width(), bounds_.height());
   if (!wl2_egl_window_) {
     LOG(ERROR) << "Failed to create wl2 egl window";
-    return false;
+    return;
   }
 
   void* egl_window = ecore_wl2_egl_window_native_get(wl2_egl_window_);
   if (!egl_window) {
     LOG(ERROR) << "Failed to get native egl window";
-    return false;
+    return;
   }
 
   delegate_->OnAcceleratedWidgetAvailable(
@@ -213,8 +236,6 @@ bool EflWindow::Initialize(const PlatformWindowInitProperties& properties) {
 #else
   delegate_->OnAcceleratedWidgetAvailable(ecore_evas_window_get(ee_));
 #endif
-
-  return true;
 }
 
 }  // namespace ui
index 192ddf7..1aaad68 100644 (file)
@@ -66,7 +66,7 @@ class EflWindow : public PlatformWindow, public PlatformEventDispatcher {
   uint32_t DispatchEvent(const PlatformEvent& event) override;
 
  private:
-  bool Initialize(const PlatformWindowInitProperties& properties);
+  void Initialize(const PlatformWindowInitProperties& properties);
 
   PlatformWindowDelegate* delegate_;
 
index 24ee523..7d5fdae 100644 (file)
@@ -69,6 +69,7 @@ shared_library("chromium-ewk") {
     "//components/password_manager/content/browser",
     "//components/password_manager/core/browser",
     "//components/password_manager/core/common",
+    "//components/permissions",
     "//components/plugins/renderer",
     "//components/sessions",
     "//components/variations",
@@ -89,6 +90,7 @@ shared_library("chromium-ewk") {
     "//ui/events",
     "//ui/events:events_base",
     "//ui/gl",
+    "//ui/views:test_support",
     "//v8",
   ]
 
index ed97268..01e57d8 100644 (file)
@@ -55,6 +55,7 @@ BrowserContextEfl::ResourceContextEfl::ResourceContextEfl(
     : getter_(nullptr), cookie_manager_(cookie_manager) {}
 
 BrowserContextEfl::~BrowserContextEfl() {
+  NotifyWillBeDestroyed();
 #if defined(TIZEN_AUTOFILL_SUPPORT)
   autofill::PersonalDataManagerFactory::GetInstance()
       ->PersonalDataManagerRemove(this);
index d38d54a..0cccd72 100644 (file)
 #include "content/public/common/content_switches.h"
 #include "efl/init.h"
 #include "extensions/common/switches.h"
+#include "gpu/config/gpu_switches.h"
 #include "sandbox/policy/switches.h"
 #include "tizen/system_info.h"
 #include "ui/base/ui_base_switches.h"
 #include "ui/events/event_switches.h"
+#include "ui/ozone/public/ozone_switches.h"
 #include "url/gurl.h"
 
 int CommandLineEfl::argc_ = 0;
@@ -57,6 +59,10 @@ content::MainFunctionParams CommandLineEfl::GetDefaultPortParams() {
   efl::AppendPortParams(*p_command_line);
 
   p_command_line->AppendSwitch(sandbox::policy::switches::kNoSandbox);
+  p_command_line->AppendSwitch(switches::kIgnoreGpuBlocklist);
+  p_command_line->AppendSwitch(switches::kInProcessGPU);
+  p_command_line->AppendSwitchASCII(switches::kOzonePlatform, "efl");
+  p_command_line->AppendSwitch(switches::kEnableOffscreenRendering);
 
   AppendMemoryOptimizationSwitches(p_command_line);
 
@@ -84,8 +90,6 @@ content::MainFunctionParams CommandLineEfl::GetDefaultPortParams() {
 #endif
   }
 
-  p_command_line->AppendSwitch(switches::kDisableFrameRateLimit);
-
 #if !defined(EWK_BRINGUP)
   if (p_command_line->HasSwitch(switches::kDisableIpcSandbox))
     p_command_line->AppendSwitch(switches::kDisableRendererZygote);
index 1378f3c..ddf0186 100644 (file)
@@ -23,6 +23,22 @@ base::StringPiece ContentClientEfl::GetDataResource(
       resource_id, scale_factor);
 }
 
+base::RefCountedMemory* ContentClientEfl::GetDataResourceBytes(
+    int resource_id) {
+  return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
+      resource_id);
+}
+
+std::string ContentClientEfl::GetDataResourceString(int resource_id) {
+  return ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
+      resource_id);
+}
+
+gfx::Image& ContentClientEfl::GetNativeImageNamed(int resource_id) {
+  return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
+      resource_id);
+}
+
 bool ContentClientEfl::CanSendWhileSwappedOut(const IPC::Message* message) {
   // For legacy API support we perform a few browser -> renderer synchronous IPC
   // messages that block the browser. However, the synchronous IPC replies might
index c9f6fc6..cfc3651 100644 (file)
@@ -20,6 +20,9 @@ class ContentClientEfl : public content::ContentClient {
   base::StringPiece GetDataResource(
       int resource_id,
       ui::ResourceScaleFactor scale_factor) override;
+  base::RefCountedMemory* GetDataResourceBytes(int resource_id) override;
+  std::string GetDataResourceString(int resource_id) override;
+  gfx::Image& GetNativeImageNamed(int resource_id) override;
   bool CanSendWhileSwappedOut(const IPC::Message* message);
 };
 
index c2735ea..f7d8784 100644 (file)
@@ -114,6 +114,13 @@ std::string VersionInfo::ProductNameAndVersionForUserAgent() const {
 }
 
 std::string VersionInfo::DefaultUserAgent() const {
+  // TODO: Remove this during UA bringup patch.
+  // With default user agent, Google homepage layout is improper on desktop efl,
+  // so temporarily set content shell's user agent.
+  return std::string(
+      "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) "
+      "Chrome/999.77.34.5 Safari/537.36");
+
   char* override_ua = getenv("CHROMIUM_EFL_OVERRIDE_UA_STRING");
   if (override_ua)
     return override_ua;
index f0fca25..e3dc2e8 100644 (file)
@@ -11,7 +11,6 @@
 #include "browser/quota_permission_context_efl.h"
 #include "browser/render_message_filter_efl.h"
 #include "browser/web_view_browser_message_filter.h"
-#include "browser_context_efl.h"
 #include "browser_main_parts_efl.h"
 #include "command_line_efl.h"
 #include "common/content_switches_efl.h"
@@ -76,7 +75,6 @@ void PlatformLanguageChanged(keynode_t* keynode, void* data) {
 ContentBrowserClientEfl::ContentBrowserClientEfl()
     : browser_main_parts_efl_(nullptr),
       notification_controller_(new NotificationControllerEfl),
-      browser_context_efl_(nullptr),
       accept_langs_(kDefaultAcceptLanguages) {
 #if defined(OS_TIZEN)
   PlatformLanguageChanged(nullptr, this);
@@ -85,14 +83,20 @@ ContentBrowserClientEfl::ContentBrowserClientEfl()
 }
 
 ContentBrowserClientEfl::~ContentBrowserClientEfl() {
-  if (browser_context_efl_)
-    delete browser_context_efl_;
-
 #if defined(OS_TIZEN)
   vconf_ignore_key_changed(VCONFKEY_LANGSET, PlatformLanguageChanged);
 #endif
 }
 
+void ContentBrowserClientEfl::SetBrowserContext(BrowserContext* context) {
+  browser_context_.reset(context);
+}
+
+void ContentBrowserClientEfl::CleanUpBrowserContext() {
+  browser_context_.reset(nullptr);
+  shutting_down_ = true;
+}
+
 std::unique_ptr<BrowserMainParts>
 ContentBrowserClientEfl::CreateBrowserMainParts(bool is_integration_test) {
   auto browser_main_parts = std::make_unique<BrowserMainPartsEfl>();
@@ -264,6 +268,9 @@ bool ContentBrowserClientEfl::AllowGetCookie(const GURL& url,
                                              content::ResourceContext* context,
                                              int render_process_id,
                                              int render_frame_id) {
+  if (shutting_down_)
+    return false;
+
   BrowserContextEfl::ResourceContextEfl* rc =
       static_cast<BrowserContextEfl::ResourceContextEfl*>(context);
   if (!rc)
@@ -283,6 +290,9 @@ bool ContentBrowserClientEfl::AllowSetCookie(const GURL& url,
                                              content::ResourceContext* context,
                                              int render_process_id,
                                              int render_frame_id) {
+  if (shutting_down_)
+    return false;
+
   BrowserContextEfl::ResourceContextEfl* rc =
       static_cast<BrowserContextEfl::ResourceContextEfl*>(context);
   if (!rc)
index b6803ba..9dd0776 100644 (file)
@@ -17,7 +17,6 @@ class CommandLine;
 class Ewk_Notification;
 
 namespace content {
-class BrowserContextEfl;
 class BrowserMainPartsEfl;
 class NotificationControllerEfl;
 class SharedURLLoaderFactoryEfl;
@@ -103,9 +102,8 @@ class ContentBrowserClientEfl : public ContentBrowserClient {
   std::unique_ptr<WebContentsViewDelegate> GetWebContentsViewDelegate(
       WebContents* web_contents) override;
 
-  void SetBrowserContext(BrowserContextEfl* context) {
-    browser_context_efl_ = context;
-  }
+  void SetBrowserContext(BrowserContext* context);
+  void CleanUpBrowserContext();
 
   virtual std::unique_ptr<LoginDelegate> CreateLoginDelegate(
       const net::AuthChallengeInfo& auth_info,
@@ -142,7 +140,7 @@ class ContentBrowserClientEfl : public ContentBrowserClient {
 
   std::unique_ptr<NotificationControllerEfl> notification_controller_;
 
-  BrowserContextEfl* browser_context_efl_;
+  std::unique_ptr<content::BrowserContext> browser_context_;
 
   // URLLoaderFactory backed by the NetworkContext returned by GetContext(), so
   // consumers don't all need to create their own factory.
@@ -151,8 +149,10 @@ class ContentBrowserClientEfl : public ContentBrowserClient {
   std::string preferred_langs_;
   std::vector<AcceptLangsChangedCallback> accept_langs_changed_callbacks_;
 
+  bool shutting_down_ = false;
+
   // DISALLOW_COPY_AND_ASSIGN(ContentBrowserClientEfl);
 };
-}
+}  // namespace content
 
 #endif  // CONTENT_BROWSER_CLIENT_EFL
index c2ffeb4..3219cf1 100644 (file)
@@ -88,7 +88,7 @@ void ContentMainDelegateEfl::PreSandboxStartupBrowser() {
 void ContentMainDelegateEfl::PreSandboxStartup() {
   base::FilePath pak_dir;
   base::FilePath pak_file;
-  base::PathService::Get(base::DIR_EXE, &pak_dir);
+  base::PathService::Get(base::DIR_ASSETS, &pak_dir);
   pak_file = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak"));
   ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
 
@@ -115,7 +115,7 @@ absl::optional<int> ContentMainDelegateEfl::BasicStartupComplete() {
   content::SetContentClient(&content_client_);
   PathsEfl::Register();
   LocaleEfl::Initialize();
-  return false;
+  return absl::nullopt;
 }
 
 ContentBrowserClient* ContentMainDelegateEfl::GetContentBrowserClient() const {
index c60641d..8c13cac 100644 (file)
@@ -375,16 +375,13 @@ EWebContext::~EWebContext() {
   if (injected_bundle_handle_)
     dlclose(injected_bundle_handle_);
 
-  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
-          switches::kSingleProcess)) {
-    // On single process mode, renderer thread works until ewk_shutdown.
-    // So we have to remain BrowserContextEfl include of ResourceContextEfl.
-    // It will be delete once ContentBrowserClientEfl is destroyed.
-    content::ContentBrowserClient* cbc =
-        content::GetContentClientExport()->browser();
-    auto cbce = static_cast<content::ContentBrowserClientEfl*>(cbc);
-    cbce->SetBrowserContext(browser_context_.release());
-  }
+  // Some parts(e.g. PrefService, ResourceContextEfl) are still used after
+  // destroying EWebCotext. So we have to remain BrowserContextEfl.
+  // It will be deleted by EwkGlobakData's dtor.
+  content::ContentBrowserClient* cbc =
+      content::GetContentClientExport()->browser();
+  auto cbce = static_cast<content::ContentBrowserClientEfl*>(cbc);
+  cbce->SetBrowserContext(browser_context_.release());
 #endif
 }
 
index e8b4016..3e0d5aa 100644 (file)
@@ -22,6 +22,7 @@
 #include "components/sessions/content/content_serialized_navigation_builder.h"
 #include "components/sessions/core/serialized_navigation_entry.h"
 #include "content/browser/renderer_host/render_view_host_impl.h"
+#include "content/browser/renderer_host/render_widget_host_view_aura.h"
 #include "content/browser/renderer_host/ui_events_helper.h"
 #include "content/browser/web_contents/web_contents_impl_efl.h"
 #include "content/browser/web_contents/web_contents_view.h"
 #include "third_party/blink/public/common/page/page_zoom.h"
 #include "third_party/blink/public/platform/web_string.h"
 #include "tizen/system_info.h"
+#include "ui/aura/env.h"
+#include "ui/aura/test/test_focus_client.h"
+#include "ui/aura/test/test_window_parenting_client.h"
+#include "ui/aura/window.h"
 #include "ui/base/l10n/l10n_util.h"
 #include "ui/display/screen.h"
+#include "ui/gfx/geometry/dip_util.h"
 #include "ui/gfx/geometry/vector2d_f.h"
+#include "ui/platform_window/platform_window_init_properties.h"
 #include "web_contents_delegate_efl.h"
 #include "web_contents_efl_delegate_ewk.h"
 #include "web_contents_view_efl_delegate_ewk.h"
@@ -2290,15 +2297,46 @@ void EWebView::InitializeContent() {
   wc_efl->SetEflDelegate(new WebContentsEflDelegateEwk(this));
   back_forward_list_.reset(
       new _Ewk_Back_Forward_List(web_contents_->GetController()));
-  back_forward_list_.reset(
-      new _Ewk_Back_Forward_List(web_contents_->GetController()));
 
   permission_popup_manager_.reset(new PermissionPopupManager(evas_object_));
 
-#if !defined(USE_AURA)
-  native_view_ = static_cast<Evas_Object*>(web_contents_->GetNativeView());
-#endif
+  native_view_ =
+      static_cast<WebContentsImplEfl*>(web_contents_.get())->GetEflNativeView();
   evas_object_smart_member_add(native_view_, evas_object_);
+  InitializeWindowTreeHost();
+}
+
+void EWebView::InitializeWindowTreeHost() {
+  CHECK(aura::Env::GetInstance());
+
+  int x, y, width, height;
+  Ecore_Evas* ee =
+      ecore_evas_ecore_evas_get(evas_object_evas_get(native_view_));
+  ecore_evas_geometry_get(ee, &x, &y, &width, &height);
+
+  gfx::Rect bounds(x, y, width, height);
+  ui::PlatformWindowInitProperties properties;
+  properties.bounds = bounds;
+
+  host_ = aura::WindowTreeHost::Create(std::move(properties));
+  host_->InitHost();
+  host_->window()->Show();
+
+  focus_client_ =
+      std::make_unique<aura::test::TestFocusClient>(host_->window());
+  window_parenting_client_ =
+      std::make_unique<aura::test::TestWindowParentingClient>(host_->window());
+
+  aura::Window* content = web_contents_->GetNativeView();
+  aura::Window* parent = host_->window();
+  if (!parent->Contains(content)) {
+    parent->AddChild(content);
+    content->Show();
+  }
+  content->SetBounds(bounds);
+  RenderWidgetHostView* host_view = web_contents_->GetRenderWidgetHostView();
+  if (host_view)
+    host_view->SetSize(bounds.size());
 }
 
 #if defined(OS_TIZEN) && !defined(EWK_BRINGUP)
index 41d1632..c05ad97 100644 (file)
 #include "scroll_detector.h"
 #include "third_party/blink/public/common/context_menu_data/menu_item_info.h"
 #include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h"
+#include "ui/aura/window_tree_host.h"
 #include "ui/gfx/geometry/point.h"
 #include "ui/gfx/geometry/size.h"
 #include "web_contents_delegate_efl.h"
 
+namespace aura {
+namespace client {
+class FocusClient;
+class WindowParentingClient;
+}  // namespace client
+}  // namespace aura
+
 namespace content {
 class RenderFrameHost;
 class RenderViewHost;
@@ -483,6 +491,7 @@ class EWebView {
 
  private:
   void InitializeContent();
+  void InitializeWindowTreeHost();
   void SendDelayedMessages(content::RenderViewHost* render_view_host);
 
   void EvasToBlinkCords(int x, int y, int* view_x, int* view_y);
@@ -624,6 +633,10 @@ class EWebView {
 
   content::ContentBrowserClientEfl::AcceptLangsChangedCallback
       accept_langs_changed_callback_;
+
+  std::unique_ptr<aura::WindowTreeHost> host_;
+  std::unique_ptr<aura::client::FocusClient> focus_client_;
+  std::unique_ptr<aura::client::WindowParentingClient> window_parenting_client_;
 };
 
 const unsigned int g_default_tilt_motion_sensitivity = 3;
index 7a94187..7a3906d 100644 (file)
@@ -10,6 +10,7 @@
 #include "base/path_service.h"
 #include "base/run_loop.h"
 #include "browser/autofill/personal_data_manager_factory.h"
+#include "command_line_efl.h"
 #include "components/discardable_memory/service/discardable_shared_memory_manager.h"
 #include "components/variations/variations_ids_provider.h"
 #include "content/app/mojo_ipc_support.h"
@@ -20,6 +21,7 @@
 #include "content/browser/startup_helper.h"
 #include "content/browser/utility_process_host.h"
 #include "content/child/field_trial.h"
+#include "content/common/content_client_export.h"
 #include "content/gpu/in_process_gpu_thread.h"
 #include "content/public/app/content_main.h"
 #include "content/public/app/content_main_runner.h"
 #include "content/public/common/content_switches.h"
 #include "content/renderer/in_process_renderer_thread.h"
 #include "content/utility/in_process_utility_thread.h"
+#include "content_main_delegate_efl.h"
 #include "efl/window_factory.h"
 #include "eweb_view.h"
 #include "mojo/core/embedder/embedder.h"
+#include "renderer/content_renderer_client_efl.h"
+#include "ui/aura/screen_ozone.h"
 #include "ui/base/resource/resource_bundle.h"
 #include "ui/ozone/public/ozone_platform.h"
 
-#include "command_line_efl.h"
-#include "content_main_delegate_efl.h"
-
 #ifdef OS_TIZEN
 #include <dlfcn.h>
 void* EflExtensionHandle = 0;
@@ -86,6 +88,25 @@ EwkGlobalData::~EwkGlobalData() {
   // Line below gives the message loop a extra run ('till it gets idle)
   // to perform such pending tasks.
   base::RunLoop().RunUntilIdle();
+
+  // Shutdown in-process-renderer properly before browser context is deleted.
+  // Sometimes renderer's ipc handler refers browser context during shutdown.
+  if (content::RenderProcessHost::run_renderer_in_process()) {
+    content::ContentRendererClient* crc =
+        content::GetContentClientExport()->renderer();
+    auto crce = static_cast<ContentRendererClientEfl*>(crc);
+    crce->set_shutting_down(true);
+    content::RenderProcessHostImpl::ShutDownInProcessRenderer();
+  }
+
+  // Delete browser context for browser context cleanup that use
+  // PostShutdownBlockingTask() if single process mode is enabled.
+  // (browser context is not deleted in EWebContext destructor.)
+  // Shutdown block tasks will run before browser main runner is deleted.
+  content::ContentBrowserClient* cbc =
+      content::GetContentClientExport()->browser();
+  auto cbce = static_cast<content::ContentBrowserClientEfl*>(cbc);
+  cbce->CleanUpBrowserContext();
 }
 
 EwkGlobalData* EwkGlobalData::GetInstance() {
@@ -125,7 +146,9 @@ EwkGlobalData* EwkGlobalData::GetInstance() {
   ui::OzonePlatform::InitParams init_params;
   init_params.single_process = true;
   ui::OzonePlatform::InitializeForUI(init_params);
-#endif
+  if (!display::Screen::GetScreen())
+    instance_->screen_ = std::make_unique<aura::ScopedScreenOzone>();
+#endif  // defined(USE_OZONE)
 
   content::InitializeFieldTrialAndFeatureList();
 
@@ -147,9 +170,7 @@ EwkGlobalData* EwkGlobalData::GetInstance() {
 
   instance_->browser_main_runner_ = BrowserMainRunner::Create();
   instance_->browser_main_runner_->Initialize(std::move(main_funtion_params));
-#if !defined(EWK_BRINGUP)  // FIXME: m108 bringup
-  base::ThreadRestrictions::SetIOAllowed(true);
-#endif
+  base::ThreadRestrictions::ScopedAllowIO allow_io;
 
   if (base::CommandLine::ForCurrentProcess()->HasSwitch(
           switches::kSingleProcess)) {
index e65e47b..8f675d6 100644 (file)
@@ -9,6 +9,12 @@
 #include "content/browser/startup_data_impl.h"
 #include "url_request_context_getter_efl.h"
 
+#if defined(USE_OZONE)
+namespace display {
+class ScopedNativeScreen;
+}
+#endif
+
 namespace discardable_memory {
 class DiscardableSharedMemoryManager;
 }
@@ -39,6 +45,10 @@ class EwkGlobalData
 
   static EwkGlobalData* instance_;
 
+#if defined(USE_OZONE)
+  std::unique_ptr<display::ScopedNativeScreen> screen_;
+#endif
+
   std::unique_ptr<discardable_memory::DiscardableSharedMemoryManager>
       discardable_shared_memory_manager_;
   std::unique_ptr<content::StartupDataImpl> startup_data_;
index 8945f05..f664972 100644 (file)
@@ -8,6 +8,7 @@
 #include "browser/geolocation/geolocation_permission_context_efl.h"
 #include "browser/notification/notification_controller_efl.h"
 #include "browser_context_efl.h"
+#include "components/permissions/permission_util.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/permission_controller.h"
 #include "content/public/browser/render_frame_host.h"
@@ -231,14 +232,24 @@ PermissionResult
 PermissionControllerDelegateEfl::GetPermissionResultForOriginWithoutContext(
     PermissionType permission,
     const url::Origin& origin) {
-  NOTIMPLEMENTED();
+  blink::mojom::PermissionStatus status =
+      GetPermissionStatus(permission, origin.GetURL(), origin.GetURL());
+
+  return PermissionResult(status, content::PermissionStatusSource::UNSPECIFIED);
 }
 
 blink::mojom::PermissionStatus
 PermissionControllerDelegateEfl::GetPermissionStatusForCurrentDocument(
     PermissionType permission,
     RenderFrameHost* render_frame_host) {
-  NOTIMPLEMENTED();
+  if (render_frame_host->IsNestedWithinFencedFrame())
+    return blink::mojom::PermissionStatus::DENIED;
+  return GetPermissionStatus(
+      permission,
+      permissions::PermissionUtil::GetLastCommittedOriginAsURL(
+          render_frame_host),
+      permissions::PermissionUtil::GetLastCommittedOriginAsURL(
+          render_frame_host->GetMainFrame()));
 }
 
 blink::mojom::PermissionStatus
index d414859..01ac6ff 100644 (file)
@@ -86,12 +86,9 @@ class WrtUrlParseImpl : public content::WrtUrlParseBase {
   WrtWidget* wrt_widget_;
 };
 
-ContentRendererClientEfl::ContentRendererClientEfl()
-    : javascript_can_open_windows_(true) {
-}
+ContentRendererClientEfl::ContentRendererClientEfl() {}
 
-ContentRendererClientEfl::~ContentRendererClientEfl() {
-}
+ContentRendererClientEfl::~ContentRendererClientEfl() {}
 
 void ContentRendererClientEfl::RenderThreadStarted() {
   content::RenderThread* thread = content::RenderThread::Get();
@@ -207,6 +204,10 @@ bool ContentRendererClientEfl::HandleNavigation(
     blink::WebNavigationType type,
     blink::WebNavigationPolicy default_policy,
     bool is_redirect) {
+  // During renderer is shutting down, sync message should not be sent.
+  if (shutting_down_)
+    return false;
+
 #if !defined(EWK_BRINGUP)  // FIXME: m108 bringup
   content::RenderView* render_view =
       content::RenderView::FromWebView(frame->View());
old mode 100644 (file)
new mode 100755 (executable)
index cfd8591..f0a0205
@@ -89,6 +89,9 @@ class ContentRendererClientEfl : public content::ContentRendererClient {
 
   bool IsLinkVisited(uint64_t link_hash) override;
 
+  bool shutting_down() const { return shutting_down_; }
+  void set_shutting_down(bool shutting_down) { shutting_down_ = shutting_down; }
+
  private:
   static void ApplyCustomMobileSettings(blink::WebView*);
 
@@ -96,7 +99,8 @@ class ContentRendererClientEfl : public content::ContentRendererClient {
   std::unique_ptr<WrtUrlParseImpl> wrt_url_parser_;
   std::unique_ptr<RenderThreadObserverEfl> render_thread_observer_;
   std::unique_ptr<visitedlink::VisitedLinkReader> visited_link_reader_;
-  bool javascript_can_open_windows_;
+  bool javascript_can_open_windows_ = true;
+  bool shutting_down_ = false;
 };
 
 #endif
index 827a28c..320dbea 100644 (file)
@@ -180,6 +180,12 @@ bool GLContextEGL::Initialize(GLSurface* compatible_surface,
 
   bool is_swangle = IsSoftwareGLImplementation(GetGLImplementationParts());
 
+#if defined(OS_TIZEN)
+  // Though below extension is supported on TV, enabling it is causing problems
+  // like white screen on page load. So disable it for TIZEN profiles.
+  gl_display_->ext->b_EGL_EXT_create_context_robustness = false;
+#endif
+
   if (gl_display_->ext->b_EGL_EXT_create_context_robustness || is_swangle) {
     DVLOG(1) << "EGL_EXT_create_context_robustness supported.";
     context_attributes.push_back(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT);