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

Side by Side 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, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h"
9 #include "base/debug/crash_logging.h" 10 #include "base/debug/crash_logging.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
13 #include "base/profiler/scoped_tracker.h" 14 #include "base/profiler/scoped_tracker.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
16 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
17 #include "content/browser/bad_message.h" 18 #include "content/browser/bad_message.h"
18 #include "content/browser/message_port_message_filter.h" 19 #include "content/browser/message_port_message_filter.h"
19 #include "content/browser/message_port_service.h" 20 #include "content/browser/message_port_service.h"
20 #include "content/browser/service_worker/embedded_worker_registry.h" 21 #include "content/browser/service_worker/embedded_worker_registry.h"
21 #include "content/browser/service_worker/embedded_worker_status.h" 22 #include "content/browser/service_worker/embedded_worker_status.h"
22 #include "content/browser/service_worker/service_worker_client_utils.h" 23 #include "content/browser/service_worker/service_worker_client_utils.h"
23 #include "content/browser/service_worker/service_worker_context_core.h" 24 #include "content/browser/service_worker/service_worker_context_core.h"
24 #include "content/browser/service_worker/service_worker_context_wrapper.h" 25 #include "content/browser/service_worker/service_worker_context_wrapper.h"
25 #include "content/browser/service_worker/service_worker_handle.h" 26 #include "content/browser/service_worker/service_worker_handle.h"
26 #include "content/browser/service_worker/service_worker_registration.h" 27 #include "content/browser/service_worker/service_worker_registration.h"
27 #include "content/browser/service_worker/service_worker_registration_handle.h" 28 #include "content/browser/service_worker/service_worker_registration_handle.h"
28 #include "content/common/service_worker/embedded_worker_messages.h" 29 #include "content/common/service_worker/embedded_worker_messages.h"
29 #include "content/common/service_worker/service_worker_messages.h" 30 #include "content/common/service_worker/service_worker_messages.h"
30 #include "content/common/service_worker/service_worker_types.h" 31 #include "content/common/service_worker/service_worker_types.h"
31 #include "content/common/service_worker/service_worker_utils.h" 32 #include "content/common/service_worker/service_worker_utils.h"
32 #include "content/public/browser/content_browser_client.h" 33 #include "content/public/browser/content_browser_client.h"
33 #include "content/public/common/browser_side_navigation_policy.h" 34 #include "content/public/common/browser_side_navigation_policy.h"
34 #include "content/public/common/content_client.h" 35 #include "content/public/common/content_client.h"
36 #include "content/public/common/content_switches.h"
35 #include "content/public/common/origin_util.h" 37 #include "content/public/common/origin_util.h"
36 #include "ipc/ipc_message_macros.h" 38 #include "ipc/ipc_message_macros.h"
37 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerError.h" 39 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerError.h"
38 #include "url/gurl.h" 40 #include "url/gurl.h"
39 41
40 using blink::WebServiceWorkerError; 42 using blink::WebServiceWorkerError;
41 43
42 namespace content { 44 namespace content {
43 45
44 namespace { 46 namespace {
(...skipping 12 matching lines...) Expand all
57 59
58 void RunSoon(const base::Closure& callback) { 60 void RunSoon(const base::Closure& callback) {
59 if (!callback.is_null()) 61 if (!callback.is_null())
60 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); 62 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
61 } 63 }
62 64
63 bool CanUnregisterServiceWorker(const GURL& document_url, 65 bool CanUnregisterServiceWorker(const GURL& document_url,
64 const GURL& pattern) { 66 const GURL& pattern) {
65 DCHECK(document_url.is_valid()); 67 DCHECK(document_url.is_valid());
66 DCHECK(pattern.is_valid()); 68 DCHECK(pattern.is_valid());
67 return document_url.GetOrigin() == pattern.GetOrigin() && 69 return (document_url.GetOrigin() == pattern.GetOrigin() ||
70 base::CommandLine::ForCurrentProcess()->HasSwitch(
71 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
68 OriginCanAccessServiceWorkers(document_url) && 72 OriginCanAccessServiceWorkers(document_url) &&
69 OriginCanAccessServiceWorkers(pattern); 73 OriginCanAccessServiceWorkers(pattern);
70 } 74 }
71 75
72 bool CanUpdateServiceWorker(const GURL& document_url, const GURL& pattern) { 76 bool CanUpdateServiceWorker(const GURL& document_url, const GURL& pattern) {
73 DCHECK(document_url.is_valid()); 77 DCHECK(document_url.is_valid());
74 DCHECK(pattern.is_valid()); 78 DCHECK(pattern.is_valid());
75 DCHECK(OriginCanAccessServiceWorkers(document_url)); 79 DCHECK(OriginCanAccessServiceWorkers(document_url));
76 DCHECK(OriginCanAccessServiceWorkers(pattern)); 80 DCHECK(OriginCanAccessServiceWorkers(pattern));
77 return document_url.GetOrigin() == pattern.GetOrigin(); 81 return document_url.GetOrigin() == pattern.GetOrigin() ||
82 base::CommandLine::ForCurrentProcess()->HasSwitch(
83 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-
78 } 84 }
79 85
80 bool CanGetRegistration(const GURL& document_url, 86 bool CanGetRegistration(const GURL& document_url,
81 const GURL& given_document_url) { 87 const GURL& given_document_url) {
82 DCHECK(document_url.is_valid()); 88 DCHECK(document_url.is_valid());
83 DCHECK(given_document_url.is_valid()); 89 DCHECK(given_document_url.is_valid());
84 return document_url.GetOrigin() == given_document_url.GetOrigin() && 90 return (document_url.GetOrigin() == given_document_url.GetOrigin() ||
91 base::CommandLine::ForCurrentProcess()->HasSwitch(
92 switches::kDisableWebSecurity)) &&
85 OriginCanAccessServiceWorkers(document_url) && 93 OriginCanAccessServiceWorkers(document_url) &&
86 OriginCanAccessServiceWorkers(given_document_url); 94 OriginCanAccessServiceWorkers(given_document_url);
87 } 95 }
88 96
89 } // namespace 97 } // namespace
90 98
91 ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost( 99 ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost(
92 int render_process_id, 100 int render_process_id,
93 MessagePortMessageFilter* message_port_message_filter, 101 MessagePortMessageFilter* message_port_message_filter,
94 ResourceContext* resource_context) 102 ResourceContext* resource_context)
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 if (!handle) { 1435 if (!handle) {
1428 bad_message::ReceivedBadMessage(this, 1436 bad_message::ReceivedBadMessage(this,
1429 bad_message::SWDH_TERMINATE_BAD_HANDLE); 1437 bad_message::SWDH_TERMINATE_BAD_HANDLE);
1430 return; 1438 return;
1431 } 1439 }
1432 handle->version()->StopWorker( 1440 handle->version()->StopWorker(
1433 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 1441 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
1434 } 1442 }
1435 1443
1436 } // namespace content 1444 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698