Commit a38e325b authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Setup an origin trial for HrefTranslate.

In order to setup origin trial need to make the feature & origin trial
dependent on a new runtime enabled feature that is dynamically set if
the translation service is available.

BUG=872777

Change-Id: Ic6fc5947a50c4e2a5ac659c83d75a972c31b0c12
Reviewed-on: https://chromium-review.googlesource.com/c/1332780Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607462}
parent 64b3ce15
......@@ -1006,12 +1006,7 @@ void RenderView::ApplyWebPreferences(const WebPreferences& prefs,
WebRuntimeFeatures::EnableMiddleClickAutoscroll(true);
#endif
// Only enable href translate if we have the experimental web platform
// flag on and the translation service is available.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableExperimentalWebPlatformFeatures)) {
WebRuntimeFeatures::EnableHrefTranslate(prefs.translate_service_available);
}
WebRuntimeFeatures::EnableTranslateService(prefs.translate_service_available);
}
/*static*/
......
......@@ -206,7 +206,7 @@ class WebRuntimeFeatures {
bool);
BLINK_PLATFORM_EXPORT static void EnableAutoplayIgnoresWebAudio(bool);
BLINK_PLATFORM_EXPORT static void EnableMediaControlsExpandGesture(bool);
BLINK_PLATFORM_EXPORT static void EnableHrefTranslate(bool);
BLINK_PLATFORM_EXPORT static void EnableTranslateService(bool);
BLINK_PLATFORM_EXPORT static void EnableMergeBlockingNonBlockingPools(bool);
private:
......
......@@ -30,6 +30,11 @@ bool OriginTrials::{{feature.name}}Enabled(const ExecutionContext* executionCont
{%- endfor %}
{% endif %}
{%- for depends_on in feature.depends_on %}
if (!RuntimeEnabledFeatures::{{depends_on}}Enabled())
return false;
{%- endfor %}
const OriginTrialContext* context = OriginTrialContext::From(executionContext);
if (!context) return false;
if (context->IsTrialEnabled(k{{feature.name}}TrialName))
......
......@@ -27,7 +27,7 @@ interface HTMLAnchorElement : HTMLElement {
[CEReactions, Reflect] attribute DOMString rel;
[SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
[CEReactions, Reflect] attribute DOMString hreflang;
[RuntimeEnabled=HrefTranslate, CEReactions, Reflect] attribute DOMString hrefTranslate;
[OriginTrialEnabled=HrefTranslate, CEReactions, Reflect] attribute DOMString hrefTranslate;
[CEReactions, Reflect] attribute DOMString type;
[CEReactions, Reflect, ReflectOnly=("","no-referrer","origin","no-referrer-when-downgrade","origin-when-cross-origin","unsafe-url"), ReflectMissing="", ReflectInvalid=""] attribute DOMString referrerPolicy;
......
......@@ -560,8 +560,8 @@ void WebRuntimeFeatures::EnableMediaControlsExpandGesture(bool enable) {
RuntimeEnabledFeatures::SetMediaControlsExpandGestureEnabled(enable);
}
void WebRuntimeFeatures::EnableHrefTranslate(bool enable) {
RuntimeEnabledFeatures::SetHrefTranslateEnabled(enable);
void WebRuntimeFeatures::EnableTranslateService(bool enable) {
RuntimeEnabledFeatures::SetTranslateServiceEnabled(enable);
}
void WebRuntimeFeatures::EnableBackgroundFetch(bool enable) {
......
......@@ -559,10 +559,11 @@
{
name: "HeapUnifiedGarbageCollection",
},
// Only exposed when a translation engine is available
// and experimental features are enabled.
{
name: "HrefTranslate",
depends_on: ["TranslateService"],
origin_trial_feature_name: "HrefTranslate",
status: "experimental",
},
// https://crbug.com/766694 for testing disabling the feature.
{
......@@ -1203,6 +1204,10 @@
{
name: "TransferableStreams",
},
// This is conditionally set if the platform supports translation.
{
name: "TranslateService"
},
{
name: "TrustedDOMTypes",
status: "experimental",
......
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