OLD | NEW |
| (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 MANDOLINE_UI_DESKTOP_UI_BROWSER_MANAGER_H_ | |
6 #define MANDOLINE_UI_DESKTOP_UI_BROWSER_MANAGER_H_ | |
7 | |
8 #include <set> | |
9 | |
10 #include "base/macros.h" | |
11 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | |
12 #include "mandoline/ui/desktop_ui/public/interfaces/launch_handler.mojom.h" | |
13 #include "mojo/common/weak_binding_set.h" | |
14 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | |
15 #include "mojo/shell/public/cpp/shell_client.h" | |
16 #include "url/gurl.h" | |
17 | |
18 namespace mojo { | |
19 class View; | |
20 } | |
21 | |
22 namespace mandoline { | |
23 | |
24 class BrowserWindow; | |
25 | |
26 // BrowserManager creates and manages the lifetime of Browsers. | |
27 class BrowserManager : public mojo::ShellClient, | |
28 public LaunchHandler, | |
29 public mojo::InterfaceFactory<LaunchHandler> { | |
30 public: | |
31 BrowserManager(); | |
32 ~BrowserManager() override; | |
33 | |
34 // BrowserManager owns the returned BrowserWindow. | |
35 BrowserWindow* CreateBrowser(const GURL& default_url); | |
36 | |
37 void BrowserWindowClosed(BrowserWindow* browser); | |
38 | |
39 // Get the time recorded just before the application message loop was started. | |
40 const base::TimeTicks& startup_ticks() const { return startup_ticks_; } | |
41 | |
42 private: | |
43 // Overridden from LaunchHandler: | |
44 void LaunchURL(const mojo::String& url) override; | |
45 | |
46 // Overridden from mojo::ShellClient: | |
47 void Initialize(mojo::Shell* shell, const std::string& url, | |
48 uint32_t id) override; | |
49 bool AcceptConnection(mojo::Connection* connection) override; | |
50 | |
51 // Overridden from mojo::InterfaceFactory<LaunchHandler>: | |
52 void Create(mojo::Connection* connection, | |
53 mojo::InterfaceRequest<LaunchHandler> request) override; | |
54 | |
55 mojo::Shell* shell_; | |
56 mojo::TracingImpl tracing_; | |
57 mus::mojom::WindowTreeHostFactoryPtr host_factory_; | |
58 mojo::WeakBindingSet<LaunchHandler> launch_handler_bindings_; | |
59 std::set<BrowserWindow*> browsers_; | |
60 const base::TimeTicks startup_ticks_; | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(BrowserManager); | |
63 }; | |
64 | |
65 } // namespace mandoline | |
66 | |
67 #endif // MANDOLINE_UI_DESKTOP_UI_BROWSER_MANAGER_H_ | |
OLD | NEW |