Index: third_party/WebKit/Source/platform/mojo/KURLStructTraits.h |
diff --git a/third_party/WebKit/Source/platform/mojo/KURLStructTraits.h b/third_party/WebKit/Source/platform/mojo/KURLStructTraits.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1c7b8dc078b5bdec7c391199ad19c2a5853fbd91 |
--- /dev/null |
+++ b/third_party/WebKit/Source/platform/mojo/KURLStructTraits.h |
@@ -0,0 +1,42 @@ |
+// 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. |
+ |
+#ifndef KURLStructTraits_h |
+#define KURLStructTraits_h |
+ |
+#include "platform/weborigin/KURL.h" |
esprehn
2016/05/26 20:06:00
missing WTFString.h
Marijn Kruisselbrink
2016/05/26 20:52:42
Done
|
+#include "url/mojo/url.mojom-blink.h" |
+#include "url/url_constants.h" |
+ |
+namespace mojo { |
+ |
+template <> |
+struct StructTraits<url::mojom::blink::Url, ::blink::KURL> { |
+ static WTF::String url(const ::blink::KURL& blinkUrl) |
+ { |
+ if (!blinkUrl.isValid() || blinkUrl.getString().length() > url::kMaxURLChars) { |
+ return emptyString(); |
+ } |
+ |
+ return blinkUrl.getString(); |
+ } |
+ static bool Read(url::mojom::blink::UrlDataView data, ::blink::KURL* out) |
+ { |
+ WTF::String urlString; |
+ if (!data.ReadUrl(&urlString)) |
+ return false; |
+ |
+ if (urlString.length() > url::kMaxURLChars) |
+ return false; |
+ |
+ *out = ::blink::KURL(::blink::KURL(), urlString); |
+ if (!urlString.isEmpty() && !out->isValid()) |
+ return false; |
+ |
+ return true; |
+ } |
+}; |
+} |
+ |
+#endif // KURLStructTraits_h |