OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ | 5 #ifndef EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ |
6 #define EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ | 6 #define EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "extensions/renderer/script_injection.h" | 10 #include "extensions/renderer/script_injection.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 } | 21 } |
22 | 22 |
23 namespace extensions { | 23 namespace extensions { |
24 class Extension; | 24 class Extension; |
25 | 25 |
26 // A ScriptInjector to handle tabs.executeScript(). | 26 // A ScriptInjector to handle tabs.executeScript(). |
27 class ProgrammaticScriptInjector : public ScriptInjector { | 27 class ProgrammaticScriptInjector : public ScriptInjector { |
28 public: | 28 public: |
29 ProgrammaticScriptInjector(const ExtensionMsg_ExecuteCode_Params& params, | 29 ProgrammaticScriptInjector(const ExtensionMsg_ExecuteCode_Params& params, |
30 blink::WebFrame* web_frame); | 30 blink::WebFrame* web_frame); |
31 virtual ~ProgrammaticScriptInjector(); | 31 ~ProgrammaticScriptInjector() override; |
32 | 32 |
33 private: | 33 private: |
34 // ScriptInjector implementation. | 34 // ScriptInjector implementation. |
35 virtual UserScript::InjectionType script_type() const override; | 35 UserScript::InjectionType script_type() const override; |
36 virtual bool ShouldExecuteInChildFrames() const override; | 36 bool ShouldExecuteInChildFrames() const override; |
37 virtual bool ShouldExecuteInMainWorld() const override; | 37 bool ShouldExecuteInMainWorld() const override; |
38 virtual bool IsUserGesture() const override; | 38 bool IsUserGesture() const override; |
39 virtual bool ExpectsResults() const override; | 39 bool ExpectsResults() const override; |
40 virtual bool ShouldInjectJs( | 40 bool ShouldInjectJs(UserScript::RunLocation run_location) const override; |
41 UserScript::RunLocation run_location) const override; | 41 bool ShouldInjectCss(UserScript::RunLocation run_location) const override; |
42 virtual bool ShouldInjectCss( | 42 PermissionsData::AccessType CanExecuteOnFrame( |
43 UserScript::RunLocation run_location) const override; | |
44 virtual PermissionsData::AccessType CanExecuteOnFrame( | |
45 const Extension* extension, | 43 const Extension* extension, |
46 blink::WebFrame* web_frame, | 44 blink::WebFrame* web_frame, |
47 int tab_id, | 45 int tab_id, |
48 const GURL& top_url) const override; | 46 const GURL& top_url) const override; |
49 virtual std::vector<blink::WebScriptSource> GetJsSources( | 47 std::vector<blink::WebScriptSource> GetJsSources( |
50 UserScript::RunLocation run_location) const override; | 48 UserScript::RunLocation run_location) const override; |
51 virtual std::vector<std::string> GetCssSources( | 49 std::vector<std::string> GetCssSources( |
52 UserScript::RunLocation run_location) const override; | 50 UserScript::RunLocation run_location) const override; |
53 virtual void OnInjectionComplete( | 51 void OnInjectionComplete(scoped_ptr<base::ListValue> execution_results, |
54 scoped_ptr<base::ListValue> execution_results, | 52 ScriptsRunInfo* scripts_run_info, |
55 ScriptsRunInfo* scripts_run_info, | 53 UserScript::RunLocation run_location) override; |
56 UserScript::RunLocation run_location) override; | 54 void OnWillNotInject(InjectFailureReason reason) override; |
57 virtual void OnWillNotInject(InjectFailureReason reason) override; | |
58 | 55 |
59 // Return the run location for this injector. | 56 // Return the run location for this injector. |
60 UserScript::RunLocation GetRunLocation() const; | 57 UserScript::RunLocation GetRunLocation() const; |
61 | 58 |
62 // Notify the browser that the script was injected (or never will be), and | 59 // Notify the browser that the script was injected (or never will be), and |
63 // send along any results or errors. | 60 // send along any results or errors. |
64 void Finish(const std::string& error); | 61 void Finish(const std::string& error); |
65 | 62 |
66 // The parameters for injecting the script. | 63 // The parameters for injecting the script. |
67 scoped_ptr<ExtensionMsg_ExecuteCode_Params> params_; | 64 scoped_ptr<ExtensionMsg_ExecuteCode_Params> params_; |
68 | 65 |
69 // The url of the frame into which we are injecting. | 66 // The url of the frame into which we are injecting. |
70 GURL url_; | 67 GURL url_; |
71 | 68 |
72 // The RenderView to which we send the response upon completion. | 69 // The RenderView to which we send the response upon completion. |
73 content::RenderView* render_view_; | 70 content::RenderView* render_view_; |
74 | 71 |
75 // The results of the script execution. | 72 // The results of the script execution. |
76 scoped_ptr<base::ListValue> results_; | 73 scoped_ptr<base::ListValue> results_; |
77 | 74 |
78 // Whether or not this script injection has finished. | 75 // Whether or not this script injection has finished. |
79 bool finished_; | 76 bool finished_; |
80 | 77 |
81 DISALLOW_COPY_AND_ASSIGN(ProgrammaticScriptInjector); | 78 DISALLOW_COPY_AND_ASSIGN(ProgrammaticScriptInjector); |
82 }; | 79 }; |
83 | 80 |
84 } // namespace extensions | 81 } // namespace extensions |
85 | 82 |
86 #endif // EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ | 83 #endif // EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ |
OLD | NEW |