Chromecast: extracts Linux window creation code to a common place.
[chromium-blink-merge.git] / mojo / shell / dynamic_application_loader.h
blob6d8df9f7625fa43efbd3c8493c0d3c90c73480ed
1 // Copyright 2014 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 MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_
6 #define MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_
8 #include <map>
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/weak_ptr.h"
14 #include "mojo/application_manager/application_loader.h"
15 #include "mojo/public/cpp/system/core.h"
16 #include "mojo/services/public/interfaces/network/network_service.mojom.h"
17 #include "mojo/shell/dynamic_service_runner.h"
18 #include "url/gurl.h"
20 namespace mojo {
21 namespace shell {
23 class Context;
24 class DynamicServiceRunnerFactory;
25 class DynamicServiceRunner;
27 // An implementation of ApplicationLoader that retrieves a dynamic library
28 // containing the implementation of the service and loads/runs it (via a
29 // DynamicServiceRunner).
30 class DynamicApplicationLoader : public ApplicationLoader {
31 public:
32 DynamicApplicationLoader(
33 Context* context,
34 scoped_ptr<DynamicServiceRunnerFactory> runner_factory);
35 virtual ~DynamicApplicationLoader();
37 void RegisterContentHandler(const std::string& mime_type,
38 const GURL& content_handler_url);
40 // ApplicationLoader methods:
41 virtual void Load(ApplicationManager* manager,
42 const GURL& url,
43 scoped_refptr<LoadCallbacks> callbacks) override;
44 virtual void OnApplicationError(ApplicationManager* manager,
45 const GURL& url) override;
47 private:
48 class Loader;
49 class LocalLoader;
50 class NetworkLoader;
52 typedef std::map<std::string, GURL> MimeTypeToURLMap;
53 typedef base::Callback<void(Loader*)> LoaderCompleteCallback;
55 void LoaderComplete(Loader* loader);
57 Context* const context_;
58 scoped_ptr<DynamicServiceRunnerFactory> runner_factory_;
59 NetworkServicePtr network_service_;
60 MimeTypeToURLMap mime_type_to_url_;
61 ScopedVector<Loader> loaders_;
62 LoaderCompleteCallback loader_complete_callback_;
64 DISALLOW_COPY_AND_ASSIGN(DynamicApplicationLoader);
67 } // namespace shell
68 } // namespace mojo
70 #endif // MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_