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 | |
13 namespace ppapi { | 7 namespace ppapi { |
14 | 8 |
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 | |
27 PepperFilePath::PepperFilePath() | 9 PepperFilePath::PepperFilePath() |
28 : domain_(DOMAIN_INVALID), | 10 : domain_(DOMAIN_INVALID), |
29 path_() { | 11 path_() { |
30 } | 12 } |
31 | 13 |
32 PepperFilePath::PepperFilePath(Domain domain, const FilePath& path) | 14 PepperFilePath::PepperFilePath(Domain domain, const FilePath& path) |
33 : domain_(domain), | 15 : domain_(domain), |
34 path_(path) { | 16 path_(path) { |
35 // TODO(viettrungluu): Should we DCHECK() some things here? | 17 // TODO(viettrungluu): Should we DCHECK() some things here? |
36 } | 18 } |
37 | 19 |
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 | |
51 } // namespace ppapi | 20 } // namespace ppapi |
OLD | NEW |