Commit 7505d9ce authored by David Van Cleve's avatar David Van Cleve Committed by Chromium LUCI CQ

url: Add a url.Origin(url.internal.mojom.Origin) constructor

The org.chromium.url.Origin class is a user-friendly wrapper around an
org.chromium.url.internal.mojom.Origin, which also happens to be the
type one obtains from Mojo-generated interfaces in Java that take
url.mojom.Origin in their .mojom definitions.

In order to make it possible (or, at least, explicitly "supported",
without the stigma of accessing fields of a class in an "internal"
namespace) to manipulate the origins obtained via these code-generated
interfaces, this CL adds a new url.Origin(url.internal.mojom.Origin)
constructor. In the long run, it would be best if Mojo could just
give us the user-friendly type instead of the "internal" type: that's
also tracked in the associated bug.

Bug: 1156866
Change-Id: I2e52feaca9bbd6c5514a15b07c27e7300c8e34e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586327Reviewed-by: default avatarCharlie Harrison <csharrison@chromium.org>
Commit-Queue: David Van Cleve <davidvc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836708}
parent b4d9a9a1
......@@ -15,6 +15,18 @@ public class Origin {
// The internal representation of the origin that should never be used directly.
private final org.chromium.url.internal.mojom.Origin mInternal;
/**
* This convenience constructor provides a way to wrap
* `org.chromium.url.internal.mojom.Origin`s, which are provided by Mojo-generated
* code but not intended for direct use (see crbug.com/1156866).
*
* @return An `Origin` providing user-friendly access to the origin represented by
* `mojoOrigin`.
*/
public Origin(org.chromium.url.internal.mojom.Origin mojoOrigin) {
mInternal = mojoOrigin;
}
/** @return The scheme of the origin. Returns an empty string for an opaque origin. */
public String getScheme() {
return !isOpaque() ? mInternal.scheme : "";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment