Remove 'RemoveTrailingSeparators' function from SimpleMenuModel
[chromium-blink-merge.git] / mojo / shell / context.h
blob4be704ee2603ad3a26ddf05ccb1f8950453b7f48
1 // Copyright 2013 The Chromium Authors. 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 SHELL_CONTEXT_H_
6 #define SHELL_CONTEXT_H_
8 #include <string>
10 #include "base/macros.h"
11 #include "mojo/edk/embedder/process_delegate.h"
12 #include "mojo/shell/application_manager/application_manager.h"
13 #include "mojo/shell/task_runners.h"
14 #include "mojo/shell/url_resolver.h"
16 namespace mojo {
17 namespace shell {
19 class NativeApplicationLoader;
21 // The "global" context for the shell's main process.
22 class Context : public ApplicationManager::Delegate,
23 public embedder::ProcessDelegate {
24 public:
25 Context();
26 ~Context() override;
28 static void EnsureEmbedderIsInitialized();
30 // Point to the directory containing installed services, such as the network
31 // service. By default this directory is used as the base URL for resolving
32 // unknown mojo: URLs. The network service will be loaded from this directory,
33 // even when the base URL for unknown mojo: URLs is overridden.
34 void SetShellFileRoot(const base::FilePath& path);
36 // Resolve an URL relative to the shell file root. This is a nop for
37 // everything but relative file URLs or URLs without a scheme.
38 GURL ResolveShellFileURL(const std::string& path);
40 // Override the CWD, which is used for resolving file URLs passed in from the
41 // command line.
42 void SetCommandLineCWD(const base::FilePath& path);
44 // Resolve an URL relative to the CWD mojo_shell was invoked from. This is a
45 // nop for everything but relative file URLs or URLs without a scheme.
46 GURL ResolveCommandLineURL(const std::string& path);
48 // This must be called with a message loop set up for the current thread,
49 // which must remain alive until after Shutdown() is called. Returns true on
50 // success.
51 bool Init();
53 // If Init() was called and succeeded, this must be called before destruction.
54 void Shutdown();
56 void Run(const GURL& url);
58 TaskRunners* task_runners() { return task_runners_.get(); }
59 ApplicationManager* application_manager() { return &application_manager_; }
60 URLResolver* url_resolver() { return &url_resolver_; }
62 private:
63 class NativeViewportApplicationLoader;
65 // ApplicationManager::Delegate overrides.
66 GURL ResolveURL(const GURL& url) override;
67 GURL ResolveMappings(const GURL& url) override;
69 // ProcessDelegate implementation.
70 void OnShutdownComplete() override;
72 void OnApplicationEnd(const GURL& url);
74 std::set<GURL> app_urls_;
75 scoped_ptr<TaskRunners> task_runners_;
76 ApplicationManager application_manager_;
77 URLResolver url_resolver_;
78 GURL shell_file_root_;
79 GURL command_line_cwd_;
81 DISALLOW_COPY_AND_ASSIGN(Context);
84 } // namespace shell
85 } // namespace mojo
87 #endif // SHELL_CONTEXT_H_