Index: third_party/WebKit/Source/platform/exported/FilePathConversion.cpp |
diff --git a/third_party/WebKit/Source/platform/exported/FilePathConversion.cpp b/third_party/WebKit/Source/platform/exported/FilePathConversion.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e518e595f2f330b1c56fa1ecb0a2d0ef6cf5b521 |
--- /dev/null |
+++ b/third_party/WebKit/Source/platform/exported/FilePathConversion.cpp |
@@ -0,0 +1,35 @@ |
+// Copyright 2016 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 "public/platform/FilePathConversion.h" |
+ |
+#include "base/files/file_path.h" |
+#include "public/platform/WebString.h" |
+#include "wtf/text/StringUTF8Adaptor.h" |
+#include "wtf/text/WTFString.h" |
+ |
+namespace blink { |
+ |
+base::FilePath WebStringToFilePath(const WebString& webString) |
+{ |
+ if (webString.isEmpty()) |
+ return base::FilePath(); |
+ |
+ String str = webString; |
+ if (!str.is8Bit()) { |
+ return base::FilePath::FromUTF16Unsafe( |
+ base::StringPiece16(str.characters16(), str.length())); |
+ } |
+ |
+#if OS(POSIX) |
+ StringUTF8Adaptor utf8(str); |
+ return base::FilePath::FromUTF8Unsafe(utf8.asStringPiece()); |
+#else |
+ const LChar* data8 = str.characters8(); |
+ return base::FilePath::FromUTF16Unsafe( |
+ base::string16(data8, data8 + str.length())); |
+#endif |
+} |
+ |
+} // namespace blink |