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;
25 class XWalkBrowserContext;
29 namespace application {
31 class ApplicationService;
33 // The ApplicationSystem manages the creation and destruction of services which
34 // related to applications' runtime model.
35 // There's one-to-one correspondence between ApplicationSystem and
36 // XWalkBrowserContext.
37 class ApplicationSystem {
39 virtual ~ApplicationSystem();
41 static scoped_ptr<ApplicationSystem> Create(
42 XWalkBrowserContext* browser_context);
44 // The ApplicationService is created at startup.
45 ApplicationService* application_service() {
46 return application_service_.get();
49 // Launches an application based on the given command line, there are
50 // different ways to inform which application should be launched
52 // (1) app_id from the binary name (used in Tizen);
53 // (2) app_id passed in the command line (used in Tizen);
54 // (3) launching a directory that contains an extracted package.
55 // (4) launching from the path to the packaged application file.
57 // The parameter `url` contains the current URL Crosswalk is considering to
58 // load, and the output parameter `run_default_message_loop` controls whether
59 // Crosswalk should run the mainloop or not.
61 // A return value of true indicates that ApplicationSystem handled the command
62 // line, so the caller shouldn't try to load the url by itself.
63 bool LaunchFromCommandLine(const base::CommandLine& cmd_line,
65 bool& run_default_message_loop_); // NOLINT
67 void CreateExtensions(content::RenderProcessHost* host,
68 extensions::XWalkExtensionVector* extensions);
71 explicit ApplicationSystem(XWalkBrowserContext* browser_context);
74 // Note: initialization order matters.
75 XWalkBrowserContext* browser_context_;
76 scoped_ptr<ApplicationService> application_service_;
78 DISALLOW_COPY_AND_ASSIGN(ApplicationSystem);
81 } // namespace application
84 #endif // XWALK_APPLICATION_BROWSER_APPLICATION_SYSTEM_H_