| 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 "mojo/shell/dynamic_application_loader.h" | 5 #include "shell/dynamic_application_loader.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "mojo/common/common_type_converters.h" | 19 #include "mojo/common/common_type_converters.h" |
| 20 #include "mojo/common/data_pipe_utils.h" | 20 #include "mojo/common/data_pipe_utils.h" |
| 21 #include "mojo/public/cpp/system/data_pipe.h" | 21 #include "mojo/public/cpp/system/data_pipe.h" |
| 22 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" | 22 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" |
| 23 #include "mojo/shell/context.h" | 23 #include "shell/context.h" |
| 24 #include "mojo/shell/data_pipe_peek.h" | 24 #include "shell/data_pipe_peek.h" |
| 25 #include "mojo/shell/filename_util.h" | 25 #include "shell/filename_util.h" |
| 26 #include "mojo/shell/switches.h" | 26 #include "shell/switches.h" |
| 27 #include "url/url_util.h" | 27 #include "url/url_util.h" |
| 28 | 28 |
| 29 namespace mojo { | 29 namespace mojo { |
| 30 namespace shell { | 30 namespace shell { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 static const char kMojoMagic[] = "#!mojo:"; | 34 static const char kMojoMagic[] = "#!mojo:"; |
| 35 static const size_t kMaxShebangLength = 2048; | 35 static const size_t kMaxShebangLength = 2048; |
| 36 | 36 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 base::Unretained(this))) { | 359 base::Unretained(this))) { |
| 360 } | 360 } |
| 361 | 361 |
| 362 DynamicApplicationLoader::~DynamicApplicationLoader() { | 362 DynamicApplicationLoader::~DynamicApplicationLoader() { |
| 363 } | 363 } |
| 364 | 364 |
| 365 void DynamicApplicationLoader::RegisterContentHandler( | 365 void DynamicApplicationLoader::RegisterContentHandler( |
| 366 const std::string& mime_type, | 366 const std::string& mime_type, |
| 367 const GURL& content_handler_url) { | 367 const GURL& content_handler_url) { |
| 368 DCHECK(content_handler_url.is_valid()) | 368 DCHECK(content_handler_url.is_valid()) |
| 369 << "Content handler URL is invalid for mime type " << mime_type; | 369 << "Content handler URL is invalid for mime type " << mime_type; |
| 370 mime_type_to_url_[mime_type] = content_handler_url; | 370 mime_type_to_url_[mime_type] = content_handler_url; |
| 371 } | 371 } |
| 372 | 372 |
| 373 void DynamicApplicationLoader::Load(ApplicationManager* manager, | 373 void DynamicApplicationLoader::Load(ApplicationManager* manager, |
| 374 const GURL& url, | 374 const GURL& url, |
| 375 ScopedMessagePipeHandle shell_handle, | 375 ScopedMessagePipeHandle shell_handle, |
| 376 LoadCallback load_callback) { | 376 LoadCallback load_callback) { |
| 377 if (url.SchemeIsFile()) { | 377 if (url.SchemeIsFile()) { |
| 378 loaders_.push_back(new LocalLoader( | 378 loaders_.push_back(new LocalLoader( |
| 379 url, &mime_type_to_url_, context_, runner_factory_.get(), | 379 url, &mime_type_to_url_, context_, runner_factory_.get(), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 397 // TODO(darin): What should we do about service errors? This implies that | 397 // TODO(darin): What should we do about service errors? This implies that |
| 398 // the app closed its handle to the service manager. Maybe we don't care? | 398 // the app closed its handle to the service manager. Maybe we don't care? |
| 399 } | 399 } |
| 400 | 400 |
| 401 void DynamicApplicationLoader::LoaderComplete(Loader* loader) { | 401 void DynamicApplicationLoader::LoaderComplete(Loader* loader) { |
| 402 loaders_.erase(std::find(loaders_.begin(), loaders_.end(), loader)); | 402 loaders_.erase(std::find(loaders_.begin(), loaders_.end(), loader)); |
| 403 } | 403 } |
| 404 | 404 |
| 405 } // namespace shell | 405 } // namespace shell |
| 406 } // namespace mojo | 406 } // namespace mojo |
| OLD | NEW |