| OLD | NEW |
| 1 {% from 'macros.tmpl' import license %} | 1 {% from 'macros.tmpl' import license %} |
| 2 {{license()}} | 2 {{license()}} |
| 3 | 3 |
| 4 #include "core/origin_trials/OriginTrials.h" | 4 #include "core/origin_trials/OriginTrials.h" |
| 5 | 5 |
| 6 #include "core/dom/ExecutionContext.h" |
| 6 #include "core/origin_trials/OriginTrialContext.h" | 7 #include "core/origin_trials/OriginTrialContext.h" |
| 7 #include "platform/RuntimeEnabledFeatures.h" | 8 #include "platform/RuntimeEnabledFeatures.h" |
| 8 | 9 |
| 9 namespace blink { | 10 namespace blink { |
| 10 | 11 |
| 11 namespace { | 12 OriginTrials::OriginTrials(RawPtr<OriginTrialContext> originTrialContext) |
| 13 : m_originTrialContext(originTrialContext) {} |
| 14 |
| 15 // static |
| 16 const char* OriginTrials::supplementName() |
| 17 { |
| 18 return "OriginTrials"; |
| 19 } |
| 20 |
| 21 // static |
| 22 OriginTrials* OriginTrials::from(ExecutionContext* host) |
| 23 { |
| 24 OriginTrials* originTrials = static_cast<OriginTrials*>(Supplement<Execution
Context>::from(host, supplementName())); |
| 25 if (!originTrials) { |
| 26 originTrials = new OriginTrials(host->createOriginTrialContext()); |
| 27 Supplement<ExecutionContext>::provideTo(*host, supplementName(), originT
rials); |
| 28 } |
| 29 return originTrials; |
| 30 } |
| 12 | 31 |
| 13 {% for feature in features %} | 32 {% for feature in features %} |
| 14 {% if feature.origin_trial_feature_name %} | 33 {% if feature.origin_trial_feature_name %} |
| 15 | 34 |
| 16 bool {{feature.first_lowered_name}}EnabledImpl(ExecutionContext* executionContex
t, String* errorMessage) { | 35 // static |
| 17 if (RuntimeEnabledFeatures::{{feature.first_lowered_name}}Enabled()) | 36 bool OriginTrials::{{feature.first_lowered_name}}Enabled(ExecutionContext* execu
tionContext, String& errorMessage) { |
| 18 return true; | 37 return OriginTrials::from(executionContext)->{{feature.first_lowered_name}}E
nabledImpl(&errorMessage); |
| 19 OriginTrialContext* context = OriginTrialContext::from(executionContext); | 38 } |
| 20 return context->isFeatureEnabled("{{feature.origin_trial_feature_name}}", er
rorMessage); | 39 |
| 40 // static |
| 41 bool OriginTrials::{{feature.first_lowered_name}}Enabled(ExecutionContext* execu
tionContext) { |
| 42 return OriginTrials::from(executionContext)->{{feature.first_lowered_name}}E
nabledImpl(nullptr); |
| 21 } | 43 } |
| 22 | 44 |
| 23 {% endif %} | 45 {% endif %} |
| 24 {% endfor %} | 46 {% endfor %} |
| 25 | 47 |
| 26 } // namespace | |
| 27 | |
| 28 {% for feature in features %} | 48 {% for feature in features %} |
| 29 {% if feature.origin_trial_feature_name %} | 49 {% if feature.origin_trial_feature_name %} |
| 30 | 50 |
| 31 bool OriginTrials::{{feature.first_lowered_name}}Enabled(ExecutionContext* execu
tionContext, String& errorMessage) { | 51 bool OriginTrials::{{feature.first_lowered_name}}EnabledImpl(String* errorMessag
e) { |
| 32 return {{feature.first_lowered_name}}EnabledImpl(executionContext, &errorMes
sage); | 52 if (RuntimeEnabledFeatures::{{feature.first_lowered_name}}Enabled()) |
| 53 return true; |
| 54 if (!m_originTrialContext) return false; |
| 55 return m_originTrialContext->isFeatureEnabled("{{feature.origin_trial_featur
e_name}}", errorMessage); |
| 33 } | 56 } |
| 34 | |
| 35 bool OriginTrials::{{feature.first_lowered_name}}Enabled(ExecutionContext* execu
tionContext) { | |
| 36 return {{feature.first_lowered_name}}EnabledImpl(executionContext, nullptr); | |
| 37 } | |
| 38 | |
| 39 {% endif %} | 57 {% endif %} |
| 40 {% endfor %} | 58 {% endfor %} |
| 41 | 59 |
| 60 DEFINE_TRACE(OriginTrials) |
| 61 { |
| 62 visitor->trace(m_originTrialContext); |
| 63 Supplement<ExecutionContext>::trace(visitor); |
| 64 } |
| 42 } // namespace blink | 65 } // namespace blink |
| OLD | NEW |