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

Unified Diff: extensions/renderer/script_injection.h

Issue 934763003: Refactoring: de-couple Extensions from "script injection System" [render side]:3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@decouple_brower_isolated_world_routingid_user_script_1
Patch Set: Devlin's comments. 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 6a93a020a6805da626fc9de72c9556df97d067d6..3253dd764c37bdd37d1b2d81f4fc12c526c04b70 100644
--- a/extensions/renderer/script_injection.h
+++ b/extensions/renderer/script_injection.h
@@ -8,9 +8,9 @@
#include "base/basictypes.h"
#include "base/macros.h"
#include "extensions/common/user_script.h"
+#include "extensions/renderer/injection_host.h"
#include "extensions/renderer/script_injector.h"
-class InjectionHost;
struct HostID;
namespace blink {
@@ -33,7 +33,7 @@ class ScriptInjection {
ScriptInjection(
scoped_ptr<ScriptInjector> injector,
blink::WebLocalFrame* web_frame,
- const HostID& host_id,
+ scoped_ptr<const InjectionHost> injection_host,
const UserScript::ConsumerInstanceType& consumer_instance_type,
UserScript::RunLocation run_location,
int tab_id);
@@ -43,19 +43,19 @@ class ScriptInjection {
// the script has either injected or will never inject (i.e., if the object
// is done), and false if injection is delayed (either for permission purposes
// or because |current_location| is not the designated |run_location_|).
- // NOTE: |injection_host| may be NULL, if the injection_host is removed!
bool TryToInject(UserScript::RunLocation current_location,
- const InjectionHost* injection_host,
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(ScriptsRunInfo* scripts_run_info);
+
+ // Resets the pointer of the injection host when the host is gone.
+ void OnHostRemoved();
// Accessors.
blink::WebLocalFrame* web_frame() const { return web_frame_; }
- const HostID& host_id() const { return host_id_; }
+ const HostID& host_id() const { return injection_host_->id(); }
int64 request_id() const { return request_id_; }
private:
@@ -64,13 +64,11 @@ 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(ScriptsRunInfo* scripts_run_info);
// Inject any JS scripts into the |frame|, optionally populating
// |execution_results|.
- void InjectJs(const InjectionHost* injection_host,
- blink::WebLocalFrame* frame,
+ void InjectJs(blink::WebLocalFrame* frame,
base::ListValue* execution_results);
// Inject any CSS source into the |frame|.
@@ -85,8 +83,8 @@ class ScriptInjection {
// The (main) WebFrame into which this should inject the script.
blink::WebLocalFrame* web_frame_;
- // The id of the associated injection_host.
- HostID host_id_;
+ // The associated injection host.
+ scoped_ptr<const InjectionHost> injection_host_;
// The type of the instance on which the host will inject the script.
UserScript::ConsumerInstanceType consumer_instance_type_;

Powered by Google App Engine
This is Rietveld 408576698