#include "xwalk/application/browser/application_service.h"
#include "xwalk/application/browser/application_system.h"
#include "xwalk/extensions/browser/xwalk_extension_service.h"
+#include "xwalk/extensions/common/xwalk_extension_switches.h"
#include "xwalk/runtime/browser/application_component.h"
#include "xwalk/runtime/browser/runtime_context.h"
+#include "xwalk/runtime/browser/storage_component.h"
#include "xwalk/runtime/browser/sysapps_component.h"
#include "xwalk/runtime/browser/xwalk_app_extension_bridge.h"
#include "xwalk/runtime/browser/xwalk_browser_main_parts.h"
namespace {
-const char kDefaultLocale[] = "en-US";
XWalkRunner* g_xwalk_runner = NULL;
} // namespace
-XWalkRunner::XWalkRunner()
- : is_running_as_service_(false) {
+XWalkRunner::XWalkRunner() {
VLOG(1) << "Creating XWalkRunner object.";
DCHECK(!g_xwalk_runner);
g_xwalk_runner = this;
XWalkRuntimeFeatures::GetInstance()->Initialize(
CommandLine::ForCurrentProcess());
- CommandLine* cmd_line = CommandLine::ForCurrentProcess();
- is_running_as_service_ = cmd_line->HasSwitch(switches::kXWalkRunAsService);
// Initializing after the g_xwalk_runner is set to ensure
// XWalkRunner::GetInstance() can be used in all sub objects if needed.
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.
+
+#if defined(OS_ANDROID)
CommandLine* cmd_line = CommandLine::ForCurrentProcess();
- if (!cmd_line->HasSwitch(switches::kUninstall))
+ if (!cmd_line->HasSwitch(switches::kXWalkDisableExtensions))
+#endif
+ {
extension_service_.reset(new extensions::XWalkExtensionService(
app_extension_bridge_.get()));
+ }
+
CreateComponents();
app_extension_bridge_->SetApplicationSystem(app_component_->app_system());
}
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
if (XWalkRuntimeFeatures::isSysAppsEnabled())
AddComponent(CreateSysAppsComponent().PassAs<XWalkComponent>());
+ if (XWalkRuntimeFeatures::isStorageAPIEnabled())
+ AddComponent(CreateStorageComponent().PassAs<XWalkComponent>());
}
void XWalkRunner::DestroyComponents() {
return make_scoped_ptr(new SysAppsComponent());
}
+scoped_ptr<StorageComponent> XWalkRunner::CreateStorageComponent() {
+ return make_scoped_ptr(new StorageComponent());
+}
+
void XWalkRunner::InitializeRuntimeVariablesForExtensions(
const content::RenderProcessHost* host,
- base::ValueMap& variables) {
+ base::ValueMap* variables) {
application::Application* app = app_system()->application_service()->
GetApplicationByRenderHostID(host->GetID());
if (app)
- variables["app_id"] = base::Value::CreateStringValue(app->id());
+ (*variables)["app_id"] = base::Value::CreateStringValue(app->id());
}
void XWalkRunner::OnRenderProcessWillLaunch(content::RenderProcessHost* host) {
main_parts->CreateInternalExtensionsForExtensionThread(
host, &extension_thread_extensions);
- base::ValueMap runtime_variables;
- InitializeRuntimeVariablesForExtensions(host, runtime_variables);
+ scoped_ptr<base::ValueMap> runtime_variables(new base::ValueMap);
+ InitializeRuntimeVariablesForExtensions(host, runtime_variables.get());
extension_service_->OnRenderProcessWillLaunch(
host, &ui_thread_extensions, &extension_thread_extensions,
- runtime_variables);
+ runtime_variables.Pass());
}
void XWalkRunner::OnRenderProcessHostGone(content::RenderProcessHost* host) {