Home | History | Annotate | Download | only in extensions
      1 // Copyright (c) 2010 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.
      4 
      5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_EXTENT_H_
      6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_EXTENT_H_
      7 #pragma once
      8 
      9 #include <vector>
     10 
     11 class GURL;
     12 class URLPattern;
     13 
     14 // Represents the set of URLs an extension uses for web content.
     15 class ExtensionExtent {
     16  public:
     17   typedef std::vector<URLPattern> PatternList;
     18 
     19   ExtensionExtent();
     20   ExtensionExtent(const ExtensionExtent& rhs);
     21   ~ExtensionExtent();
     22   ExtensionExtent& operator=(const ExtensionExtent& rhs);
     23 
     24   bool is_empty() const;
     25 
     26   const PatternList& patterns() const { return patterns_; }
     27   void AddPattern(const URLPattern& pattern);
     28   void ClearPaths();
     29 
     30   // Test if the extent contains a URL.
     31   bool ContainsURL(const GURL& url) const;
     32 
     33   // Returns true if there is a single URL that would be in two extents.
     34   bool OverlapsWith(const ExtensionExtent& other) const;
     35 
     36  private:
     37   // The list of URL patterns that comprise the extent.
     38   PatternList patterns_;
     39 };
     40 
     41 #endif  // CHROME_COMMON_EXTENSIONS_EXTENSION_EXTENT_H_
     42