1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef XWALK_APPLICATION_BROWSER_APPLICATION_SYSTEM_H_
6 #define XWALK_APPLICATION_BROWSER_APPLICATION_SYSTEM_H_
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "xwalk/extensions/common/xwalk_extension_vector.h"
21 class RenderProcessHost;
29 namespace application {
31 class ApplicationService;
32 class ApplicationServiceProvider;
33 class ApplicationStorage;
35 // The ApplicationSystem manages the creation and destruction of services which
36 // related to applications' runtime model.
37 // There's one-to-one correspondence between ApplicationSystem and
39 class ApplicationSystem {
41 virtual ~ApplicationSystem();
43 static scoped_ptr<ApplicationSystem> Create(RuntimeContext* runtime_context);
45 // The ApplicationService is created at startup.
46 ApplicationService* application_service() {
47 return application_service_.get();
50 ApplicationStorage* application_storage() {
51 return application_storage_.get();
54 // Launches an application based on the given command line, there are
55 // different ways to inform which application should be launched
57 // (1) app_id from the binary name (used in Tizen);
58 // (2) app_id passed in the command line;
59 // (3) launching a directory that contains an extracted package.
61 // The parameter `url` contains the current URL Crosswalk is considering to
62 // load, and the output parameter `run_default_message_loop` controls whether
63 // Crosswalk should run the mainloop or not.
65 // A return value of true indicates that ApplicationSystem handled the command
66 // line, so the caller shouldn't try to load the url by itself.
67 bool LaunchFromCommandLine(const base::CommandLine& cmd_line,
69 bool& run_default_message_loop_);
71 void CreateExtensions(content::RenderProcessHost* host,
72 extensions::XWalkExtensionVector* extensions);
75 explicit ApplicationSystem(RuntimeContext* runtime_context);
79 bool LaunchWithCommandLineParam(const T& param,
80 const base::CommandLine& cmd_line);
81 // Note: initialization order matters.
82 xwalk::RuntimeContext* runtime_context_;
83 scoped_ptr<ApplicationStorage> application_storage_;
84 scoped_ptr<ApplicationService> application_service_;
86 DISALLOW_COPY_AND_ASSIGN(ApplicationSystem);
89 } // namespace application
92 #endif // XWALK_APPLICATION_BROWSER_APPLICATION_SYSTEM_H_