diff options
author | horo <horo@chromium.org> | 2014-10-31 19:08:28 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-01 02:08:43 +0000 |
commit | e09b6c8616f4a8e45e91a171eedddefde9522ac2 (patch) | |
tree | a2bf42602693c66c8d5089e68aca52f7ae788d9a /content/public/browser/service_worker_context.h | |
parent | 2178ec8cf854f0996a2d66649f52841e1ed18795 (diff) | |
download | chromium_src-e09b6c8616f4a8e45e91a171eedddefde9522ac2.zip chromium_src-e09b6c8616f4a8e45e91a171eedddefde9522ac2.tar.gz chromium_src-e09b6c8616f4a8e45e91a171eedddefde9522ac2.tar.bz2 |
[ServiceWorker] Don't send the UMA related headers to the ServiceWorker.
Chrome add "X-Chrome-UMA-Enabled" (and sometimes "X-Client-Data") headers while accessing Google servers if UMA is enabled.
This header is added before sending the request to the ServiceWorker.
So the request which is passed to the ServiceWorker contains this header.
If event.request.mode is 'cors' and event.request.headers has "x-chrome-uma-enabled", fetch(event.request) send a CORS preflight request.
This preflight request contains "Access-Control-Request-Headers: x-chrome-uma-enabled" header.
But the response from the Google server doesn't contain "Access-Control-Allow-Headers: x-chrome-uma-enabled" header.
So this fetch fails.
To avoid this problem this patch removes these headers before sending the request to the ServiceWorker.
This patch introduces ServiceWorkerContext::AddExcludedHeadersForFetchEvent() method and changes DevToolsNetworkTransactionFactory to call this method.
BUG=425649
Review URL: https://codereview.chromium.org/666973003
Cr-Commit-Position: refs/heads/master@{#302379}
Diffstat (limited to 'content/public/browser/service_worker_context.h')
-rw-r--r-- | content/public/browser/service_worker_context.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/content/public/browser/service_worker_context.h b/content/public/browser/service_worker_context.h index 594408a..94ab73f 100644 --- a/content/public/browser/service_worker_context.h +++ b/content/public/browser/service_worker_context.h @@ -5,6 +5,9 @@ #ifndef CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ #define CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ +#include <set> +#include <string> + #include "base/basictypes.h" #include "base/callback_forward.h" #include "content/public/browser/service_worker_usage_info.h" @@ -24,6 +27,15 @@ class ServiceWorkerContext { typedef base::Callback<void(const std::vector<ServiceWorkerUsageInfo>& usage_info)> GetUsageInfoCallback; + // Registers the header name which should not be passed to the ServiceWorker. + // Must be called from the IO thread. + CONTENT_EXPORT static void AddExcludedHeadersForFetchEvent( + const std::set<std::string>& header_names); + + // Returns true if the header name should not be passed to the ServiceWorker. + // Must be called from the IO thread. + static bool IsExcludedHeaderNameForFetchEvent(const std::string& header_name); + // Equivalent to calling navigator.serviceWorker.register(script_url, {scope: // pattern}) from a renderer, except that |pattern| is an absolute URL instead // of relative to some current origin. |callback| is passed true when the JS |