Chromium Code Reviews| Index: third_party/WebKit/Source/platform/exported/URLConversion.cpp |
| diff --git a/third_party/WebKit/Source/platform/exported/URLConversion.cpp b/third_party/WebKit/Source/platform/exported/URLConversion.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..35542e35f5661e5e6394105c5a053a1ac526d69f |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/exported/URLConversion.cpp |
| @@ -0,0 +1,27 @@ |
| +// 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/URLConversion.h" |
| + |
| +#include "public/platform/WebString.h" |
| +#include "url/gurl.h" |
| +#include "wtf/text/StringUTF8Adaptor.h" |
| +#include "wtf/text/WTFString.h" |
| + |
| +namespace blink { |
| + |
| +GURL WebStringToGURL(const WebString& webStr) |
|
esprehn
2016/01/14 01:47:59
webString
|
| +{ |
| + WTF::String str = webStr; |
|
esprehn
2016/01/14 01:47:59
no need for WTF:: prefix.
also wtfString, don't a
|
| + if (str.is8Bit()) { |
| + // Ensure the (possibly Latin-1) 8-bit string is UTF-8 for GURL. |
| + WTF::StringUTF8Adaptor utf8(str); |
| + return GURL(utf8.asStringPiece()); |
|
esprehn
2016/01/14 01:47:59
Note that this isn't safe unless the GURL copies t
|
| + } |
| + |
| + // GURL can consume UTF-16 directly. |
| + return GURL(base::StringPiece16(str.characters16(), str.length())); |
| +} |
| + |
| +} // namespace blink |