| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_URL_PATTERN_SET_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_URL_PATTERN_SET_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_URL_PATTERN_SET_H_ | 6 #define CHROME_COMMON_EXTENSIONS_URL_PATTERN_SET_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "chrome/common/extensions/url_pattern.h" | 11 #include "chrome/common/extensions/url_pattern.h" |
| 12 | 12 |
| 13 class GURL; | 13 class GURL; |
| 14 | 14 |
| 15 // Represents the set of URLs an extension uses for web content. | 15 // Represents the set of URLs an extension uses for web content. |
| 16 class URLPatternSet { | 16 class URLPatternSet { |
| 17 public: | 17 public: |
| 18 // Clears |out| and populates the set with the union of |set1| and |set2|. |
| 19 // NOTE: this does not discard duplicates. |
| 20 static void CreateUnion(const URLPatternSet& set1, |
| 21 const URLPatternSet& set2, |
| 22 URLPatternSet* out); |
| 23 |
| 18 URLPatternSet(); | 24 URLPatternSet(); |
| 19 URLPatternSet(const URLPatternSet& rhs); | 25 URLPatternSet(const URLPatternSet& rhs); |
| 20 ~URLPatternSet(); | 26 ~URLPatternSet(); |
| 21 URLPatternSet& operator=(const URLPatternSet& rhs); | 27 URLPatternSet& operator=(const URLPatternSet& rhs); |
| 22 | 28 |
| 23 bool is_empty() const; | 29 bool is_empty() const; |
| 24 | 30 |
| 25 const URLPatternList& patterns() const { return patterns_; } | 31 const URLPatternList& patterns() const { return patterns_; } |
| 26 void AddPattern(const URLPattern& pattern); | 32 void AddPattern(const URLPattern& pattern); |
| 27 void ClearPatterns(); | 33 void ClearPatterns(); |
| 28 | 34 |
| 29 // Test if the extent contains a URL. | 35 // Test if the extent contains a URL. |
| 30 bool MatchesURL(const GURL& url) const; | 36 bool MatchesURL(const GURL& url) const; |
| 31 | 37 |
| 32 // Returns true if there is a single URL that would be in two extents. | 38 // Returns true if there is a single URL that would be in two extents. |
| 33 bool OverlapsWith(const URLPatternSet& other) const; | 39 bool OverlapsWith(const URLPatternSet& other) const; |
| 34 | 40 |
| 35 private: | 41 private: |
| 36 // The list of URL patterns that comprise the extent. | 42 // The list of URL patterns that comprise the extent. |
| 37 URLPatternList patterns_; | 43 URLPatternList patterns_; |
| 38 }; | 44 }; |
| 39 | 45 |
| 40 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_SET_H_ | 46 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_SET_H_ |
| OLD | NEW |