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