| 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "content/public/common/browser_side_navigation_policy.h" |
| 13 #include "content/public/common/content_switches.h" |
| 12 #include "content/public/common/origin_util.h" | 14 #include "content/public/common/origin_util.h" |
| 13 | 15 |
| 14 namespace content { | 16 namespace content { |
| 15 | 17 |
| 16 namespace { | 18 namespace { |
| 17 | 19 |
| 18 bool PathContainsDisallowedCharacter(const GURL& url) { | 20 bool PathContainsDisallowedCharacter(const GURL& url) { |
| 19 std::string path = url.path(); | 21 std::string path = url.path(); |
| 20 DCHECK(base::IsStringUTF8(path)); | 22 DCHECK(base::IsStringUTF8(path)); |
| 21 | 23 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 } | 128 } |
| 127 const GURL& first = urls.front(); | 129 const GURL& first = urls.front(); |
| 128 for (const GURL& url : urls) { | 130 for (const GURL& url : urls) { |
| 129 if (first.GetOrigin() != url.GetOrigin()) | 131 if (first.GetOrigin() != url.GetOrigin()) |
| 130 return false; | 132 return false; |
| 131 } | 133 } |
| 132 return true; | 134 return true; |
| 133 } | 135 } |
| 134 | 136 |
| 135 // static | 137 // static |
| 138 bool ServiceWorkerUtils::IsServicificationEnabled() { |
| 139 return IsBrowserSideNavigationEnabled() && |
| 140 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 141 switches::kEnableNetworkService); |
| 142 } |
| 143 |
| 144 // static |
| 136 bool ServiceWorkerUtils::IsMojoForServiceWorkerEnabled() { | 145 bool ServiceWorkerUtils::IsMojoForServiceWorkerEnabled() { |
| 137 return true; | 146 return true; |
| 138 } | 147 } |
| 139 | 148 |
| 140 bool LongestScopeMatcher::MatchLongest(const GURL& scope) { | 149 bool LongestScopeMatcher::MatchLongest(const GURL& scope) { |
| 141 if (!ServiceWorkerUtils::ScopeMatches(scope, url_)) | 150 if (!ServiceWorkerUtils::ScopeMatches(scope, url_)) |
| 142 return false; | 151 return false; |
| 143 if (match_.is_empty() || match_.spec().size() < scope.spec().size()) { | 152 if (match_.is_empty() || match_.spec().size() < scope.spec().size()) { |
| 144 match_ = scope; | 153 match_ = scope; |
| 145 return true; | 154 return true; |
| 146 } | 155 } |
| 147 return false; | 156 return false; |
| 148 } | 157 } |
| 149 | 158 |
| 150 } // namespace content | 159 } // namespace content |
| OLD | NEW |