OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/shared_impl/file_path.h" | 5 #include "ppapi/shared_impl/file_path.h" |
6 | 6 |
| 7 #include <string> |
| 8 |
| 9 #if defined(OS_WIN) |
| 10 #include "base/utf_string_conversions.h" |
| 11 #endif |
| 12 |
7 namespace ppapi { | 13 namespace ppapi { |
8 | 14 |
| 15 namespace { |
| 16 |
| 17 FilePath GetFilePathFromUTF8(const std::string& utf8_path) { |
| 18 #if defined(OS_WIN) |
| 19 return FilePath(UTF8ToUTF16(utf8_path)); |
| 20 #else |
| 21 return FilePath(utf8_path); |
| 22 #endif |
| 23 } |
| 24 |
| 25 } // namespace |
| 26 |
9 PepperFilePath::PepperFilePath() | 27 PepperFilePath::PepperFilePath() |
10 : domain_(DOMAIN_INVALID), | 28 : domain_(DOMAIN_INVALID), |
11 path_() { | 29 path_() { |
12 } | 30 } |
13 | 31 |
14 PepperFilePath::PepperFilePath(Domain domain, const FilePath& path) | 32 PepperFilePath::PepperFilePath(Domain domain, const FilePath& path) |
15 : domain_(domain), | 33 : domain_(domain), |
16 path_(path) { | 34 path_(path) { |
17 // TODO(viettrungluu): Should we DCHECK() some things here? | 35 // TODO(viettrungluu): Should we DCHECK() some things here? |
18 } | 36 } |
19 | 37 |
| 38 // static |
| 39 PepperFilePath PepperFilePath::MakeAbsolute(const FilePath& path) { |
| 40 return PepperFilePath(DOMAIN_ABSOLUTE, path); |
| 41 } |
| 42 |
| 43 // static |
| 44 PepperFilePath PepperFilePath::MakeModuleLocal(const std::string& name, |
| 45 const char* utf8_path) { |
| 46 FilePath full_path = GetFilePathFromUTF8(name).Append( |
| 47 GetFilePathFromUTF8(utf8_path)); |
| 48 return PepperFilePath(DOMAIN_MODULE_LOCAL, full_path); |
| 49 } |
| 50 |
20 } // namespace ppapi | 51 } // namespace ppapi |
OLD | NEW |