| 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..0362eb30565219cb5be0257f84f2375c9e8293d3
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/platform/mojo/SecurityOriginStructTraits.h
|
| @@ -0,0 +1,54 @@
|
| +// 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)
|
| + {
|
| + 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;
|
| + 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 'UnsafelyCreateOriginWithoutNormalization' were
|
| + // invalid.
|
| + if (!data.unique() && (*out)->isUnique())
|
| + return false;
|
| +
|
| + return true;
|
| + }
|
| +};
|
| +}
|
| +
|
| +#endif // SecurityOriginStructTraits_h
|
|
|