| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/callback_forward.h" |
| 12 #include "chrome/common/extensions/user_script.h" |
| 13 |
| 14 namespace content { |
| 15 class WebContents; |
| 16 } |
| 17 |
| 18 namespace extensions { |
| 19 |
| 20 // Interface for executing extension content scripts (e.g. executeScript) as |
| 21 // described by the ExtensionMsg_ExecuteCode_Params IPC, and notifying the |
| 22 // caller when responded with ExtensionHostMsg_ExecuteCodeFinished. |
| 23 class ScriptExecutor { |
| 24 public: |
| 25 virtual ~ScriptExecutor() {} |
| 26 |
| 27 // Callback from ExecuteScript. The arguments are (success, error). |
| 28 typedef base::Callback<void(bool, const std::string&)> ExecuteScriptCallback; |
| 29 |
| 30 // Executes a script. The arguments match ExtensionMsg_ExecuteCode_Params in |
| 31 // extension_messages.h (request_id is populated automatically). |
| 32 // |
| 33 // |callback| will always be called even if the IPC'd renderer is destroyed |
| 34 // before a response is received (in this case the callback will be with a |
| 35 // failure and appropriate error message). |
| 36 virtual void ExecuteScript(const std::string& extension_id, |
| 37 bool is_javascript, |
| 38 const std::string& code, |
| 39 bool all_frames, |
| 40 UserScript::RunLocation run_at, |
| 41 bool in_main_world, |
| 42 const ExecuteScriptCallback& callback) = 0; |
| 43 }; |
| 44 |
| 45 } // namespace extensions |
| 46 |
| 47 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_H_ |
| OLD | NEW |