summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/extension_extent.h
blob: 187303d5ad9cba54872a2e12881cead4e9c1f6a0 (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
34
// 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.

#ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_EXTENT_H_
#define CHROME_COMMON_EXTENSIONS_EXTENSION_EXTENT_H_

#include <string>
#include <vector>

#include "googleurl/src/gurl.h"

// Represents the set of URLs an extension uses for web content.
class ExtensionExtent {
 public:
  const std::vector<std::string>& paths() const { return paths_; }
  void add_path(const std::string& val) { paths_.push_back(val); }
  void clear_paths() { paths_.clear(); }

  const GURL& origin() const { return origin_; }
  void set_origin(const GURL& val) { origin_ = val; }

  bool ContainsURL(const GURL& url) const;

 private:
  // The security origin (scheme+host+port) of the extent.
  GURL origin_;

  // A set of path prefixes that further restrict the set of valid URLs below
  // origin_. This may be empty.
  std::vector<std::string> paths_;
};

#endif  // CHROME_COMMON_EXTENSIONS_EXTENSION_EXTENT_H_