OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/extensions/script_executor.h" | 5 #include "chrome/browser/extensions/script_executor.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
10 #include "chrome/browser/extensions/active_script_controller.h" | 10 #include "chrome/browser/extensions/active_script_controller.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 script_observers_(script_observers) { | 111 script_observers_(script_observers) { |
112 CHECK(web_contents_); | 112 CHECK(web_contents_); |
113 } | 113 } |
114 | 114 |
115 ScriptExecutor::~ScriptExecutor() {} | 115 ScriptExecutor::~ScriptExecutor() {} |
116 | 116 |
117 void ScriptExecutor::ExecuteScript(const std::string& extension_id, | 117 void ScriptExecutor::ExecuteScript(const std::string& extension_id, |
118 ScriptExecutor::ScriptType script_type, | 118 ScriptExecutor::ScriptType script_type, |
119 const std::string& code, | 119 const std::string& code, |
120 ScriptExecutor::FrameScope frame_scope, | 120 ScriptExecutor::FrameScope frame_scope, |
| 121 ScriptExecutor::MatchAboutBlank about_blank, |
121 UserScript::RunLocation run_at, | 122 UserScript::RunLocation run_at, |
122 ScriptExecutor::WorldType world_type, | 123 ScriptExecutor::WorldType world_type, |
123 ScriptExecutor::ProcessType process_type, | 124 ScriptExecutor::ProcessType process_type, |
124 const GURL& webview_src, | 125 const GURL& webview_src, |
125 const GURL& file_url, | 126 const GURL& file_url, |
126 bool user_gesture, | 127 bool user_gesture, |
127 ScriptExecutor::ResultType result_type, | 128 ScriptExecutor::ResultType result_type, |
128 const ExecuteScriptCallback& callback) { | 129 const ExecuteScriptCallback& callback) { |
129 ActiveScriptController* active_script_controller = | 130 ActiveScriptController* active_script_controller = |
130 ActiveScriptController::GetForWebContents(web_contents_); | 131 ActiveScriptController::GetForWebContents(web_contents_); |
131 content::NavigationEntry* visible_entry = | 132 content::NavigationEntry* visible_entry = |
132 web_contents_->GetController().GetVisibleEntry(); | 133 web_contents_->GetController().GetVisibleEntry(); |
133 if (active_script_controller && visible_entry) { | 134 if (active_script_controller && visible_entry) { |
134 // TODO(rdevlin.cronin): Now, this is just a notification. Soon, it should | 135 // TODO(rdevlin.cronin): Now, this is just a notification. Soon, it should |
135 // block until the user gives the OK to execute. | 136 // block until the user gives the OK to execute. |
136 active_script_controller->NotifyScriptExecuting(extension_id, | 137 active_script_controller->NotifyScriptExecuting(extension_id, |
137 visible_entry->GetPageID()); | 138 visible_entry->GetPageID()); |
138 } | 139 } |
139 | |
140 ExtensionMsg_ExecuteCode_Params params; | 140 ExtensionMsg_ExecuteCode_Params params; |
141 params.request_id = next_request_id_++; | 141 params.request_id = next_request_id_++; |
142 params.extension_id = extension_id; | 142 params.extension_id = extension_id; |
143 params.is_javascript = (script_type == JAVASCRIPT); | 143 params.is_javascript = (script_type == JAVASCRIPT); |
144 params.code = code; | 144 params.code = code; |
145 params.all_frames = (frame_scope == ALL_FRAMES); | 145 params.all_frames = (frame_scope == ALL_FRAMES); |
| 146 params.match_about_blank = (about_blank == MATCH_ABOUT_BLANK); |
146 params.run_at = static_cast<int>(run_at); | 147 params.run_at = static_cast<int>(run_at); |
147 params.in_main_world = (world_type == MAIN_WORLD); | 148 params.in_main_world = (world_type == MAIN_WORLD); |
148 params.is_web_view = (process_type == WEB_VIEW_PROCESS); | 149 params.is_web_view = (process_type == WEB_VIEW_PROCESS); |
149 params.webview_src = webview_src; | 150 params.webview_src = webview_src; |
150 params.file_url = file_url; | 151 params.file_url = file_url; |
151 params.wants_result = (result_type == JSON_SERIALIZED_RESULT); | 152 params.wants_result = (result_type == JSON_SERIALIZED_RESULT); |
152 params.user_gesture = user_gesture; | 153 params.user_gesture = user_gesture; |
153 | 154 |
154 // Handler handles IPCs and deletes itself on completion. | 155 // Handler handles IPCs and deletes itself on completion. |
155 new Handler(script_observers_, web_contents_, params, callback); | 156 new Handler(script_observers_, web_contents_, params, callback); |
156 } | 157 } |
157 | 158 |
158 } // namespace extensions | 159 } // namespace extensions |
OLD | NEW |