Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: extensions/common/url_pattern_set.h

Issue 12209094: Support requesting subsets of host permissions using the permissions API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix urlpatternsettest Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 EXTENSIONS_COMMMON_URL_PATTERN_SET_H_ 5 #ifndef EXTENSIONS_COMMMON_URL_PATTERN_SET_H_
6 #define EXTENSIONS_COMMMON_URL_PATTERN_SET_H_ 6 #define EXTENSIONS_COMMMON_URL_PATTERN_SET_H_
7 7
8 #include <ostream>
8 #include <set> 9 #include <set>
9 10
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "extensions/common/url_pattern.h" 12 #include "extensions/common/url_pattern.h"
12 13
13 class GURL; 14 class GURL;
14 15
15 namespace base { 16 namespace base {
16 class ListValue; 17 class ListValue;
17 class Value; 18 class Value;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 62
62 // Adds a pattern to the set. Returns true if a new pattern was inserted, 63 // Adds a pattern to the set. Returns true if a new pattern was inserted,
63 // false if the pattern was already in the set. 64 // false if the pattern was already in the set.
64 bool AddPattern(const URLPattern& pattern); 65 bool AddPattern(const URLPattern& pattern);
65 66
66 // Adds all patterns from |set| into this. 67 // Adds all patterns from |set| into this.
67 void AddPatterns(const URLPatternSet& set); 68 void AddPatterns(const URLPatternSet& set);
68 69
69 void ClearPatterns(); 70 void ClearPatterns();
70 71
71 // Returns true if the permission |set| is a subset of this. 72 // Returns true if every URL that matches |set| is matched by this. In other
73 // words, if every pattern in |set| is encompassed by a pattern in this.
72 bool Contains(const URLPatternSet& set) const; 74 bool Contains(const URLPatternSet& set) const;
73 75
74 // Test if the extent contains a URL. 76 // Test if the extent contains a URL.
75 bool MatchesURL(const GURL& url) const; 77 bool MatchesURL(const GURL& url) const;
76 78
77 bool MatchesSecurityOrigin(const GURL& origin) const; 79 bool MatchesSecurityOrigin(const GURL& origin) const;
78 80
79 // Returns true if there is a single URL that would be in two extents. 81 // Returns true if there is a single URL that would be in two extents.
80 bool OverlapsWith(const URLPatternSet& other) const; 82 bool OverlapsWith(const URLPatternSet& other) const;
81 83
82 // Converts to and from Value for serialization to preferences. 84 // Converts to and from Value for serialization to preferences.
83 scoped_ptr<base::ListValue> ToValue() const; 85 scoped_ptr<base::ListValue> ToValue() const;
84 bool Populate(const base::ListValue& value, 86 bool Populate(const base::ListValue& value,
85 int valid_schemes, 87 int valid_schemes,
86 bool allow_file_access, 88 bool allow_file_access,
87 std::string* error); 89 std::string* error);
88 90
89 bool Populate(const std::vector<std::string>& patterns, 91 bool Populate(const std::vector<std::string>& patterns,
90 int valid_schemes, 92 int valid_schemes,
91 bool allow_file_access, 93 bool allow_file_access,
92 std::string* error); 94 std::string* error);
93 95
94 private: 96 private:
97 // Returns true if any pattern in this set encompasses |pattern|.
98 bool Encompasses(const URLPattern& pattern) const;
99
95 // The list of URL patterns that comprise the extent. 100 // The list of URL patterns that comprise the extent.
96 std::set<URLPattern> patterns_; 101 std::set<URLPattern> patterns_;
97 }; 102 };
98 103
104 std::ostream& operator<<(std::ostream& out, const URLPatternSet& set);
105
99 } // namespace extensions 106 } // namespace extensions
100 107
101 #endif // EXTENSIONS_COMMMON_URL_PATTERN_SET_H_ 108 #endif // EXTENSIONS_COMMMON_URL_PATTERN_SET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698