Index: extensions/renderer/script_injection.h |
diff --git a/extensions/renderer/script_injection.h b/extensions/renderer/script_injection.h |
index d7edd666165ec3d3ed1c21f12557287748c20899..59bdf5c76599034c3e9307ab5e37a49e76ec4f33 100644 |
--- a/extensions/renderer/script_injection.h |
+++ b/extensions/renderer/script_injection.h |
@@ -5,17 +5,32 @@ |
#ifndef EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_ |
#define EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_ |
+#include <map> |
+ |
#include "base/basictypes.h" |
#include "base/macros.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/memory/scoped_vector.h" |
#include "extensions/common/user_script.h" |
#include "extensions/renderer/script_injector.h" |
+#include "extensions/renderer/scripts_run_info.h" |
+#include "v8/include/v8.h" |
namespace blink { |
class WebLocalFrame; |
+class WebScriptExecutionCallback; |
+template<typename T> class WebVector; |
+} |
+ |
+namespace v8 { |
+class Value; |
+template <class T> class Local; |
} |
namespace extensions { |
class Extension; |
+class ScriptInjectionManager; |
struct ScriptsRunInfo; |
// A script wrapper which is aware of whether or not it is allowed to execute, |
@@ -41,31 +56,40 @@ class ScriptInjection { |
// or because |current_location| is not the designated |run_location_|). |
// NOTE: |extension| may be NULL, if the extension is removed! |
bool TryToInject(UserScript::RunLocation current_location, |
- const Extension* extension, |
- ScriptsRunInfo* scripts_run_info); |
+ const Extension* extension); |
// Called when permission for the given injection has been granted. |
// Returns true if the injection ran. |
- bool OnPermissionGranted(const Extension* extension, |
- ScriptsRunInfo* scripts_run_info); |
+ bool OnPermissionGranted(const Extension* extension); |
+ |
+ // Called when JS injection for the given frame has been completed. |
+ void OnJSInjectionCompleted(blink::WebLocalFrame* frame, |
+ const blink::WebVector<v8::Local<v8::Value> >&); |
// Accessors. |
blink::WebLocalFrame* web_frame() const { return web_frame_; } |
const std::string& extension_id() const { return extension_id_; } |
int64 request_id() const { return request_id_; } |
+ bool is_complete() const { return complete_; } |
+ UserScript::RunLocation run_location() const { return run_location_; } |
+ |
+ void SetScriptInjectionManager(ScriptInjectionManager* manager); |
private: |
// Send a message to the browser requesting permission to execute. |
void RequestPermission(); |
- // Injects the script, optionally populating |scripts_run_info|. |
- void Inject(const Extension* extension, ScriptsRunInfo* scripts_run_info); |
+ // Injects the script. |
+ void Inject(const Extension* extension); |
// Inject any JS scripts into the |frame|, optionally populating |
// |execution_results|. |
void InjectJs(const Extension* extension, |
- blink::WebLocalFrame* frame, |
- base::ListValue* execution_results); |
+ blink::WebLocalFrame* frame); |
+ |
+ // If all injection are sended to frame and results received, |
+ // OnInjectionComplete will be called on injector |
+ void TryToFinish(); |
// Inject any CSS source into the |frame|. |
void InjectCss(blink::WebLocalFrame* frame); |
@@ -96,6 +120,25 @@ class ScriptInjection { |
// or because it will never complete. |
bool complete_; |
+ // A mapping of WebLocalFrame* to an index of result in results array |
+ std::map<blink::WebLocalFrame*, size_t> frame_result_index_; |
+ |
+ // Results storage |
+ scoped_ptr<base::ListValue> execution_results_; |
+ |
+ // Flag is true when all injections for each frame started |
+ bool all_injection_started_; |
+ |
+ // Pending execution callbacks |
+ ScopedVector<blink::WebScriptExecutionCallback> callbacks_; |
+ |
+ // Injection run info |
+ scoped_ptr<ScriptsRunInfo> scripts_run_info_; |
+ |
+ // If not null ScriptInjectionManager::OnInjectionFinished will be called |
+ // after injection finished. |
+ ScriptInjectionManager* script_injection_manager_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ScriptInjection); |
}; |