| 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 #ifndef CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ | 5 #ifndef CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ |
| 6 #define CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ | 6 #define CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 #include "content/common/service_worker/service_worker_status_code.h" | 10 #include "content/common/service_worker/service_worker_status_code.h" |
| 11 #include "content/common/service_worker/service_worker_types.h" |
| 11 #include "content/public/common/resource_type.h" | 12 #include "content/public/common/resource_type.h" |
| 12 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 class ServiceWorkerUtils { | 17 class ServiceWorkerUtils { |
| 17 public: | 18 public: |
| 18 static bool IsMainResourceType(ResourceType type) { | 19 static bool IsMainResourceType(ResourceType type) { |
| 19 return IsResourceTypeFrame(type) || type == RESOURCE_TYPE_SHARED_WORKER; | 20 return IsResourceTypeFrame(type) || type == RESOURCE_TYPE_SHARED_WORKER; |
| 20 } | 21 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 31 // Service-Worker-Allowed header value. | 32 // Service-Worker-Allowed header value. |
| 32 CONTENT_EXPORT static bool IsPathRestrictionSatisfied( | 33 CONTENT_EXPORT static bool IsPathRestrictionSatisfied( |
| 33 const GURL& scope, | 34 const GURL& scope, |
| 34 const GURL& script_url, | 35 const GURL& script_url, |
| 35 const std::string* service_worker_allowed_header_value, | 36 const std::string* service_worker_allowed_header_value, |
| 36 std::string* error_message); | 37 std::string* error_message); |
| 37 | 38 |
| 38 static bool ContainsDisallowedCharacter(const GURL& scope, | 39 static bool ContainsDisallowedCharacter(const GURL& scope, |
| 39 const GURL& script_url, | 40 const GURL& script_url, |
| 40 std::string* error_message); | 41 std::string* error_message); |
| 42 |
| 43 // PlzNavigate |
| 44 // Returns true if the |provider_id| was assigned by the browser process. |
| 45 static bool IsBrowserAssignedProviderId(int provider_id) { |
| 46 return provider_id < kInvalidServiceWorkerProviderId; |
| 47 } |
| 41 }; | 48 }; |
| 42 | 49 |
| 43 class CONTENT_EXPORT LongestScopeMatcher { | 50 class CONTENT_EXPORT LongestScopeMatcher { |
| 44 public: | 51 public: |
| 45 explicit LongestScopeMatcher(const GURL& url) : url_(url) {} | 52 explicit LongestScopeMatcher(const GURL& url) : url_(url) {} |
| 46 virtual ~LongestScopeMatcher() {} | 53 virtual ~LongestScopeMatcher() {} |
| 47 | 54 |
| 48 // Returns true if |scope| matches |url_| longer than |match_|. | 55 // Returns true if |scope| matches |url_| longer than |match_|. |
| 49 bool MatchLongest(const GURL& scope); | 56 bool MatchLongest(const GURL& scope); |
| 50 | 57 |
| 51 private: | 58 private: |
| 52 const GURL url_; | 59 const GURL url_; |
| 53 GURL match_; | 60 GURL match_; |
| 54 | 61 |
| 55 DISALLOW_COPY_AND_ASSIGN(LongestScopeMatcher); | 62 DISALLOW_COPY_AND_ASSIGN(LongestScopeMatcher); |
| 56 }; | 63 }; |
| 57 | 64 |
| 58 } // namespace content | 65 } // namespace content |
| 59 | 66 |
| 60 #endif // CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ | 67 #endif // CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ |
| OLD | NEW |