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 #include <dlfcn.h> | 5 #include <dlfcn.h> |
6 #include <python2.7/Python.h> | 6 #include <python2.7/Python.h> |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/i18n/icu_util.h" | 10 #include "base/i18n/icu_util.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 class PythonContentHandlerApp : public ApplicationDelegate { | 205 class PythonContentHandlerApp : public ApplicationDelegate { |
206 public: | 206 public: |
207 PythonContentHandlerApp() | 207 PythonContentHandlerApp() |
208 : content_handler_(false), | 208 : content_handler_(false), |
209 debug_content_handler_(true), | 209 debug_content_handler_(true), |
210 content_handler_factory_(&content_handler_), | 210 content_handler_factory_(&content_handler_), |
211 debug_content_handler_factory_(&debug_content_handler_) {} | 211 debug_content_handler_factory_(&debug_content_handler_) {} |
212 | 212 |
213 private: | 213 private: |
214 // Overridden from ApplicationDelegate: | 214 // Overridden from ApplicationDelegate: |
215 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | 215 bool ConfigureIncomingConnection( |
216 if (IsDebug(connection->GetServiceProviderImpl() | 216 mojo::ServiceProviderImpl* service_provider_impl) override { |
217 .connection_context() | 217 if (IsDebug(service_provider_impl->connection_context().connection_url)) { |
218 .connection_url)) { | 218 service_provider_impl->AddService<mojo::ContentHandler>( |
219 connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>( | |
220 debug_content_handler_factory_.GetInterfaceRequestHandler()); | 219 debug_content_handler_factory_.GetInterfaceRequestHandler()); |
221 } else { | 220 } else { |
222 connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>( | 221 service_provider_impl->AddService<mojo::ContentHandler>( |
223 content_handler_factory_.GetInterfaceRequestHandler()); | 222 content_handler_factory_.GetInterfaceRequestHandler()); |
224 } | 223 } |
225 return true; | 224 return true; |
226 } | 225 } |
227 | 226 |
228 bool IsDebug(const std::string& requestedUrl) { | 227 bool IsDebug(const std::string& requestedUrl) { |
229 GURL url(requestedUrl); | 228 GURL url(requestedUrl); |
230 if (url.has_query()) { | 229 if (url.has_query()) { |
231 std::vector<std::string> query_parameters = base::SplitString( | 230 std::vector<std::string> query_parameters = base::SplitString( |
232 url.query(), "&", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 231 url.query(), "&", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
(...skipping 13 matching lines...) Expand all Loading... |
246 | 245 |
247 } // namespace content_handler | 246 } // namespace content_handler |
248 } // namespace python | 247 } // namespace python |
249 } // namespace services | 248 } // namespace services |
250 | 249 |
251 MojoResult MojoMain(MojoHandle application_request) { | 250 MojoResult MojoMain(MojoHandle application_request) { |
252 mojo::ApplicationRunnerChromium runner( | 251 mojo::ApplicationRunnerChromium runner( |
253 new services::python::content_handler::PythonContentHandlerApp()); | 252 new services::python::content_handler::PythonContentHandlerApp()); |
254 return runner.Run(application_request); | 253 return runner.Run(application_request); |
255 } | 254 } |
OLD | NEW |