| 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" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_split.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "mojo/application/application_runner_chromium.h" | 13 #include "mojo/application/application_runner_chromium.h" |
| 14 #include "mojo/application/content_handler_factory.h" | 14 #include "mojo/application/content_handler_factory.h" |
| 15 #include "mojo/data_pipe_utils/data_pipe_utils.h" | 15 #include "mojo/data_pipe_utils/data_pipe_utils.h" |
| 16 #include "mojo/public/c/system/main.h" | 16 #include "mojo/public/c/system/main.h" |
| 17 #include "mojo/public/cpp/application/application_delegate.h" | 17 #include "mojo/public/cpp/application/application_delegate.h" |
| 18 #include "mojo/public/cpp/application/application_impl.h" | 18 #include "mojo/public/cpp/application/application_impl.h" |
| 19 #include "mojo/public/cpp/application/interface_factory_impl.h" | 19 #include "mojo/public/cpp/application/interface_factory_impl.h" |
| 20 #include "mojo/public/python/src/common.h" | 20 #include "mojo/public/python/src/common.h" |
| 21 #include "third_party/zlib/google/zip_reader.h" | 21 #include "third_party/zlib/google/zip_reader.h" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 if (IsDebug(connection->GetConnectionURL())) | 217 if (IsDebug(connection->GetConnectionURL())) |
| 218 connection->AddService(&debug_content_handler_factory_); | 218 connection->AddService(&debug_content_handler_factory_); |
| 219 else | 219 else |
| 220 connection->AddService(&content_handler_factory_); | 220 connection->AddService(&content_handler_factory_); |
| 221 return true; | 221 return true; |
| 222 } | 222 } |
| 223 | 223 |
| 224 bool IsDebug(const std::string& requestedUrl) { | 224 bool IsDebug(const std::string& requestedUrl) { |
| 225 GURL url(requestedUrl); | 225 GURL url(requestedUrl); |
| 226 if (url.has_query()) { | 226 if (url.has_query()) { |
| 227 std::vector<std::string> query_parameters; | 227 std::vector<std::string> query_parameters = base::SplitString( |
| 228 Tokenize(url.query(), "&", &query_parameters); | 228 url.query(), "&", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 229 return std::find(query_parameters.begin(), query_parameters.end(), | 229 return std::find(query_parameters.begin(), query_parameters.end(), |
| 230 "debug=true") != query_parameters.end(); | 230 "debug=true") != query_parameters.end(); |
| 231 } | 231 } |
| 232 return false; | 232 return false; |
| 233 } | 233 } |
| 234 | 234 |
| 235 PythonContentHandler content_handler_; | 235 PythonContentHandler content_handler_; |
| 236 PythonContentHandler debug_content_handler_; | 236 PythonContentHandler debug_content_handler_; |
| 237 ContentHandlerFactory content_handler_factory_; | 237 ContentHandlerFactory content_handler_factory_; |
| 238 ContentHandlerFactory debug_content_handler_factory_; | 238 ContentHandlerFactory debug_content_handler_factory_; |
| 239 | 239 |
| 240 DISALLOW_COPY_AND_ASSIGN(PythonContentHandlerApp); | 240 DISALLOW_COPY_AND_ASSIGN(PythonContentHandlerApp); |
| 241 }; | 241 }; |
| 242 | 242 |
| 243 } // namespace content_handler | 243 } // namespace content_handler |
| 244 } // namespace python | 244 } // namespace python |
| 245 } // namespace services | 245 } // namespace services |
| 246 | 246 |
| 247 MojoResult MojoMain(MojoHandle application_request) { | 247 MojoResult MojoMain(MojoHandle application_request) { |
| 248 mojo::ApplicationRunnerChromium runner( | 248 mojo::ApplicationRunnerChromium runner( |
| 249 new services::python::content_handler::PythonContentHandlerApp()); | 249 new services::python::content_handler::PythonContentHandlerApp()); |
| 250 return runner.Run(application_request); | 250 return runner.Run(application_request); |
| 251 } | 251 } |
| OLD | NEW |