#include <vector>
#include "base/command_line.h"
#include "base/logging.h"
+#include "content/public/browser/render_process_host.h"
+#include "xwalk/application/browser/application.h"
+#include "xwalk/application/browser/application_service.h"
#include "xwalk/application/browser/application_system.h"
#include "xwalk/extensions/browser/xwalk_extension_service.h"
#include "xwalk/runtime/browser/application_component.h"
#include "xwalk/runtime/browser/runtime_context.h"
#include "xwalk/runtime/browser/sysapps_component.h"
-#include "xwalk/runtime/browser/xwalk_component.h"
+#include "xwalk/runtime/browser/xwalk_app_extension_bridge.h"
#include "xwalk/runtime/browser/xwalk_browser_main_parts.h"
+#include "xwalk/runtime/browser/xwalk_component.h"
#include "xwalk/runtime/browser/xwalk_content_browser_client.h"
#include "xwalk/runtime/common/xwalk_runtime_features.h"
#include "xwalk/runtime/common/xwalk_switches.h"
#if defined(OS_ANDROID)
#include "xwalk/runtime/browser/xwalk_runner_android.h"
-#elif defined(OS_TIZEN_MOBILE)
+#elif defined(OS_TIZEN)
#include "xwalk/runtime/browser/xwalk_runner_tizen.h"
#endif
namespace {
+const char kDefaultLocale[] = "en-US";
XWalkRunner* g_xwalk_runner = NULL;
} // namespace
void XWalkRunner::PreMainMessageLoopRun() {
runtime_context_.reset(new RuntimeContext);
-
+ app_extension_bridge_.reset(new XWalkAppExtensionBridge());
// FIXME(cmarcelo): Remove this check once we remove the --uninstall
// command line.
CommandLine* cmd_line = CommandLine::ForCurrentProcess();
if (!cmd_line->HasSwitch(switches::kUninstall))
- extension_service_.reset(new extensions::XWalkExtensionService);
-
+ extension_service_.reset(new extensions::XWalkExtensionService(
+ app_extension_bridge_.get()));
CreateComponents();
+ app_extension_bridge_->SetApplicationSystem(app_component_->app_system());
}
void XWalkRunner::PostMainMessageLoopRun() {
runtime_context_.reset();
}
+std::string XWalkRunner::GetLocale() const {
+ return kDefaultLocale;
+}
+
void XWalkRunner::CreateComponents() {
scoped_ptr<ApplicationComponent> app_component(CreateAppComponent());
// Keep a reference as some code still needs to call
return make_scoped_ptr(new SysAppsComponent());
}
-void XWalkRunner::OnRenderProcessHostCreated(content::RenderProcessHost* host) {
+void XWalkRunner::InitializeRuntimeVariablesForExtensions(
+ const content::RenderProcessHost* host,
+ base::ValueMap& variables) {
+ application::Application* app = app_system()->application_service()->
+ GetApplicationByRenderHostID(host->GetID());
+
+ if (app)
+ variables["app_id"] = base::Value::CreateStringValue(app->id());
+}
+
+void XWalkRunner::OnRenderProcessWillLaunch(content::RenderProcessHost* host) {
if (!extension_service_)
return;
main_parts->CreateInternalExtensionsForExtensionThread(
host, &extension_thread_extensions);
- extension_service_->OnRenderProcessHostCreated(
- host, &ui_thread_extensions, &extension_thread_extensions);
+ base::ValueMap runtime_variables;
+ InitializeRuntimeVariablesForExtensions(host, runtime_variables);
+ extension_service_->OnRenderProcessWillLaunch(
+ host, &ui_thread_extensions, &extension_thread_extensions,
+ runtime_variables);
}
void XWalkRunner::OnRenderProcessHostGone(content::RenderProcessHost* host) {
XWalkRunner* runner = NULL;
#if defined(OS_ANDROID)
runner = new XWalkRunnerAndroid;
-#elif defined(OS_TIZEN_MOBILE)
+#elif defined(OS_TIZEN)
runner = new XWalkRunnerTizen;
#else
runner = new XWalkRunner;