| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_EXTENT_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_EXTENT_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_EXTENT_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_EXTENT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> |
| 10 #include <string> |
| 9 #include <vector> | 11 #include <vector> |
| 10 | 12 |
| 11 class GURL; | 13 class GURL; |
| 12 class URLPattern; | 14 class URLPattern; |
| 13 | 15 |
| 14 // Represents the set of URLs an extension uses for web content. | 16 // Represents the set of URLs an extension uses for web content. |
| 15 class ExtensionExtent { | 17 class ExtensionExtent { |
| 16 public: | 18 public: |
| 17 typedef std::vector<URLPattern> PatternList; | 19 typedef std::vector<URLPattern> PatternList; |
| 18 | 20 |
| 19 ExtensionExtent(); | 21 ExtensionExtent(); |
| 20 ExtensionExtent(const ExtensionExtent& rhs); | 22 ExtensionExtent(const ExtensionExtent& rhs); |
| 21 ~ExtensionExtent(); | 23 ~ExtensionExtent(); |
| 22 ExtensionExtent& operator=(const ExtensionExtent& rhs); | 24 ExtensionExtent& operator=(const ExtensionExtent& rhs); |
| 23 | 25 |
| 24 bool is_empty() const; | 26 bool is_empty() const; |
| 25 | 27 |
| 26 const PatternList& patterns() const { return patterns_; } | 28 const PatternList& patterns() const { return patterns_; } |
| 27 void AddPattern(const URLPattern& pattern); | 29 void AddPattern(const URLPattern& pattern); |
| 28 void ClearPaths(); | 30 void ClearPaths(); |
| 29 | 31 |
| 30 // Test if the extent contains a URL. | 32 // Test if the extent contains a URL. |
| 31 bool ContainsURL(const GURL& url) const; | 33 bool ContainsURL(const GURL& url) const; |
| 32 | 34 |
| 33 // Returns true if there is a single URL that would be in two extents. | 35 // Returns true if there is a single URL that would be in two extents. |
| 34 bool OverlapsWith(const ExtensionExtent& other) const; | 36 bool OverlapsWith(const ExtensionExtent& other) const; |
| 35 | 37 |
| 38 // Gets the pattern list as a set of strings. |
| 39 void GetAsStringSet(std::set<std::string>* string_patterns) const; |
| 36 private: | 40 private: |
| 37 // The list of URL patterns that comprise the extent. | 41 // The list of URL patterns that comprise the extent. |
| 38 PatternList patterns_; | 42 PatternList patterns_; |
| 39 }; | 43 }; |
| 40 | 44 |
| 41 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_EXTENT_H_ | 45 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_EXTENT_H_ |
| OLD | NEW |