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

Unified 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: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
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..29527bf41688972a01fe82280b57f595cf53c200
--- /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"
+#include "url/mojo/url.mojom-blink.h"
+#include "url/url_constants.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<url::mojom::blink::Url, blink::KURL> {
Ken Rockot(use gerrit already) 2016/05/25 15:09:20 You will need to qualify blink::KURL here for now.
yzshen1 2016/05/25 16:43:14 Ah, that seems unfortunate. Moving those things in
+ static WTF::String url(const blink::KURL& r)
+ {
+ if (!r.isValid() || r.getString().length() > url::kMaxURLChars) {
+ return emptyString();
+ }
+
+ return r.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
« 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