class Ewk_Notification;
namespace content {
+class BrowserContextEfl;
class BrowserMainPartsEfl;
#if defined(ENABLE_NOTIFICATIONS)
class NotificationControllerEfl;
typedef void (*Notification_Cancel_Callback)(uint64_t, void*);
ContentBrowserClientEfl();
+ ~ContentBrowserClientEfl() override;
virtual BrowserMainParts* CreateBrowserMainParts(
const MainFunctionParams& parameters) override;
WebContentsViewDelegate* GetWebContentsViewDelegate(
WebContents* web_contents) override;
+ void SetBrowserContext(BrowserContextEfl* context) {
+ browser_context_efl_ = context;
+ }
+
private:
static void SetCertificatePemOnUIThread(int render_process_id,
int render_view_id,
std::unique_ptr<ResourceDispatcherHostDelegateEfl>
resource_disp_host_del_efl_;
BrowserMainPartsEfl* browser_main_parts_efl_;
+
#if defined(ENABLE_NOTIFICATIONS)
std::unique_ptr<NotificationControllerEfl> notification_controller_;
#endif
+ BrowserContextEfl* browser_context_efl_;
+
DISALLOW_COPY_AND_ASSIGN(ContentBrowserClientEfl);
};
}
#include <string>
#include <vector>
+#if defined(OS_TIZEN)
+#include <dlfcn.h>
+#endif
+
#include "base/synchronization/waitable_event.h"
#include "components/autofill/content/browser/content_autofill_driver.h"
//#include "content/browser/memory/memory_pressure_controller_impl.h"
#include "wrt/wrt_widget_host.h"
#if defined(OS_TIZEN)
+#include "base/command_line.h"
+#include "common/content_switches_efl.h"
#include "content/browser/zygote_host/zygote_communication_linux.h"
+#include "content/common/content_client_export.h"
+#include "content/public/common/content_switches.h"
#include "content/public/common/zygote_handle.h"
+#include "content_browser_client_efl.h"
#endif
using content::BrowserThread;
namespace {
+#if defined(OS_TIZEN)
+const char* const kDynamicPreloading = "DynamicPreloading";
+typedef void (*DynamicPreloading)(void);
+#endif
+
/**
* @brief Helper class for obtaining WebStorage origins
*/
widget_encoded_bundle_ = encoded_bundle;
#if defined(OS_TIZEN)
- // Drop process privillages while web app is launching from WRT process pool.
- content::GetGenericZygote()->DropProcessPrivileges(tizen_app_id_);
-#endif
+ base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
+ // Add the switches in here to load injected bundle in renderer thread
+ // in single process mode
+ if (command_line.HasSwitch(switches::kSingleProcess)) {
+ command_line.AppendSwitchASCII(switches::kInjectedBundlePath,
+ injected_bundle_path_);
+ command_line.AppendSwitchASCII(switches::kTizenAppId, tizen_app_id_);
+ command_line.AppendSwitchASCII(switches::kWidgetScale,
+ std::to_string(widget_scale_));
+ command_line.AppendSwitchASCII(switches::kWidgetTheme, widget_theme_);
+ command_line.AppendSwitchASCII(switches::kWidgetEncodedBundle,
+ widget_encoded_bundle_);
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+ // Drop process privillages while web app is launching
+ // from WRT process pool. It should be handled in webengine side
+ // in product tv profile because this profile uses the zygote process.
+ content::GetGenericZygote()->DropProcessPrivileges(tizen_app_id_);
+#endif // OS_TIZEN_TV_PRODUCT
+ } else {
+ // Drop process privillages while web app is launching
+ // from WRT process pool. It is not necessary in single process mode,
+ // because it is handled in crosswalk side in single process mode.
+ content::GetGenericZygote()->DropProcessPrivileges(tizen_app_id_);
+ }
+#endif // OS_TIZEN
}
void EWebContext::SendWrtMessage(const Ewk_Wrt_Message_Data& data) {
EWebContext::EWebContext(bool incognito, const std::string& injectedBundlePath)
: injected_bundle_path_(injectedBundlePath),
+#if defined(OS_TIZEN)
+ injected_bundle_handle_(nullptr),
+#endif
widget_scale_(0),
m_pixmap(0),
inspector_server_(NULL) {
tizen_extensible_.reset(TizenExtensible::create());
#if defined(OS_TIZEN)
- // Preload injected bundle on zygote process for process pool.
if (should_preload_injected_bundle) {
- content::GetGenericZygote()->LoadInjectedBundlePath(injected_bundle_path_);
+ base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kSingleProcess)) {
+ // Preload injected bundle on here for process pool,
+ // because the zygote process doesn't exist in single process mode.
+ // The loaded handle must be closed on termination.
+ injected_bundle_handle_ =
+ dlopen(injected_bundle_path_.c_str(), RTLD_LAZY);
+ if (!injected_bundle_handle_) {
+ LOG(ERROR) << "No handle to " << injected_bundle_path_.c_str()
+ << " error " << dlerror();
+ return;
+ }
+
+ DynamicPreloading dp = reinterpret_cast<DynamicPreloading>(
+ dlsym(injected_bundle_handle_, kDynamicPreloading));
+ if (dp) {
+ dp();
+ } else {
+ LOG(ERROR) << "Fail to load symbol '" << kDynamicPreloading
+ << "', error " << dlerror();
+ }
+ } else {
+ // Preload injected bundle on zygote process for process pool.
+ content::GetGenericZygote()
+ ->LoadInjectedBundlePath(injected_bundle_path_);
+ }
}
#endif
}
-EWebContext::~EWebContext() {}
+EWebContext::~EWebContext() {
+#if defined(OS_TIZEN)
+ 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());
+ }
+#endif
+}
void EWebContext::ClearNetworkCache() {
BrowsingDataRemoverEfl* remover =