| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ |
| 6 #define EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ | 6 #define EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ |
| 7 | 7 |
| 8 #include "extensions/browser/api/execute_code_function.h" | 8 #include "extensions/browser/api/execute_code_function.h" |
| 9 | 9 |
| 10 #include "extensions/browser/component_extension_resource_manager.h" | 10 #include "extensions/browser/component_extension_resource_manager.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 kLoadFileError, resource_.relative_path().AsUTF8Unsafe()); | 122 kLoadFileError, resource_.relative_path().AsUTF8Unsafe()); |
| 123 SendResponse(false); | 123 SendResponse(false); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 bool ExecuteCodeFunction::Execute(const std::string& code_string) { | 127 bool ExecuteCodeFunction::Execute(const std::string& code_string) { |
| 128 ScriptExecutor* executor = GetScriptExecutor(); | 128 ScriptExecutor* executor = GetScriptExecutor(); |
| 129 if (!executor) | 129 if (!executor) |
| 130 return false; | 130 return false; |
| 131 | 131 |
| 132 if (!extension()) | 132 if (!extension() && !IsWebView()) |
| 133 return false; | 133 return false; |
| 134 | 134 |
| 135 ScriptExecutor::ScriptType script_type = ScriptExecutor::JAVASCRIPT; | 135 ScriptExecutor::ScriptType script_type = ScriptExecutor::JAVASCRIPT; |
| 136 if (ShouldInsertCSS()) | 136 if (ShouldInsertCSS()) |
| 137 script_type = ScriptExecutor::CSS; | 137 script_type = ScriptExecutor::CSS; |
| 138 | 138 |
| 139 ScriptExecutor::FrameScope frame_scope = | 139 ScriptExecutor::FrameScope frame_scope = |
| 140 details_->all_frames.get() && *details_->all_frames | 140 details_->all_frames.get() && *details_->all_frames |
| 141 ? ScriptExecutor::ALL_FRAMES | 141 ? ScriptExecutor::ALL_FRAMES |
| 142 : ScriptExecutor::TOP_FRAME; | 142 : ScriptExecutor::TOP_FRAME; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 155 case InjectDetails::RUN_AT_DOCUMENT_START: | 155 case InjectDetails::RUN_AT_DOCUMENT_START: |
| 156 run_at = UserScript::DOCUMENT_START; | 156 run_at = UserScript::DOCUMENT_START; |
| 157 break; | 157 break; |
| 158 case InjectDetails::RUN_AT_DOCUMENT_END: | 158 case InjectDetails::RUN_AT_DOCUMENT_END: |
| 159 run_at = UserScript::DOCUMENT_END; | 159 run_at = UserScript::DOCUMENT_END; |
| 160 break; | 160 break; |
| 161 } | 161 } |
| 162 CHECK_NE(UserScript::UNDEFINED, run_at); | 162 CHECK_NE(UserScript::UNDEFINED, run_at); |
| 163 | 163 |
| 164 executor->ExecuteScript( | 164 executor->ExecuteScript( |
| 165 extension()->id(), | 165 host_id_, |
| 166 script_type, | 166 script_type, |
| 167 code_string, | 167 code_string, |
| 168 frame_scope, | 168 frame_scope, |
| 169 match_about_blank, | 169 match_about_blank, |
| 170 run_at, | 170 run_at, |
| 171 ScriptExecutor::ISOLATED_WORLD, | 171 ScriptExecutor::ISOLATED_WORLD, |
| 172 IsWebView() ? ScriptExecutor::WEB_VIEW_PROCESS | 172 IsWebView() ? ScriptExecutor::WEB_VIEW_PROCESS |
| 173 : ScriptExecutor::DEFAULT_PROCESS, | 173 : ScriptExecutor::DEFAULT_PROCESS, |
| 174 GetWebViewSrc(), | 174 GetWebViewSrc(), |
| 175 file_url_, | 175 file_url_, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 const base::ListValue& result) { | 237 const base::ListValue& result) { |
| 238 if (!error.empty()) | 238 if (!error.empty()) |
| 239 SetError(error); | 239 SetError(error); |
| 240 | 240 |
| 241 SendResponse(error.empty()); | 241 SendResponse(error.empty()); |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace extensions | 244 } // namespace extensions |
| 245 | 245 |
| 246 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ | 246 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ |
| OLD | NEW |