OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 5 #ifndef SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
6 #define SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 6 #define SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 ScopedMessagePipeHandle ConnectToServiceByName( | 85 ScopedMessagePipeHandle ConnectToServiceByName( |
86 const GURL& application_url, | 86 const GURL& application_url, |
87 const std::string& interface_name); | 87 const std::string& interface_name); |
88 | 88 |
89 void RegisterContentHandler(const std::string& mime_type, | 89 void RegisterContentHandler(const std::string& mime_type, |
90 const GURL& content_handler_url); | 90 const GURL& content_handler_url); |
91 | 91 |
92 // Registers a package alias. When attempting to load |alias|, it will | 92 // Registers a package alias. When attempting to load |alias|, it will |
93 // instead redirect to |content_handler_package|, which is a content handler | 93 // instead redirect to |content_handler_package|, which is a content handler |
94 // which will be passed the |alias| as the URLResponse::url. | 94 // which will be passed the |alias| as the URLResponse::url. Different values |
| 95 // of |alias| with the same |qualifier| that are in the same |
| 96 // |content_handler_package| will run in the same process in multi-process |
| 97 // mode. |
95 void RegisterApplicationPackageAlias(const GURL& alias, | 98 void RegisterApplicationPackageAlias(const GURL& alias, |
96 const GURL& content_handler_package); | 99 const GURL& content_handler_package, |
| 100 const std::string& qualifier); |
97 | 101 |
98 // Sets the default Loader to be used if not overridden by SetLoaderForURL() | 102 // Sets the default Loader to be used if not overridden by SetLoaderForURL() |
99 // or SetLoaderForScheme(). | 103 // or SetLoaderForScheme(). |
100 void set_default_loader(scoped_ptr<ApplicationLoader> loader) { | 104 void set_default_loader(scoped_ptr<ApplicationLoader> loader) { |
101 default_loader_ = loader.Pass(); | 105 default_loader_ = loader.Pass(); |
102 } | 106 } |
103 void set_native_runner_factory( | 107 void set_native_runner_factory( |
104 scoped_ptr<NativeRunnerFactory> runner_factory) { | 108 scoped_ptr<NativeRunnerFactory> runner_factory) { |
105 native_runner_factory_ = runner_factory.Pass(); | 109 native_runner_factory_ = runner_factory.Pass(); |
106 } | 110 } |
(...skipping 20 matching lines...) Expand all Loading... |
127 // Applications connected by this ApplicationManager will observe pipe errors | 131 // Applications connected by this ApplicationManager will observe pipe errors |
128 // and have a chance to shutdown. | 132 // and have a chance to shutdown. |
129 void TerminateShellConnections(); | 133 void TerminateShellConnections(); |
130 | 134 |
131 // Removes a ShellImpl when it encounters an error. | 135 // Removes a ShellImpl when it encounters an error. |
132 void OnShellImplError(ShellImpl* shell_impl); | 136 void OnShellImplError(ShellImpl* shell_impl); |
133 | 137 |
134 private: | 138 private: |
135 class ContentHandlerConnection; | 139 class ContentHandlerConnection; |
136 | 140 |
137 using ApplicationPackagedAlias = std::map<GURL, GURL>; | 141 using ApplicationPackagedAlias = std::map<GURL, std::pair<GURL, std::string>>; |
138 using IdentityToShellImplMap = std::map<Identity, ShellImpl*>; | 142 using IdentityToShellImplMap = std::map<Identity, ShellImpl*>; |
139 using MimeTypeToURLMap = std::map<std::string, GURL>; | 143 using MimeTypeToURLMap = std::map<std::string, GURL>; |
140 using SchemeToLoaderMap = std::map<std::string, ApplicationLoader*>; | 144 using SchemeToLoaderMap = std::map<std::string, ApplicationLoader*>; |
141 using URLToContentHandlerMap = std::map<GURL, ContentHandlerConnection*>; | 145 using URLToContentHandlerMap = |
| 146 std::map<std::pair<GURL, std::string>, ContentHandlerConnection*>; |
142 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>; | 147 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>; |
143 using URLToNativeOptionsMap = std::map<GURL, NativeRunnerFactory::Options>; | 148 using URLToNativeOptionsMap = std::map<GURL, NativeRunnerFactory::Options>; |
144 | 149 |
145 void ConnectToApplicationWithParameters( | 150 void ConnectToApplicationWithParameters( |
146 const GURL& application_url, | 151 const GURL& application_url, |
| 152 const std::string& qualifier, |
147 const GURL& requestor_url, | 153 const GURL& requestor_url, |
148 InterfaceRequest<ServiceProvider> services, | 154 InterfaceRequest<ServiceProvider> services, |
149 ServiceProviderPtr exposed_services, | 155 ServiceProviderPtr exposed_services, |
150 const base::Closure& on_application_end, | 156 const base::Closure& on_application_end, |
151 const std::vector<std::string>& pre_redirect_parameters); | 157 const std::vector<std::string>& pre_redirect_parameters); |
152 | 158 |
153 bool ConnectToRunningApplication(const GURL& resolved_url, | 159 bool ConnectToRunningApplication(const GURL& resolved_url, |
| 160 const std::string& qualifier, |
154 const GURL& requestor_url, | 161 const GURL& requestor_url, |
155 InterfaceRequest<ServiceProvider>* services, | 162 InterfaceRequest<ServiceProvider>* services, |
156 ServiceProviderPtr* exposed_services); | 163 ServiceProviderPtr* exposed_services); |
157 | 164 |
158 bool ConnectToApplicationWithLoader( | 165 bool ConnectToApplicationWithLoader( |
159 const GURL& requested_url, | 166 const GURL& requested_url, |
| 167 const std::string& qualifier, |
160 const GURL& resolved_url, | 168 const GURL& resolved_url, |
161 const GURL& requestor_url, | 169 const GURL& requestor_url, |
162 InterfaceRequest<ServiceProvider>* services, | 170 InterfaceRequest<ServiceProvider>* services, |
163 ServiceProviderPtr* exposed_services, | 171 ServiceProviderPtr* exposed_services, |
164 const base::Closure& on_application_end, | 172 const base::Closure& on_application_end, |
165 const std::vector<std::string>& parameters, | 173 const std::vector<std::string>& parameters, |
166 ApplicationLoader* loader); | 174 ApplicationLoader* loader); |
167 | 175 |
168 InterfaceRequest<Application> RegisterShell( | 176 InterfaceRequest<Application> RegisterShell( |
169 const GURL& app_url, | 177 const GURL& app_url, |
| 178 const std::string& qualifier, |
170 const GURL& requestor_url, | 179 const GURL& requestor_url, |
171 InterfaceRequest<ServiceProvider> services, | 180 InterfaceRequest<ServiceProvider> services, |
172 ServiceProviderPtr exposed_services, | 181 ServiceProviderPtr exposed_services, |
173 const base::Closure& on_application_end, | 182 const base::Closure& on_application_end, |
174 const std::vector<std::string>& parameters); | 183 const std::vector<std::string>& parameters); |
175 | 184 |
176 ShellImpl* GetShellImpl(const GURL& url); | 185 ShellImpl* GetShellImpl(const GURL& url, const std::string& qualifier); |
177 | 186 |
178 void ConnectToClient(ShellImpl* shell_impl, | 187 void ConnectToClient(ShellImpl* shell_impl, |
179 const GURL& resolved_url, | 188 const GURL& resolved_url, |
180 const GURL& requestor_url, | 189 const GURL& requestor_url, |
181 InterfaceRequest<ServiceProvider> services, | 190 InterfaceRequest<ServiceProvider> services, |
182 ServiceProviderPtr exposed_services); | 191 ServiceProviderPtr exposed_services); |
183 | 192 |
184 // Called once |fetcher| has found app. |requested_url| is the url of the | 193 // Called once |fetcher| has found app. |requested_url| is the url of the |
185 // requested application before any mappings/resolution have been applied. | 194 // requested application before any mappings/resolution have been applied. |
186 void HandleFetchCallback(const GURL& requested_url, | 195 void HandleFetchCallback(const GURL& requested_url, |
| 196 const std::string& qualifier, |
187 const GURL& requestor_url, | 197 const GURL& requestor_url, |
188 InterfaceRequest<ServiceProvider> services, | 198 InterfaceRequest<ServiceProvider> services, |
189 ServiceProviderPtr exposed_services, | 199 ServiceProviderPtr exposed_services, |
190 const base::Closure& on_application_end, | 200 const base::Closure& on_application_end, |
191 const std::vector<std::string>& parameters, | 201 const std::vector<std::string>& parameters, |
192 NativeApplicationCleanup cleanup, | 202 NativeApplicationCleanup cleanup, |
193 scoped_ptr<Fetcher> fetcher); | 203 scoped_ptr<Fetcher> fetcher); |
194 | 204 |
195 void RunNativeApplication(InterfaceRequest<Application> application_request, | 205 void RunNativeApplication(InterfaceRequest<Application> application_request, |
196 const NativeRunnerFactory::Options& options, | 206 const NativeRunnerFactory::Options& options, |
197 NativeApplicationCleanup cleanup, | 207 NativeApplicationCleanup cleanup, |
198 scoped_ptr<Fetcher> fetcher, | 208 scoped_ptr<Fetcher> fetcher, |
199 const base::FilePath& file_path, | 209 const base::FilePath& file_path, |
200 bool path_exists); | 210 bool path_exists); |
201 | 211 |
202 void LoadWithContentHandler(const GURL& content_handler_url, | 212 void LoadWithContentHandler(const GURL& content_handler_url, |
| 213 const std::string& qualifier, |
203 InterfaceRequest<Application> application_request, | 214 InterfaceRequest<Application> application_request, |
204 URLResponsePtr url_response); | 215 URLResponsePtr url_response); |
205 | 216 |
206 // Returns the appropriate loader for |url|, or null if there is no loader | 217 // Returns the appropriate loader for |url|, or null if there is no loader |
207 // configured for the URL. | 218 // configured for the URL. |
208 ApplicationLoader* GetLoaderForURL(const GURL& url); | 219 ApplicationLoader* GetLoaderForURL(const GURL& url); |
209 | 220 |
210 // Removes a ContentHandler when it encounters an error. | 221 // Removes a ContentHandler when it encounters an error. |
211 void OnContentHandlerError(ContentHandlerConnection* content_handler); | 222 void OnContentHandlerError(ContentHandlerConnection* content_handler); |
212 | 223 |
(...skipping 20 matching lines...) Expand all Loading... |
233 bool disable_cache_; | 244 bool disable_cache_; |
234 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; | 245 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; |
235 | 246 |
236 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); | 247 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); |
237 }; | 248 }; |
238 | 249 |
239 } // namespace shell | 250 } // namespace shell |
240 } // namespace mojo | 251 } // namespace mojo |
241 | 252 |
242 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 253 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
OLD | NEW |