| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 bool AllOriginsMatch(const GURL& url_a, const GURL& url_b, const GURL& url_c) { | 34 bool AllOriginsMatch(const GURL& url_a, const GURL& url_b, const GURL& url_c) { |
| 35 return url_a.GetOrigin() == url_b.GetOrigin() && | 35 return url_a.GetOrigin() == url_b.GetOrigin() && |
| 36 url_a.GetOrigin() == url_c.GetOrigin(); | 36 url_a.GetOrigin() == url_c.GetOrigin(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 // static | 41 // static |
| 42 bool ServiceWorkerUtils::ScopeMatches(const GURL& scope, const GURL& url) { | 42 bool ServiceWorkerUtils::ScopeMatches(const GURL& scope, const GURL& url) { |
| 43 DCHECK(!scope.has_ref()); | 43 DCHECK(!scope.has_ref()); |
| 44 DCHECK(!url.has_ref()); | |
| 45 return base::StartsWith(url.spec(), scope.spec(), | 44 return base::StartsWith(url.spec(), scope.spec(), |
| 46 base::CompareCase::SENSITIVE); | 45 base::CompareCase::SENSITIVE); |
| 47 } | 46 } |
| 48 | 47 |
| 49 // static | 48 // static |
| 50 bool ServiceWorkerUtils::IsPathRestrictionSatisfied( | 49 bool ServiceWorkerUtils::IsPathRestrictionSatisfied( |
| 51 const GURL& scope, | 50 const GURL& scope, |
| 52 const GURL& script_url, | 51 const GURL& script_url, |
| 53 const std::string* service_worker_allowed_header_value, | 52 const std::string* service_worker_allowed_header_value, |
| 54 std::string* error_message) { | 53 std::string* error_message) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 if (!ServiceWorkerUtils::ScopeMatches(scope, url_)) | 126 if (!ServiceWorkerUtils::ScopeMatches(scope, url_)) |
| 128 return false; | 127 return false; |
| 129 if (match_.is_empty() || match_.spec().size() < scope.spec().size()) { | 128 if (match_.is_empty() || match_.spec().size() < scope.spec().size()) { |
| 130 match_ = scope; | 129 match_ = scope; |
| 131 return true; | 130 return true; |
| 132 } | 131 } |
| 133 return false; | 132 return false; |
| 134 } | 133 } |
| 135 | 134 |
| 136 } // namespace content | 135 } // namespace content |
| OLD | NEW |