| 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_SET_H_ | 5 #ifndef EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ |
| 6 #define EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ | 6 #define EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 // Populate |injections| with any ScriptInjections that should run on the | 53 // Populate |injections| with any ScriptInjections that should run on the |
| 54 // given |web_frame| and |tab_id|, at the given |run_location|. | 54 // given |web_frame| and |tab_id|, at the given |run_location|. |
| 55 // |extensions| is passed in to verify the corresponding extension is still | 55 // |extensions| is passed in to verify the corresponding extension is still |
| 56 // valid. | 56 // valid. |
| 57 void GetInjections(ScopedVector<ScriptInjection>* injections, | 57 void GetInjections(ScopedVector<ScriptInjection>* injections, |
| 58 blink::WebFrame* web_frame, | 58 blink::WebFrame* web_frame, |
| 59 int tab_id, | 59 int tab_id, |
| 60 UserScript::RunLocation run_location); | 60 UserScript::RunLocation run_location); |
| 61 | 61 |
| 62 scoped_ptr<ScriptInjection> GetDeclarativeScriptInjection( |
| 63 int script_id, |
| 64 blink::WebFrame* web_frame, |
| 65 int tab_id, |
| 66 UserScript::RunLocation run_location, |
| 67 const GURL& document_url, |
| 68 const Extension* extension); |
| 69 |
| 62 // Updates scripts given the shared memory region containing user scripts. | 70 // Updates scripts given the shared memory region containing user scripts. |
| 63 // Returns true if the scripts were successfully updated. | 71 // Returns true if the scripts were successfully updated. |
| 64 bool UpdateUserScripts(base::SharedMemoryHandle shared_memory, | 72 bool UpdateUserScripts(base::SharedMemoryHandle shared_memory, |
| 65 const std::set<std::string>& changed_extensions); | 73 const std::set<std::string>& changed_extensions); |
| 66 | 74 |
| 67 const std::vector<UserScript*>& scripts() const { return scripts_.get(); } | 75 const std::vector<UserScript*>& scripts() const { return scripts_.get(); } |
| 68 | 76 |
| 69 private: | 77 private: |
| 70 // Returns a new ScriptInjection for the given |script| to execute in the | 78 // Returns a new ScriptInjection for the given |script| to execute in the |
| 71 // |web_frame|, or NULL if the script should not execute. | 79 // |web_frame|, or NULL if the script should not execute. |
| 72 scoped_ptr<ScriptInjection> GetInjectionForScript( | 80 scoped_ptr<ScriptInjection> GetInjectionForScript( |
| 73 UserScript* script, | 81 UserScript* script, |
| 74 blink::WebFrame* web_frame, | 82 blink::WebFrame* web_frame, |
| 75 int tab_id, | 83 int tab_id, |
| 76 UserScript::RunLocation run_location, | 84 UserScript::RunLocation run_location, |
| 77 const GURL& document_url, | 85 const GURL& document_url, |
| 78 const Extension* extension); | 86 const Extension* extension, |
| 87 bool is_declarative); |
| 79 | 88 |
| 80 // Shared memory containing raw script data. | 89 // Shared memory containing raw script data. |
| 81 scoped_ptr<base::SharedMemory> shared_memory_; | 90 scoped_ptr<base::SharedMemory> shared_memory_; |
| 82 | 91 |
| 83 // The set of all known extensions. Owned by the Dispatcher. | 92 // The set of all known extensions. Owned by the Dispatcher. |
| 84 const ExtensionSet* extensions_; | 93 const ExtensionSet* extensions_; |
| 85 | 94 |
| 86 // The UserScripts this injector manages. | 95 // The UserScripts this injector manages. |
| 87 ScopedVector<UserScript> scripts_; | 96 ScopedVector<UserScript> scripts_; |
| 88 | 97 |
| 89 // The associated observers. | 98 // The associated observers. |
| 90 ObserverList<Observer> observers_; | 99 ObserverList<Observer> observers_; |
| 91 | 100 |
| 92 DISALLOW_COPY_AND_ASSIGN(UserScriptSet); | 101 DISALLOW_COPY_AND_ASSIGN(UserScriptSet); |
| 93 }; | 102 }; |
| 94 | 103 |
| 95 } // namespace extensions | 104 } // namespace extensions |
| 96 | 105 |
| 97 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ | 106 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ |
| OLD | NEW |