OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "public/platform/FilePathConversion.h" | |
6 | |
7 #include "base/files/file_path.h" | |
8 #include "public/platform/WebString.h" | |
9 #include "wtf/text/StringUTF8Adaptor.h" | |
10 #include "wtf/text/WTFString.h" | |
11 | |
12 namespace blink { | |
13 | |
14 base::FilePath WebStringToFilePath(const WebString& webString) | |
15 { | |
16 if (webString.isEmpty()) | |
17 return base::FilePath(); | |
18 | |
19 // Depending on platforms base::FilePath can be efficiently constructed | |
20 // from UTF8 or UTF16. | |
Nico
2016/02/15 16:45:14
After:
Windows:
- 8bit:
- ascii-only: calls Fro
| |
21 String str = webString; | |
22 if (str.is8Bit()) { | |
23 StringUTF8Adaptor utf8(str); | |
24 return base::FilePath::FromUTF8Unsafe(utf8.asStringPiece()); | |
25 } | |
26 return base::FilePath::FromUTF16Unsafe( | |
Nico
2016/02/15 16:45:14
does this branch have test coverage?
| |
27 base::StringPiece16(str.characters16(), str.length())); | |
28 } | |
29 | |
30 } // namespace blink | |
OLD | NEW |