| 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/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 static bool IsMojoForServiceWorkerEnabled(); | 45 static bool IsMojoForServiceWorkerEnabled(); |
| 46 | 46 |
| 47 // Returns true if all members of |urls| have the same origin, and | 47 // Returns true if all members of |urls| have the same origin, and |
| 48 // OriginCanAccessServiceWorkers is true for this origin. | 48 // OriginCanAccessServiceWorkers is true for this origin. |
| 49 // If --disable-web-security is enabled, the same origin check is | 49 // If --disable-web-security is enabled, the same origin check is |
| 50 // not performed. | 50 // not performed. |
| 51 CONTENT_EXPORT static bool AllOriginsMatchAndCanAccessServiceWorkers( | 51 CONTENT_EXPORT static bool AllOriginsMatchAndCanAccessServiceWorkers( |
| 52 const std::vector<GURL>& urls); | 52 const std::vector<GURL>& urls); |
| 53 | 53 |
| 54 // Returns true if servicified service worker is enabled. |
| 55 CONTENT_EXPORT static bool IsServicificationEnabled(); |
| 56 |
| 54 // PlzNavigate | 57 // PlzNavigate |
| 55 // Returns true if the |provider_id| was assigned by the browser process. | 58 // Returns true if the |provider_id| was assigned by the browser process. |
| 56 static bool IsBrowserAssignedProviderId(int provider_id) { | 59 static bool IsBrowserAssignedProviderId(int provider_id) { |
| 57 return provider_id < kInvalidServiceWorkerProviderId; | 60 return provider_id < kInvalidServiceWorkerProviderId; |
| 58 } | 61 } |
| 59 }; | 62 }; |
| 60 | 63 |
| 61 class CONTENT_EXPORT LongestScopeMatcher { | 64 class CONTENT_EXPORT LongestScopeMatcher { |
| 62 public: | 65 public: |
| 63 explicit LongestScopeMatcher(const GURL& url) : url_(url) {} | 66 explicit LongestScopeMatcher(const GURL& url) : url_(url) {} |
| 64 virtual ~LongestScopeMatcher() {} | 67 virtual ~LongestScopeMatcher() {} |
| 65 | 68 |
| 66 // Returns true if |scope| matches |url_| longer than |match_|. | 69 // Returns true if |scope| matches |url_| longer than |match_|. |
| 67 bool MatchLongest(const GURL& scope); | 70 bool MatchLongest(const GURL& scope); |
| 68 | 71 |
| 69 private: | 72 private: |
| 70 const GURL url_; | 73 const GURL url_; |
| 71 GURL match_; | 74 GURL match_; |
| 72 | 75 |
| 73 DISALLOW_COPY_AND_ASSIGN(LongestScopeMatcher); | 76 DISALLOW_COPY_AND_ASSIGN(LongestScopeMatcher); |
| 74 }; | 77 }; |
| 75 | 78 |
| 76 } // namespace content | 79 } // namespace content |
| 77 | 80 |
| 78 #endif // CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ | 81 #endif // CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ |
| OLD | NEW |