Index: extensions/renderer/programmatic_script_injection.h |
diff --git a/extensions/renderer/programmatic_script_injection.h b/extensions/renderer/programmatic_script_injection.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d1c43a7c6fdcc2ebbbe70d2cb81b464df0a997ce |
--- /dev/null |
+++ b/extensions/renderer/programmatic_script_injection.h |
@@ -0,0 +1,57 @@ |
+// 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_PROGRAMMATIC_SCRIPT_INJECTION_H_ |
+#define EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTION_H_ |
+ |
+#include "base/macros.h" |
+#include "extensions/renderer/script_injection.h" |
+ |
+class GURL; |
+struct ExtensionMsg_ExecuteCode_Params; |
+ |
+namespace blink { |
+class WebFrame; |
+} |
+ |
+namespace content { |
+class RenderView; |
+} |
+ |
+namespace extensions { |
+class Extension; |
+ |
+// A ScriptInjection to handle tabs.executeScript(). |
+class ProgrammaticScriptInjection : public ScriptInjection { |
+ public: |
+ ProgrammaticScriptInjection(blink::WebFrame* web_frame, |
+ const ExtensionMsg_ExecuteCode_Params& params, |
+ int tab_id); |
+ virtual ~ProgrammaticScriptInjection(); |
+ |
+ private: |
+ // Returns the associated RenderView. |
+ content::RenderView* GetRenderView(); |
+ |
+ // Returns true if the script can execute on the given |frame|. |
+ // |top_url| is passed in for efficiency when this is used in a loop. |
+ bool CanExecuteOnFrame(const Extension* extension, |
+ const blink::WebFrame* frame, |
+ const GURL& top_url) const; |
+ |
+ // ScriptInjection implementation. |
+ virtual void ExtensionNotFound() OVERRIDE; |
+ virtual bool Allowed(const Extension* extension) OVERRIDE; |
+ virtual void Inject(ScriptsRunInfo* scripts_run_info, |
+ const Extension* extension) OVERRIDE; |
+ |
+ // The parameters for injecting the script. |
+ scoped_ptr<ExtensionMsg_ExecuteCode_Params> params_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ProgrammaticScriptInjection); |
+}; |
+ |
+} // namespace extensions |
+ |
+#endif // EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTION_H_ |