Index: extensions/renderer/user_script_injection.h |
diff --git a/extensions/renderer/user_script_injection.h b/extensions/renderer/user_script_injection.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d55e15650d0c004be1abd8b29dc61412aadae75c |
--- /dev/null |
+++ b/extensions/renderer/user_script_injection.h |
@@ -0,0 +1,75 @@ |
+// Copyright 2014 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 EXTENSIONS_RENDERER_USER_SCRIPT_INJECTION_H_ |
+#define EXTENSIONS_RENDERER_USER_SCRIPT_INJECTION_H_ |
+ |
+#include "extensions/renderer/script_injection.h" |
+ |
+#include <string> |
+ |
+#include "base/memory/scoped_ptr.h" |
+#include "base/scoped_observer.h" |
+#include "extensions/common/user_script.h" |
+#include "extensions/renderer/user_script_injection_list.h" |
+ |
+namespace blink { |
+class WebFrame; |
+} |
+ |
+namespace extensions { |
+class Extension; |
+ |
+// A ScriptInjection for UserScripts. |
+class UserScriptInjection : public ScriptInjection, |
+ public UserScriptInjectionList::Observer { |
+ public: |
+ UserScriptInjection(blink::WebFrame* web_frame, |
+ const std::string& extension_id, |
+ UserScript::RunLocation run_location, |
+ int tab_id, |
+ UserScriptInjectionList* script_list, |
+ const UserScript* script, |
+ bool inject_js, |
+ bool inject_css); |
+ virtual ~UserScriptInjection(); |
+ |
+ int64 script_id() const { return script_id_; } |
+ void set_script(const UserScript* script) { script_ = script; } |
+ |
+ private: |
+ // Inject the JS/CSS specified in |script_|. |
+ void InjectJS(const Extension* extension, ScriptsRunInfo* scripts_run_info); |
+ void InjectCSS(ScriptsRunInfo* scripts_run_info); |
+ |
+ // ScriptInjection implementation. |
+ virtual bool Allowed(const Extension* extension) OVERRIDE; |
+ virtual void Inject(ScriptsRunInfo* scripts_run_info, |
+ const Extension* extension) OVERRIDE; |
+ |
+ // UserScriptInjectionList::Observer implementation. |
+ virtual void OnUserScriptsUpdated( |
+ const std::set<std::string>& changed_extensions, |
+ const std::vector<UserScript*>& scripts) OVERRIDE; |
+ |
+ // The associated user script. Owned by the UserScriptInjection that created |
+ // this object. |
+ const UserScript* script_; |
+ |
+ // The id of the associated user script. |
+ int64 script_id_; |
+ |
+ // Whether or not this should inject JS. |
+ bool inject_js_; |
+ |
+ // Whether or not this should inject CSS. |
+ bool inject_css_; |
+ |
+ ScopedObserver<UserScriptInjectionList, UserScriptInjectionList::Observer> |
+ user_script_injection_list_observer_; |
+}; |
+ |
+} // namespace extensions |
+ |
+#endif // EXTENSIONS_RENDERER_USER_SCRIPT_INJECTION_H_ |