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

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

Issue 1763943002: WIP add code to check http headers for origin trial tokens Base URL: https://chromium.googlesource.com/chromium/src.git@move-trial-token-code
Patch Set: rebase Created 4 years, 9 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
« no previous file with comments | « content/common/origin_trials/trial_token_validator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/origin_trials/trial_token_validator.cc
diff --git a/content/common/origin_trials/trial_token_validator.cc b/content/common/origin_trials/trial_token_validator.cc
index d9c210d4046278d487627576869de12d06c1b371..ed38734970f71eff848fccfc56379c324faeae1a 100644
--- a/content/common/origin_trials/trial_token_validator.cc
+++ b/content/common/origin_trials/trial_token_validator.cc
@@ -7,6 +7,8 @@
#include "base/time/time.h"
#include "content/common/origin_trials/trial_token.h"
#include "content/public/common/content_client.h"
+#include "net/http/http_response_headers.h"
+#include "net/url_request/url_request.h"
namespace content {
@@ -23,4 +25,17 @@ bool TrialTokenValidator::ValidateToken(const std::string& token,
trial_token->IsValid(base::Time::Now(), public_key);
}
+bool TrialTokenValidator::RequestEnablesFeature(const net::URLRequest* request,
+ base::StringPiece featureName) {
+ url::Origin origin(request->url());
+ size_t iter = 0;
+ std::string token;
+ while (request->response_headers()->EnumerateHeader(&iter, "Origin-Trial",
+ &token)) {
+ if (ValidateToken(token, origin, featureName))
+ return true;
+ }
+ return false;
+}
+
} // namespace content
« no previous file with comments | « content/common/origin_trials/trial_token_validator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698