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

Unified Diff: third_party/WebKit/Source/core/origin_trials/OriginTrialContext.h

Issue 2673953003: Allow origin trials to be enabled by script (Closed)
Patch Set: Created 3 years, 10 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/core/origin_trials/OriginTrialContext.h
diff --git a/third_party/WebKit/Source/core/origin_trials/OriginTrialContext.h b/third_party/WebKit/Source/core/origin_trials/OriginTrialContext.h
index 51f5bf3ead1ee0bbdf0c14be0545592cfcd1e15f..2a31580b5f6e6aa277098de70c2a2c07d28726b3 100644
--- a/third_party/WebKit/Source/core/origin_trials/OriginTrialContext.h
+++ b/third_party/WebKit/Source/core/origin_trials/OriginTrialContext.h
@@ -71,22 +71,29 @@ class CORE_EXPORT OriginTrialContext final
// controls) should be considered enabled for the current execution context.
bool isTrialEnabled(const String& trialName);
- // Installs JavaScript bindings on the Window object for any features which
+ // Installs JavaScript bindings on the relevant objects for any features which
// should be enabled by the current set of trial tokens. This method is called
- // every time a token is added to the document, so that global interfaces will
- // be properly visible, even if the V8 context is being reused (i.e., after
- // navigation). If the V8 context is not initialized, this method will return
- // without doing anything.
+ // every time a token is added to the document (including when tokens are
+ // added via script). JavaScript-exposed members will be properly visible, for
+ // existing objects in the V8 context. If the V8 context is not initialized,
+ // or there are no enabled features, or all enabled features are already
+ // initialized, this method returns without doing anything. That is, it is
+ // safe to call this method multiple times, even if no trials are newly
+ // enabled.
void initializePendingFeatures();
DECLARE_VIRTUAL_TRACE();
private:
- void validateToken(const String& token);
+ // Validate the trial token. If valid, the trial named in the token is
+ // added to the list of enabled trials. Returns true or false to indicate if
+ // the token is valid.
+ bool enableTrialFromToken(const String& token);
Member<ExecutionContext> m_host;
Vector<String> m_tokens;
HashSet<String> m_enabledTrials;
+ HashSet<String> m_installedTrials;
WebTrialTokenValidator* m_trialTokenValidator;
};

Powered by Google App Engine
This is Rietveld 408576698