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.
5 #ifndef MANDOLINE_UI_DESKTOP_UI_BROWSER_MANAGER_H_
6 #define MANDOLINE_UI_DESKTOP_UI_BROWSER_MANAGER_H_
10 #include "components/view_manager/public/interfaces/view_tree_host.mojom.h"
11 #include "mandoline/ui/desktop_ui/public/interfaces/launch_handler.mojom.h"
12 #include "mojo/application/public/cpp/application_delegate.h"
13 #include "mojo/application/public/cpp/application_impl.h"
14 #include "mojo/application/public/cpp/connect.h"
15 #include "mojo/common/weak_binding_set.h"
26 // BrowserManager creates and manages the lifetime of Browsers.
27 class BrowserManager
: public mojo::ApplicationDelegate
,
29 public mojo::InterfaceFactory
<LaunchHandler
> {
32 ~BrowserManager() override
;
34 // BrowserManager owns the returned BrowserWindow.
35 BrowserWindow
* CreateBrowser(const GURL
& default_url
);
37 void BrowserWindowClosed(BrowserWindow
* browser
);
39 // Get the time recorded just before the application message loop was started.
40 const base::Time
& startup_time() const { return startup_time_
; }
43 // Overridden from LaunchHandler:
44 void LaunchURL(const mojo::String
& url
) override
;
46 // Overridden from mojo::ApplicationDelegate:
47 void Initialize(mojo::ApplicationImpl
* app
) override
;
48 bool ConfigureIncomingConnection(
49 mojo::ApplicationConnection
* connection
) override
;
51 // Overridden from mojo::InterfaceFactory<LaunchHandler>:
52 void Create(mojo::ApplicationConnection
* connection
,
53 mojo::InterfaceRequest
<LaunchHandler
> request
) override
;
55 mojo::ApplicationImpl
* app_
;
56 mojo::ViewTreeHostFactoryPtr host_factory_
;
57 mojo::WeakBindingSet
<LaunchHandler
> launch_handler_bindings_
;
58 std::set
<BrowserWindow
*> browsers_
;
59 base::Time startup_time_
;
61 DISALLOW_COPY_AND_ASSIGN(BrowserManager
);
64 } // namespace mandoline
66 #endif // MANDOLINE_UI_DESKTOP_UI_BROWSER_MANAGER_H_