Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Unified Diff: third_party/WebKit/Source/bindings/scripts/v8_utilities.py

Issue 1861433002: Make [OriginTrialEnabled] and [RuntimeEnabled] mutually exclusive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@586594-separate-tests
Patch Set: Correct IDL for Web Bluetooth Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/scripts/v8_utilities.py
diff --git a/third_party/WebKit/Source/bindings/scripts/v8_utilities.py b/third_party/WebKit/Source/bindings/scripts/v8_utilities.py
index 723bb55c77a94accf20f7910f852acb16beb121a..183763570ceb21108928d84ef7249b514e7e816e 100644
--- a/third_party/WebKit/Source/bindings/scripts/v8_utilities.py
+++ b/third_party/WebKit/Source/bindings/scripts/v8_utilities.py
@@ -366,27 +366,44 @@ def measure_as(definition_or_member, interface):
return None
-def runtime_feature_name(definition_or_member):
+# [OriginTrialEnabled]
+def origin_trial_enabled_function_name(definition_or_member, interface):
+ """Returns the name of the OriginTrials enabled function.
+
+ An exception is raised if both the OriginTrialEnabled and RuntimeEnabled
+ extended attributes are applied to the same IDL member. Only one of the
+ two attributes can be applied to any member - they are mutually exclusive.
+
+ The returned function checks if the IDL member should be enabled.
+ Given extended attribute OriginTrialEnabled=FeatureName, return:
+ OriginTrials::{featureName}Enabled
+
+ If the OriginTrialEnabled extended attribute is found, the includes are
+ also updated as a side-effect.
+ """
extended_attributes = definition_or_member.extended_attributes
- if 'RuntimeEnabled' not in extended_attributes:
- return None
- return extended_attributes['RuntimeEnabled']
+ is_origin_trial_enabled = 'OriginTrialEnabled' in extended_attributes
+ if (is_origin_trial_enabled and 'RuntimeEnabled' in extended_attributes):
+ raise Exception('[OriginTrialEnabled] and [RuntimeEnabled] must '
+ 'not be specified on the same definition: '
+ '%s.%s' % (definition_or_member.idl_name, definition_or_member.name))
-def is_origin_trial_enabled(definition_or_member):
- return 'OriginTrialEnabled' in definition_or_member.extended_attributes
+ if is_origin_trial_enabled:
+ includes.add('core/inspector/ConsoleMessage.h')
+ includes.add('core/origin_trials/OriginTrials.h')
+ trial_name = extended_attributes['OriginTrialEnabled']
+ return 'OriginTrials::%sEnabled' % uncapitalize(trial_name)
-def origin_trial_name(definition_or_member):
- return definition_or_member.extended_attributes['OriginTrialEnabled'] if is_origin_trial_enabled(definition_or_member) else None
+ return None
-def origin_trial_enabled_function(definition_or_member):
- trial_name = origin_trial_name(definition_or_member)
- feature_name = runtime_feature_name(definition_or_member)
- if not feature_name or not trial_name:
- return
- return 'OriginTrials::%sEnabled' % uncapitalize(feature_name)
+def runtime_feature_name(definition_or_member):
+ extended_attributes = definition_or_member.extended_attributes
+ if 'RuntimeEnabled' not in extended_attributes:
+ return None
+ return extended_attributes['RuntimeEnabled']
# [RuntimeEnabled]
@@ -396,17 +413,16 @@ def runtime_enabled_function_name(definition_or_member):
The returned function checks if a method/attribute is enabled.
Given extended attribute RuntimeEnabled=FeatureName, return:
RuntimeEnabledFeatures::{featureName}Enabled
+
+ If the RuntimeEnabled extended attribute is found, the includes
+ are also updated as a side-effect.
"""
feature_name = runtime_feature_name(definition_or_member)
- # If an origin trial is on the method/attribute, it overrides the runtime
- # enabled status. For now, we are unconditionally installing these
- # attributes/methods, so we are acting as though the runtime enabled
- # function doesn't exist. (It is checked in the generated OriginTrials
- # function, instead)
- trial_name = origin_trial_name(definition_or_member)
- if not feature_name or trial_name:
+ if not feature_name:
return
+
+ includes.add('platform/RuntimeEnabledFeatures.h')
return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name)

Powered by Google App Engine
This is Rietveld 408576698