| 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 "base/basictypes.h" | 8 #include <stdint.h> |
| 9 |
| 9 #include "base/callback.h" | 10 #include "base/callback.h" |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "extensions/common/user_script.h" | 14 #include "extensions/common/user_script.h" |
| 14 #include "extensions/renderer/injection_host.h" | 15 #include "extensions/renderer/injection_host.h" |
| 15 #include "extensions/renderer/script_injector.h" | 16 #include "extensions/renderer/script_injector.h" |
| 16 | 17 |
| 17 struct HostID; | 18 struct HostID; |
| 18 | 19 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 InjectionResult OnPermissionGranted(ScriptsRunInfo* scripts_run_info); | 76 InjectionResult OnPermissionGranted(ScriptsRunInfo* scripts_run_info); |
| 76 | 77 |
| 77 // Resets the pointer of the injection host when the host is gone. | 78 // Resets the pointer of the injection host when the host is gone. |
| 78 void OnHostRemoved(); | 79 void OnHostRemoved(); |
| 79 | 80 |
| 80 void invalidate_render_frame() { render_frame_ = nullptr; } | 81 void invalidate_render_frame() { render_frame_ = nullptr; } |
| 81 | 82 |
| 82 // Accessors. | 83 // Accessors. |
| 83 content::RenderFrame* render_frame() const { return render_frame_; } | 84 content::RenderFrame* render_frame() const { return render_frame_; } |
| 84 const HostID& host_id() const { return injection_host_->id(); } | 85 const HostID& host_id() const { return injection_host_->id(); } |
| 85 int64 request_id() const { return request_id_; } | 86 int64_t request_id() const { return request_id_; } |
| 86 | 87 |
| 87 private: | 88 private: |
| 88 class FrameWatcher; | 89 class FrameWatcher; |
| 89 | 90 |
| 90 // Sends a message to the browser to request permission to inject. | 91 // Sends a message to the browser to request permission to inject. |
| 91 void RequestPermissionFromBrowser(); | 92 void RequestPermissionFromBrowser(); |
| 92 | 93 |
| 93 // Injects the script. Returns INJECTION_FINISHED if injection has finished, | 94 // Injects the script. Returns INJECTION_FINISHED if injection has finished, |
| 94 // otherwise INJECTION_BLOCKED. | 95 // otherwise INJECTION_BLOCKED. |
| 95 InjectionResult Inject(ScriptsRunInfo* scripts_run_info); | 96 InjectionResult Inject(ScriptsRunInfo* scripts_run_info); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 114 content::RenderFrame* render_frame_; | 115 content::RenderFrame* render_frame_; |
| 115 | 116 |
| 116 // The associated injection host. | 117 // The associated injection host. |
| 117 scoped_ptr<const InjectionHost> injection_host_; | 118 scoped_ptr<const InjectionHost> injection_host_; |
| 118 | 119 |
| 119 // The location in the document load at which we inject the script. | 120 // The location in the document load at which we inject the script. |
| 120 UserScript::RunLocation run_location_; | 121 UserScript::RunLocation run_location_; |
| 121 | 122 |
| 122 // This injection's request id. This will be -1 unless the injection is | 123 // This injection's request id. This will be -1 unless the injection is |
| 123 // currently waiting on permission. | 124 // currently waiting on permission. |
| 124 int64 request_id_; | 125 int64_t request_id_; |
| 125 | 126 |
| 126 // Whether or not the injection is complete, either via injecting the script | 127 // Whether or not the injection is complete, either via injecting the script |
| 127 // or because it will never complete. | 128 // or because it will never complete. |
| 128 bool complete_; | 129 bool complete_; |
| 129 | 130 |
| 130 // Whether or not the injection successfully injected JS. | 131 // Whether or not the injection successfully injected JS. |
| 131 bool did_inject_js_; | 132 bool did_inject_js_; |
| 132 | 133 |
| 133 // Results storage. | 134 // Results storage. |
| 134 scoped_ptr<base::Value> execution_result_; | 135 scoped_ptr<base::Value> execution_result_; |
| 135 | 136 |
| 136 // The callback to run upon completing asynchronously. | 137 // The callback to run upon completing asynchronously. |
| 137 CompletionCallback async_completion_callback_; | 138 CompletionCallback async_completion_callback_; |
| 138 | 139 |
| 139 // A helper class to hold the render frame and watch for its deletion. | 140 // A helper class to hold the render frame and watch for its deletion. |
| 140 scoped_ptr<FrameWatcher> frame_watcher_; | 141 scoped_ptr<FrameWatcher> frame_watcher_; |
| 141 | 142 |
| 142 base::WeakPtrFactory<ScriptInjection> weak_ptr_factory_; | 143 base::WeakPtrFactory<ScriptInjection> weak_ptr_factory_; |
| 143 | 144 |
| 144 DISALLOW_COPY_AND_ASSIGN(ScriptInjection); | 145 DISALLOW_COPY_AND_ASSIGN(ScriptInjection); |
| 145 }; | 146 }; |
| 146 | 147 |
| 147 } // namespace extensions | 148 } // namespace extensions |
| 148 | 149 |
| 149 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_ | 150 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_ |
| OLD | NEW |