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

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

Issue 396033002: Support "always allow" for runtime script execution (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: S'more changes Created 6 years, 4 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
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 #include "extensions/common/url_pattern_set.h" 5 #include "extensions/common/url_pattern_set.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <ostream> 8 #include <ostream>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 void URLPatternSet::AddPatterns(const URLPatternSet& set) { 136 void URLPatternSet::AddPatterns(const URLPatternSet& set) {
137 patterns_.insert(set.patterns().begin(), 137 patterns_.insert(set.patterns().begin(),
138 set.patterns().end()); 138 set.patterns().end());
139 } 139 }
140 140
141 void URLPatternSet::ClearPatterns() { 141 void URLPatternSet::ClearPatterns() {
142 patterns_.clear(); 142 patterns_.clear();
143 } 143 }
144 144
145 bool URLPatternSet::AddOrigin(int valid_schemes, const GURL& origin) {
146 DCHECK_EQ(origin.GetOrigin(), origin);
147 URLPattern origin_pattern(valid_schemes);
148 // Origin adding could fail if |origin| does not match |valid_schemes|.
149 if (origin_pattern.Parse(origin.GetOrigin().spec()) !=
150 URLPattern::PARSE_SUCCESS) {
151 return false;
152 }
153 origin_pattern.SetPath("/*");
154 return AddPattern(origin_pattern);
155 }
156
145 bool URLPatternSet::Contains(const URLPatternSet& other) const { 157 bool URLPatternSet::Contains(const URLPatternSet& other) const {
146 for (URLPatternSet::const_iterator it = other.begin(); 158 for (URLPatternSet::const_iterator it = other.begin();
147 it != other.end(); ++it) { 159 it != other.end(); ++it) {
148 if (!ContainsPattern(*it)) 160 if (!ContainsPattern(*it))
149 return false; 161 return false;
150 } 162 }
151 163
152 return true; 164 return true;
153 } 165 }
154 166
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 for (size_t i = 0; i < value.GetSize(); ++i) { 269 for (size_t i = 0; i < value.GetSize(); ++i) {
258 std::string item; 270 std::string item;
259 if (!value.GetString(i, &item)) 271 if (!value.GetString(i, &item))
260 return false; 272 return false;
261 patterns.push_back(item); 273 patterns.push_back(item);
262 } 274 }
263 return Populate(patterns, valid_schemes, allow_file_access, error); 275 return Populate(patterns, valid_schemes, allow_file_access, error);
264 } 276 }
265 277
266 } // namespace extensions 278 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698