Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: mojo/shell/application_manager.h

Issue 1311353005: Adds a way to determine id of content handler that created app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nuke comment Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/shell/application_instance.cc ('k') | mojo/shell/application_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "mojo/application/public/interfaces/application.mojom.h" 14 #include "mojo/application/public/interfaces/application.mojom.h"
15 #include "mojo/application/public/interfaces/service_provider.mojom.h" 15 #include "mojo/application/public/interfaces/service_provider.mojom.h"
16 #include "mojo/application/public/interfaces/shell.mojom.h"
16 #include "mojo/public/cpp/bindings/interface_ptr_info.h" 17 #include "mojo/public/cpp/bindings/interface_ptr_info.h"
17 #include "mojo/public/cpp/bindings/interface_request.h" 18 #include "mojo/public/cpp/bindings/interface_request.h"
18 #include "mojo/services/network/public/interfaces/network_service.mojom.h" 19 #include "mojo/services/network/public/interfaces/network_service.mojom.h"
19 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h" 20 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
20 #include "mojo/services/updater/updater.mojom.h" 21 #include "mojo/services/updater/updater.mojom.h"
21 #include "mojo/shell/application_loader.h" 22 #include "mojo/shell/application_loader.h"
22 #include "mojo/shell/capability_filter.h" 23 #include "mojo/shell/capability_filter.h"
23 #include "mojo/shell/fetcher.h" 24 #include "mojo/shell/fetcher.h"
24 #include "mojo/shell/identity.h" 25 #include "mojo/shell/identity.h"
25 #include "mojo/shell/native_runner.h" 26 #include "mojo/shell/native_runner.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 DISALLOW_COPY_AND_ASSIGN(TestAPI); 76 DISALLOW_COPY_AND_ASSIGN(TestAPI);
76 }; 77 };
77 78
78 explicit ApplicationManager(Delegate* delegate); 79 explicit ApplicationManager(Delegate* delegate);
79 ~ApplicationManager(); 80 ~ApplicationManager();
80 81
81 // Loads a service if necessary and establishes a new client connection. 82 // Loads a service if necessary and establishes a new client connection.
82 // |originator| can be NULL (e.g. for the first application or in tests), but 83 // |originator| can be NULL (e.g. for the first application or in tests), but
83 // typically is non-NULL and identifies the instance initiating the 84 // typically is non-NULL and identifies the instance initiating the
84 // connection. 85 // connection.
85 void ConnectToApplication(ApplicationInstance* originator, 86 void ConnectToApplication(
86 URLRequestPtr requested_url, 87 ApplicationInstance* originator,
87 const std::string& qualifier, 88 URLRequestPtr requested_url,
88 const GURL& requestor_url, 89 const std::string& qualifier,
89 InterfaceRequest<ServiceProvider> services, 90 const GURL& requestor_url,
90 ServiceProviderPtr exposed_services, 91 InterfaceRequest<ServiceProvider> services,
91 const CapabilityFilter& capability_filter, 92 ServiceProviderPtr exposed_services,
92 const base::Closure& on_application_end); 93 const CapabilityFilter& capability_filter,
94 const base::Closure& on_application_end,
95 const Shell::ConnectToApplicationCallback& connect_callback);
93 96
94 // Must only be used by shell internals and test code as it does not forward 97 // Must only be used by shell internals and test code as it does not forward
95 // capability filters. 98 // capability filters.
96 template <typename Interface> 99 template <typename Interface>
97 inline void ConnectToService(const GURL& application_url, 100 inline void ConnectToService(const GURL& application_url,
98 InterfacePtr<Interface>* ptr) { 101 InterfacePtr<Interface>* ptr) {
99 ScopedMessagePipeHandle service_handle = 102 ScopedMessagePipeHandle service_handle =
100 ConnectToServiceByName(application_url, Interface::Name_); 103 ConnectToServiceByName(application_url, Interface::Name_);
101 ptr->Bind(InterfacePtrInfo<Interface>(service_handle.Pass(), 0u)); 104 ptr->Bind(InterfacePtrInfo<Interface>(service_handle.Pass(), 0u));
102 } 105 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 using ApplicationPackagedAlias = std::map<GURL, std::pair<GURL, std::string>>; 163 using ApplicationPackagedAlias = std::map<GURL, std::pair<GURL, std::string>>;
161 using IdentityToApplicationInstanceMap = 164 using IdentityToApplicationInstanceMap =
162 std::map<Identity, ApplicationInstance*>; 165 std::map<Identity, ApplicationInstance*>;
163 using MimeTypeToURLMap = std::map<std::string, GURL>; 166 using MimeTypeToURLMap = std::map<std::string, GURL>;
164 using SchemeToLoaderMap = std::map<std::string, ApplicationLoader*>; 167 using SchemeToLoaderMap = std::map<std::string, ApplicationLoader*>;
165 using URLToContentHandlerMap = 168 using URLToContentHandlerMap =
166 std::map<std::pair<GURL, std::string>, ContentHandlerConnection*>; 169 std::map<std::pair<GURL, std::string>, ContentHandlerConnection*>;
167 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>; 170 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>;
168 using URLToNativeOptionsMap = std::map<GURL, NativeRunnerFactory::Options>; 171 using URLToNativeOptionsMap = std::map<GURL, NativeRunnerFactory::Options>;
169 172
170 bool ConnectToRunningApplication(ApplicationInstance* originator, 173 bool ConnectToRunningApplication(
171 const GURL& resolved_url, 174 ApplicationInstance* originator,
172 const std::string& qualifier, 175 const GURL& resolved_url,
173 const GURL& requestor_url, 176 const std::string& qualifier,
174 InterfaceRequest<ServiceProvider>* services, 177 const GURL& requestor_url,
175 ServiceProviderPtr* exposed_services, 178 InterfaceRequest<ServiceProvider>* services,
176 const CapabilityFilter& filter); 179 ServiceProviderPtr* exposed_services,
180 const CapabilityFilter& filter,
181 const Shell::ConnectToApplicationCallback& connect_callback);
177 182
178 bool ConnectToApplicationWithLoader( 183 bool ConnectToApplicationWithLoader(
179 ApplicationInstance* originator, 184 ApplicationInstance* originator,
180 const GURL& requested_url, 185 const GURL& requested_url,
181 const std::string& qualifier, 186 const std::string& qualifier,
182 const GURL& resolved_url, 187 const GURL& resolved_url,
183 const GURL& requestor_url, 188 const GURL& requestor_url,
184 InterfaceRequest<ServiceProvider>* services, 189 InterfaceRequest<ServiceProvider>* services,
185 ServiceProviderPtr* exposed_services, 190 ServiceProviderPtr* exposed_services,
186 const CapabilityFilter& filter, 191 const CapabilityFilter& filter,
187 const base::Closure& on_application_end, 192 const base::Closure& on_application_end,
193 const Shell::ConnectToApplicationCallback& connect_callback,
188 ApplicationLoader* loader); 194 ApplicationLoader* loader);
189 195
190 InterfaceRequest<Application> RegisterInstance( 196 InterfaceRequest<Application> RegisterInstance(
191 ApplicationInstance* originator, 197 ApplicationInstance* originator,
192 const GURL& app_url, 198 const GURL& app_url,
193 const std::string& qualifier, 199 const std::string& qualifier,
194 const GURL& requestor_url, 200 const GURL& requestor_url,
195 InterfaceRequest<ServiceProvider> services, 201 InterfaceRequest<ServiceProvider> services,
196 ServiceProviderPtr exposed_services, 202 ServiceProviderPtr exposed_services,
197 const CapabilityFilter& filter, 203 const CapabilityFilter& filter,
198 const base::Closure& on_application_end); 204 const base::Closure& on_application_end,
205 const Shell::ConnectToApplicationCallback& connect_callback,
206 ApplicationInstance** resulting_instance);
199 207
200 // Called once |fetcher| has found app. |requested_url| is the url of the 208 // Called once |fetcher| has found app. |requested_url| is the url of the
201 // requested application before any mappings/resolution have been applied. 209 // requested application before any mappings/resolution have been applied.
202 void HandleFetchCallback(ApplicationInstance* originator, 210 void HandleFetchCallback(
203 const GURL& requested_url, 211 ApplicationInstance* originator,
204 const std::string& qualifier, 212 const GURL& requested_url,
205 const GURL& requestor_url, 213 const std::string& qualifier,
206 InterfaceRequest<ServiceProvider> services, 214 const GURL& requestor_url,
207 ServiceProviderPtr exposed_services, 215 InterfaceRequest<ServiceProvider> services,
208 const CapabilityFilter& filter, 216 ServiceProviderPtr exposed_services,
209 const base::Closure& on_application_end, 217 const CapabilityFilter& filter,
210 NativeApplicationCleanup cleanup, 218 const base::Closure& on_application_end,
211 scoped_ptr<Fetcher> fetcher); 219 const Shell::ConnectToApplicationCallback& connect_callback,
220 NativeApplicationCleanup cleanup,
221 scoped_ptr<Fetcher> fetcher);
212 222
213 void RunNativeApplication(InterfaceRequest<Application> application_request, 223 void RunNativeApplication(InterfaceRequest<Application> application_request,
214 bool start_sandboxed, 224 bool start_sandboxed,
215 const NativeRunnerFactory::Options& options, 225 const NativeRunnerFactory::Options& options,
216 NativeApplicationCleanup cleanup, 226 NativeApplicationCleanup cleanup,
217 scoped_ptr<Fetcher> fetcher, 227 scoped_ptr<Fetcher> fetcher,
218 const base::FilePath& file_path, 228 const base::FilePath& file_path,
219 bool path_exists); 229 bool path_exists);
220 230
221 void LoadWithContentHandler(ApplicationInstance* originator, 231 void LoadWithContentHandler(
222 const GURL& content_handler_url, 232 ApplicationInstance* originator,
223 const GURL& requestor_url, 233 const GURL& content_handler_url,
224 const std::string& qualifier, 234 const GURL& requestor_url,
225 const CapabilityFilter& filter, 235 const std::string& qualifier,
226 InterfaceRequest<Application> application_request, 236 const CapabilityFilter& filter,
227 URLResponsePtr url_response); 237 const Shell::ConnectToApplicationCallback& connect_callback,
238 ApplicationInstance* app,
239 InterfaceRequest<Application> application_request,
240 URLResponsePtr url_response);
228 241
229 // Returns the appropriate loader for |url|, or null if there is no loader 242 // Returns the appropriate loader for |url|, or null if there is no loader
230 // configured for the URL. 243 // configured for the URL.
231 ApplicationLoader* GetLoaderForURL(const GURL& url); 244 ApplicationLoader* GetLoaderForURL(const GURL& url);
232 245
233 void CleanupRunner(NativeRunner* runner); 246 void CleanupRunner(NativeRunner* runner);
234 247
235 ScopedMessagePipeHandle ConnectToServiceByName( 248 ScopedMessagePipeHandle ConnectToServiceByName(
236 const GURL& application_url, 249 const GURL& application_url,
237 const std::string& interface_name); 250 const std::string& interface_name);
(...skipping 12 matching lines...) Expand all
250 // Note: The keys are URLs after mapping and resolving. 263 // Note: The keys are URLs after mapping and resolving.
251 URLToNativeOptionsMap url_to_native_options_; 264 URLToNativeOptionsMap url_to_native_options_;
252 265
253 base::SequencedWorkerPool* blocking_pool_; 266 base::SequencedWorkerPool* blocking_pool_;
254 NetworkServicePtr network_service_; 267 NetworkServicePtr network_service_;
255 URLLoaderFactoryPtr url_loader_factory_; 268 URLLoaderFactoryPtr url_loader_factory_;
256 updater::UpdaterPtr updater_; 269 updater::UpdaterPtr updater_;
257 MimeTypeToURLMap mime_type_to_url_; 270 MimeTypeToURLMap mime_type_to_url_;
258 ScopedVector<NativeRunner> native_runners_; 271 ScopedVector<NativeRunner> native_runners_;
259 bool disable_cache_; 272 bool disable_cache_;
273 // Counter used to assign ids to content_handlers.
274 uint32_t content_handler_id_counter_;
260 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; 275 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_;
261 276
262 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); 277 DISALLOW_COPY_AND_ASSIGN(ApplicationManager);
263 }; 278 };
264 279
280 Shell::ConnectToApplicationCallback EmptyConnectCallback();
281
265 } // namespace shell 282 } // namespace shell
266 } // namespace mojo 283 } // namespace mojo
267 284
268 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ 285 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_
OLDNEW
« no previous file with comments | « mojo/shell/application_instance.cc ('k') | mojo/shell/application_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698