Index: extensions/renderer/script_injection.h |
diff --git a/extensions/renderer/script_injection.h b/extensions/renderer/script_injection.h |
index a8835457d95312b220ded68cba089261eb05e745..e2cc7b91a4f26e70a02ceec2b884356bde5538b1 100644 |
--- a/extensions/renderer/script_injection.h |
+++ b/extensions/renderer/script_injection.h |
@@ -5,8 +5,12 @@ |
#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 "extensions/common/user_script.h" |
#include "extensions/renderer/script_injector.h" |
@@ -15,9 +19,16 @@ struct HostID; |
namespace blink { |
class WebLocalFrame; |
+template<typename T> class WebVector; |
+} |
+ |
+namespace v8 { |
+class Value; |
+template <class T> class Local; |
} |
namespace extensions { |
+class ScriptInjectionManager; |
struct ScriptsRunInfo; |
// A script wrapper which is aware of whether or not it is allowed to execute, |
@@ -44,17 +55,24 @@ class ScriptInjection { |
// NOTE: |injection_host| may be NULL, if the injection_host is removed! |
bool TryToInject(UserScript::RunLocation current_location, |
Devlin
2015/02/25 18:02:15
As a result of some of these changes, I think it b
kozy
2015/02/27 17:32:28
Done.
|
const InjectionHost* injection_host, |
- ScriptsRunInfo* scripts_run_info); |
+ scoped_refptr<ScriptsRunInfo> scripts_run_info); |
// Called when permission for the given injection has been granted. |
// Returns true if the injection ran. |
- bool OnPermissionGranted(const InjectionHost* injection_host, |
- ScriptsRunInfo* scripts_run_info); |
+ bool OnPermissionGranted(const InjectionHost* injection_host); |
+ |
+ // 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 HostID& host_id() const { return host_id_; } |
+ UserScript::RunLocation run_location() const { return run_location_; } |
int64 request_id() const { return request_id_; } |
+ bool is_complete() const { return complete_; } |
+ |
+ void SetScriptInjectionManager(ScriptInjectionManager* manager); |
private: |
// Sends a message to the browser, either that the script injection would |
@@ -62,14 +80,16 @@ class ScriptInjection { |
void SendInjectionMessage(bool request_permission); |
// Injects the script, optionally populating |scripts_run_info|. |
- void Inject(const InjectionHost* injection_host, |
- ScriptsRunInfo* scripts_run_info); |
+ void Inject(const InjectionHost* injection_host); |
// Inject any JS scripts into the |frame|, optionally populating |
// |execution_results|. |
void InjectJs(const InjectionHost* injection_host, |
- 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); |
@@ -100,6 +120,22 @@ class ScriptInjection { |
// or because it will never complete. |
bool complete_; |
+ // The scripts run info passed from injection user |
+ scoped_refptr<ScriptsRunInfo> scripts_run_info_; |
+ |
+ // 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 injections for each frame started |
+ bool all_injection_started_; |
+ |
+ // If not null ScriptInjectionManager::OnInjectionFinished will be called |
+ // after injection finished. |
+ ScriptInjectionManager* script_injection_manager_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ScriptInjection); |
}; |