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

Unified Diff: content/renderer/origin_trials/trial_token_validator.cc

Issue 1653263005: [Experimental Framework] Move the trial token public key out of content and into the embedder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase, and update for recent token changes Created 4 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: content/renderer/origin_trials/trial_token_validator.cc
diff --git a/content/renderer/origin_trials/trial_token_validator.cc b/content/renderer/origin_trials/trial_token_validator.cc
index bbdd85728cf3df84cda88c3a893dd1b7eeba2d82..1df8dc78c3d1c193d4f036aa1a5f4cca7232d6a8 100644
--- a/content/renderer/origin_trials/trial_token_validator.cc
+++ b/content/renderer/origin_trials/trial_token_validator.cc
@@ -5,6 +5,8 @@
#include "content/renderer/origin_trials/trial_token_validator.h"
#include "base/time/time.h"
+#include "content/public/common/content_client.h"
+#include "content/public/renderer/content_renderer_client.h"
#include "content/renderer/origin_trials/trial_token.h"
namespace content {
@@ -15,10 +17,17 @@ TrialTokenValidator::~TrialTokenValidator() {}
bool TrialTokenValidator::validateToken(const blink::WebString& token,
const blink::WebString& origin,
const blink::WebString& featureName) {
- scoped_ptr<TrialToken> trialToken = TrialToken::Parse(token.utf8());
- return trialToken &&
- trialToken->IsAppropriate(origin.utf8(), featureName.utf8()) &&
- trialToken->IsValid(base::Time::Now());
+ scoped_ptr<TrialToken> trial_token = TrialToken::Parse(token.utf8());
+
+ ContentClient* content_client = GetContentClient();
+ CHECK(content_client);
+
+ base::StringPiece public_key =
+ content_client->renderer()->GetOriginTrialPublicKey();
+
+ return !public_key.empty() && trial_token &&
+ trial_token->IsAppropriate(origin.utf8(), featureName.utf8()) &&
+ trial_token->IsValid(base::Time::Now(), public_key);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698