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 <map> | |
8 #include <memory> | 9 #include <memory> |
9 #include <set> | 10 #include <set> |
10 #include <string> | 11 #include <string> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
15 #include "base/memory/shared_memory.h" | 16 #include "base/memory/shared_memory.h" |
16 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
17 #include "extensions/common/user_script.h" | 18 #include "extensions/common/user_script.h" |
19 #include "third_party/WebKit/public/platform/WebString.h" | |
20 #include "third_party/WebKit/public/web/WebScriptSource.h" | |
18 | 21 |
19 class GURL; | 22 class GURL; |
20 | 23 |
21 namespace content { | 24 namespace content { |
22 class RenderFrame; | 25 class RenderFrame; |
23 } | 26 } |
24 | 27 |
25 namespace extensions { | 28 namespace extensions { |
26 class ScriptInjection; | 29 class ScriptInjection; |
27 | 30 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 UserScript::RunLocation run_location, | 66 UserScript::RunLocation run_location, |
64 const GURL& document_url, | 67 const GURL& document_url, |
65 bool log_activity); | 68 bool log_activity); |
66 | 69 |
67 // Updates scripts given the shared memory region containing user scripts. | 70 // Updates scripts given the shared memory region containing user scripts. |
68 // Returns true if the scripts were successfully updated. | 71 // Returns true if the scripts were successfully updated. |
69 bool UpdateUserScripts(base::SharedMemoryHandle shared_memory, | 72 bool UpdateUserScripts(base::SharedMemoryHandle shared_memory, |
70 const std::set<HostID>& changed_hosts, | 73 const std::set<HostID>& changed_hosts, |
71 bool whitelisted_only); | 74 bool whitelisted_only); |
72 | 75 |
76 // Returns the contents of a script with id |script_id|. | |
77 // Note that copying is cheap as this uses WebScriptSource/WebString. | |
78 std::vector<blink::WebScriptSource> GetJsSources(int script_id); | |
79 std::vector<blink::WebString> GetCssSources(int script_id); | |
80 | |
73 private: | 81 private: |
74 // Returns a new ScriptInjection for the given |script| to execute in the | 82 // Returns a new ScriptInjection for the given |script| to execute in the |
75 // |render_frame|, or NULL if the script should not execute. | 83 // |render_frame|, or NULL if the script should not execute. |
76 std::unique_ptr<ScriptInjection> GetInjectionForScript( | 84 std::unique_ptr<ScriptInjection> GetInjectionForScript( |
77 const UserScript* script, | 85 const UserScript* script, |
78 content::RenderFrame* render_frame, | 86 content::RenderFrame* render_frame, |
79 int tab_id, | 87 int tab_id, |
80 UserScript::RunLocation run_location, | 88 UserScript::RunLocation run_location, |
81 const GURL& document_url, | 89 const GURL& document_url, |
82 bool is_declarative, | 90 bool is_declarative, |
83 bool log_activity); | 91 bool log_activity); |
84 | 92 |
85 // Shared memory containing raw script data. | 93 // Shared memory containing raw script data. |
86 std::unique_ptr<base::SharedMemory> shared_memory_; | 94 std::unique_ptr<base::SharedMemory> shared_memory_; |
87 | 95 |
88 // The UserScripts this injector manages. | 96 // The UserScripts this injector manages. |
89 UserScriptList scripts_; | 97 UserScriptList scripts_; |
90 | 98 |
99 // Map of user script id -> list of JavaScript sources. | |
100 std::map<int, std::vector<blink::WebScriptSource>> js_script_sources_; | |
101 // Map of user script id -> list of JavaScript sources. | |
Devlin
2016/08/25 17:07:35
nit: not js :)
lazyboy
2016/09/06 19:37:32
Acknowledged.
| |
102 std::map<int, std::vector<blink::WebString>> css_script_sources_; | |
103 | |
91 // The associated observers. | 104 // The associated observers. |
92 base::ObserverList<Observer> observers_; | 105 base::ObserverList<Observer> observers_; |
93 | 106 |
94 DISALLOW_COPY_AND_ASSIGN(UserScriptSet); | 107 DISALLOW_COPY_AND_ASSIGN(UserScriptSet); |
95 }; | 108 }; |
96 | 109 |
97 } // namespace extensions | 110 } // namespace extensions |
98 | 111 |
99 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ | 112 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ |
OLD | NEW |