| 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" |
| 11 #include "chrome/browser/extensions/location_bar_controller.h" |
| 12 #include "chrome/browser/extensions/tab_helper.h" |
| 10 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
| 11 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 12 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
| 13 #include "extensions/common/extension_messages.h" | 16 #include "extensions/common/extension_messages.h" |
| 14 #include "ipc/ipc_message.h" | 17 #include "ipc/ipc_message.h" |
| 15 #include "ipc/ipc_message_macros.h" | 18 #include "ipc/ipc_message_macros.h" |
| 16 | 19 |
| 17 namespace base { | 20 namespace base { |
| 18 class ListValue; | 21 class ListValue; |
| 19 } // namespace base | 22 } // namespace base |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 const std::string& code, | 116 const std::string& code, |
| 114 ScriptExecutor::FrameScope frame_scope, | 117 ScriptExecutor::FrameScope frame_scope, |
| 115 UserScript::RunLocation run_at, | 118 UserScript::RunLocation run_at, |
| 116 ScriptExecutor::WorldType world_type, | 119 ScriptExecutor::WorldType world_type, |
| 117 ScriptExecutor::ProcessType process_type, | 120 ScriptExecutor::ProcessType process_type, |
| 118 const GURL& webview_src, | 121 const GURL& webview_src, |
| 119 const GURL& file_url, | 122 const GURL& file_url, |
| 120 bool user_gesture, | 123 bool user_gesture, |
| 121 ScriptExecutor::ResultType result_type, | 124 ScriptExecutor::ResultType result_type, |
| 122 const ExecuteScriptCallback& callback) { | 125 const ExecuteScriptCallback& callback) { |
| 126 LocationBarController* location_bar_controller = |
| 127 TabHelper::FromWebContents(web_contents_)->location_bar_controller(); |
| 128 // TODO(rdevlin.cronin): Now, this is just a notification. Soon, it should |
| 129 // block until the user gives the OK to execute. |
| 130 location_bar_controller->active_script_controller()->NotifyScriptExecuting( |
| 131 extension_id); |
| 132 |
| 123 ExtensionMsg_ExecuteCode_Params params; | 133 ExtensionMsg_ExecuteCode_Params params; |
| 124 params.request_id = next_request_id_++; | 134 params.request_id = next_request_id_++; |
| 125 params.extension_id = extension_id; | 135 params.extension_id = extension_id; |
| 126 params.is_javascript = (script_type == JAVASCRIPT); | 136 params.is_javascript = (script_type == JAVASCRIPT); |
| 127 params.code = code; | 137 params.code = code; |
| 128 params.all_frames = (frame_scope == ALL_FRAMES); | 138 params.all_frames = (frame_scope == ALL_FRAMES); |
| 129 params.run_at = static_cast<int>(run_at); | 139 params.run_at = static_cast<int>(run_at); |
| 130 params.in_main_world = (world_type == MAIN_WORLD); | 140 params.in_main_world = (world_type == MAIN_WORLD); |
| 131 params.is_web_view = (process_type == WEB_VIEW_PROCESS); | 141 params.is_web_view = (process_type == WEB_VIEW_PROCESS); |
| 132 params.webview_src = webview_src; | 142 params.webview_src = webview_src; |
| 133 params.file_url = file_url; | 143 params.file_url = file_url; |
| 134 params.wants_result = (result_type == JSON_SERIALIZED_RESULT); | 144 params.wants_result = (result_type == JSON_SERIALIZED_RESULT); |
| 135 params.user_gesture = user_gesture; | 145 params.user_gesture = user_gesture; |
| 136 | 146 |
| 137 // Handler handles IPCs and deletes itself on completion. | 147 // Handler handles IPCs and deletes itself on completion. |
| 138 new Handler(script_observers_, web_contents_, params, callback); | 148 new Handler(script_observers_, web_contents_, params, callback); |
| 139 } | 149 } |
| 140 | 150 |
| 141 } // namespace extensions | 151 } // namespace extensions |
| OLD | NEW |