API that will be used by the WRT web apps to inject specific bundle to perform some
additional operations directly on JS context. Currently libwrt-injected-bundle.so
is injected by default.
Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=10976
Reviewed by: DONGJUN KiM, Piotr Tworek
Reviewed by: DONGJUN KiM, Hyunhak Kim, Piotr Tworek, arno renevier, commitbot
Change-Id: I86145ede4bd50bc7af7ee69b4a7a3f241ff4965a
Signed-off-by: yh106.jung <yh106.jung@samsung.com>
// to web applications and thereby apply different styling based on these
// different modes using CSS Media Queries.
const char kEnableViewMode[] = "enable-view-mode";
+const char kInjectedBundlePath[] = "injected-bundle-path";
// Don't dump stuff here, follow the same order as the header.
// to web applications and thereby apply different styling based on these
// different modes using CSS Media Queries.
CONTENT_EXPORT extern const char kEnableViewMode[];
+CONTENT_EXPORT extern const char kInjectedBundlePath[];
// DON'T ADD RANDOM STUFF HERE. Put it in the main section above in
// alphabetical order, or in one of the ifdefs (also in order in each section).
#include "base/memory/scoped_ptr.h"
#include "browser_main_parts_efl.h"
#include "browser_context_efl.h"
+#include "eweb_context.h"
#include "web_contents_delegate_efl.h"
#include "web_contents_view_delegate_ewk.h"
#include "devtools_manager_delegate_efl.h"
#include "browser/render_message_filter_efl.h"
#include "browser/resource_dispatcher_host_delegate_efl.h"
#include "browser/web_view_browser_message_filter.h"
+#include "common/content_switches_efl.h"
#include "content/browser/web_contents/web_contents_view_efl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_iterator.h"
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/common/platform_notification_data.h"
+#include "content/public/common/content_switches.h"
#include "common/web_contents_utils.h"
#if defined(OS_TIZEN)
void ContentBrowserClientEfl::AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) {
+ if (command_line->HasSwitch(switches::kProcessType)) {
+ std::string processType = command_line->
+ GetSwitchValueASCII(switches::kProcessType);
+ if (processType == switches::kRendererProcess) {
+ if (content::RenderProcessHost* host =
+ content::RenderProcessHost::FromID(child_process_id)) {
+ if (EWebContext* context = static_cast<BrowserContextEfl*>(
+ host->GetBrowserContext())->WebContext()) {
+ const std::string& injectedBundlePath =
+ context->GetInjectedBundlePath();
+ if (!injectedBundlePath.empty())
+ command_line->AppendSwitchASCII(
+ switches::kInjectedBundlePath, injectedBundlePath);
+ }
+ }
+ }
+ }
CommandLineEfl::AppendProcessSpecificArgs(*command_line);
}
web_cache_manager_.reset(new WebCacheManagerEfl(browser_context_.get()));
}
+EWebContext::EWebContext(const std::string& injectedBundlePath)
+ : injected_bundle_path_(injectedBundlePath),
+ m_pixmap(0),
+ inspector_server_(NULL) {
+ CHECK(EwkGlobalData::GetInstance());
+
+ // WRT does not really care about incognito, so set it to false
+ browser_context_.reset(new BrowserContextEfl(this, false));
+ web_cache_manager_.reset(new WebCacheManagerEfl(browser_context_.get()));
+}
+
EWebContext::~EWebContext() {
}
unsigned int InspectorServerStart(unsigned int port);
bool InspectorServerStop();
+ const std::string& GetInjectedBundlePath() const { return injected_bundle_path_; }
+
private:
EWebContext(bool incognito);
+ EWebContext(const std::string& injectedBundlePath);
~EWebContext();
friend class Ewk_Context;
scoped_ptr<content::BrowserContextEfl> browser_context_;
scoped_ptr<Ewk_Cookie_Manager> ewk_cookie_manager_;
std::string proxy_uri_;
+ std::string injected_bundle_path_;
scoped_ptr<EwkDidStartDownloadCallback> start_download_callback_;
scoped_ptr<EwkMimeOverrideCallback> mime_override_callback_;
int m_pixmap;
return context;
}
+//static
+Ewk_Context* Ewk_Context::Create(const std::string& injectedBundlePath) {
+ Ewk_Context* context = new Ewk_Context(injectedBundlePath);
+ context->AddRef();
+ return context;
+}
+
// static
void Ewk_Context::Delete(Ewk_Context* context) {
if (context) {
Ewk_Context::Ewk_Context(bool incognito) : impl(new EWebContext(incognito)) {
}
+Ewk_Context::Ewk_Context(const std::string& injectedBundlePath)
+ : impl(new EWebContext(injectedBundlePath)) {
+}
+
Ewk_Context::~Ewk_Context() {
if (this == default_context_)
default_context_= NULL;
static Ewk_Context* DefaultContext();
static void DefaultContextRelease();
static Ewk_Context* Create(bool incognito = false);
+ static Ewk_Context* Create(const std::string& injectedBundlePath);
static void Delete(Ewk_Context*);
// Get related class
EWebContext* impl;
Ewk_Context(bool incognito);
+ Ewk_Context(const std::string& injectedBundlePath);
~Ewk_Context();
friend class base::RefCounted<Ewk_Context>;
Ewk_Context *ewk_context_new_with_injected_bundle_path(const char *path)
{
- //with chromium engine this API not used.
- //returning default context
- NOTIMPLEMENTED();
- return NULL;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
+ return Ewk_Context::Create(std::string(path));
}
void ewk_context_delete(Ewk_Context* context)
#include <vconf/vconf.h>
#endif
-#include "url/gurl.h"
+#include "base/command_line.h"
#include "base/path_service.h"
+#include "common/content_switches_efl.h"
#include "common/render_messages_ewk.h"
#include "content/common/paths_efl.h"
#include "content/public/renderer/render_thread.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebView.h"
+#include "url/gurl.h"
#if defined(OS_TIZEN_MOBILE)
#include "content/common/tts_messages_efl.h"
{
content::RenderThread* thread = content::RenderThread::Get();
- wrt_widget_.reset(new WrtWidget);
- thread->AddObserver(wrt_widget_->GetObserver());
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kInjectedBundlePath)) {
+ wrt_widget_.reset(new WrtWidget);
+ thread->AddObserver(wrt_widget_->GetObserver());
+ wrt_url_parser_.reset(new WrtUrlParseImpl(wrt_widget_.get()));
+ }
render_process_observer_.reset(new RenderProcessObserverEfl(this));
thread->AddObserver(render_process_observer_.get());
visited_link_slave_.reset(new visitedlink::VisitedLinkSlave());
thread->AddObserver(visited_link_slave_.get());
-
- wrt_url_parser_.reset(new WrtUrlParseImpl(wrt_widget_.get()));
}
void ContentRendererClientEfl::RenderFrameCreated(content::RenderFrame* render_frame) {
const GURL& url,
const GURL& first_party_for_cookies,
GURL* new_url) {
- wrt_widget_->ParseUrl(url, *new_url);
+ if (wrt_widget_) {
+ wrt_widget_->ParseUrl(url, *new_url);
+ } else {
+ *new_url = url;
+ }
+
return true;
}
int extension_group,
int world_id) {
const content::RenderView* render_view = content::RenderView::FromWebView(frame->view());
-
- wrt_widget_->StartSession(context, render_view->GetRoutingID(),
+ if (wrt_widget_)
+ wrt_widget_->StartSession(context, render_view->GetRoutingID(),
frame->document().baseURL().string().utf8());
}
void ContentRendererClientEfl::WillReleaseScriptContext(blink::WebFrame* frame,
v8::Handle<v8::Context> context,
int world_id) {
- wrt_widget_->StopSession(context);
+ if (wrt_widget_)
+ wrt_widget_->StopSession(context);
}
unsigned long long ContentRendererClientEfl::VisitedLinkHash(const char* canonical_url,
#include "dynamicplugin.h"
#include <dlfcn.h>
-#include <base/logging.h>
+
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "common/content_switches_efl.h"
namespace {
-const char* const INJECTED_BUNDLE_LIBRARY = "/usr/lib/libwrt-injected-bundle.so";
const char* const START_SESSION_FUNCTION = "DynamicPluginStartSession";
const char* const URL_PARSING_FUNCTION = "DynamicUrlParsing";
const char* const SET_WIDGET_INFO_FUNCTION = "DynamicSetWidgetInfo";
m_parseURL(0),
m_setWidgetInfo(0),
m_databaseAttach(0) {
- m_handle = dlopen(INJECTED_BUNDLE_LIBRARY, RTLD_LAZY);
+ const base::CommandLine& commandLine = *base::CommandLine::ForCurrentProcess();
+ std::string injectedBundlePath =
+ commandLine.GetSwitchValueASCII(switches::kInjectedBundlePath);
+ if (injectedBundlePath.empty())
+ return;
+ m_handle = dlopen(injectedBundlePath.c_str(), RTLD_LAZY);
if (!m_handle) {
- LOG(ERROR) << "No handle to " << INJECTED_BUNDLE_LIBRARY << " " << dlerror() << "\n";
+ LOG(ERROR) << "No handle to " << injectedBundlePath.c_str() << " " << dlerror() << "\n";
return;
}
'<(DEPTH)/tizen_src/build/system.gyp:edje',
'<(DEPTH)/tizen_src/build/system.gyp:elementary',
'<(DEPTH)/testing/gtest.gyp:gtest',
+ 'bundle_sample',
'chromium-ewk',
],
'include_dirs': [
'utc_blink_ewk_context_menu_item_tag_get_func.cpp',
'utc_blink_ewk_context_menu_nth_item_get_func.cpp',
'utc_blink_ewk_context_new_func.cpp',
+ 'utc_blink_ewk_context_new_with_injected_bundle_path_func.cc',
'utc_blink_ewk_context_notify_low_memory_func.cpp',
'utc_blink_ewk_context_pixmap_set_func.cpp',
'utc_blink_ewk_context_preferred_languages_set_func.cpp',
'<!@(pkg-config --libs-only-l glib-2.0)',
],
},
-
+ 'copies': [{
+ 'destination':'resources/ewk_context/injected_bundle/chromium/',
+ 'files': [ '<(PRODUCT_DIR)/lib/libbundle_sample.so' ],
+ }],
'conditions': [
['building_for_tizen==1', {
'cflags': [
}]
],
+ },
+ {
+ 'target_name': 'bundle_sample',
+ 'type': 'shared_library',
+ 'sources': [
+ 'resources/ewk_context/injected_bundle/chromium/bundle_sample.cc',
+ ],
+ 'dependencies': [
+ '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
+ ],
+ 'include_dirs': [
+ '.',
+ '<(DEPTH)/v8/include',
+ ],
}]
}
--- /dev/null
+// Copyright 2015 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <v8.h>
+
+#define EXPORT __attribute__((__visibility__("default")))
+
+namespace {
+void Run(const char* source) {
+ v8::Script::Compile(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source))->Run();
+}
+} // namespace
+
+extern "C" EXPORT void DynamicPluginStartSession(int widget_id,
+ v8::Handle<v8::Context> context,
+ int routingHandle,
+ double scale,
+ const char* encodeBundle,
+ const char* theme,
+ const char* baseURL) {
+ Run("document.write(\"DynamicPluginStartSession\");");
+}
+
+extern "C" EXPORT void DynamicDatabaseAttach(int attach) {
+}
+// Copyright 2015 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
#include <WebKit2/WKBundle.h>
#include <WebKit2/WKBundleInitialize.h>
#include <WebKit2/WKBundlePage.h>
--- /dev/null
+// Copyright 2015 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// See README.md how to run this test in DESKTOP mode.
+
+#include "utc_blink_ewk_base.h"
+
+class utc_blink_ewk_context_new_with_injected_bundle_path_func : public utc_blink_ewk_base
+{
+protected:
+ utc_blink_ewk_context_new_with_injected_bundle_path_func()
+ : timer(NULL),
+ webview(NULL) {
+ }
+
+ Ecore_Timer* timer;
+ Evas_Object* webview;
+ static const std::string injectedBundlePath;
+
+ static void getPlainText(Evas_Object* webview, const char* plainText, void* data)
+ {
+ ASSERT_TRUE(data);
+ utc_blink_ewk_context_new_with_injected_bundle_path_func* owner =
+ static_cast<utc_blink_ewk_context_new_with_injected_bundle_path_func*>(data);
+ owner->EventLoopStop(Success);
+ if (!plainText)
+ utc_fail();
+
+ if (strcmp(plainText, "DynamicPluginStartSession"))
+ utc_fail();
+ }
+ static Eina_Bool timerCallback(void* data)
+ {
+ utc_blink_ewk_context_new_with_injected_bundle_path_func* owner =
+ static_cast<utc_blink_ewk_context_new_with_injected_bundle_path_func*>(data);
+ ewk_view_plain_text_get(owner->webview, getPlainText, owner);
+ }
+ void runWithTimer()
+ {
+ timer = ecore_timer_add(1, timerCallback, this);
+ }
+
+ Evas_Object* CreateWindow()
+ {
+ Evas_Object* window = elm_win_add(NULL, "TC Launcher", ELM_WIN_BASIC);
+ return ewk_view_add_with_context(evas_object_evas_get(window),
+ ewk_context_new_with_injected_bundle_path(GetResourcePath(injectedBundlePath.c_str()).c_str()));
+ }
+};
+
+const std::string utc_blink_ewk_context_new_with_injected_bundle_path_func::injectedBundlePath =
+ "ewk_context/injected_bundle/chromium/libbundle_sample.so";
+
+/**
+ * @brief Checking whether context with injected bundle path is returned
+ */
+TEST_F(utc_blink_ewk_context_new_with_injected_bundle_path_func, POS_TEST)
+{
+ ASSERT_TRUE(ewk_context_new_with_injected_bundle_path(
+ GetResourcePath(injectedBundlePath.c_str()).c_str()));
+}
+
+TEST_F(utc_blink_ewk_context_new_with_injected_bundle_path_func, POS_TEST1)
+{
+ webview = CreateWindow();
+ const char simpleHTML[] = "<html><body><script>document.write(\"\");</script></body></html>";
+ ASSERT_TRUE(ewk_view_html_string_load(webview, simpleHTML, NULL, NULL));
+ ewk_send_widget_info(ewk_view_context_get(webview), 1, 1.0, "theme", "encodeBundle");
+ runWithTimer();
+ ASSERT_EQ(Success, EventLoopStart());
+}
+
+TEST_F(utc_blink_ewk_context_new_with_injected_bundle_path_func, NEG_TEST)
+{
+ Ewk_Context* context = ewk_context_new_with_injected_bundle_path(0);
+ ASSERT_TRUE(!context);
+}