| {% from 'templates/macros.tmpl' import license, source_files_for_generated_file %} |
| {{license()}} |
| |
| {{source_files_for_generated_file(template_file, input_files)}} |
| |
| #include "third_party/blink/public/web/web_origin_trials.h" |
| |
| #include "third_party/blink/renderer/core/dom/document.h" |
| #include "third_party/blink/renderer/core/execution_context/execution_context.h" |
| #include "third_party/blink/renderer/core/origin_trials/origin_trials.h" |
| #include "third_party/blink/public/platform/web_string.h" |
| #include "third_party/blink/public/web/web_document.h" |
| |
| namespace blink { |
| |
| bool WebOriginTrials::isTrialEnabled(const WebDocument* web_document, const WebString& trial) { |
| if (!web_document) return false; |
| if (!origin_trials::IsTrialValid(trial)) |
| return false; |
| Document* document = *web_document; |
| for (OriginTrialFeature feature : origin_trials::FeaturesForTrial(trial)) { |
| switch (feature) { |
| {% for feature in features %} |
| {% if feature.origin_trial_feature_name %} |
| case OriginTrialFeature::k{{feature.name}}: |
| if (!RuntimeEnabledFeatures::{{feature.name}}Enabled( |
| document->GetExecutionContext())) { |
| return false; |
| } |
| break; |
| {% endif %} |
| {% endfor %} |
| default: |
| break; |
| } |
| } |
| return true; |
| } |
| |
| |
| } // namespace blink |