file_path.cc revision 5821806d5e7f356e8fa4b058a389a808ea183019
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
3// found in the LICENSE file.
4
5#include "ppapi/shared_impl/file_path.h"
6
7#include <string>
8
9#if defined(OS_WIN)
10#include "base/utf_string_conversions.h"
11#endif
12
13namespace ppapi {
14
15namespace {
16
17FilePath 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
27PepperFilePath::PepperFilePath()
28    : domain_(DOMAIN_INVALID),
29      path_() {
30}
31
32PepperFilePath::PepperFilePath(Domain domain, const FilePath& path)
33    : domain_(domain),
34      path_(path) {
35  // TODO(viettrungluu): Should we DCHECK() some things here?
36}
37
38// static
39PepperFilePath PepperFilePath::MakeAbsolute(const FilePath& path) {
40  return PepperFilePath(DOMAIN_ABSOLUTE, path);
41}
42
43// static
44PepperFilePath 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
52