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_USER_SCRIPT_INJECTOR_H_ | 5 #ifndef EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_ |
6 #define EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_ | 6 #define EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/scoped_observer.h" | 11 #include "base/scoped_observer.h" |
12 #include "extensions/common/user_script.h" | 12 #include "extensions/common/user_script.h" |
13 #include "extensions/renderer/script_injection.h" | 13 #include "extensions/renderer/script_injection.h" |
14 #include "extensions/renderer/user_script_set.h" | 14 #include "extensions/renderer/user_script_set.h" |
15 | 15 |
16 class InjectionHost; | 16 class InjectionHost; |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 class WebFrame; | 19 class WebFrame; |
20 } | 20 } |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 | 23 |
24 // A ScriptInjector for UserScripts. | 24 // A ScriptInjector for UserScripts. |
25 class UserScriptInjector : public ScriptInjector, | 25 class UserScriptInjector : public ScriptInjector, |
26 public UserScriptSet::Observer { | 26 public UserScriptSet::Observer { |
27 public: | 27 public: |
28 UserScriptInjector(const UserScript* user_script, | 28 UserScriptInjector(const UserScript* user_script, |
29 UserScriptSet* user_script_set, | 29 UserScriptSet* user_script_set, |
30 bool is_declarative); | 30 bool is_declarative, |
| 31 bool has_guest_content_script); |
31 ~UserScriptInjector() override; | 32 ~UserScriptInjector() override; |
32 | 33 |
33 private: | 34 private: |
34 // UserScriptSet::Observer implementation. | 35 // UserScriptSet::Observer implementation. |
35 void OnUserScriptsUpdated(const std::set<HostID>& changed_hosts, | 36 void OnUserScriptsUpdated(const std::set<HostID>& changed_hosts, |
36 const std::vector<UserScript*>& scripts) override; | 37 const std::vector<UserScript*>& scripts) override; |
37 | 38 |
38 // ScriptInjector implementation. | 39 // ScriptInjector implementation. |
39 UserScript::InjectionType script_type() const override; | 40 UserScript::InjectionType script_type() const override; |
40 bool ShouldExecuteInChildFrames() const override; | 41 bool ShouldExecuteInChildFrames() const override; |
(...skipping 26 matching lines...) Expand all Loading... |
67 // deleted. | 68 // deleted. |
68 int script_id_; | 69 int script_id_; |
69 | 70 |
70 // The associated host id, preserved for the same reason as |script_id|. | 71 // The associated host id, preserved for the same reason as |script_id|. |
71 HostID host_id_; | 72 HostID host_id_; |
72 | 73 |
73 // Indicates whether or not this script is declarative. This influences which | 74 // Indicates whether or not this script is declarative. This influences which |
74 // script permissions are checked before injection. | 75 // script permissions are checked before injection. |
75 bool is_declarative_; | 76 bool is_declarative_; |
76 | 77 |
| 78 // Indicates whether the injector belongs to a guest render process that has |
| 79 // content scripts. |
| 80 bool has_guest_content_script_; |
| 81 |
77 ScopedObserver<UserScriptSet, UserScriptSet::Observer> | 82 ScopedObserver<UserScriptSet, UserScriptSet::Observer> |
78 user_script_set_observer_; | 83 user_script_set_observer_; |
79 | 84 |
80 DISALLOW_COPY_AND_ASSIGN(UserScriptInjector); | 85 DISALLOW_COPY_AND_ASSIGN(UserScriptInjector); |
81 }; | 86 }; |
82 | 87 |
83 } // namespace extensions | 88 } // namespace extensions |
84 | 89 |
85 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_ | 90 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_ |
OLD | NEW |