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/URLConversion.h" | |
6 | |
7 #include "public/platform/WebString.h" | |
8 #include "url/gurl.h" | |
9 #include "wtf/text/StringUTF8Adaptor.h" | |
10 #include "wtf/text/WTFString.h" | |
11 | |
12 namespace blink { | |
13 | |
14 GURL WebStringToGURL(const WebString& webStr) | |
esprehn
2016/01/14 01:47:59
webString
| |
15 { | |
16 WTF::String str = webStr; | |
esprehn
2016/01/14 01:47:59
no need for WTF:: prefix.
also wtfString, don't a
| |
17 if (str.is8Bit()) { | |
18 // Ensure the (possibly Latin-1) 8-bit string is UTF-8 for GURL. | |
19 WTF::StringUTF8Adaptor utf8(str); | |
20 return GURL(utf8.asStringPiece()); | |
esprehn
2016/01/14 01:47:59
Note that this isn't safe unless the GURL copies t
| |
21 } | |
22 | |
23 // GURL can consume UTF-16 directly. | |
24 return GURL(base::StringPiece16(str.characters16(), str.length())); | |
25 } | |
26 | |
27 } // namespace blink | |
OLD | NEW |