| 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 { |
| 11 |
| 12 OriginTrials::OriginTrials(PassOwnPtrWillBeRawPtr<OriginTrialContext> originTria
lContext) |
| 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 = reinterpret_cast<OriginTrials*>(WillBeHeapSuppl
ement<ExecutionContext>::from(host, supplementName())); |
| 25 if (!originTrials) { |
| 26 originTrials = new OriginTrials(host->createOriginTrialContext()); |
| 27 WillBeHeapSupplement<ExecutionContext>::provideTo(*host, supplementName(
), adoptPtrWillBeNoop(originTrials)); |
| 28 } |
| 29 return originTrials; |
| 30 } |
| 31 |
| 10 {% for feature in features %} | 32 {% for feature in features %} |
| 11 {% if feature.origin_trial_feature_name %} | 33 {% if feature.origin_trial_feature_name %} |
| 12 | 34 |
| 13 // static | 35 // static |
| 14 bool OriginTrials::{{feature.first_lowered_name}}Enabled(ExecutionContext* execu
tionContext, String& errorMessage) { | 36 bool OriginTrials::{{feature.first_lowered_name}}Enabled(ExecutionContext* execu
tionContext, String& errorMessage) { |
| 15 return {{feature.first_lowered_name}}EnabledImpl(executionContext, &errorMes
sage); | 37 return OriginTrials::from(executionContext)->{{feature.first_lowered_name}}E
nabledImpl(&errorMessage); |
| 16 } | 38 } |
| 17 | 39 |
| 18 // static | 40 // static |
| 19 bool OriginTrials::{{feature.first_lowered_name}}Enabled(ExecutionContext* execu
tionContext) { | 41 bool OriginTrials::{{feature.first_lowered_name}}Enabled(ExecutionContext* execu
tionContext) { |
| 20 return {{feature.first_lowered_name}}EnabledImpl(executionContext, nullptr); | 42 return OriginTrials::from(executionContext)->{{feature.first_lowered_name}}E
nabledImpl(nullptr); |
| 21 } | 43 } |
| 44 |
| 22 {% endif %} | 45 {% endif %} |
| 23 {% endfor %} | 46 {% endfor %} |
| 24 | 47 |
| 25 {% for feature in features %} | 48 {% for feature in features %} |
| 26 {% if feature.origin_trial_feature_name %} | 49 {% if feature.origin_trial_feature_name %} |
| 27 | 50 |
| 28 // static | 51 bool OriginTrials::{{feature.first_lowered_name}}EnabledImpl(String* errorMessag
e) { |
| 29 bool OriginTrials::{{feature.first_lowered_name}}EnabledImpl(ExecutionContext* e
xecutionContext, String* errorMessage) { | |
| 30 if (RuntimeEnabledFeatures::{{feature.first_lowered_name}}Enabled()) | 52 if (RuntimeEnabledFeatures::{{feature.first_lowered_name}}Enabled()) |
| 31 return true; | 53 return true; |
| 32 return OriginTrialContext::isFeatureEnabled(executionContext, "{{feature.ori
gin_trial_feature_name}}", errorMessage); | 54 if (!m_originTrialContext) return false; |
| 55 return m_originTrialContext->isFeatureEnabled("{{feature.origin_trial_featur
e_name}}", errorMessage); |
| 33 } | 56 } |
| 34 {% endif %} | 57 {% endif %} |
| 35 {% endfor %} | 58 {% endfor %} |
| 36 | 59 |
| 60 DEFINE_TRACE(OriginTrials) |
| 61 { |
| 62 visitor->trace(m_originTrialContext); |
| 63 WillBeHeapSupplement<ExecutionContext>::trace(visitor); |
| 64 } |
| 37 } // namespace blink | 65 } // namespace blink |
| OLD | NEW |