summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/extension_extent.cc
blob: f71629135427cad29903ef09489eb32639035ecb (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
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/common/extensions/extension_extent.h"

#include "base/string_util.h"

bool ExtensionExtent::ContainsURL(const GURL& url) const {
  if (origin_.is_empty() || !url.is_valid())
    return false;

  if (url.GetOrigin() != origin_)
    return false;

  if (paths_.empty())
    return true;

  for (size_t i = 0; i < paths_.size(); ++i) {
    if (StartsWithASCII(url.path(),
                        std::string("/") + paths_[i],
                        false)) {  // not case sensitive
      return true;
    }
  }

  return false;
}