| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(ApplicationConnection* connection) override { |
| 216 if (IsDebug(connection->GetServiceProviderImpl() | 216 if (IsDebug(connection->GetServiceProviderImpl() |
| 217 .connection_context() | 217 .connection_context() |
| 218 .connection_url)) | 218 .connection_url)) { |
| 219 connection->AddService(&debug_content_handler_factory_); | 219 connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>( |
| 220 else | 220 debug_content_handler_factory_.GetInterfaceRequestHandler()); |
| 221 connection->AddService(&content_handler_factory_); | 221 } else { |
| 222 connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>( |
| 223 content_handler_factory_.GetInterfaceRequestHandler()); |
| 224 } |
| 222 return true; | 225 return true; |
| 223 } | 226 } |
| 224 | 227 |
| 225 bool IsDebug(const std::string& requestedUrl) { | 228 bool IsDebug(const std::string& requestedUrl) { |
| 226 GURL url(requestedUrl); | 229 GURL url(requestedUrl); |
| 227 if (url.has_query()) { | 230 if (url.has_query()) { |
| 228 std::vector<std::string> query_parameters = base::SplitString( | 231 std::vector<std::string> query_parameters = base::SplitString( |
| 229 url.query(), "&", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 232 url.query(), "&", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 230 return std::find(query_parameters.begin(), query_parameters.end(), | 233 return std::find(query_parameters.begin(), query_parameters.end(), |
| 231 "debug=true") != query_parameters.end(); | 234 "debug=true") != query_parameters.end(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 243 | 246 |
| 244 } // namespace content_handler | 247 } // namespace content_handler |
| 245 } // namespace python | 248 } // namespace python |
| 246 } // namespace services | 249 } // namespace services |
| 247 | 250 |
| 248 MojoResult MojoMain(MojoHandle application_request) { | 251 MojoResult MojoMain(MojoHandle application_request) { |
| 249 mojo::ApplicationRunnerChromium runner( | 252 mojo::ApplicationRunnerChromium runner( |
| 250 new services::python::content_handler::PythonContentHandlerApp()); | 253 new services::python::content_handler::PythonContentHandlerApp()); |
| 251 return runner.Run(application_request); | 254 return runner.Run(application_request); |
| 252 } | 255 } |
| OLD | NEW |