Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Unified Diff: extensions/renderer/script_injection.h

Issue 878513005: Extensions: suspend extension's scripts when V8 is paused (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: check added Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
};

Powered by Google App Engine
This is Rietveld 408576698