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 "mojo/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/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/strings/utf_string_conversions.h" |
14 #include "mojo/common/common_type_converters.h" | 15 #include "mojo/common/common_type_converters.h" |
15 #include "mojo/common/data_pipe_utils.h" | 16 #include "mojo/common/data_pipe_utils.h" |
16 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" | 17 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" |
17 #include "mojo/shell/context.h" | 18 #include "mojo/shell/context.h" |
| 19 #include "mojo/shell/filename_util.h" |
18 #include "mojo/shell/switches.h" | 20 #include "mojo/shell/switches.h" |
19 #include "net/base/filename_util.h" | 21 #include "url/url_util.h" |
20 | 22 |
21 namespace mojo { | 23 namespace mojo { |
22 namespace shell { | 24 namespace shell { |
23 | 25 |
24 // Encapsulates loading and running one individual application. | 26 // Encapsulates loading and running one individual application. |
25 // | 27 // |
26 // Loaders are owned by DynamicApplicationLoader. DynamicApplicationLoader must | 28 // Loaders are owned by DynamicApplicationLoader. DynamicApplicationLoader must |
27 // ensure that all the parameters passed to Loader subclasses stay valid through | 29 // ensure that all the parameters passed to Loader subclasses stay valid through |
28 // Loader's lifetime. | 30 // Loader's lifetime. |
29 // | 31 // |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 LocalLoader(const GURL& url, | 87 LocalLoader(const GURL& url, |
86 Context* context, | 88 Context* context, |
87 DynamicServiceRunnerFactory* runner_factory, | 89 DynamicServiceRunnerFactory* runner_factory, |
88 scoped_refptr<ApplicationLoader::LoadCallbacks> load_callbacks, | 90 scoped_refptr<ApplicationLoader::LoadCallbacks> load_callbacks, |
89 const LoaderCompleteCallback& loader_complete_callback) | 91 const LoaderCompleteCallback& loader_complete_callback) |
90 : Loader(context, | 92 : Loader(context, |
91 runner_factory, | 93 runner_factory, |
92 load_callbacks, | 94 load_callbacks, |
93 loader_complete_callback), | 95 loader_complete_callback), |
94 weak_ptr_factory_(this) { | 96 weak_ptr_factory_(this) { |
95 base::FilePath path; | 97 DCHECK(url.SchemeIsFile()); |
96 net::FileURLToFilePath(url, &path); | 98 url::RawCanonOutputW<1024> output; |
| 99 url::DecodeURLEscapeSequences( |
| 100 url.path().data(), static_cast<int>(url.path().length()), &output); |
| 101 base::string16 decoded_path = |
| 102 base::string16(output.data(), output.length()); |
| 103 #if defined(OS_WIN) |
| 104 base::FilePath path(decoded_path); |
| 105 #else |
| 106 base::FilePath path(base::UTF16ToUTF8(decoded_path)); |
| 107 #endif |
97 | 108 |
98 // Async for consistency with network case. | 109 // Async for consistency with network case. |
99 base::MessageLoop::current()->PostTask( | 110 base::MessageLoop::current()->PostTask( |
100 FROM_HERE, | 111 FROM_HERE, |
101 base::Bind(&LocalLoader::RunLibrary, | 112 base::Bind(&LocalLoader::RunLibrary, |
102 weak_ptr_factory_.GetWeakPtr(), | 113 weak_ptr_factory_.GetWeakPtr(), |
103 path, | 114 path, |
104 base::PathExists(path))); | 115 base::PathExists(path))); |
105 } | 116 } |
106 | 117 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // TODO(darin): What should we do about service errors? This implies that | 250 // TODO(darin): What should we do about service errors? This implies that |
240 // the app closed its handle to the service manager. Maybe we don't care? | 251 // the app closed its handle to the service manager. Maybe we don't care? |
241 } | 252 } |
242 | 253 |
243 void DynamicApplicationLoader::LoaderComplete(Loader* loader) { | 254 void DynamicApplicationLoader::LoaderComplete(Loader* loader) { |
244 loaders_.erase(std::find(loaders_.begin(), loaders_.end(), loader)); | 255 loaders_.erase(std::find(loaders_.begin(), loaders_.end(), loader)); |
245 } | 256 } |
246 | 257 |
247 } // namespace shell | 258 } // namespace shell |
248 } // namespace mojo | 259 } // namespace mojo |
OLD | NEW |