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

Unified Diff: chrome/browser/extensions/execute_code_in_tab_function.cc

Issue 518013: Merge 32634 - Make executeScript and insertCSS inject code into all frames.... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/249/src/
Patch Set: Created 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/execute_code_in_tab_function.cc
===================================================================
--- chrome/browser/extensions/execute_code_in_tab_function.cc (revision 35240)
+++ chrome/browser/extensions/execute_code_in_tab_function.cc (working copy)
@@ -17,6 +17,7 @@
const wchar_t* kCodeKey = L"code";
const wchar_t* kFileKey = L"file";
+const wchar_t* kAllFramesKey = L"allFrames";
bool ExecuteCodeInTabFunction::RunImpl() {
EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST));
@@ -28,9 +29,16 @@
if (number_of_value == 0) {
error_ = keys::kNoCodeOrFileToExecuteError;
return false;
- } else if (number_of_value > 1) {
- error_ = keys::kMoreThanOneValuesError;
- return false;
+ } else {
+ bool has_code = script_info->HasKey(kCodeKey);
+ bool has_file = script_info->HasKey(kFileKey);
+ if (has_code && has_file) {
+ error_ = keys::kMoreThanOneValuesError;
+ return false;
+ } else if (!has_code && !has_file) {
+ error_ = keys::kNoCodeOrFileToExecuteError;
+ return false;
+ }
}
execute_tab_id_ = -1;
@@ -66,6 +74,11 @@
return false;
}
+ if (script_info->HasKey(kAllFramesKey)) {
+ if (!script_info->GetBoolean(kAllFramesKey, &all_frames_))
+ return false;
+ }
+
std::string code_string;
if (script_info->HasKey(kCodeKey)) {
if (!script_info->GetString(kCodeKey, &code_string))
@@ -133,7 +146,7 @@
NotificationService::AllSources());
AddRef(); // balanced in Observe()
contents->ExecuteCode(request_id(), extension_id(), is_js_code,
- code_string);
+ code_string, all_frames_);
}
void ExecuteCodeInTabFunction::Observe(NotificationType type,
« no previous file with comments | « chrome/browser/extensions/execute_code_in_tab_function.h ('k') | chrome/browser/extensions/execute_script_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698