// 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)
#if defined(USE_EFL)
extern const char kLimitMemoryAllocationInScheduleDelayedWork[];
+extern const char kEnableOffscreenRendering[];
#endif
#if BUILDFLAG(IS_POSIX)
#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();
}
// 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.
return nullptr;
}
-#if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_ANDROID)
+#if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_ANDROID) || defined(USE_EFL)
void ThreadControllerImpl::AttachToMessagePump() {
NOTREACHED();
}
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)
#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 {
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() {
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)
#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;
// RenderWidgetHostViewAura, public:
RenderWidgetHostViewAura::RenderWidgetHostViewAura(
- RenderWidgetHost* widget_host)
+ RenderWidgetHost* widget_host,
+ WebContents& web_contents)
: RenderWidgetHostViewBase(widget_host),
window_(nullptr),
in_shutdown_(false),
}
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
}
////////////////////////////////////////////////////////////////////////////////
#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;
}
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;
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();
absl::optional<display::ScopedDisplayObserver> display_observer_;
+#if defined(USE_EFL)
+ std::unique_ptr<RWHVAuraOffscreenHelperEfl> offscreen_helper_;
+#endif
+
base::WeakPtrFactory<RenderWidgetHostViewAura> weak_ptr_factory_{this};
};
#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 {
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
#include "content/public/browser/android/child_process_importance.h"
#endif
+#if defined(USE_EFL)
+#include <Evas.h>
+#endif
+
namespace base {
class FilePath;
} // namespace base
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(); }
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};
};
#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(
// 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.
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 =
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) {
"//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",
--- /dev/null
+// 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
--- /dev/null
+// 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
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
}
};
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
cmdline.AppendSwitch(switches::kDisableGpuRasterization);
#endif
#endif // EWK_BRINGUP
-
-#if !defined(OS_TIZEN)
- cmdline.AppendSwitch(switches::kIgnoreGpuBlocklist);
-#endif
}
} // namespace efl
#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"
}
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_);
}
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_);
}
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;
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)
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(
#else
delegate_->OnAcceleratedWidgetAvailable(ecore_evas_window_get(ee_));
#endif
-
- return true;
}
} // namespace ui
uint32_t DispatchEvent(const PlatformEvent& event) override;
private:
- bool Initialize(const PlatformWindowInitProperties& properties);
+ void Initialize(const PlatformWindowInitProperties& properties);
PlatformWindowDelegate* delegate_;
"//components/password_manager/content/browser",
"//components/password_manager/core/browser",
"//components/password_manager/core/common",
+ "//components/permissions",
"//components/plugins/renderer",
"//components/sessions",
"//components/variations",
"//ui/events",
"//ui/events:events_base",
"//ui/gl",
+ "//ui/views:test_support",
"//v8",
]
: getter_(nullptr), cookie_manager_(cookie_manager) {}
BrowserContextEfl::~BrowserContextEfl() {
+ NotifyWillBeDestroyed();
#if defined(TIZEN_AUTOFILL_SUPPORT)
autofill::PersonalDataManagerFactory::GetInstance()
->PersonalDataManagerRemove(this);
#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;
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);
#endif
}
- p_command_line->AppendSwitch(switches::kDisableFrameRateLimit);
-
#if !defined(EWK_BRINGUP)
if (p_command_line->HasSwitch(switches::kDisableIpcSandbox))
p_command_line->AppendSwitch(switches::kDisableRendererZygote);
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
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);
};
}
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;
#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"
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);
}
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>();
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)
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)
class Ewk_Notification;
namespace content {
-class BrowserContextEfl;
class BrowserMainPartsEfl;
class NotificationControllerEfl;
class SharedURLLoaderFactoryEfl;
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,
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.
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
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);
content::SetContentClient(&content_client_);
PathsEfl::Register();
LocaleEfl::Initialize();
- return false;
+ return absl::nullopt;
}
ContentBrowserClient* ContentMainDelegateEfl::GetContentBrowserClient() const {
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
}
#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"
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)
#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;
private:
void InitializeContent();
+ void InitializeWindowTreeHost();
void SendDelayedMessages(content::RenderViewHost* render_view_host);
void EvasToBlinkCords(int x, int y, int* view_x, int* view_y);
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;
#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"
#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;
// 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() {
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();
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)) {
#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;
}
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_;
#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"
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
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();
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());
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*);
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
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);