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/browser/service_worker/service_worker_utils.h" | 5 #include "content/browser/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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 std::string scope_string = scope.path(); | 71 std::string scope_string = scope.path(); |
72 if (!StartsWithASCII(scope_string, max_scope_string, true)) { | 72 if (!StartsWithASCII(scope_string, max_scope_string, true)) { |
73 *error_message = "The path of the provided scope ('"; | 73 *error_message = "The path of the provided scope ('"; |
74 error_message->append(scope_string); | 74 error_message->append(scope_string); |
75 error_message->append("') is not under the max scope allowed ("); | 75 error_message->append("') is not under the max scope allowed ("); |
76 if (service_worker_allowed_header_value) | 76 if (service_worker_allowed_header_value) |
77 error_message->append("set by Service-Worker-Allowed: "); | 77 error_message->append("set by Service-Worker-Allowed: "); |
78 error_message->append("'"); | 78 error_message->append("'"); |
79 error_message->append(max_scope_string); | 79 error_message->append(max_scope_string); |
80 error_message->append("')."); | 80 error_message->append( |
| 81 "'). Adjust the scope, move the Service Worker script, or use the " |
| 82 "Service-Worker-Allowed HTTP header to allow the scope."); |
81 return false; | 83 return false; |
82 } | 84 } |
83 return true; | 85 return true; |
84 } | 86 } |
85 | 87 |
86 // static | 88 // static |
87 bool ServiceWorkerUtils::ContainsDisallowedCharacter( | 89 bool ServiceWorkerUtils::ContainsDisallowedCharacter( |
88 const GURL& scope, | 90 const GURL& scope, |
89 const GURL& script_url, | 91 const GURL& script_url, |
90 std::string* error_message) { | 92 std::string* error_message) { |
(...skipping 13 matching lines...) Expand all Loading... |
104 if (!ServiceWorkerUtils::ScopeMatches(scope, url_)) | 106 if (!ServiceWorkerUtils::ScopeMatches(scope, url_)) |
105 return false; | 107 return false; |
106 if (match_.is_empty() || match_.spec().size() < scope.spec().size()) { | 108 if (match_.is_empty() || match_.spec().size() < scope.spec().size()) { |
107 match_ = scope; | 109 match_ = scope; |
108 return true; | 110 return true; |
109 } | 111 } |
110 return false; | 112 return false; |
111 } | 113 } |
112 | 114 |
113 } // namespace content | 115 } // namespace content |
OLD | NEW |