| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // |run_location|. | 53 // |run_location|. |
| 54 virtual bool ShouldInjectJs(UserScript::RunLocation run_location) const = 0; | 54 virtual bool ShouldInjectJs(UserScript::RunLocation run_location) const = 0; |
| 55 | 55 |
| 56 // Returns true if the script should inject CSS at the given |run_location|. | 56 // Returns true if the script should inject CSS at the given |run_location|. |
| 57 virtual bool ShouldInjectCss(UserScript::RunLocation run_location) const = 0; | 57 virtual bool ShouldInjectCss(UserScript::RunLocation run_location) const = 0; |
| 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::WebFrame* web_frame, | 62 blink::WebFrame* web_frame, |
| 63 int tab_id, | 63 int tab_id) const = 0; |
| 64 const GURL& top_url) const = 0; | |
| 65 | 64 |
| 66 // Returns the javascript sources to inject at the given |run_location|. | 65 // Returns the javascript sources to inject at the given |run_location|. |
| 67 // Only called if ShouldInjectJs() is true. | 66 // Only called if ShouldInjectJs() is true. |
| 68 virtual std::vector<blink::WebScriptSource> GetJsSources( | 67 virtual std::vector<blink::WebScriptSource> GetJsSources( |
| 69 UserScript::RunLocation run_location) const = 0; | 68 UserScript::RunLocation run_location) 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) const = 0; | 73 UserScript::RunLocation run_location) const = 0; |
| 75 | 74 |
| 76 // Fill scriptrs run info based on information about injection. | 75 // Fill scriptrs run info based on information about injection. |
| 77 virtual void GetRunInfo( | 76 virtual void GetRunInfo( |
| 78 ScriptsRunInfo* scripts_run_info, | 77 ScriptsRunInfo* scripts_run_info, |
| 79 UserScript::RunLocation run_location) const = 0; | 78 UserScript::RunLocation run_location) const = 0; |
| 80 | 79 |
| 81 // Notifies the script that injection has completed, with a possibly-populated | 80 // Notifies the script that injection has completed, with a possibly-populated |
| 82 // list of results (depending on whether or not ExpectsResults() was true). | 81 // list of results (depending on whether or not ExpectsResults() was true). |
| 83 virtual void OnInjectionComplete( | 82 virtual void OnInjectionComplete( |
| 84 scoped_ptr<base::Value> execution_result, | 83 scoped_ptr<base::Value> execution_result, |
| 85 UserScript::RunLocation run_location) = 0; | 84 UserScript::RunLocation run_location) = 0; |
| 86 | 85 |
| 87 // Notifies the script that injection will never occur. | 86 // Notifies the script that injection will never occur. |
| 88 virtual void OnWillNotInject(InjectFailureReason reason) = 0; | 87 virtual void OnWillNotInject(InjectFailureReason reason) = 0; |
| 89 }; | 88 }; |
| 90 | 89 |
| 91 } // namespace extensions | 90 } // namespace extensions |
| 92 | 91 |
| 93 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTOR_H_ | 92 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTOR_H_ |
| OLD | NEW |