Chromium Code Reviews| 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 |
| 32 // ScriptInjector implementation. | |
| 33 virtual bool is_declarative() const OVERRIDE; | |
|
Devlin
2014/08/21 17:06:17
why?
Mark Dittmer
2014/08/23 12:21:39
ditto (comment in programmatic_script_injector.h)
| |
| 34 | |
| 31 private: | 35 private: |
| 32 // UserScriptSet::Observer implementation. | 36 // UserScriptSet::Observer implementation. |
| 33 virtual void OnUserScriptsUpdated( | 37 virtual void OnUserScriptsUpdated( |
| 34 const std::set<std::string>& changed_extensions, | 38 const std::set<std::string>& changed_extensions, |
| 35 const std::vector<UserScript*>& scripts) OVERRIDE; | 39 const std::vector<UserScript*>& scripts) OVERRIDE; |
| 36 | 40 |
| 37 // ScriptInjector implementation. | 41 // ScriptInjector implementation. |
| 38 virtual UserScript::InjectionType script_type() const OVERRIDE; | 42 virtual UserScript::InjectionType script_type() const OVERRIDE; |
| 39 virtual bool ShouldExecuteInChildFrames() const OVERRIDE; | 43 virtual bool ShouldExecuteInChildFrames() const OVERRIDE; |
| 40 virtual bool ShouldExecuteInMainWorld() const OVERRIDE; | 44 virtual bool ShouldExecuteInMainWorld() const OVERRIDE; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 64 const UserScript* script_; | 68 const UserScript* script_; |
| 65 | 69 |
| 66 // The id of the associated user script. We cache this because when we update | 70 // 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 | 71 // the |script_| associated with this injection, the old referance may be |
| 68 // deleted. | 72 // deleted. |
| 69 int64 script_id_; | 73 int64 script_id_; |
| 70 | 74 |
| 71 // The associated extension id, preserved for the same reason as |script_id|. | 75 // The associated extension id, preserved for the same reason as |script_id|. |
| 72 std::string extension_id_; | 76 std::string extension_id_; |
| 73 | 77 |
| 78 // Indicates whether or not this script is declarative. This influences which | |
| 79 // script permissions are checked before injection. | |
| 80 bool is_declarative_; | |
| 81 | |
| 74 ScopedObserver<UserScriptSet, UserScriptSet::Observer> | 82 ScopedObserver<UserScriptSet, UserScriptSet::Observer> |
| 75 user_script_set_observer_; | 83 user_script_set_observer_; |
| 76 | 84 |
| 77 DISALLOW_COPY_AND_ASSIGN(UserScriptInjector); | 85 DISALLOW_COPY_AND_ASSIGN(UserScriptInjector); |
| 78 }; | 86 }; |
| 79 | 87 |
| 80 } // namespace extensions | 88 } // namespace extensions |
| 81 | 89 |
| 82 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_ | 90 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_ |
| OLD | NEW |