summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi/file_path.cc
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-26 00:16:05 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-26 00:16:05 +0000
commit494184c1d68dfbdaa51af78f680e59dd0bfc6143 (patch)
treef897b02dc34dbc4e860c9dad561311d1a9e16e34 /webkit/plugins/ppapi/file_path.cc
parent287b86bfa8405f38377eb4b6c33c28b8a926fb2a (diff)
downloadchromium_src-494184c1d68dfbdaa51af78f680e59dd0bfc6143.zip
chromium_src-494184c1d68dfbdaa51af78f680e59dd0bfc6143.tar.gz
chromium_src-494184c1d68dfbdaa51af78f680e59dd0bfc6143.tar.bz2
Pepper/Flapper: Refactor module-local file stuff to make it easier/nicer to add file ref versions.
BUG=none TEST=everything still works Review URL: http://codereview.chromium.org/6599015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76124 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/ppapi/file_path.cc')
-rw-r--r--webkit/plugins/ppapi/file_path.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/webkit/plugins/ppapi/file_path.cc b/webkit/plugins/ppapi/file_path.cc
new file mode 100644
index 0000000..a7ed447
--- /dev/null
+++ b/webkit/plugins/ppapi/file_path.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/plugins/ppapi/file_path.h"
+
+#include <string>
+
+#include "webkit/plugins/ppapi/plugin_module.h"
+
+#if defined(OS_WIN)
+#include "base/utf_string_conversions.h"
+#endif
+
+namespace webkit {
+namespace ppapi {
+
+namespace {
+
+FilePath GetFilePathFromUTF8(const std::string& utf8_path) {
+#if defined(OS_WIN)
+ return FilePath(UTF8ToUTF16(utf8_path));
+#else
+ return FilePath(utf8_path);
+#endif
+}
+
+} // namespace
+
+PepperFilePath::PepperFilePath()
+ : domain_(DOMAIN_INVALID),
+ path_() {
+}
+
+PepperFilePath::PepperFilePath(Domain domain, FilePath path)
+ : domain_(domain),
+ path_(path) {
+ // TODO(viettrungluu): Should we DCHECK() some things here?
+}
+
+// static
+PepperFilePath PepperFilePath::MakeAbsolute(const char* utf8_path) {
+ return PepperFilePath(DOMAIN_ABSOLUTE, GetFilePathFromUTF8(utf8_path));
+}
+
+// static
+PepperFilePath PepperFilePath::MakeModuleLocal(PluginModule* module,
+ const char* utf8_path) {
+ FilePath full_path = GetFilePathFromUTF8(module->name()).Append(
+ GetFilePathFromUTF8(utf8_path));
+ return PepperFilePath(DOMAIN_MODULE_LOCAL, full_path);
+}
+
+} // namespace ppapi
+} // namespace webkit