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