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

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: 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 // 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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698