OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "shell/application_manager/local_fetcher.h" | 5 #include "shell/application_manager/local_fetcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "mojo/common/common_type_converters.h" | 13 #include "mojo/common/common_type_converters.h" |
14 #include "mojo/common/data_pipe_utils.h" | 14 #include "mojo/common/data_pipe_utils.h" |
15 #include "url/url_util.h" | 15 #include "url/url_util.h" |
16 | 16 |
17 namespace mojo { | 17 namespace mojo { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 void IgnoreResult(bool result) { | 21 void IgnoreResult(bool result) { |
22 } | 22 } |
23 | 23 |
24 } // namespace | 24 } // namespace |
25 | 25 |
26 // A loader for local files. | 26 // A loader for local files. |
27 LocalFetcher::LocalFetcher(const GURL& url, | 27 LocalFetcher::LocalFetcher(const GURL& url, |
| 28 const GURL& url_without_query, |
28 const FetchCallback& loader_callback) | 29 const FetchCallback& loader_callback) |
29 : Fetcher(loader_callback), url_(url), path_(UrlToFile(url)) { | 30 : Fetcher(loader_callback), url_(url), path_(UrlToFile(url_without_query)) { |
30 loader_callback_.Run(make_scoped_ptr(this)); | 31 loader_callback_.Run(make_scoped_ptr(this)); |
31 } | 32 } |
32 | 33 |
33 base::FilePath LocalFetcher::UrlToFile(const GURL& url) { | 34 base::FilePath LocalFetcher::UrlToFile(const GURL& url) { |
34 DCHECK(url.SchemeIsFile()); | 35 DCHECK(url.SchemeIsFile()); |
35 url::RawCanonOutputW<1024> output; | 36 url::RawCanonOutputW<1024> output; |
36 url::DecodeURLEscapeSequences(url.path().data(), | 37 url::DecodeURLEscapeSequences(url.path().data(), |
37 static_cast<int>(url.path().length()), &output); | 38 static_cast<int>(url.path().length()), &output); |
38 base::string16 decoded_path = base::string16(output.data(), output.length()); | 39 base::string16 decoded_path = base::string16(output.data(), output.length()); |
39 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 std::string start_of_file; | 93 std::string start_of_file; |
93 ReadFileToString(path_, &start_of_file, kMaxShebangLength); | 94 ReadFileToString(path_, &start_of_file, kMaxShebangLength); |
94 size_t return_position = start_of_file.find('\n'); | 95 size_t return_position = start_of_file.find('\n'); |
95 if (return_position == std::string::npos) | 96 if (return_position == std::string::npos) |
96 return false; | 97 return false; |
97 *line = start_of_file.substr(0, return_position + 1); | 98 *line = start_of_file.substr(0, return_position + 1); |
98 return true; | 99 return true; |
99 } | 100 } |
100 | 101 |
101 } // namespace mojo | 102 } // namespace mojo |
OLD | NEW |