Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Side by Side Diff: content/browser/mojo/mojo_shell_context.h

Issue 1149833007: Embed a mojo ApplicationManager in content/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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.
4
5 #ifndef CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_
6 #define CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_
7
8 #include <map>
9
10 #include "base/callback_forward.h"
11 #include "base/compiler_specific.h"
12 #include "base/lazy_instance.h"
13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "content/common/content_export.h"
16 #include "mojo/shell/application_manager.h"
17
18 class GURL;
19
20 namespace mojo {
21 class ApplicationDelegate;
22 }
23
24 namespace content {
25
26 // MojoShellContext hosts the browser's ApplicationManager, coordinating
27 // app registration and interconnection.
28 class CONTENT_EXPORT MojoShellContext
29 : public NON_EXPORTED_BASE(mojo::shell::ApplicationManager::Delegate) {
30 public:
31 using StaticApplicationMap =
32 std::map<GURL, base::Callback<scoped_ptr<mojo::ApplicationDelegate>()>>;
33
34 MojoShellContext();
35 ~MojoShellContext() override;
36
37 // Connects an application at |url| and gets a handle to its exposed services.
38 // This is only intended for use in browser code that's not part of some Mojo
39 // application. May be called from any thread.
40 static void ConnectToApplication(
41 const GURL& url,
42 mojo::InterfaceRequest<mojo::ServiceProvider> request);
43
44 static void SetApplicationsForTest(const StaticApplicationMap* apps);
45
46 private:
47 class Proxy;
48 friend class Proxy;
49
50 void ConnectToApplicationOnOwnThread(
51 const GURL& url,
52 mojo::InterfaceRequest<mojo::ServiceProvider> request);
53
54 // mojo::shell::ApplicationManager::Delegate:
55 GURL ResolveMappings(const GURL& url) override;
56 GURL ResolveMojoURL(const GURL& url) override;
57 bool CreateFetcher(
58 const GURL& url,
59 const mojo::shell::Fetcher::FetchCallback& loader_callback) override;
60
61 static base::LazyInstance<scoped_ptr<Proxy>> proxy_;
62
63 scoped_ptr<mojo::shell::ApplicationManager> application_manager_;
64
65 DISALLOW_COPY_AND_ASSIGN(MojoShellContext);
66 };
67
68 } // namespace content
69
70 #endif // CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698