Chromium Code Reviews| Index: chrome/browser/extensions/script_executor.h |
| diff --git a/chrome/browser/extensions/script_executor.h b/chrome/browser/extensions/script_executor.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..50d17e85adc344220d5de272b54e7064bd6edcf2 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/script_executor.h |
| @@ -0,0 +1,47 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_H_ |
| +#pragma once |
| + |
| +#include <string> |
| + |
| +#include "base/callback_forward.h" |
| +#include "chrome/common/extensions/user_script.h" |
| + |
| +namespace content { |
| +class WebContents; |
| +} |
| + |
| +namespace extensions { |
| + |
| +// Interface for executing extension content scripts (e.g. executeScript) as |
|
koz (OOO until 15th September)
2012/05/11 01:09:16
Woah, an interface! What is this, Java? :-P
not at google - send to devlin
2012/05/14 02:27:16
I wish!
|
| +// described by the ExtensionMsg_ExecuteCode_Params IPC, and notifying the |
| +// caller when responded with ExtensionHostMsg_ExecuteCodeFinished. |
| +class ScriptExecutor { |
| + public: |
| + virtual ~ScriptExecutor() {} |
| + |
| + // Callback from ExecuteScript. The arguments are (success, error). |
| + typedef base::Callback<void(bool, const std::string&)> ExecuteScriptCallback; |
| + |
| + // Executes a script. The arguments match ExtensionMsg_ExecuteCode_Params in |
| + // extension_messages.h (request_id is populated automatically). |
| + // |
| + // |callback| will always be called even if the IPC'd renderer is destroyed |
| + // before a response is received (in this case the callback will be with a |
| + // failure and appropriate error message). |
| + virtual void ExecuteScript(const std::string& extension_id, |
|
koz (OOO until 15th September)
2012/05/11 01:09:16
I notice that the call sites here become less read
not at google - send to devlin
2012/05/14 02:27:16
I agree these parameters are confusing; particular
|
| + bool is_javascript, |
| + const std::string& code, |
| + bool all_frames, |
| + UserScript::RunLocation run_at, |
| + bool in_main_world, |
| + const ExecuteScriptCallback& callback) = 0; |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_H_ |