| 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_INJECTION_H_ | 5 #ifndef EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_ |
| 6 #define EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_ | 6 #define EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // Resets the pointer of the injection host when the host is gone. | 77 // Resets the pointer of the injection host when the host is gone. |
| 78 void OnHostRemoved(); | 78 void OnHostRemoved(); |
| 79 | 79 |
| 80 void invalidate_render_frame() { render_frame_ = nullptr; } | 80 void invalidate_render_frame() { render_frame_ = nullptr; } |
| 81 | 81 |
| 82 // Accessors. | 82 // Accessors. |
| 83 content::RenderFrame* render_frame() const { return render_frame_; } | 83 content::RenderFrame* render_frame() const { return render_frame_; } |
| 84 const HostID& host_id() const { return injection_host_->id(); } | 84 const HostID& host_id() const { return injection_host_->id(); } |
| 85 int64_t request_id() const { return request_id_; } | 85 int64_t request_id() const { return request_id_; } |
| 86 | 86 |
| 87 // Called when JS injection for the given frame has been completed. |
| 88 void OnJsInjectionCompleted(const std::vector<v8::Local<v8::Value>>& results, |
| 89 base::TimeDelta elapsed); |
| 90 |
| 87 private: | 91 private: |
| 88 class FrameWatcher; | 92 class FrameWatcher; |
| 89 | 93 |
| 90 // Sends a message to the browser to request permission to inject. | 94 // Sends a message to the browser to request permission to inject. |
| 91 void RequestPermissionFromBrowser(); | 95 void RequestPermissionFromBrowser(); |
| 92 | 96 |
| 93 // Injects the script. Returns INJECTION_FINISHED if injection has finished, | 97 // Injects the script. Returns INJECTION_FINISHED if injection has finished, |
| 94 // otherwise INJECTION_BLOCKED. | 98 // otherwise INJECTION_BLOCKED. |
| 95 InjectionResult Inject(ScriptsRunInfo* scripts_run_info); | 99 InjectionResult Inject(ScriptsRunInfo* scripts_run_info); |
| 96 | 100 |
| 97 // Inject any JS scripts into the frame for the injection. | 101 // Inject any JS scripts into the frame for the injection. |
| 98 void InjectJs(std::set<std::string>* executing_scripts, | 102 void InjectJs(std::set<std::string>* executing_scripts, |
| 99 size_t* num_injected_js_scripts); | 103 size_t* num_injected_js_scripts); |
| 100 | 104 |
| 101 // Called when JS injection for the given frame has been completed. | |
| 102 void OnJsInjectionCompleted(const std::vector<v8::Local<v8::Value>>& results); | |
| 103 | |
| 104 // Inject any CSS source into the frame for the injection. | 105 // Inject any CSS source into the frame for the injection. |
| 105 void InjectCss(std::set<std::string>* injected_stylesheets, | 106 void InjectCss(std::set<std::string>* injected_stylesheets, |
| 106 size_t* num_injected_stylesheets); | 107 size_t* num_injected_stylesheets); |
| 107 | 108 |
| 108 // Notify that we will not inject, and mark it as acknowledged. | 109 // Notify that we will not inject, and mark it as acknowledged. |
| 109 void NotifyWillNotInject(ScriptInjector::InjectFailureReason reason); | 110 void NotifyWillNotInject(ScriptInjector::InjectFailureReason reason); |
| 110 | 111 |
| 111 // The injector for this injection. | 112 // The injector for this injection. |
| 112 std::unique_ptr<ScriptInjector> injector_; | 113 std::unique_ptr<ScriptInjector> injector_; |
| 113 | 114 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 144 std::unique_ptr<FrameWatcher> frame_watcher_; | 145 std::unique_ptr<FrameWatcher> frame_watcher_; |
| 145 | 146 |
| 146 base::WeakPtrFactory<ScriptInjection> weak_ptr_factory_; | 147 base::WeakPtrFactory<ScriptInjection> weak_ptr_factory_; |
| 147 | 148 |
| 148 DISALLOW_COPY_AND_ASSIGN(ScriptInjection); | 149 DISALLOW_COPY_AND_ASSIGN(ScriptInjection); |
| 149 }; | 150 }; |
| 150 | 151 |
| 151 } // namespace extensions | 152 } // namespace extensions |
| 152 | 153 |
| 153 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_ | 154 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_ |
| OLD | NEW |