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

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

Issue 2640823004: Allow origin trials to be enabled by script (Closed)
Patch Set: Address comments Created 3 years, 11 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 cef1f0b3820ccc8cf036a089df88222034e40122..9a1cb8a008697750ec885142dc8a4f89567a461a 100644
--- a/third_party/WebKit/Source/core/origin_trials/OriginTrialContext.h
+++ b/third_party/WebKit/Source/core/origin_trials/OriginTrialContext.h
@@ -71,21 +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, or even if the V8 context is being
+ // reused (i.e., after navigation). If the V8 context is not initialized, or
haraken 2017/01/28 02:25:20 I'd drop the ", or even if..." part. That's a very
chasej 2017/01/30 19:15:56 Done.
+ // 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);
Vector<String> m_tokens;
HashSet<String> m_enabledTrials;
+ HashSet<String> m_installedTrials;
WebTrialTokenValidator* m_trialTokenValidator;
};

Powered by Google App Engine
This is Rietveld 408576698