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_SCRIPT_INJECTOR_H_ | 5 #ifndef EXTENSIONS_RENDERER_SCRIPT_INJECTOR_H_ |
6 #define EXTENSIONS_RENDERER_SCRIPT_INJECTOR_H_ | 6 #define EXTENSIONS_RENDERER_SCRIPT_INJECTOR_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 virtual bool ShouldExecuteInMainWorld() const = 0; | 44 virtual bool ShouldExecuteInMainWorld() const = 0; |
45 | 45 |
46 // Returns true if the script is running inside a user gesture. | 46 // Returns true if the script is running inside a user gesture. |
47 virtual bool IsUserGesture() const = 0; | 47 virtual bool IsUserGesture() const = 0; |
48 | 48 |
49 // Returns true if the script expects results. | 49 // Returns true if the script expects results. |
50 virtual bool ExpectsResults() const = 0; | 50 virtual bool ExpectsResults() const = 0; |
51 | 51 |
52 // Returns true if the script should inject JS source at the given | 52 // Returns true if the script should inject JS source at the given |
53 // |run_location|. | 53 // |run_location|. |
54 virtual bool ShouldInjectJs(UserScript::RunLocation run_location) const = 0; | 54 virtual bool ShouldInjectJs(UserScript::RunLocation run_location, |
| 55 const std::set<GURL>& injected_scripts) const = 0; |
55 | 56 |
56 // Returns true if the script should inject CSS at the given |run_location|. | 57 // Returns true if the script should inject CSS at the given |run_location|. |
57 virtual bool ShouldInjectCss(UserScript::RunLocation run_location) const = 0; | 58 virtual bool ShouldInjectCss( |
| 59 UserScript::RunLocation run_location, |
| 60 const std::set<GURL>& injected_scripts) const = 0; |
58 | 61 |
59 // Returns true if the script should execute on the given |frame|. | 62 // Returns true if the script should execute on the given |frame|. |
60 virtual PermissionsData::AccessType CanExecuteOnFrame( | 63 virtual PermissionsData::AccessType CanExecuteOnFrame( |
61 const InjectionHost* injection_host, | 64 const InjectionHost* injection_host, |
62 blink::WebLocalFrame* web_frame, | 65 blink::WebLocalFrame* web_frame, |
63 int tab_id) const = 0; | 66 int tab_id) const = 0; |
64 | 67 |
65 // Returns the javascript sources to inject at the given |run_location|. | 68 // Returns the javascript sources to inject at the given |run_location|. |
66 // Only called if ShouldInjectJs() is true. | 69 // Only called if ShouldInjectJs() is true. |
67 virtual std::vector<blink::WebScriptSource> GetJsSources( | 70 virtual std::vector<blink::WebScriptSource> GetJsSources( |
68 UserScript::RunLocation run_location) const = 0; | 71 UserScript::RunLocation run_location, |
| 72 std::set<GURL>& injected_scripts) const = 0; |
69 | 73 |
70 // Returns the css to inject at the given |run_location|. | 74 // Returns the css to inject at the given |run_location|. |
71 // Only called if ShouldInjectCss() is true. | 75 // Only called if ShouldInjectCss() is true. |
72 virtual std::vector<blink::WebString> GetCssSources( | 76 virtual std::vector<blink::WebString> GetCssSources( |
73 UserScript::RunLocation run_location) const = 0; | 77 UserScript::RunLocation run_location, |
| 78 std::set<GURL>& injected_scripts) const = 0; |
74 | 79 |
75 // Fill scriptrs run info based on information about injection. | 80 // Fill scriptrs run info based on information about injection. |
76 virtual void GetRunInfo( | 81 virtual void GetRunInfo(ScriptsRunInfo* scripts_run_info, |
77 ScriptsRunInfo* scripts_run_info, | 82 UserScript::RunLocation run_location, |
78 UserScript::RunLocation run_location) const = 0; | 83 bool js_injection_completed, |
| 84 bool should_inject_css) const = 0; |
79 | 85 |
80 // Notifies the script that injection has completed, with a possibly-populated | 86 // Notifies the script that injection has completed, with a possibly-populated |
81 // list of results (depending on whether or not ExpectsResults() was true). | 87 // list of results (depending on whether or not ExpectsResults() was true). |
82 // |render_frame| contains the render frame, or null if the frame was | 88 // |render_frame| contains the render frame, or null if the frame was |
83 // invalidated. | 89 // invalidated. |
84 virtual void OnInjectionComplete( | 90 virtual void OnInjectionComplete( |
85 std::unique_ptr<base::Value> execution_result, | 91 std::unique_ptr<base::Value> execution_result, |
86 UserScript::RunLocation run_location, | 92 UserScript::RunLocation run_location, |
87 content::RenderFrame* render_frame) = 0; | 93 content::RenderFrame* render_frame) = 0; |
88 | 94 |
89 // Notifies the script that injection will never occur. | 95 // Notifies the script that injection will never occur. |
90 // |render_frame| contains the render frame, or null if the frame was | 96 // |render_frame| contains the render frame, or null if the frame was |
91 // invalidated. | 97 // invalidated. |
92 virtual void OnWillNotInject(InjectFailureReason reason, | 98 virtual void OnWillNotInject(InjectFailureReason reason, |
93 content::RenderFrame* render_frame) = 0; | 99 content::RenderFrame* render_frame) = 0; |
94 }; | 100 }; |
95 | 101 |
96 } // namespace extensions | 102 } // namespace extensions |
97 | 103 |
98 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTOR_H_ | 104 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTOR_H_ |
OLD | NEW |