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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 ScriptExecutor::ScriptExecutor( | 102 ScriptExecutor::ScriptExecutor( |
103 content::WebContents* web_contents, | 103 content::WebContents* web_contents, |
104 ObserverList<TabHelper::ScriptExecutionObserver>* script_observers) | 104 ObserverList<TabHelper::ScriptExecutionObserver>* script_observers) |
105 : next_request_id_(0), | 105 : next_request_id_(0), |
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(const std::string& extension_id, |
112 const std::string& extension_id, | 112 ScriptExecutor::ScriptType script_type, |
113 ScriptExecutor::ScriptType script_type, | 113 const std::string& code, |
114 const std::string& code, | 114 ScriptExecutor::FrameScope frame_scope, |
115 ScriptExecutor::FrameScope frame_scope, | 115 UserScript::RunLocation run_at, |
116 UserScript::RunLocation run_at, | 116 ScriptExecutor::WorldType world_type, |
117 ScriptExecutor::WorldType world_type, | 117 ScriptExecutor::ProcessType process_type, |
118 ScriptExecutor::ProcessType process_type, | 118 const std::string webview_src, |
119 const GURL& file_url, | 119 const GURL& file_url, |
120 bool user_gesture, | 120 bool user_gesture, |
121 ScriptExecutor::ResultType result_type, | 121 ScriptExecutor::ResultType result_type, |
122 const ExecuteScriptCallback& callback) { | 122 const ExecuteScriptCallback& callback) { |
123 ExtensionMsg_ExecuteCode_Params params; | 123 ExtensionMsg_ExecuteCode_Params params; |
124 params.request_id = next_request_id_++; | 124 params.request_id = next_request_id_++; |
125 params.extension_id = extension_id; | 125 params.extension_id = extension_id; |
126 params.is_javascript = (script_type == JAVASCRIPT); | 126 params.is_javascript = (script_type == JAVASCRIPT); |
127 params.code = code; | 127 params.code = code; |
128 params.all_frames = (frame_scope == ALL_FRAMES); | 128 params.all_frames = (frame_scope == ALL_FRAMES); |
129 params.run_at = static_cast<int>(run_at); | 129 params.run_at = static_cast<int>(run_at); |
130 params.in_main_world = (world_type == MAIN_WORLD); | 130 params.in_main_world = (world_type == MAIN_WORLD); |
131 params.is_web_view = (process_type == WEB_VIEW_PROCESS); | 131 params.is_web_view = (process_type == WEB_VIEW_PROCESS); |
| 132 params.webview_src = webview_src; |
132 params.file_url = file_url; | 133 params.file_url = file_url; |
133 params.wants_result = (result_type == JSON_SERIALIZED_RESULT); | 134 params.wants_result = (result_type == JSON_SERIALIZED_RESULT); |
134 params.user_gesture = user_gesture; | 135 params.user_gesture = user_gesture; |
135 | 136 |
136 // Handler handles IPCs and deletes itself on completion. | 137 // Handler handles IPCs and deletes itself on completion. |
137 new Handler(script_observers_, web_contents_, params, callback); | 138 new Handler(script_observers_, web_contents_, params, callback); |
138 } | 139 } |
139 | 140 |
140 } // namespace extensions | 141 } // namespace extensions |
OLD | NEW |