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

Unified Diff: content/browser/service_worker/service_worker_dispatcher_host.cc

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: add browser_tests 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/browser/service_worker/service_worker_dispatcher_host.cc
diff --git a/content/browser/service_worker/service_worker_dispatcher_host.cc b/content/browser/service_worker/service_worker_dispatcher_host.cc
index 7355acc9a7b1f8ebfca03c71eb8ab67235c443be..c1c57d75a55e09a65c08db5b38bb5d6c1f893786 100644
--- a/content/browser/service_worker/service_worker_dispatcher_host.cc
+++ b/content/browser/service_worker/service_worker_dispatcher_host.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "base/command_line.h"
#include "base/debug/crash_logging.h"
#include "base/logging.h"
#include "base/macros.h"
@@ -32,6 +33,7 @@
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/browser_side_navigation_policy.h"
#include "content/public/common/content_client.h"
+#include "content/public/common/content_switches.h"
#include "content/public/common/origin_util.h"
#include "ipc/ipc_message_macros.h"
#include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerError.h"
@@ -64,7 +66,9 @@ bool CanUnregisterServiceWorker(const GURL& document_url,
const GURL& pattern) {
DCHECK(document_url.is_valid());
DCHECK(pattern.is_valid());
- return document_url.GetOrigin() == pattern.GetOrigin() &&
+ return (document_url.GetOrigin() == pattern.GetOrigin() ||
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableWebSecurity)) &&
nhiroki 2016/08/01 04:32:45 Checking the flag whenever matching origins could
horo 2016/08/01 07:40:55 Done. I introduced PassOriginEqualitySecurityCheck
OriginCanAccessServiceWorkers(document_url) &&
OriginCanAccessServiceWorkers(pattern);
}
@@ -74,14 +78,18 @@ bool CanUpdateServiceWorker(const GURL& document_url, const GURL& pattern) {
DCHECK(pattern.is_valid());
DCHECK(OriginCanAccessServiceWorkers(document_url));
DCHECK(OriginCanAccessServiceWorkers(pattern));
- return document_url.GetOrigin() == pattern.GetOrigin();
+ return document_url.GetOrigin() == pattern.GetOrigin() ||
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableWebSecurity);
nhiroki 2016/08/01 04:32:45 Just to confirm: This flag has an effect only when
horo 2016/08/01 07:40:55 If "user-data-dir" flag is not set, "disable-web-
}
bool CanGetRegistration(const GURL& document_url,
const GURL& given_document_url) {
DCHECK(document_url.is_valid());
DCHECK(given_document_url.is_valid());
- return document_url.GetOrigin() == given_document_url.GetOrigin() &&
+ return (document_url.GetOrigin() == given_document_url.GetOrigin() ||
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableWebSecurity)) &&
OriginCanAccessServiceWorkers(document_url) &&
OriginCanAccessServiceWorkers(given_document_url);
}

Powered by Google App Engine
This is Rietveld 408576698