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 MOJO_SHELL_SHELL_IMPL_H_
6 #define MOJO_SHELL_SHELL_IMPL_H_
8 #include "base/callback.h"
9 #include "mojo/application/public/interfaces/application.mojom.h"
10 #include "mojo/application/public/interfaces/shell.mojom.h"
11 #include "mojo/public/cpp/bindings/binding.h"
12 #include "mojo/public/cpp/bindings/error_handler.h"
13 #include "mojo/shell/identity.h"
19 class ApplicationManager
;
21 class ShellImpl
: public Shell
, public ErrorHandler
{
23 ShellImpl(ApplicationPtr application
,
24 ApplicationManager
* manager
,
25 const Identity
& resolved_identity
,
26 const base::Closure
& on_application_end
);
28 ~ShellImpl() override
;
30 void InitializeApplication();
32 void ConnectToClient(const GURL
& requested_url
,
33 const GURL
& requestor_url
,
34 InterfaceRequest
<ServiceProvider
> services
,
35 ServiceProviderPtr exposed_services
);
37 Application
* application() { return application_
.get(); }
38 const Identity
& identity() const { return identity_
; }
39 base::Closure
on_application_end() const { return on_application_end_
; }
42 // Shell implementation:
43 void ConnectToApplication(mojo::URLRequestPtr app_request
,
44 InterfaceRequest
<ServiceProvider
> services
,
45 ServiceProviderPtr exposed_services
) override
;
46 void QuitApplication() override
;
48 // ErrorHandler implementation:
49 void OnConnectionError() override
;
51 void OnQuitRequestedResult(bool can_quit
);
53 struct QueuedClientRequest
{
54 QueuedClientRequest();
55 ~QueuedClientRequest();
58 InterfaceRequest
<ServiceProvider
> services
;
59 ServiceProviderPtr exposed_services
;
62 ApplicationManager
* const manager_
;
63 const Identity identity_
;
64 base::Closure on_application_end_
;
65 ApplicationPtr application_
;
66 Binding
<Shell
> binding_
;
68 std::vector
<QueuedClientRequest
*> queued_client_requests_
;
70 DISALLOW_COPY_AND_ASSIGN(ShellImpl
);
76 #endif // MOJO_SHELL_SHELL_IMPL_H_