Index: chrome/browser/extensions/execute_code_in_tab_function.cc |
diff --git a/chrome/browser/extensions/execute_code_in_tab_function.cc b/chrome/browser/extensions/execute_code_in_tab_function.cc |
index 35e7b3cd8bd4e11f3ace072f2e1bb022a5b92b4c..2c8b5295fbc1d821d1cce10390dd64e41899238f 100644 |
--- a/chrome/browser/extensions/execute_code_in_tab_function.cc |
+++ b/chrome/browser/extensions/execute_code_in_tab_function.cc |
@@ -22,6 +22,7 @@ |
#include "chrome/common/extensions/extension_l10n_util.h" |
#include "chrome/common/extensions/extension_message_bundle.h" |
#include "chrome/common/extensions/extension_messages.h" |
+#include "chrome/common/extensions/user_script.h" |
Aaron Boodman
2012/03/03 00:59:10
Since you include the header in the .h file, it is
eaugusti
2012/03/27 00:43:33
Done.
|
#include "content/browser/renderer_host/render_view_host.h" |
#include "content/browser/renderer_host/render_view_host.h" |
#include "content/public/browser/web_contents.h" |
@@ -32,7 +33,8 @@ namespace keys = extension_tabs_module_constants; |
ExecuteCodeInTabFunction::ExecuteCodeInTabFunction() |
: execute_tab_id_(-1), |
- all_frames_(false) { |
+ all_frames_(false), |
+ run_at_(UserScript::DOCUMENT_IDLE) { |
} |
ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() { |
@@ -96,6 +98,23 @@ bool ExecuteCodeInTabFunction::RunImpl() { |
return false; |
} |
+ if (script_info->HasKey(keys::kRunAtKey)) { |
+ std::string run_string; |
+ if (!script_info->GetString(keys::kRunAtKey, &run_string)) |
Aaron Boodman
2012/03/03 00:59:10
You can do:
EXTENSION_FUNCTION_VALIDATE(script_in
eaugusti
2012/03/27 00:43:33
Done.
|
+ return false; |
+ |
+ if (run_string == keys::kRunAtNow) |
+ run_at_ = UserScript::DOCUMENT_NOW; |
+ else if (run_string == keys::kRunAtDocumentStart) |
+ run_at_ = UserScript::DOCUMENT_START; |
+ else if (run_string == keys::kRunAtDocumentEnd) |
+ run_at_ = UserScript::DOCUMENT_END; |
+ else if (run_string == keys::kRunAtDocumentIdle) |
+ run_at_ = UserScript::DOCUMENT_IDLE; |
+ else |
+ return false; |
Aaron Boodman
2012/03/03 00:59:10
same here, this can be EXTENSION_FUNCTION_VALIDATE
eaugusti
2012/03/27 00:43:33
Done.
|
+ } |
+ |
std::string code_string; |
if (script_info->HasKey(keys::kCodeKey)) { |
if (!script_info->GetString(keys::kCodeKey, &code_string)) |
@@ -223,6 +242,7 @@ bool ExecuteCodeInTabFunction::Execute(const std::string& code_string) { |
params.is_javascript = is_js_code; |
params.code = code_string; |
params.all_frames = all_frames_; |
+ params.run_at = run_at_; |
params.in_main_world = false; |
contents->web_contents()->GetRenderViewHost()->Send( |
new ExtensionMsg_ExecuteCode( |