Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: third_party/WebKit/Source/platform/exported/FilePathConversion.cpp

Issue 1686263008: Add utility method for WebString to base::FilePath conversion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase! Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 String str = webString;
20 if (!str.is8Bit()) {
21 return base::FilePath::FromUTF16Unsafe(
22 base::StringPiece16(str.characters16(), str.length()));
23 }
24
25 #if OS(POSIX)
26 StringUTF8Adaptor utf8(str);
27 return base::FilePath::FromUTF8Unsafe(utf8.asStringPiece());
28 #else
29 const LChar* data8 = str.characters8();
30 return base::FilePath::FromUTF16Unsafe(
31 base::string16(data8, data8 + str.length()));
32 #endif
33 }
34
35 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698