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

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

Issue 412008: Introduce a new 'all_frames' property to content scripts and (Closed)
Patch Set: responses to comments 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 result->set_run_location(UserScript::DOCUMENT_END); 213 result->set_run_location(UserScript::DOCUMENT_END);
214 } else if (run_location == values::kRunAtDocumentIdle) { 214 } else if (run_location == values::kRunAtDocumentIdle) {
215 result->set_run_location(UserScript::DOCUMENT_IDLE); 215 result->set_run_location(UserScript::DOCUMENT_IDLE);
216 } else { 216 } else {
217 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidRunAt, 217 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidRunAt,
218 IntToString(definition_index)); 218 IntToString(definition_index));
219 return false; 219 return false;
220 } 220 }
221 } 221 }
222 222
223 // all frames
224 if (content_script->HasKey(keys::kAllFrames)) {
225 bool all_frames = false;
226 if (!content_script->GetBoolean(keys::kAllFrames, &all_frames)) {
227 *error = ExtensionErrorUtils::FormatErrorMessage(
228 errors::kInvalidAllFrames, IntToString(definition_index));
229 return false;
230 }
231 result->set_match_all_frames(all_frames);
232 }
233
223 // matches 234 // matches
224 ListValue* matches = NULL; 235 ListValue* matches = NULL;
225 if (!content_script->GetList(keys::kMatches, &matches)) { 236 if (!content_script->GetList(keys::kMatches, &matches)) {
226 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatches, 237 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatches,
227 IntToString(definition_index)); 238 IntToString(definition_index));
228 return false; 239 return false;
229 } 240 }
230 241
231 if (matches->GetSize() == 0) { 242 if (matches->GetSize() == 0) {
232 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatchCount, 243 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatchCount,
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 if (!list_value->GetDictionary(i, &content_script)) { 1007 if (!list_value->GetDictionary(i, &content_script)) {
997 *error = ExtensionErrorUtils::FormatErrorMessage( 1008 *error = ExtensionErrorUtils::FormatErrorMessage(
998 errors::kInvalidContentScript, IntToString(i)); 1009 errors::kInvalidContentScript, IntToString(i));
999 return false; 1010 return false;
1000 } 1011 }
1001 1012
1002 UserScript script; 1013 UserScript script;
1003 if (!LoadUserScriptHelper(content_script, i, error, &script)) 1014 if (!LoadUserScriptHelper(content_script, i, error, &script))
1004 return false; // Failed to parse script context definition 1015 return false; // Failed to parse script context definition
1005 script.set_extension_id(id()); 1016 script.set_extension_id(id());
1006 if (converted_from_user_script_) 1017 if (converted_from_user_script_) {
1007 script.set_emulate_greasemonkey(true); 1018 script.set_emulate_greasemonkey(true);
1019 script.set_match_all_frames(true); // greasemonkey matches all frames
1020 }
1008 content_scripts_.push_back(script); 1021 content_scripts_.push_back(script);
1009 } 1022 }
1010 } 1023 }
1011 1024
1012 // Initialize page action (optional). 1025 // Initialize page action (optional).
1013 if (source.HasKey(keys::kPageActions)) { 1026 if (source.HasKey(keys::kPageActions)) {
1014 ListValue* list_value; 1027 ListValue* list_value;
1015 if (!source.GetList(keys::kPageActions, &list_value)) { 1028 if (!source.GetList(keys::kPageActions, &list_value)) {
1016 *error = errors::kInvalidPageActionsList; 1029 *error = errors::kInvalidPageActionsList;
1017 return false; 1030 return false;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 UserScript::PatternList::const_iterator pattern = 1275 UserScript::PatternList::const_iterator pattern =
1263 content_script->url_patterns().begin(); 1276 content_script->url_patterns().begin();
1264 for (; pattern != content_script->url_patterns().end(); ++pattern) { 1277 for (; pattern != content_script->url_patterns().end(); ++pattern) {
1265 if (pattern->match_subdomains() && pattern->host().empty()) 1278 if (pattern->match_subdomains() && pattern->host().empty())
1266 return true; 1279 return true;
1267 } 1280 }
1268 } 1281 }
1269 1282
1270 return false; 1283 return false;
1271 } 1284 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/static/content_scripts.html ('k') | chrome/common/extensions/extension_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698