| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "public/platform/FilePathConversion.h" | 5 #include "public/platform/FilePathConversion.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "public/platform/WebString.h" | 8 #include "public/platform/WebString.h" |
| 9 #include "wtf/text/StringUTF8Adaptor.h" | 9 #include "wtf/text/StringUTF8Adaptor.h" |
| 10 #include "wtf/text/WTFString.h" | 10 #include "wtf/text/WTFString.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #if OS(POSIX) | 24 #if OS(POSIX) |
| 25 StringUTF8Adaptor utf8(str); | 25 StringUTF8Adaptor utf8(str); |
| 26 return base::FilePath::FromUTF8Unsafe(utf8.asStringPiece()); | 26 return base::FilePath::FromUTF8Unsafe(utf8.asStringPiece()); |
| 27 #else | 27 #else |
| 28 const LChar* data8 = str.characters8(); | 28 const LChar* data8 = str.characters8(); |
| 29 return base::FilePath::FromUTF16Unsafe( | 29 return base::FilePath::FromUTF16Unsafe( |
| 30 base::string16(data8, data8 + str.length())); | 30 base::string16(data8, data8 + str.length())); |
| 31 #endif | 31 #endif |
| 32 } | 32 } |
| 33 | 33 |
| 34 WebString FilePathToWebString(const base::FilePath& path) { |
| 35 if (path.empty()) |
| 36 return WebString(); |
| 37 |
| 38 #if OS(POSIX) |
| 39 return WebString::fromUTF8(path.value()); |
| 40 #else |
| 41 return WebString::fromUTF16(path.AsUTF16Unsafe()); |
| 42 #endif |
| 43 } |
| 44 |
| 34 } // namespace blink | 45 } // namespace blink |
| OLD | NEW |