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
3 // found in the LICENSE file.
5 #include "content/browser/service_worker/service_worker_utils.h"
7 #include "base/command_line.h"
8 #include "base/strings/string_util.h"
9 #include "content/public/common/content_switches.h"
14 bool ServiceWorkerUtils::IsFeatureEnabled() {
15 static bool enabled = CommandLine::ForCurrentProcess()->HasSwitch(
16 switches::kEnableServiceWorker);
21 bool ServiceWorkerUtils::ScopeMatches(const GURL& scope, const GURL& url) {
22 // This is a really basic, naive
23 // TODO(alecflett): Formalize what scope matches mean.
24 // Temporarily borrowed directly from appcache::Namespace::IsMatch().
25 // We have to escape '?' characters since MatchPattern also treats those
26 // as wildcards which we don't want here, we only do '*'s.
27 std::string scope_spec(scope.spec());
28 if (scope.has_query())
29 ReplaceSubstringsAfterOffset(&scope_spec, 0, "?", "\\?");
30 return MatchPattern(url.spec(), scope_spec);
33 } // namespace content