| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/common/service_worker/service_worker_utils.h" | 5 #include "content/common/service_worker/service_worker_utils.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | |
| 10 #include "base/logging.h" | 9 #include "base/logging.h" |
| 11 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 12 #include "content/public/common/origin_util.h" | 11 #include "content/public/common/origin_util.h" |
| 13 | 12 |
| 14 namespace content { | 13 namespace content { |
| 15 | 14 |
| 16 namespace { | 15 namespace { |
| 17 | 16 |
| 18 bool PathContainsDisallowedCharacter(const GURL& url) { | 17 bool PathContainsDisallowedCharacter(const GURL& url) { |
| 19 std::string path = url.path(); | 18 std::string path = url.path(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 DCHECK(context_url.is_valid()); | 111 DCHECK(context_url.is_valid()); |
| 113 DCHECK(pattern.is_valid()); | 112 DCHECK(pattern.is_valid()); |
| 114 DCHECK(script_url.is_valid()); | 113 DCHECK(script_url.is_valid()); |
| 115 return ServiceWorkerUtils::PassOriginEqualitySecurityCheck<GURL>( | 114 return ServiceWorkerUtils::PassOriginEqualitySecurityCheck<GURL>( |
| 116 context_url, pattern, script_url) && | 115 context_url, pattern, script_url) && |
| 117 OriginCanAccessServiceWorkers(context_url) && | 116 OriginCanAccessServiceWorkers(context_url) && |
| 118 OriginCanAccessServiceWorkers(pattern) && | 117 OriginCanAccessServiceWorkers(pattern) && |
| 119 OriginCanAccessServiceWorkers(script_url); | 118 OriginCanAccessServiceWorkers(script_url); |
| 120 } | 119 } |
| 121 | 120 |
| 122 // static | |
| 123 bool ServiceWorkerUtils::IsMojoForServiceWorkerEnabled() { | |
| 124 return base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 125 switches::kMojoServiceWorker); | |
| 126 } | |
| 127 | |
| 128 bool LongestScopeMatcher::MatchLongest(const GURL& scope) { | 121 bool LongestScopeMatcher::MatchLongest(const GURL& scope) { |
| 129 if (!ServiceWorkerUtils::ScopeMatches(scope, url_)) | 122 if (!ServiceWorkerUtils::ScopeMatches(scope, url_)) |
| 130 return false; | 123 return false; |
| 131 if (match_.is_empty() || match_.spec().size() < scope.spec().size()) { | 124 if (match_.is_empty() || match_.spec().size() < scope.spec().size()) { |
| 132 match_ = scope; | 125 match_ = scope; |
| 133 return true; | 126 return true; |
| 134 } | 127 } |
| 135 return false; | 128 return false; |
| 136 } | 129 } |
| 137 | 130 |
| 138 } // namespace content | 131 } // namespace content |
| OLD | NEW |