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

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

Issue 930243006: Simplify the ApplicationLoader interface in preparation for changes. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: ptal Created 5 years, 10 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
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 #include <set> 9 #include <set>
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 void RegisterExternalApplication(const GURL& application_url, 73 void RegisterExternalApplication(const GURL& application_url,
74 const std::vector<std::string>& args, 74 const std::vector<std::string>& args,
75 ApplicationPtr application); 75 ApplicationPtr application);
76 76
77 // Sets the default Loader to be used if not overridden by SetLoaderForURL() 77 // Sets the default Loader to be used if not overridden by SetLoaderForURL()
78 // or SetLoaderForScheme(). 78 // or SetLoaderForScheme().
79 void set_default_loader(scoped_ptr<ApplicationLoader> loader) { 79 void set_default_loader(scoped_ptr<ApplicationLoader> loader) {
80 default_loader_ = loader.Pass(); 80 default_loader_ = loader.Pass();
81 } 81 }
82 void set_native_application_loader(
83 scoped_ptr<NativeApplicationLoader> loader) {
84 native_application_loader_ = loader.Pass();
85 }
82 // Sets a Loader to be used for a specific url. 86 // Sets a Loader to be used for a specific url.
83 void SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, const GURL& url); 87 void SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, const GURL& url);
84 // Sets a Loader to be used for a specific url scheme. 88 // Sets a Loader to be used for a specific url scheme.
85 void SetLoaderForScheme(scoped_ptr<ApplicationLoader> loader, 89 void SetLoaderForScheme(scoped_ptr<ApplicationLoader> loader,
86 const std::string& scheme); 90 const std::string& scheme);
87 // These strings will be passed to the Initialize() method when an 91 // These strings will be passed to the Initialize() method when an
88 // Application is instantiated. 92 // Application is instantiated.
89 void SetArgsForURL(const std::vector<std::string>& args, const GURL& url); 93 void SetArgsForURL(const std::vector<std::string>& args, const GURL& url);
90 94
91 // Destroys all Shell-ends of connections established with Applications. 95 // Destroys all Shell-ends of connections established with Applications.
92 // Applications connected by this ApplicationManager will observe pipe errors 96 // Applications connected by this ApplicationManager will observe pipe errors
93 // and have a chance to shutdown. 97 // and have a chance to shutdown.
94 void TerminateShellConnections(); 98 void TerminateShellConnections();
95 99
96 // Removes a ShellImpl when it encounters an error. 100 // Removes a ShellImpl when it encounters an error.
97 void OnShellImplError(ShellImpl* shell_impl); 101 void OnShellImplError(ShellImpl* shell_impl);
98 102
99 private: 103 private:
100 enum IncludeDefaultLoader {
101 INCLUDE_DEFAULT_LOADER,
102 DONT_INCLUDE_DEFAULT_LOADER,
103 };
104
105 class ContentHandlerConnection; 104 class ContentHandlerConnection;
106 105
107 typedef std::map<std::string, ApplicationLoader*> SchemeToLoaderMap; 106 typedef std::map<std::string, ApplicationLoader*> SchemeToLoaderMap;
108 typedef std::map<GURL, ApplicationLoader*> URLToLoaderMap; 107 typedef std::map<GURL, ApplicationLoader*> URLToLoaderMap;
109 typedef std::map<GURL, ShellImpl*> URLToShellImplMap; 108 typedef std::map<GURL, ShellImpl*> URLToShellImplMap;
110 typedef std::map<GURL, ContentHandlerConnection*> URLToContentHandlerMap; 109 typedef std::map<GURL, ContentHandlerConnection*> URLToContentHandlerMap;
111 typedef std::map<GURL, std::vector<std::string>> URLToArgsMap; 110 typedef std::map<GURL, std::vector<std::string>> URLToArgsMap;
112 111
113 void ConnectToApplicationImpl(const GURL& requested_url, 112 bool ConnectToRunningApplication(const GURL& application_url,
114 const GURL& resolved_url, 113 const GURL& requestor_url,
115 const GURL& requestor_url, 114 InterfaceRequest<ServiceProvider>* services,
116 InterfaceRequest<ServiceProvider> services, 115 ServiceProviderPtr* exposed_services);
117 ServiceProviderPtr exposed_services, 116
118 ApplicationLoader* loader); 117 bool ConnectToApplicationWithLoader(
118 const GURL& requested_url,
119 const GURL& resolved_url,
120 const GURL& requestor_url,
121 InterfaceRequest<ServiceProvider>* services,
122 ServiceProviderPtr* exposed_services,
123 ApplicationLoader* loader);
124
125 InterfaceRequest<Application> RegisterShell(
126 const GURL& requested_url,
127 const GURL& resolved_url,
128 const GURL& requestor_url,
129 InterfaceRequest<ServiceProvider> services,
130 ServiceProviderPtr exposed_services);
119 131
120 ShellImpl* GetShellImpl(const GURL& url); 132 ShellImpl* GetShellImpl(const GURL& url);
121 133
122 void ConnectToClient(ShellImpl* shell_impl, 134 void ConnectToClient(ShellImpl* shell_impl,
123 const GURL& url, 135 const GURL& url,
124 const GURL& requestor_url, 136 const GURL& requestor_url,
125 InterfaceRequest<ServiceProvider> services, 137 InterfaceRequest<ServiceProvider> services,
126 ServiceProviderPtr exposed_services); 138 ServiceProviderPtr exposed_services);
127 139
128 void LoadWithContentHandler(const GURL& content_handler_url, 140 void LoadWithContentHandler(const GURL& content_handler_url,
129 InterfaceRequest<Application> application_request, 141 InterfaceRequest<Application> application_request,
130 URLResponsePtr url_response); 142 URLResponsePtr url_response);
131 143
132 // Return the appropriate loader for |url|. This can return NULL if there is 144 // Return the appropriate loader for |url|. This can return NULL if there is
133 // no default loader configured. 145 // no loader configured for the URL.
134 ApplicationLoader* GetLoaderForURL(const GURL& url, 146 ApplicationLoader* GetLoaderForURL(const GURL& url);
135 IncludeDefaultLoader fallback);
136 147
137 // Removes a ContentHandler when it encounters an error. 148 // Removes a ContentHandler when it encounters an error.
138 void OnContentHandlerError(ContentHandlerConnection* content_handler); 149 void OnContentHandlerError(ContentHandlerConnection* content_handler);
139 150
140 // Returns the arguments for the given url. 151 // Returns the arguments for the given url.
141 Array<String> GetArgsForURL(const GURL& url); 152 Array<String> GetArgsForURL(const GURL& url);
142 153
143 Delegate* delegate_; 154 Delegate* delegate_;
144 // Loader management. 155 // Loader management.
156 // Loaders are chosen in the order they are listed here.
145 URLToLoaderMap url_to_loader_; 157 URLToLoaderMap url_to_loader_;
146 SchemeToLoaderMap scheme_to_loader_; 158 SchemeToLoaderMap scheme_to_loader_;
147 scoped_ptr<ApplicationLoader> default_loader_; 159 scoped_ptr<ApplicationLoader> default_loader_;
160 scoped_ptr<NativeApplicationLoader> native_application_loader_;
148 161
149 URLToShellImplMap url_to_shell_impl_; 162 URLToShellImplMap url_to_shell_impl_;
150 URLToContentHandlerMap url_to_content_handler_; 163 URLToContentHandlerMap url_to_content_handler_;
151 URLToArgsMap url_to_args_; 164 URLToArgsMap url_to_args_;
152 165
153 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; 166 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_;
154 167
155 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); 168 DISALLOW_COPY_AND_ASSIGN(ApplicationManager);
156 }; 169 };
157 170
158 } // namespace mojo 171 } // namespace mojo
159 172
160 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ 173 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_
OLDNEW
« no previous file with comments | « shell/application_manager/application_loader.cc ('k') | shell/application_manager/application_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698