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