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

Side by Side Diff: third_party/WebKit/Source/platform/mojo/KURLStructTraits.h

Issue 2000253006: Implement URL and Origin typemaps/struct traits for blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try to fix gyp rules Created 4 years, 6 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 #ifndef KURLStructTraits_h
6 #define KURLStructTraits_h
7
8 #include "platform/weborigin/KURL.h"
9 #include "url/mojo/url.mojom-blink.h"
10 #include "url/url_constants.h"
11 #include "wtf/text/WTFString.h"
12
13 namespace mojo {
14
15 template <>
16 struct StructTraits<url::mojom::blink::Url, ::blink::KURL> {
17 static WTF::String url(const ::blink::KURL& blinkUrl)
18 {
19 if (!blinkUrl.isValid() || blinkUrl.getString().length() > url::kMaxURLC hars) {
20 return emptyString();
21 }
22
23 return blinkUrl.getString();
24 }
25 static bool Read(url::mojom::blink::UrlDataView data, ::blink::KURL* out)
26 {
27 WTF::String urlString;
28 if (!data.ReadUrl(&urlString))
29 return false;
30
31 if (urlString.length() > url::kMaxURLChars)
32 return false;
33
34 *out = ::blink::KURL(::blink::KURL(), urlString);
35 if (!urlString.isEmpty() && !out->isValid())
36 return false;
37
38 return true;
39 }
40 };
41 }
42
43 #endif // KURLStructTraits_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/mojo/KURLSecurityOriginTest.cpp ('k') | third_party/WebKit/Source/platform/mojo/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698