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_PROGRAMMATIC_SCRIPT_INJECTOR_H_ | 5 #ifndef EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ |
6 #define EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ | 6 #define EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "extensions/renderer/script_injection.h" | 11 #include "extensions/renderer/script_injection.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
14 struct ExtensionMsg_ExecuteCode_Params; | 14 struct ExtensionMsg_ExecuteCode_Params; |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 class RenderFrame; | 17 class RenderFrame; |
18 } | 18 } |
19 | 19 |
20 namespace extensions { | 20 namespace extensions { |
21 | 21 |
22 // A ScriptInjector to handle tabs.executeScript(). | 22 // A ScriptInjector to handle tabs.executeScript(). |
23 class ProgrammaticScriptInjector : public ScriptInjector { | 23 class ProgrammaticScriptInjector : public ScriptInjector { |
24 public: | 24 public: |
25 ProgrammaticScriptInjector(const ExtensionMsg_ExecuteCode_Params& params, | 25 ProgrammaticScriptInjector(const ExtensionMsg_ExecuteCode_Params& params, |
26 content::RenderFrame* render_frame); | 26 content::RenderFrame* render_frame); |
27 ~ProgrammaticScriptInjector() override; | 27 ~ProgrammaticScriptInjector() override; |
28 | 28 |
29 private: | 29 private: |
| 30 class FrameWatcher; |
| 31 |
30 // ScriptInjector implementation. | 32 // ScriptInjector implementation. |
31 UserScript::InjectionType script_type() const override; | 33 UserScript::InjectionType script_type() const override; |
32 bool ShouldExecuteInMainWorld() const override; | 34 bool ShouldExecuteInMainWorld() const override; |
33 bool IsUserGesture() const override; | 35 bool IsUserGesture() const override; |
34 bool ExpectsResults() const override; | 36 bool ExpectsResults() const override; |
35 bool ShouldInjectJs(UserScript::RunLocation run_location) const override; | 37 bool ShouldInjectJs(UserScript::RunLocation run_location) const override; |
36 bool ShouldInjectCss(UserScript::RunLocation run_location) const override; | 38 bool ShouldInjectCss(UserScript::RunLocation run_location) const override; |
37 PermissionsData::AccessType CanExecuteOnFrame( | 39 PermissionsData::AccessType CanExecuteOnFrame( |
38 const InjectionHost* injection_host, | 40 const InjectionHost* injection_host, |
39 blink::WebLocalFrame* web_frame, | 41 blink::WebLocalFrame* web_frame, |
(...skipping 19 matching lines...) Expand all Loading... |
59 scoped_ptr<ExtensionMsg_ExecuteCode_Params> params_; | 61 scoped_ptr<ExtensionMsg_ExecuteCode_Params> params_; |
60 | 62 |
61 // The url of the frame into which we are injecting. | 63 // The url of the frame into which we are injecting. |
62 GURL url_; | 64 GURL url_; |
63 | 65 |
64 // The URL of the frame's origin. This is usually identical to |url_|, but | 66 // The URL of the frame's origin. This is usually identical to |url_|, but |
65 // could be different for e.g. about:blank URLs. Do not use this value to make | 67 // could be different for e.g. about:blank URLs. Do not use this value to make |
66 // security decisions, to avoid race conditions (e.g. due to navigation). | 68 // security decisions, to avoid race conditions (e.g. due to navigation). |
67 GURL effective_url_; | 69 GURL effective_url_; |
68 | 70 |
69 // The RenderFrame to which we send the response upon completion. | 71 // A helper class to hold the render frame and watch for its deletion. |
70 content::RenderFrame* render_frame_; | 72 scoped_ptr<FrameWatcher> frame_watcher_; |
71 | 73 |
72 // The results of the script execution. | 74 // The results of the script execution. |
73 base::ListValue results_; | 75 base::ListValue results_; |
74 | 76 |
75 // Whether or not this script injection has finished. | 77 // Whether or not this script injection has finished. |
76 bool finished_; | 78 bool finished_; |
77 | 79 |
78 DISALLOW_COPY_AND_ASSIGN(ProgrammaticScriptInjector); | 80 DISALLOW_COPY_AND_ASSIGN(ProgrammaticScriptInjector); |
79 }; | 81 }; |
80 | 82 |
81 } // namespace extensions | 83 } // namespace extensions |
82 | 84 |
83 #endif // EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ | 85 #endif // EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ |
OLD | NEW |