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_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "content/browser/service_worker/service_worker_provider_host.h" | |
nhiroki
2015/06/01 05:04:09
nit: not necessary?
| |
9 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
10 #include "content/common/service_worker/service_worker_status_code.h" | 11 #include "content/common/service_worker/service_worker_status_code.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 } |
21 | 22 |
22 // A helper for creating a do-nothing status callback. | 23 // A helper for creating a do-nothing status callback. |
23 static void NoOpStatusCallback(ServiceWorkerStatusCode status) {} | 24 static void NoOpStatusCallback(ServiceWorkerStatusCode status) {} |
25 // A helper for creating a do-nothing client info callback. | |
26 static void NoOpClientInfoCallback(const ServiceWorkerClientInfo&) {} | |
nhiroki
2015/06/01 05:04:09
Can you move this into service_worker_context_wrap
horo
2015/06/02 03:14:48
Done.
horo
2015/06/02 03:14:48
Done.
| |
24 | 27 |
25 // Returns true if |scope| matches |url|. | 28 // Returns true if |scope| matches |url|. |
26 CONTENT_EXPORT static bool ScopeMatches(const GURL& scope, const GURL& url); | 29 CONTENT_EXPORT static bool ScopeMatches(const GURL& scope, const GURL& url); |
27 | 30 |
28 // Returns true if the script at |script_url| is allowed to control |scope| | 31 // Returns true if the script at |script_url| is allowed to control |scope| |
29 // according to Service Worker's path restriction policy. If | 32 // according to Service Worker's path restriction policy. If |
30 // |service_worker_allowed| is not null, it points to the | 33 // |service_worker_allowed| is not null, it points to the |
31 // Service-Worker-Allowed header value. | 34 // Service-Worker-Allowed header value. |
32 CONTENT_EXPORT static bool IsPathRestrictionSatisfied( | 35 CONTENT_EXPORT static bool IsPathRestrictionSatisfied( |
33 const GURL& scope, | 36 const GURL& scope, |
(...skipping 17 matching lines...) Expand all Loading... | |
51 private: | 54 private: |
52 const GURL url_; | 55 const GURL url_; |
53 GURL match_; | 56 GURL match_; |
54 | 57 |
55 DISALLOW_COPY_AND_ASSIGN(LongestScopeMatcher); | 58 DISALLOW_COPY_AND_ASSIGN(LongestScopeMatcher); |
56 }; | 59 }; |
57 | 60 |
58 } // namespace content | 61 } // namespace content |
59 | 62 |
60 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ | 63 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ |
OLD | NEW |