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 namespace blink { | 16 namespace blink { |
17 class WebFrame; | 17 class WebFrame; |
18 } | 18 } |
19 | 19 |
20 namespace extensions { | 20 namespace extensions { |
21 class Extension; | 21 class Extension; |
22 | 22 |
23 // A ScriptInjector for UserScripts. | 23 // A ScriptInjector for UserScripts. |
24 class UserScriptInjector : public ScriptInjector, | 24 class UserScriptInjector : public ScriptInjector, |
25 public UserScriptSet::Observer { | 25 public UserScriptSet::Observer { |
26 public: | 26 public: |
27 UserScriptInjector(const UserScript* user_script, | 27 UserScriptInjector(const UserScript* user_script, |
28 UserScriptSet* user_script_set); | 28 UserScriptSet* user_script_set, |
| 29 bool is_declarative); |
29 virtual ~UserScriptInjector(); | 30 virtual ~UserScriptInjector(); |
30 | 31 |
31 private: | 32 private: |
32 // UserScriptSet::Observer implementation. | 33 // UserScriptSet::Observer implementation. |
33 virtual void OnUserScriptsUpdated( | 34 virtual void OnUserScriptsUpdated( |
34 const std::set<std::string>& changed_extensions, | 35 const std::set<std::string>& changed_extensions, |
35 const std::vector<UserScript*>& scripts) OVERRIDE; | 36 const std::vector<UserScript*>& scripts) OVERRIDE; |
36 | 37 |
37 // ScriptInjector implementation. | 38 // ScriptInjector implementation. |
38 virtual UserScript::InjectionType script_type() const OVERRIDE; | 39 virtual UserScript::InjectionType script_type() const OVERRIDE; |
(...skipping 25 matching lines...) Expand all Loading... |
64 const UserScript* script_; | 65 const UserScript* script_; |
65 | 66 |
66 // The id of the associated user script. We cache this because when we update | 67 // The id of the associated user script. We cache this because when we update |
67 // the |script_| associated with this injection, the old referance may be | 68 // the |script_| associated with this injection, the old referance may be |
68 // deleted. | 69 // deleted. |
69 int script_id_; | 70 int script_id_; |
70 | 71 |
71 // The associated extension id, preserved for the same reason as |script_id|. | 72 // The associated extension id, preserved for the same reason as |script_id|. |
72 std::string extension_id_; | 73 std::string extension_id_; |
73 | 74 |
| 75 // Indicates whether or not this script is declarative. This influences which |
| 76 // script permissions are checked before injection. |
| 77 bool is_declarative_; |
| 78 |
74 ScopedObserver<UserScriptSet, UserScriptSet::Observer> | 79 ScopedObserver<UserScriptSet, UserScriptSet::Observer> |
75 user_script_set_observer_; | 80 user_script_set_observer_; |
76 | 81 |
77 DISALLOW_COPY_AND_ASSIGN(UserScriptInjector); | 82 DISALLOW_COPY_AND_ASSIGN(UserScriptInjector); |
78 }; | 83 }; |
79 | 84 |
80 } // namespace extensions | 85 } // namespace extensions |
81 | 86 |
82 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_ | 87 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_ |
OLD | NEW |