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

Unified Diff: content/common/service_worker/service_worker_utils.h

Issue 2196633002: [ServiceWorker] Don't check the origin equality when disable-web-security flag is set. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporated nhiroki's comment Created 4 years, 5 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/common/service_worker/service_worker_utils.h
diff --git a/content/common/service_worker/service_worker_utils.h b/content/common/service_worker/service_worker_utils.h
index 5be59c0aa801055cb3642838c8e0f33b798128a7..4ea403a3203ad5646f4ea1888f5b0271b91f33fe 100644
--- a/content/common/service_worker/service_worker_utils.h
+++ b/content/common/service_worker/service_worker_utils.h
@@ -5,10 +5,12 @@
#ifndef CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_
#define CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_
+#include "base/command_line.h"
#include "base/macros.h"
#include "content/common/content_export.h"
#include "content/common/service_worker/service_worker_status_code.h"
#include "content/common/service_worker/service_worker_types.h"
+#include "content/public/common/content_switches.h"
#include "content/public/common/resource_type.h"
#include "url/gurl.h"
@@ -44,6 +46,21 @@ class ServiceWorkerUtils {
const GURL& pattern,
const GURL& script_url);
+ // Returns true when '--disable-web-security' flag is set. Otherwise returns
+ // whether the all origins of |urls| are same as the origin of |url|.
+ template <typename... Args>
+ static bool PassOriginEqualitySecurityCheck(const GURL& url,
+ const Args&... urls) {
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableWebSecurity))
+ return true;
+ for (const GURL& u : {urls...}) {
+ if (url.GetOrigin() != u.GetOrigin())
+ return false;
+ }
+ return true;
+ }
+
// PlzNavigate
// Returns true if the |provider_id| was assigned by the browser process.
static bool IsBrowserAssignedProviderId(int provider_id) {

Powered by Google App Engine
This is Rietveld 408576698