| 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 "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 web_contents_(web_contents), | 106 web_contents_(web_contents), |
| 107 script_observers_(script_observers) {} | 107 script_observers_(script_observers) {} |
| 108 | 108 |
| 109 ScriptExecutor::~ScriptExecutor() {} | 109 ScriptExecutor::~ScriptExecutor() {} |
| 110 | 110 |
| 111 void ScriptExecutor::ExecuteScript( | 111 void ScriptExecutor::ExecuteScript( |
| 112 const std::string& extension_id, | 112 const std::string& extension_id, |
| 113 ScriptExecutor::ScriptType script_type, | 113 ScriptExecutor::ScriptType script_type, |
| 114 const std::string& code, | 114 const std::string& code, |
| 115 ScriptExecutor::FrameScope frame_scope, | 115 ScriptExecutor::FrameScope frame_scope, |
| 116 ScriptExecutor::MatchAboutBlank match_about_blank, |
| 116 UserScript::RunLocation run_at, | 117 UserScript::RunLocation run_at, |
| 117 ScriptExecutor::WorldType world_type, | 118 ScriptExecutor::WorldType world_type, |
| 118 ScriptExecutor::ProcessType process_type, | 119 ScriptExecutor::ProcessType process_type, |
| 119 const GURL& file_url, | 120 const GURL& file_url, |
| 120 bool user_gesture, | 121 bool user_gesture, |
| 121 ScriptExecutor::ResultType result_type, | 122 ScriptExecutor::ResultType result_type, |
| 122 const ExecuteScriptCallback& callback) { | 123 const ExecuteScriptCallback& callback) { |
| 123 ExtensionMsg_ExecuteCode_Params params; | 124 ExtensionMsg_ExecuteCode_Params params; |
| 124 params.request_id = next_request_id_++; | 125 params.request_id = next_request_id_++; |
| 125 params.extension_id = extension_id; | 126 params.extension_id = extension_id; |
| 126 params.is_javascript = (script_type == JAVASCRIPT); | 127 params.is_javascript = (script_type == JAVASCRIPT); |
| 127 params.code = code; | 128 params.code = code; |
| 128 params.all_frames = (frame_scope == ALL_FRAMES); | 129 params.all_frames = (frame_scope == ALL_FRAMES); |
| 130 params.match_about_blank = (match_about_blank == MATCH_ABOUT_BLANK); |
| 129 params.run_at = static_cast<int>(run_at); | 131 params.run_at = static_cast<int>(run_at); |
| 130 params.in_main_world = (world_type == MAIN_WORLD); | 132 params.in_main_world = (world_type == MAIN_WORLD); |
| 131 params.is_web_view = (process_type == WEB_VIEW_PROCESS); | 133 params.is_web_view = (process_type == WEB_VIEW_PROCESS); |
| 132 params.file_url = file_url; | 134 params.file_url = file_url; |
| 133 params.wants_result = (result_type == JSON_SERIALIZED_RESULT); | 135 params.wants_result = (result_type == JSON_SERIALIZED_RESULT); |
| 134 params.user_gesture = user_gesture; | 136 params.user_gesture = user_gesture; |
| 135 | 137 |
| 136 // Handler handles IPCs and deletes itself on completion. | 138 // Handler handles IPCs and deletes itself on completion. |
| 137 new Handler(script_observers_, web_contents_, params, callback); | 139 new Handler(script_observers_, web_contents_, params, callback); |
| 138 } | 140 } |
| 139 | 141 |
| 140 } // namespace extensions | 142 } // namespace extensions |
| OLD | NEW |