#include "xwalk/extensions/renderer/xwalk_module_system.h"
#include "xwalk/extensions/renderer/xwalk_v8tools_module.h"
+#if defined(OS_TIZEN)
+#include "xwalk/application/common/constants.h"
+#endif
+
namespace xwalk {
namespace extensions {
delegate_(delegate) {
content::RenderThread* thread = content::RenderThread::Get();
thread->AddObserver(this);
-
IPC::SyncChannel* browser_channel = thread->GetChannel();
SetupBrowserProcessClient(browser_channel);
}
}
+#if defined(OS_TIZEN)
+void CreateExtensionModulesWithoutDeviceAPI(XWalkExtensionClient* client,
+ XWalkModuleSystem* module_system) {
+ const XWalkExtensionClient::ExtensionAPIMap& extensions =
+ client->extension_apis();
+ XWalkExtensionClient::ExtensionAPIMap::const_iterator it = extensions.begin();
+ for (; it != extensions.end(); ++it) {
+ XWalkExtensionClient::ExtensionCodePoints* codepoint = it->second;
+ if (codepoint->api.empty() || it->first.find("tizen") == 0)
+ continue;
+ scoped_ptr<XWalkExtensionModule> module(
+ new XWalkExtensionModule(client, module_system,
+ it->first, codepoint->api));
+ module_system->RegisterExtensionModule(module.Pass(),
+ codepoint->entry_points);
+ }
+}
+#endif
} // namespace
void XWalkExtensionRendererController::DidCreateScriptContext(
- WebKit::WebFrame* frame, v8::Handle<v8::Context> context) {
+ blink::WebFrame* frame, v8::Handle<v8::Context> context) {
XWalkModuleSystem* module_system = new XWalkModuleSystem(context);
XWalkModuleSystem::SetModuleSystemInContext(
scoped_ptr<XWalkModuleSystem>(module_system), context);
module_system);
if (external_extensions_client_) {
+#if defined(OS_TIZEN)
+ // On Tizen platform, only local pages can access to device APIs.
+ GURL url = static_cast<GURL>(frame->document().url());
+ if (!url.SchemeIs(xwalk::application::kApplicationScheme) &&
+ !url.SchemeIsFile())
+ CreateExtensionModulesWithoutDeviceAPI(external_extensions_client_.get(),
+ module_system);
+ else
+ CreateExtensionModules(external_extensions_client_.get(), module_system);
+#else
CreateExtensionModules(external_extensions_client_.get(),
module_system);
+#endif
}
module_system->Initialize();
}
void XWalkExtensionRendererController::WillReleaseScriptContext(
- WebKit::WebFrame* frame, v8::Handle<v8::Context> context) {
+ blink::WebLocalFrame* frame, v8::Handle<v8::Context> context) {
v8::Context::Scope contextScope(context);
XWalkModuleSystem::ResetModuleSystemFromContext(context);
}
// FIXME(cmarcelo): Need to account for failure in creating the channel.
external_extensions_client_.reset(new XWalkExtensionClient);
- extension_process_channel_.reset(new IPC::SyncChannel(handle,
+ extension_process_channel_ = IPC::SyncChannel::Create(handle,
IPC::Channel::MODE_CLIENT, external_extensions_client_.get(),
content::RenderThread::Get()->GetIOMessageLoopProxy(), true,
- &shutdown_event_));
+ &shutdown_event_);
external_extensions_client_->Initialize(extension_process_channel_.get());
}