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

Unified Diff: extensions/renderer/programmatic_script_injection.h

Issue 321993003: Refactor renderer-side script injection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Missing files Created 6 years, 6 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/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_

Powered by Google App Engine
This is Rietveld 408576698