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" |
(...skipping 22 matching lines...) Expand all Loading... |
33 TRACE_EVENT1("mojo_shell", "LocalFetcher::LocalFetcher", "url", url.spec()); | 33 TRACE_EVENT1("mojo_shell", "LocalFetcher::LocalFetcher", "url", url.spec()); |
34 loader_callback_.Run(make_scoped_ptr(this)); | 34 loader_callback_.Run(make_scoped_ptr(this)); |
35 } | 35 } |
36 | 36 |
37 base::FilePath LocalFetcher::UrlToFile(const GURL& url) { | 37 base::FilePath LocalFetcher::UrlToFile(const GURL& url) { |
38 DCHECK(url.SchemeIsFile()); | 38 DCHECK(url.SchemeIsFile()); |
39 url::RawCanonOutputW<1024> output; | 39 url::RawCanonOutputW<1024> output; |
40 url::DecodeURLEscapeSequences(url.path().data(), | 40 url::DecodeURLEscapeSequences(url.path().data(), |
41 static_cast<int>(url.path().length()), &output); | 41 static_cast<int>(url.path().length()), &output); |
42 base::string16 decoded_path = base::string16(output.data(), output.length()); | 42 base::string16 decoded_path = base::string16(output.data(), output.length()); |
43 #if defined(OS_WIN) | 43 return base::FilePath(base::UTF16ToUTF8(decoded_path)); |
44 base::TrimString(decoded_path, L"/", &decoded_path); | |
45 base::FilePath path(decoded_path); | |
46 #else | |
47 base::FilePath path(base::UTF16ToUTF8(decoded_path)); | |
48 #endif | |
49 return path; | |
50 } | 44 } |
51 | 45 |
52 const GURL& LocalFetcher::GetURL() const { | 46 const GURL& LocalFetcher::GetURL() const { |
53 return url_; | 47 return url_; |
54 } | 48 } |
55 | 49 |
56 GURL LocalFetcher::GetRedirectURL() const { | 50 GURL LocalFetcher::GetRedirectURL() const { |
57 return GURL::EmptyGURL(); | 51 return GURL::EmptyGURL(); |
58 } | 52 } |
59 | 53 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 ReadFileToString(path_, &start_of_file, kMaxShebangLength); | 91 ReadFileToString(path_, &start_of_file, kMaxShebangLength); |
98 size_t return_position = start_of_file.find('\n'); | 92 size_t return_position = start_of_file.find('\n'); |
99 if (return_position == std::string::npos) | 93 if (return_position == std::string::npos) |
100 return false; | 94 return false; |
101 *line = start_of_file.substr(0, return_position + 1); | 95 *line = start_of_file.substr(0, return_position + 1); |
102 return true; | 96 return true; |
103 } | 97 } |
104 | 98 |
105 } // namespace shell | 99 } // namespace shell |
106 } // namespace mojo | 100 } // namespace mojo |
OLD | NEW |