std::set<int64_t> extension_thread_instances_ids_;
};
-XWalkExtensionService::XWalkExtensionService()
- : extension_thread_("XWalkExtensionThread") {
+bool XWalkExtensionService::Delegate::RegisterPermissions(
+ int render_process_id,
+ const std::string& extension_name,
+ const std::string& perm_table) {
+ return false;
+}
+
+XWalkExtensionService::XWalkExtensionService(Delegate* delegate)
+ : extension_thread_("XWalkExtensionThread"),
+ delegate_(delegate) {
if (!g_external_extensions_path_for_testing_.empty())
external_extensions_path_ = g_external_extensions_path_for_testing_;
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
external_extensions_path_ = path;
}
-void XWalkExtensionService::OnRenderProcessHostCreated(
+void XWalkExtensionService::OnRenderProcessHostCreatedInternal(
content::RenderProcessHost* host,
XWalkExtensionVector* ui_thread_extensions,
- XWalkExtensionVector* extension_thread_extensions) {
- CHECK(host);
-
+ XWalkExtensionVector* extension_thread_extensions,
+ const base::ValueMap& runtime_variables) {
XWalkExtensionData* data = new XWalkExtensionData;
data->set_render_process_host(host);
CommandLine* cmd_line = CommandLine::ForCurrentProcess();
if (!cmd_line->HasSwitch(switches::kXWalkDisableExtensionProcess))
- CreateExtensionProcessHost(host, data);
+ CreateExtensionProcessHost(host, data, runtime_variables);
else if (!external_extensions_path_.empty()) {
RegisterExternalExtensionsInDirectory(
data->in_process_ui_thread_server(),
- external_extensions_path_);
+ external_extensions_path_, runtime_variables);
}
extension_data_map_[host->GetID()] = data;
}
+void XWalkExtensionService::OnRenderProcessWillLaunch(
+ content::RenderProcessHost* host,
+ XWalkExtensionVector* ui_thread_extensions,
+ XWalkExtensionVector* extension_thread_extensions,
+ const base::ValueMap& runtime_variables) {
+ CHECK(host);
+
+ if (!g_external_extensions_path_for_testing_.empty()) {
+ base::ValueMap test_variables;
+ test_variables["runtime_name"] = base::Value::CreateStringValue("xwalk");
+ OnRenderProcessHostCreatedInternal(host, ui_thread_extensions,
+ extension_thread_extensions, test_variables);
+ return;
+ }
+
+ OnRenderProcessHostCreatedInternal(host, ui_thread_extensions,
+ extension_thread_extensions, runtime_variables);
+}
+
// static
void
XWalkExtensionService::SetCreateExtensionThreadExtensionsCallbackForTesting(
}
void XWalkExtensionService::CreateExtensionProcessHost(
- content::RenderProcessHost* host, XWalkExtensionData* data) {
+ content::RenderProcessHost* host, XWalkExtensionData* data,
+ const base::ValueMap& runtime_variables) {
data->set_extension_process_host(make_scoped_ptr(
- new XWalkExtensionProcessHost(host, external_extensions_path_, this)));
+ new XWalkExtensionProcessHost(host, external_extensions_path_, this,
+ runtime_variables)));
}
void XWalkExtensionService::OnExtensionProcessDied(
delete data;
}
+void XWalkExtensionService::OnCheckAPIAccessControl(
+ int render_process_id,
+ const std::string& extension_name,
+ const std::string& api_name,
+ const PermissionCallback& callback) {
+ CHECK(delegate_);
+ delegate_->CheckAPIAccessControl(render_process_id, extension_name,
+ api_name, callback);
+}
+
+bool XWalkExtensionService::OnRegisterPermissions(
+ int render_process_id,
+ const std::string& extension_name,
+ const std::string& perm_table) {
+ CHECK(delegate_);
+ return delegate_->RegisterPermissions(render_process_id,
+ extension_name, perm_table);
+}
+
} // namespace extensions
} // namespace xwalk