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_CONNECT_TO_APPLICATION_PARAMS_H_
6 #define MOJO_SHELL_CONNECT_TO_APPLICATION_PARAMS_H_
10 #include "base/callback.h"
11 #include "mojo/application/public/interfaces/service_provider.mojom.h"
12 #include "mojo/application/public/interfaces/shell.mojom.h"
13 #include "mojo/public/cpp/bindings/interface_request.h"
14 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
15 #include "mojo/shell/identity.h"
21 class ApplicationInstance
;
23 // This class represents a request for the application manager to connect to an
25 class ConnectToApplicationParams
{
27 ConnectToApplicationParams();
28 ~ConnectToApplicationParams();
30 // Sets |source_|. If |source| is null, |source_| is reset.
31 void SetSource(ApplicationInstance
* source
);
33 // The following methods set both |target_| and |target_url_request_|.
34 void SetTarget(const Identity
& target
);
35 void SetTargetURL(const GURL
& target_url
);
36 void SetTargetURLRequest(URLRequestPtr request
);
37 void SetTargetURLRequest(URLRequestPtr request
, const Identity
& target
);
39 void set_source(const Identity
& source
) { source_
= source
; }
40 const Identity
& source() const { return source_
; }
41 const Identity
& target() const { return target_
; }
43 const URLRequest
* target_url_request() const {
44 return target_url_request_
.get();
46 // NOTE: This doesn't reset |target_|.
47 URLRequestPtr
TakeTargetURLRequest() { return target_url_request_
.Pass(); }
49 void set_services(InterfaceRequest
<ServiceProvider
> value
) {
50 services_
= value
.Pass();
52 InterfaceRequest
<ServiceProvider
> TakeServices() { return services_
.Pass(); }
54 void set_exposed_services(ServiceProviderPtr value
) {
55 exposed_services_
= value
.Pass();
57 ServiceProviderPtr
TakeExposedServices() { return exposed_services_
.Pass(); }
59 void set_on_application_end(const base::Closure
& value
) {
60 on_application_end_
= value
;
62 const base::Closure
& on_application_end() const {
63 return on_application_end_
;
66 void set_connect_callback(const Shell::ConnectToApplicationCallback
& value
) {
67 connect_callback_
= value
;
69 const Shell::ConnectToApplicationCallback
& connect_callback() const {
70 return connect_callback_
;
74 // It may be null (i.e., is_null() returns true) which indicates that there is
75 // no source (e.g., for the first application or in tests).
77 // The identity of the application being connected to.
79 // The URL request to fetch the application. It may contain more information
80 // than |target_| (e.g., headers, request body). When it is taken, |target_|
82 URLRequestPtr target_url_request_
;
84 InterfaceRequest
<ServiceProvider
> services_
;
85 ServiceProviderPtr exposed_services_
;
86 base::Closure on_application_end_
;
87 Shell::ConnectToApplicationCallback connect_callback_
;
89 DISALLOW_COPY_AND_ASSIGN(ConnectToApplicationParams
);
95 #endif // MOJO_SHELL_CONNECT_TO_APPLICATION_PARAMS_H_