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 "base/basictypes.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "extensions/common/user_script.h" | 10 #include "extensions/common/user_script.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // Returns true if the injection ran. | 48 // Returns true if the injection ran. |
49 bool OnPermissionGranted(const Extension* extension, | 49 bool OnPermissionGranted(const Extension* extension, |
50 ScriptsRunInfo* scripts_run_info); | 50 ScriptsRunInfo* scripts_run_info); |
51 | 51 |
52 // Accessors. | 52 // Accessors. |
53 blink::WebLocalFrame* web_frame() const { return web_frame_; } | 53 blink::WebLocalFrame* web_frame() const { return web_frame_; } |
54 const std::string& extension_id() const { return extension_id_; } | 54 const std::string& extension_id() const { return extension_id_; } |
55 int64 request_id() const { return request_id_; } | 55 int64 request_id() const { return request_id_; } |
56 | 56 |
57 private: | 57 private: |
58 // Send a message to the browser requesting permission to execute. | 58 // Sends a message to the browser, either that the script injection would |
59 void RequestPermission(); | 59 // like to inject, or to notify the browser that it is currently injecting. |
| 60 void SendInjectionMessage(bool request_permission); |
60 | 61 |
61 // Injects the script, optionally populating |scripts_run_info|. | 62 // Injects the script, optionally populating |scripts_run_info|. |
62 void Inject(const Extension* extension, ScriptsRunInfo* scripts_run_info); | 63 void Inject(const Extension* extension, ScriptsRunInfo* scripts_run_info); |
63 | 64 |
64 // Inject any JS scripts into the |frame|, optionally populating | 65 // Inject any JS scripts into the |frame|, optionally populating |
65 // |execution_results|. | 66 // |execution_results|. |
66 void InjectJs(const Extension* extension, | 67 void InjectJs(const Extension* extension, |
67 blink::WebLocalFrame* frame, | 68 blink::WebLocalFrame* frame, |
68 base::ListValue* execution_results); | 69 base::ListValue* execution_results); |
69 | 70 |
70 // Inject any CSS source into the |frame|. | 71 // Inject any CSS source into the |frame|. |
71 void InjectCss(blink::WebLocalFrame* frame); | 72 void InjectCss(blink::WebLocalFrame* frame); |
72 | 73 |
73 // Notify that we will not inject, and mark it as acknowledged. | 74 // Notify that we will not inject, and mark it as acknowledged. |
74 void NotifyWillNotInject(ScriptInjector::InjectFailureReason reason); | 75 void NotifyWillNotInject(ScriptInjector::InjectFailureReason reason); |
75 | 76 |
| 77 // Notifies the browser of script injection, if appropriate. |
| 78 void NotifyBrowserOfInjection(const Extension* extension); |
| 79 |
76 // The injector for this injection. | 80 // The injector for this injection. |
77 scoped_ptr<ScriptInjector> injector_; | 81 scoped_ptr<ScriptInjector> injector_; |
78 | 82 |
79 // The (main) WebFrame into which this should inject the script. | 83 // The (main) WebFrame into which this should inject the script. |
80 blink::WebLocalFrame* web_frame_; | 84 blink::WebLocalFrame* web_frame_; |
81 | 85 |
82 // The id of the associated extension. | 86 // The id of the associated extension. |
83 std::string extension_id_; | 87 std::string extension_id_; |
84 | 88 |
85 // The location in the document load at which we inject the script. | 89 // The location in the document load at which we inject the script. |
86 UserScript::RunLocation run_location_; | 90 UserScript::RunLocation run_location_; |
87 | 91 |
88 // The tab id associated with the frame. | 92 // The tab id associated with the frame. |
89 int tab_id_; | 93 int tab_id_; |
90 | 94 |
91 // This injection's request id. This will be -1 unless the injection is | 95 // This injection's request id. This will be -1 unless the injection is |
92 // currently waiting on permission. | 96 // currently waiting on permission. |
93 int64 request_id_; | 97 int64 request_id_; |
94 | 98 |
95 // Whether or not the injection is complete, either via injecting the script | 99 // Whether or not the injection is complete, either via injecting the script |
96 // or because it will never complete. | 100 // or because it will never complete. |
97 bool complete_; | 101 bool complete_; |
98 | 102 |
99 DISALLOW_COPY_AND_ASSIGN(ScriptInjection); | 103 DISALLOW_COPY_AND_ASSIGN(ScriptInjection); |
100 }; | 104 }; |
101 | 105 |
102 } // namespace extensions | 106 } // namespace extensions |
103 | 107 |
104 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_ | 108 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_ |
OLD | NEW |