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 MOJO_SHELL_CONNECT_TO_APPLICATION_PARAMS_H_ | 5 #ifndef MOJO_SHELL_CONNECT_TO_APPLICATION_PARAMS_H_ |
6 #define MOJO_SHELL_CONNECT_TO_APPLICATION_PARAMS_H_ | 6 #define MOJO_SHELL_CONNECT_TO_APPLICATION_PARAMS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "mojo/application/public/interfaces/service_provider.mojom.h" | 11 #include "mojo/application/public/interfaces/service_provider.mojom.h" |
12 #include "mojo/application/public/interfaces/shell.mojom.h" | 12 #include "mojo/application/public/interfaces/shell.mojom.h" |
13 #include "mojo/public/cpp/bindings/interface_request.h" | 13 #include "mojo/public/cpp/bindings/interface_request.h" |
14 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | 14 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" |
| 15 #include "mojo/shell/capability_filter.h" |
15 #include "mojo/shell/identity.h" | 16 #include "mojo/shell/identity.h" |
16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
17 | 18 |
18 namespace mojo { | 19 namespace mojo { |
19 namespace shell { | 20 namespace shell { |
20 | 21 |
21 class ApplicationInstance; | 22 class ApplicationInstance; |
22 | 23 |
23 // This class represents a request for the application manager to connect to an | 24 // This class represents a request for the application manager to connect to an |
24 // application. | 25 // application. |
25 class ConnectToApplicationParams { | 26 class ConnectToApplicationParams { |
26 public: | 27 public: |
27 ConnectToApplicationParams(); | 28 ConnectToApplicationParams(); |
28 ~ConnectToApplicationParams(); | 29 ~ConnectToApplicationParams(); |
29 | 30 |
30 // Sets |source_|. If |source| is null, |source_| is reset. | 31 // Sets both |originator_identity_| and |originator_filter_|. If |originator| |
31 void SetSource(ApplicationInstance* source); | 32 // is null, both fields are reset. |
| 33 void SetOriginatorInfo(ApplicationInstance* originator); |
32 | 34 |
33 // The following methods set both |target_| and |target_url_request_|. | 35 // Sets both |app_url_| and |app_url_request_|. |
34 void SetTarget(const Identity& target); | 36 void SetURLInfo(const GURL& app_url); |
35 void SetTargetURL(const GURL& target_url); | 37 // Sets both |app_url_| and |app_url_request_|. |
36 void SetTargetURLRequest(URLRequestPtr request); | 38 void SetURLInfo(URLRequestPtr app_url_request); |
37 void SetTargetURLRequest(URLRequestPtr request, const Identity& target); | |
38 | 39 |
39 void set_source(const Identity& source) { source_ = source; } | 40 void set_originator_identity(const Identity& value) { |
40 const Identity& source() const { return source_; } | 41 originator_identity_ = value; |
41 const Identity& target() const { return target_; } | 42 } |
| 43 const Identity& originator_identity() const { return originator_identity_; } |
42 | 44 |
43 const URLRequest* target_url_request() const { | 45 void set_originator_filter(const CapabilityFilter& value) { |
44 return target_url_request_.get(); | 46 originator_filter_ = value; |
45 } | 47 } |
46 // NOTE: This doesn't reset |target_|. | 48 const CapabilityFilter& originator_filter() const { |
47 URLRequestPtr TakeTargetURLRequest() { return target_url_request_.Pass(); } | 49 return originator_filter_; |
| 50 } |
| 51 |
| 52 const GURL& app_url() const { return app_url_; } |
| 53 |
| 54 const URLRequest* app_url_request() const { return app_url_request_.get(); } |
| 55 // NOTE: This doesn't reset |app_url_|. |
| 56 URLRequestPtr TakeAppURLRequest() { return app_url_request_.Pass(); } |
| 57 |
| 58 void set_qualifier(const std::string& value) { qualifier_ = value; } |
| 59 const std::string& qualifier() const { return qualifier_; } |
48 | 60 |
49 void set_services(InterfaceRequest<ServiceProvider> value) { | 61 void set_services(InterfaceRequest<ServiceProvider> value) { |
50 services_ = value.Pass(); | 62 services_ = value.Pass(); |
51 } | 63 } |
52 InterfaceRequest<ServiceProvider> TakeServices() { return services_.Pass(); } | 64 InterfaceRequest<ServiceProvider> TakeServices() { return services_.Pass(); } |
53 | 65 |
54 void set_exposed_services(ServiceProviderPtr value) { | 66 void set_exposed_services(ServiceProviderPtr value) { |
55 exposed_services_ = value.Pass(); | 67 exposed_services_ = value.Pass(); |
56 } | 68 } |
57 ServiceProviderPtr TakeExposedServices() { return exposed_services_.Pass(); } | 69 ServiceProviderPtr TakeExposedServices() { return exposed_services_.Pass(); } |
58 | 70 |
| 71 void set_filter(const CapabilityFilter& value) { filter_ = value; } |
| 72 const CapabilityFilter& filter() const { return filter_; } |
| 73 |
59 void set_on_application_end(const base::Closure& value) { | 74 void set_on_application_end(const base::Closure& value) { |
60 on_application_end_ = value; | 75 on_application_end_ = value; |
61 } | 76 } |
62 const base::Closure& on_application_end() const { | 77 const base::Closure& on_application_end() const { |
63 return on_application_end_; | 78 return on_application_end_; |
64 } | 79 } |
65 | 80 |
66 void set_connect_callback(const Shell::ConnectToApplicationCallback& value) { | 81 void set_connect_callback(const Shell::ConnectToApplicationCallback& value) { |
67 connect_callback_ = value; | 82 connect_callback_ = value; |
68 } | 83 } |
69 const Shell::ConnectToApplicationCallback& connect_callback() const { | 84 const Shell::ConnectToApplicationCallback& connect_callback() const { |
70 return connect_callback_; | 85 return connect_callback_; |
71 } | 86 } |
72 | 87 |
73 private: | 88 private: |
74 // It may be null (i.e., is_null() returns true) which indicates that there is | 89 // 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). | 90 // no originator (e.g., for the first application or in tests). |
76 Identity source_; | 91 Identity originator_identity_; |
77 // The identity of the application being connected to. | 92 // Should be ignored if |originator_identity_| is null. |
78 Identity target_; | 93 CapabilityFilter originator_filter_; |
| 94 // The URL of the application that is being connected to. |
| 95 GURL app_url_; |
79 // The URL request to fetch the application. It may contain more information | 96 // 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_| | 97 // than |app_url_| (e.g., headers, request body). When it is taken, |app_url_| |
81 // remains unchanged. | 98 // remains unchanged. |
82 URLRequestPtr target_url_request_; | 99 URLRequestPtr app_url_request_; |
83 | 100 // Please see the comments in identity.h for the exact meaning of qualifier. |
| 101 std::string qualifier_; |
84 InterfaceRequest<ServiceProvider> services_; | 102 InterfaceRequest<ServiceProvider> services_; |
85 ServiceProviderPtr exposed_services_; | 103 ServiceProviderPtr exposed_services_; |
| 104 CapabilityFilter filter_; |
86 base::Closure on_application_end_; | 105 base::Closure on_application_end_; |
87 Shell::ConnectToApplicationCallback connect_callback_; | 106 Shell::ConnectToApplicationCallback connect_callback_; |
88 | 107 |
89 DISALLOW_COPY_AND_ASSIGN(ConnectToApplicationParams); | 108 DISALLOW_COPY_AND_ASSIGN(ConnectToApplicationParams); |
90 }; | 109 }; |
91 | 110 |
92 } // namespace shell | 111 } // namespace shell |
93 } // namespace mojo | 112 } // namespace mojo |
94 | 113 |
95 #endif // MOJO_SHELL_CONNECT_TO_APPLICATION_PARAMS_H_ | 114 #endif // MOJO_SHELL_CONNECT_TO_APPLICATION_PARAMS_H_ |
OLD | NEW |