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

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

Issue 8885022: Move URLPattern::ParseOption into a field. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more minor sprucing Created 9 years 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 // Read url patterns. 177 // Read url patterns.
178 size_t num_patterns = 0; 178 size_t num_patterns = 0;
179 CHECK(pickle.ReadSize(iter, &num_patterns)); 179 CHECK(pickle.ReadSize(iter, &num_patterns));
180 180
181 url_set_.ClearPatterns(); 181 url_set_.ClearPatterns();
182 for (size_t i = 0; i < num_patterns; ++i) { 182 for (size_t i = 0; i < num_patterns; ++i) {
183 int valid_schemes; 183 int valid_schemes;
184 CHECK(pickle.ReadInt(iter, &valid_schemes)); 184 CHECK(pickle.ReadInt(iter, &valid_schemes));
185 std::string pattern_str; 185 std::string pattern_str;
186 URLPattern pattern(valid_schemes); 186 URLPattern pattern(URLPattern::IGNORE_PORTS, 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.SetValidSchemes(valid_schemes | URLPattern::SCHEME_FILE); 194 pattern.SetValidSchemes(valid_schemes | URLPattern::SCHEME_FILE);
195 CHECK(URLPattern::PARSE_SUCCESS == 195 CHECK(URLPattern::PARSE_SUCCESS == pattern.Parse(pattern_str));
196 pattern.Parse(pattern_str, URLPattern::IGNORE_PORTS));
197 if (!had_file_scheme) 196 if (!had_file_scheme)
198 pattern.SetValidSchemes(valid_schemes); 197 pattern.SetValidSchemes(valid_schemes);
199 198
200 url_set_.AddPattern(pattern); 199 url_set_.AddPattern(pattern);
201 } 200 }
202 201
203 // Read js scripts. 202 // Read js scripts.
204 size_t num_js_files = 0; 203 size_t num_js_files = 0;
205 CHECK(pickle.ReadSize(iter, &num_js_files)); 204 CHECK(pickle.ReadSize(iter, &num_js_files));
206 js_scripts_.clear(); 205 js_scripts_.clear();
207 for (size_t i = 0; i < num_js_files; ++i) { 206 for (size_t i = 0; i < num_js_files; ++i) {
208 File file; 207 File file;
209 file.Unpickle(pickle, iter); 208 file.Unpickle(pickle, iter);
210 js_scripts_.push_back(file); 209 js_scripts_.push_back(file);
211 } 210 }
212 211
213 // Read css scripts. 212 // Read css scripts.
214 size_t num_css_files = 0; 213 size_t num_css_files = 0;
215 CHECK(pickle.ReadSize(iter, &num_css_files)); 214 CHECK(pickle.ReadSize(iter, &num_css_files));
216 css_scripts_.clear(); 215 css_scripts_.clear();
217 for (size_t i = 0; i < num_css_files; ++i) { 216 for (size_t i = 0; i < num_css_files; ++i) {
218 File file; 217 File file;
219 file.Unpickle(pickle, iter); 218 file.Unpickle(pickle, iter);
220 css_scripts_.push_back(file); 219 css_scripts_.push_back(file);
221 } 220 }
222 } 221 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/url_pattern_unittest.cc ('k') | chrome/common/extensions/user_script_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698