| OLD | NEW |
| 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/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 void RunSoon(const base::Closure& callback) { | 58 void RunSoon(const base::Closure& callback) { |
| 59 if (!callback.is_null()) | 59 if (!callback.is_null()) |
| 60 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); | 60 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); |
| 61 } | 61 } |
| 62 | 62 |
| 63 bool CanUnregisterServiceWorker(const GURL& document_url, | 63 bool CanUnregisterServiceWorker(const GURL& document_url, |
| 64 const GURL& pattern) { | 64 const GURL& pattern) { |
| 65 DCHECK(document_url.is_valid()); | 65 DCHECK(document_url.is_valid()); |
| 66 DCHECK(pattern.is_valid()); | 66 DCHECK(pattern.is_valid()); |
| 67 return document_url.GetOrigin() == pattern.GetOrigin() && | 67 return ServiceWorkerUtils::PassOriginEqualitySecurityCheck<GURL>(document_url, |
| 68 pattern) && |
| 68 OriginCanAccessServiceWorkers(document_url) && | 69 OriginCanAccessServiceWorkers(document_url) && |
| 69 OriginCanAccessServiceWorkers(pattern); | 70 OriginCanAccessServiceWorkers(pattern); |
| 70 } | 71 } |
| 71 | 72 |
| 72 bool CanUpdateServiceWorker(const GURL& document_url, const GURL& pattern) { | 73 bool CanUpdateServiceWorker(const GURL& document_url, const GURL& pattern) { |
| 73 DCHECK(document_url.is_valid()); | 74 DCHECK(document_url.is_valid()); |
| 74 DCHECK(pattern.is_valid()); | 75 DCHECK(pattern.is_valid()); |
| 75 DCHECK(OriginCanAccessServiceWorkers(document_url)); | 76 DCHECK(OriginCanAccessServiceWorkers(document_url)); |
| 76 DCHECK(OriginCanAccessServiceWorkers(pattern)); | 77 DCHECK(OriginCanAccessServiceWorkers(pattern)); |
| 77 return document_url.GetOrigin() == pattern.GetOrigin(); | 78 return ServiceWorkerUtils::PassOriginEqualitySecurityCheck<GURL>(document_url, |
| 79 pattern); |
| 78 } | 80 } |
| 79 | 81 |
| 80 bool CanGetRegistration(const GURL& document_url, | 82 bool CanGetRegistration(const GURL& document_url, |
| 81 const GURL& given_document_url) { | 83 const GURL& given_document_url) { |
| 82 DCHECK(document_url.is_valid()); | 84 DCHECK(document_url.is_valid()); |
| 83 DCHECK(given_document_url.is_valid()); | 85 DCHECK(given_document_url.is_valid()); |
| 84 return document_url.GetOrigin() == given_document_url.GetOrigin() && | 86 return ServiceWorkerUtils::PassOriginEqualitySecurityCheck<GURL>( |
| 87 document_url, given_document_url) && |
| 85 OriginCanAccessServiceWorkers(document_url) && | 88 OriginCanAccessServiceWorkers(document_url) && |
| 86 OriginCanAccessServiceWorkers(given_document_url); | 89 OriginCanAccessServiceWorkers(given_document_url); |
| 87 } | 90 } |
| 88 | 91 |
| 89 } // namespace | 92 } // namespace |
| 90 | 93 |
| 91 ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost( | 94 ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost( |
| 92 int render_process_id, | 95 int render_process_id, |
| 93 MessagePortMessageFilter* message_port_message_filter, | 96 MessagePortMessageFilter* message_port_message_filter, |
| 94 ResourceContext* resource_context) | 97 ResourceContext* resource_context) |
| (...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 if (!handle) { | 1430 if (!handle) { |
| 1428 bad_message::ReceivedBadMessage(this, | 1431 bad_message::ReceivedBadMessage(this, |
| 1429 bad_message::SWDH_TERMINATE_BAD_HANDLE); | 1432 bad_message::SWDH_TERMINATE_BAD_HANDLE); |
| 1430 return; | 1433 return; |
| 1431 } | 1434 } |
| 1432 handle->version()->StopWorker( | 1435 handle->version()->StopWorker( |
| 1433 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1436 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 1434 } | 1437 } |
| 1435 | 1438 |
| 1436 } // namespace content | 1439 } // namespace content |
| OLD | NEW |