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

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

Issue 430003: Revert change that disallowed content scripts access to file:// (Closed)
Patch Set: Can't go back, only through Created 11 years, 1 month 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 IntToString(definition_index), IntToString(j)); 240 IntToString(definition_index), IntToString(j));
241 return false; 241 return false;
242 } 242 }
243 243
244 URLPattern pattern; 244 URLPattern pattern;
245 if (!pattern.Parse(match_str)) { 245 if (!pattern.Parse(match_str)) {
246 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatch, 246 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatch,
247 IntToString(definition_index), IntToString(j)); 247 IntToString(definition_index), IntToString(j));
248 return false; 248 return false;
249 } 249 }
250 std::string scheme = pattern.scheme();
251 if (scheme == "file") {
252 // No content scripts are allowed unless the command line override switch
253 // was provided.
254 if (!CommandLine::ForCurrentProcess()->HasSwitch(
255 switches::kEnableJsOnFileUrls)) {
256 continue;
257 }
258 }
259 250
260 result->add_url_pattern(pattern); 251 result->add_url_pattern(pattern);
261 } 252 }
262 253
263 // Include/exclude globs (mostly for Greasemonkey compatibility). 254 // include/exclude globs (mostly for Greasemonkey compat)
264 if (!LoadGlobsHelper(content_script, definition_index, keys::kIncludeGlobs, 255 if (!LoadGlobsHelper(content_script, definition_index, keys::kIncludeGlobs,
265 error, &UserScript::add_glob, result)) { 256 error, &UserScript::add_glob, result)) {
266 return false; 257 return false;
267 } 258 }
268 259
269 if (!LoadGlobsHelper(content_script, definition_index, keys::kExcludeGlobs, 260 if (!LoadGlobsHelper(content_script, definition_index, keys::kExcludeGlobs,
270 error, &UserScript::add_exclude_glob, result)) { 261 error, &UserScript::add_exclude_glob, result)) {
271 return false; 262 return false;
272 } 263 }
273 264
274 // js and css keys. 265 // js and css keys
275 ListValue* js = NULL; 266 ListValue* js = NULL;
276 if (content_script->HasKey(keys::kJs) && 267 if (content_script->HasKey(keys::kJs) &&
277 !content_script->GetList(keys::kJs, &js)) { 268 !content_script->GetList(keys::kJs, &js)) {
278 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidJsList, 269 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidJsList,
279 IntToString(definition_index)); 270 IntToString(definition_index));
280 return false; 271 return false;
281 } 272 }
282 273
283 ListValue* css = NULL; 274 ListValue* css = NULL;
284 if (content_script->HasKey(keys::kCss) && 275 if (content_script->HasKey(keys::kCss) &&
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 UserScript::PatternList::const_iterator pattern = 1253 UserScript::PatternList::const_iterator pattern =
1263 content_script->url_patterns().begin(); 1254 content_script->url_patterns().begin();
1264 for (; pattern != content_script->url_patterns().end(); ++pattern) { 1255 for (; pattern != content_script->url_patterns().end(); ++pattern) {
1265 if (pattern->match_subdomains() && pattern->host().empty()) 1256 if (pattern->match_subdomains() && pattern->host().empty())
1266 return true; 1257 return true;
1267 } 1258 }
1268 } 1259 }
1269 1260
1270 return false; 1261 return false;
1271 } 1262 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698