Index: third_party/WebKit/Source/platform/mojo/SecurityOriginStructTraits.h |
diff --git a/third_party/WebKit/Source/platform/mojo/SecurityOriginStructTraits.h b/third_party/WebKit/Source/platform/mojo/SecurityOriginStructTraits.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4b192ee7629540263d3522d259d24d2a29ac44a4 |
--- /dev/null |
+++ b/third_party/WebKit/Source/platform/mojo/SecurityOriginStructTraits.h |
@@ -0,0 +1,53 @@ |
+// 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 SecurityOriginStructTraits_h |
+#define SecurityOriginStructTraits_h |
+ |
+#include "platform/weborigin/SecurityOrigin.h" |
+#include "url/mojo/origin.mojom-blink.h" |
+ |
+namespace mojo { |
+ |
+template <> |
+struct StructTraits<url::mojom::blink::Origin, RefPtr<::blink::SecurityOrigin>> { |
+ static WTF::String scheme(const RefPtr<::blink::SecurityOrigin>& r) |
esprehn
2016/05/25 17:06:27
ditto, don't use single letter vars
Marijn Kruisselbrink
2016/05/25 17:35:08
Fixed
|
+ { |
+ return r->protocol(); |
+ } |
+ static WTF::String host(const RefPtr<::blink::SecurityOrigin>& r) |
+ { |
+ return r->host(); |
+ } |
+ static uint16_t port(const RefPtr<::blink::SecurityOrigin>& r) |
+ { |
+ return r->port(); |
+ } |
+ static bool unique(const RefPtr<::blink::SecurityOrigin>& r) |
+ { |
+ return r->isUnique(); |
+ } |
+ static bool Read(url::mojom::blink::OriginDataView data, RefPtr<::blink::SecurityOrigin>* out) |
+ { |
+ if (data.unique()) { |
+ *out = ::blink::SecurityOrigin::createUnique(); |
+ } else { |
+ WTF::String scheme, host; |
esprehn
2016/05/25 17:06:27
one line per var
Marijn Kruisselbrink
2016/05/25 17:35:08
Fixed
|
+ if (!data.ReadScheme(&scheme) || !data.ReadHost(&host)) |
+ return false; |
+ |
+ *out = ::blink::SecurityOrigin::create(scheme, host, data.port()); |
+ } |
+ |
+ // If a unique origin was created, but the unique flag wasn't set, then |
+ // the values provided to 'create' were invalid. |
+ if (!data.unique() && (*out)->isUnique()) |
esprehn
2016/05/25 17:06:27
does the contract for these say it's okay to still
Marijn Kruisselbrink
2016/05/25 17:35:08
Documented at https://www.chromium.org/developers/
|
+ return false; |
+ |
+ return true; |
+ } |
+}; |
+} |
+ |
+#endif // SecurityOriginStructTraits_h |