Commit 7b78e293 authored by Henrique Ferreiro's avatar Henrique Ferreiro Committed by Commit Bot

Add support for {MIN,MAX}_VALUE to Java Mojo bindings for enums

This CL adds the equivalent to k{Min,Max}Value from the C++ bindings to
the Java bindings as {MIN,MAX}_VALUE, and ports ReferrerPolicy to use it
allowing the removal of kLast in referrer_policy.mojom.

Bug: 1114575
Change-Id: Ie9321f6a251b352e57e27d8a17d565c70c3a8d63
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2343028Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarAlex Gough <ajgo@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Cr-Commit-Position: refs/heads/master@{#800213}
parent 96fb4562
......@@ -591,7 +591,7 @@ public class IntentHandler {
public static int getReferrerPolicyFromIntent(Intent intent) {
int policy =
IntentUtils.safeGetIntExtra(intent, EXTRA_REFERRER_POLICY, ReferrerPolicy.DEFAULT);
if (policy < 0 || policy >= ReferrerPolicy.LAST) {
if (policy < ReferrerPolicy.MIN_VALUE || policy >= ReferrerPolicy.MAX_VALUE) {
policy = ReferrerPolicy.DEFAULT;
}
return policy;
......
......@@ -972,7 +972,9 @@ public class CustomTabsConnection {
intent.getIntExtra(PARALLEL_REQUEST_REFERRER_POLICY_KEY, ReferrerPolicy.DEFAULT);
if (url == null) return ParallelRequestStatus.FAILURE_INVALID_URL;
if (referrer == null) return ParallelRequestStatus.FAILURE_INVALID_REFERRER;
if (policy < 0 || policy > ReferrerPolicy.LAST) policy = ReferrerPolicy.DEFAULT;
if (policy < ReferrerPolicy.MIN_VALUE || policy > ReferrerPolicy.MAX_VALUE) {
policy = ReferrerPolicy.DEFAULT;
}
if (url.toString().equals("") || !isValid(url)) {
return ParallelRequestStatus.FAILURE_INVALID_URL;
......@@ -1013,7 +1015,7 @@ public class CustomTabsConnection {
intent.getIntExtra(PARALLEL_REQUEST_REFERRER_POLICY_KEY, ReferrerPolicy.DEFAULT);
if (resourceList == null || referrer == null) return 0;
if (policy < 0 || policy > ReferrerPolicy.LAST) policy = ReferrerPolicy.DEFAULT;
if (policy < 0 || policy > ReferrerPolicy.MAX_VALUE) policy = ReferrerPolicy.DEFAULT;
Origin origin = Origin.create(referrer);
if (origin == null) return 0;
if (!mClientManager.isFirstPartyOriginForSession(session, origin)) return 0;
......
......@@ -4,6 +4,12 @@ public {{ 'static ' if not top_level }}final class {{enum|name}} {
{% for field in enum.fields %}
public static final int {{field|name}} = {{field.numeric_value}};
{%- endfor %}
{%- if enum.min_value is not none %}
public static final int MIN_VALUE = {{enum.min_value}};
{%- endif %}
{%- if enum.max_value is not none %}
public static final int MAX_VALUE = {{enum.max_value}};
{%- endif %}
{%- if enum|covers_continuous_range %}
......
......@@ -15,5 +15,4 @@ enum ReferrerPolicy {
kStrictOriginWhenCrossOrigin,
kSameOrigin,
kStrictOrigin,
kLast = kStrictOrigin,
};
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