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

Side by Side Diff: chrome/common/extensions/user_script.cc

Issue 7229012: Use extension match pattern syntax in content settings extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 9 years, 5 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) 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 #include "chrome/common/extensions/user_script.h" 5 #include "chrome/common/extensions/user_script.h"
6 6
7 #include "base/pickle.h" 7 #include "base/pickle.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 9
10 namespace { 10 namespace {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 URLPattern pattern(valid_schemes); 186 URLPattern pattern(valid_schemes);
187 CHECK(pickle.ReadString(iter, &pattern_str)); 187 CHECK(pickle.ReadString(iter, &pattern_str));
188 188
189 // We remove the file scheme if it's not actually allowed (see Extension:: 189 // We remove the file scheme if it's not actually allowed (see Extension::
190 // LoadUserScriptHelper), but we need it temporarily while loading the 190 // LoadUserScriptHelper), but we need it temporarily while loading the
191 // pattern so that it's valid. 191 // pattern so that it's valid.
192 bool had_file_scheme = (valid_schemes & URLPattern::SCHEME_FILE) != 0; 192 bool had_file_scheme = (valid_schemes & URLPattern::SCHEME_FILE) != 0;
193 if (!had_file_scheme) 193 if (!had_file_scheme)
194 pattern.set_valid_schemes(valid_schemes | URLPattern::SCHEME_FILE); 194 pattern.set_valid_schemes(valid_schemes | URLPattern::SCHEME_FILE);
195 CHECK(URLPattern::PARSE_SUCCESS == 195 CHECK(URLPattern::PARSE_SUCCESS ==
196 pattern.Parse(pattern_str, URLPattern::PARSE_LENIENT)); 196 pattern.Parse(pattern_str, URLPattern::IGNORE_PORTS));
197 if (!had_file_scheme) 197 if (!had_file_scheme)
198 pattern.set_valid_schemes(valid_schemes); 198 pattern.set_valid_schemes(valid_schemes);
199 199
200 url_set_.AddPattern(pattern); 200 url_set_.AddPattern(pattern);
201 } 201 }
202 202
203 // Read js scripts. 203 // Read js scripts.
204 size_t num_js_files = 0; 204 size_t num_js_files = 0;
205 CHECK(pickle.ReadSize(iter, &num_js_files)); 205 CHECK(pickle.ReadSize(iter, &num_js_files));
206 js_scripts_.clear(); 206 js_scripts_.clear();
207 for (size_t i = 0; i < num_js_files; ++i) { 207 for (size_t i = 0; i < num_js_files; ++i) {
208 File file; 208 File file;
209 file.Unpickle(pickle, iter); 209 file.Unpickle(pickle, iter);
210 js_scripts_.push_back(file); 210 js_scripts_.push_back(file);
211 } 211 }
212 212
213 // Read css scripts. 213 // Read css scripts.
214 size_t num_css_files = 0; 214 size_t num_css_files = 0;
215 CHECK(pickle.ReadSize(iter, &num_css_files)); 215 CHECK(pickle.ReadSize(iter, &num_css_files));
216 css_scripts_.clear(); 216 css_scripts_.clear();
217 for (size_t i = 0; i < num_css_files; ++i) { 217 for (size_t i = 0; i < num_css_files; ++i) {
218 File file; 218 File file;
219 file.Unpickle(pickle, iter); 219 file.Unpickle(pickle, iter);
220 css_scripts_.push_back(file); 220 css_scripts_.push_back(file);
221 } 221 }
222 } 222 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698