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 <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "extensions/renderer/script_injection.h" | 12 #include "extensions/renderer/script_injection.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 struct ExtensionMsg_ExecuteCode_Params; | 15 struct ExtensionMsg_ExecuteCode_Params; |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 class RenderFrame; | 18 class RenderFrame; |
19 } | 19 } |
20 | 20 |
21 namespace extensions { | 21 namespace extensions { |
22 struct ScriptsRunInfo; | |
Devlin
2016/09/08 17:47:31
nitty nit: no longer needed.
| |
22 | 23 |
23 // A ScriptInjector to handle tabs.executeScript(). | 24 // A ScriptInjector to handle tabs.executeScript(). |
24 class ProgrammaticScriptInjector : public ScriptInjector { | 25 class ProgrammaticScriptInjector : public ScriptInjector { |
25 public: | 26 public: |
26 ProgrammaticScriptInjector(const ExtensionMsg_ExecuteCode_Params& params, | 27 ProgrammaticScriptInjector(const ExtensionMsg_ExecuteCode_Params& params, |
27 content::RenderFrame* render_frame); | 28 content::RenderFrame* render_frame); |
28 ~ProgrammaticScriptInjector() override; | 29 ~ProgrammaticScriptInjector() override; |
29 | 30 |
30 private: | 31 private: |
31 // ScriptInjector implementation. | 32 // ScriptInjector implementation. |
32 UserScript::InjectionType script_type() const override; | 33 UserScript::InjectionType script_type() const override; |
33 bool ShouldExecuteInMainWorld() const override; | 34 bool ShouldExecuteInMainWorld() const override; |
34 bool IsUserGesture() const override; | 35 bool IsUserGesture() const override; |
35 bool ExpectsResults() const override; | 36 bool ExpectsResults() const override; |
36 bool ShouldInjectJs(UserScript::RunLocation run_location) const override; | 37 bool ShouldInjectJs( |
37 bool ShouldInjectCss(UserScript::RunLocation run_location) const override; | 38 UserScript::RunLocation run_location, |
39 const std::set<std::string>& executing_scripts) const override; | |
40 bool ShouldInjectCss( | |
41 UserScript::RunLocation run_location, | |
42 const std::set<std::string>& injected_stylesheets) const override; | |
38 PermissionsData::AccessType CanExecuteOnFrame( | 43 PermissionsData::AccessType CanExecuteOnFrame( |
39 const InjectionHost* injection_host, | 44 const InjectionHost* injection_host, |
40 blink::WebLocalFrame* web_frame, | 45 blink::WebLocalFrame* web_frame, |
41 int tab_id) const override; | 46 int tab_id) const override; |
42 std::vector<blink::WebScriptSource> GetJsSources( | 47 std::vector<blink::WebScriptSource> GetJsSources( |
43 UserScript::RunLocation run_location) const override; | 48 UserScript::RunLocation run_location, |
49 std::set<std::string>* executing_scripts, | |
50 size_t* num_injected_js_scripts) const override; | |
44 std::vector<blink::WebString> GetCssSources( | 51 std::vector<blink::WebString> GetCssSources( |
45 UserScript::RunLocation run_location) const override; | 52 UserScript::RunLocation run_location, |
46 void GetRunInfo(ScriptsRunInfo* scripts_run_info, | 53 std::set<std::string>* injected_stylesheets, |
47 UserScript::RunLocation run_location) const override; | 54 size_t* num_injected_stylesheets) const override; |
48 void OnInjectionComplete(std::unique_ptr<base::Value> execution_result, | 55 void OnInjectionComplete(std::unique_ptr<base::Value> execution_result, |
49 UserScript::RunLocation run_location, | 56 UserScript::RunLocation run_location, |
50 content::RenderFrame* render_frame) override; | 57 content::RenderFrame* render_frame) override; |
51 void OnWillNotInject(InjectFailureReason reason, | 58 void OnWillNotInject(InjectFailureReason reason, |
52 content::RenderFrame* render_frame) override; | 59 content::RenderFrame* render_frame) override; |
53 | 60 |
54 // Whether it is safe to include information about the URL in error messages. | 61 // Whether it is safe to include information about the URL in error messages. |
55 bool CanShowUrlInError() const; | 62 bool CanShowUrlInError() const; |
56 | 63 |
57 // Return the run location for this injector. | 64 // Return the run location for this injector. |
(...skipping 18 matching lines...) Expand all Loading... | |
76 | 83 |
77 // Whether or not this script injection has finished. | 84 // Whether or not this script injection has finished. |
78 bool finished_; | 85 bool finished_; |
79 | 86 |
80 DISALLOW_COPY_AND_ASSIGN(ProgrammaticScriptInjector); | 87 DISALLOW_COPY_AND_ASSIGN(ProgrammaticScriptInjector); |
81 }; | 88 }; |
82 | 89 |
83 } // namespace extensions | 90 } // namespace extensions |
84 | 91 |
85 #endif // EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ | 92 #endif // EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ |
OLD | NEW |