summaryrefslogtreecommitdiffstats
path: root/chromium/content/common/origin_util.cc
blob: 76a23fe3fd586a8698617ba338c7a5f59906b64c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/public/common/origin_util.h"

#include "base/containers/contains.h"
#include "base/lazy_instance.h"
#include "base/strings/pattern.h"
#include "content/common/url_schemes.h"
#include "services/network/public/cpp/is_potentially_trustworthy.h"
#include "url/gurl.h"
#include "url/url_util.h"

namespace content {

bool OriginCanAccessServiceWorkers(const GURL& url) {
  if (!url.is_valid()) {
    return false;
  }

  if (url.SchemeIsHTTPOrHTTPS() && network::IsUrlPotentiallyTrustworthy(url)) {
    return true;
  }

  if (base::Contains(GetServiceWorkerSchemes(), url.scheme())) {
    return true;
  }

  return false;
}

}  // namespace content