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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 // Returns true if the script should execute on the given |frame|. | 59 // Returns true if the script should execute on the given |frame|. |
60 virtual PermissionsData::AccessType CanExecuteOnFrame( | 60 virtual PermissionsData::AccessType CanExecuteOnFrame( |
61 const InjectionHost* injection_host, | 61 const InjectionHost* injection_host, |
62 blink::WebLocalFrame* web_frame, | 62 blink::WebLocalFrame* web_frame, |
63 int tab_id) const = 0; | 63 int tab_id) const = 0; |
64 | 64 |
65 // Returns the javascript sources to inject at the given |run_location|. | 65 // Returns the javascript sources to inject at the given |run_location|. |
66 // Only called if ShouldInjectJs() is true. | 66 // Only called if ShouldInjectJs() is true. |
67 virtual std::vector<blink::WebScriptSource> GetJsSources( | 67 virtual std::vector<blink::WebScriptSource> GetJsSources( |
68 UserScript::RunLocation run_location, | 68 UserScript::RunLocation run_location) const = 0; |
69 ScriptsRunInfo* scripts_run_info) const = 0; | |
70 | 69 |
71 // Returns the css to inject at the given |run_location|. | 70 // Returns the css to inject at the given |run_location|. |
72 // Only called if ShouldInjectCss() is true. | 71 // Only called if ShouldInjectCss() is true. |
73 virtual std::vector<std::string> GetCssSources( | 72 virtual std::vector<std::string> GetCssSources( |
74 UserScript::RunLocation run_location, | 73 UserScript::RunLocation run_location) const = 0; |
75 ScriptsRunInfo* scripts_run_info) const = 0; | |
76 | 74 |
77 // Fill scriptrs run info based on information about injection. | 75 // Fill scriptrs run info based on information about injection. |
78 virtual void GetRunInfo( | 76 virtual void GetRunInfo( |
79 ScriptsRunInfo* scripts_run_info, | 77 ScriptsRunInfo* scripts_run_info, |
80 UserScript::RunLocation run_location) const = 0; | 78 UserScript::RunLocation run_location) const = 0; |
81 | 79 |
82 // Notifies the script that injection has completed, with a possibly-populated | 80 // Notifies the script that injection has completed, with a possibly-populated |
83 // list of results (depending on whether or not ExpectsResults() was true). | 81 // list of results (depending on whether or not ExpectsResults() was true). |
84 // |render_frame| contains the render frame, or null if the frame was | 82 // |render_frame| contains the render frame, or null if the frame was |
85 // invalidated. | 83 // invalidated. |
86 virtual void OnInjectionComplete( | 84 virtual void OnInjectionComplete( |
87 std::unique_ptr<base::Value> execution_result, | 85 std::unique_ptr<base::Value> execution_result, |
88 UserScript::RunLocation run_location, | 86 UserScript::RunLocation run_location, |
89 content::RenderFrame* render_frame) = 0; | 87 content::RenderFrame* render_frame) = 0; |
90 | 88 |
91 // Notifies the script that injection will never occur. | 89 // Notifies the script that injection will never occur. |
92 // |render_frame| contains the render frame, or null if the frame was | 90 // |render_frame| contains the render frame, or null if the frame was |
93 // invalidated. | 91 // invalidated. |
94 virtual void OnWillNotInject(InjectFailureReason reason, | 92 virtual void OnWillNotInject(InjectFailureReason reason, |
95 content::RenderFrame* render_frame) = 0; | 93 content::RenderFrame* render_frame) = 0; |
96 }; | 94 }; |
97 | 95 |
98 } // namespace extensions | 96 } // namespace extensions |
99 | 97 |
100 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTOR_H_ | 98 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTOR_H_ |
OLD | NEW |