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