Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: extensions/browser/user_script_loader.h

Issue 2227193002: Make UserScript non-copyable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync @tott Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_BROWSER_USER_SCRIPT_LOADER_H_ 5 #ifndef EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_
6 #define EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_ 6 #define EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 // Parses the includes out of |script| and returns them in |includes|. 52 // Parses the includes out of |script| and returns them in |includes|.
53 static bool ParseMetadataHeader(const base::StringPiece& script_text, 53 static bool ParseMetadataHeader(const base::StringPiece& script_text,
54 UserScript* script); 54 UserScript* script);
55 55
56 UserScriptLoader(content::BrowserContext* browser_context, 56 UserScriptLoader(content::BrowserContext* browser_context,
57 const HostID& host_id); 57 const HostID& host_id);
58 ~UserScriptLoader() override; 58 ~UserScriptLoader() override;
59 59
60 // Add |scripts| to the set of scripts managed by this loader. 60 // Add |scripts| to the set of scripts managed by this loader.
61 void AddScripts(const UserScriptList& scripts); 61 void AddScripts(std::unique_ptr<UserScriptList> scripts);
62 62
63 // Add |scripts| to the set of scripts managed by this loader. 63 // Add |scripts| to the set of scripts managed by this loader.
64 // The fetch of the content of the script starts URL request 64 // The fetch of the content of the script starts URL request
65 // to the associated render specified by 65 // to the associated render specified by
66 // |render_process_id, render_frame_id|. 66 // |render_process_id, render_frame_id|.
67 // TODO(hanxi): The renderer information doesn't really belong in this base 67 // TODO(hanxi): The renderer information doesn't really belong in this base
68 // class, but it's not an easy fix. 68 // class, but it's not an easy fix.
69 virtual void AddScripts(const UserScriptList& scripts, 69 virtual void AddScripts(std::unique_ptr<UserScriptList> scripts,
70 int render_process_id, 70 int render_process_id,
71 int render_frame_id); 71 int render_frame_id);
72 72
73 // Removes scripts with ids specified in |scripts| from the set of scripts 73 // Removes scripts with ids specified in |scripts| from the set of scripts
74 // managed by this loader. 74 // managed by this loader.
75 // TODO(lazyboy): Likely we can make |scripts| a std::vector, but 75 // TODO(lazyboy): Likely we can make |scripts| a std::vector, but
76 // WebViewContentScriptManager makes this non-trivial. 76 // WebViewContentScriptManager makes this non-trivial.
77 void RemoveScripts(const std::set<UserScriptIDPair>& scripts); 77 void RemoveScripts(const std::set<UserScriptIDPair>& scripts);
78 78
79 // Clears the set of scripts managed by this loader. 79 // Clears the set of scripts managed by this loader.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 // Contains the scripts that were found the last time scripts were updated. 144 // Contains the scripts that were found the last time scripts were updated.
145 std::unique_ptr<base::SharedMemory> shared_memory_; 145 std::unique_ptr<base::SharedMemory> shared_memory_;
146 146
147 // List of scripts from currently-installed extensions we should load. 147 // List of scripts from currently-installed extensions we should load.
148 std::unique_ptr<UserScriptList> user_scripts_; 148 std::unique_ptr<UserScriptList> user_scripts_;
149 149
150 // The mutually-exclusive information about sets of scripts that were added or 150 // The mutually-exclusive information about sets of scripts that were added or
151 // removed since the last script load. These maps are keyed by script ids. 151 // removed since the last script load. These maps are keyed by script ids.
152 // Note that we only need HostID information for removal. 152 // Note that we only need HostID information for removal.
153 std::map<int, UserScript> added_scripts_map_; 153 std::map<int, std::unique_ptr<UserScript>> added_scripts_map_;
154 std::set<UserScriptIDPair> removed_script_hosts_; 154 std::set<UserScriptIDPair> removed_script_hosts_;
155 155
156 // Indicates whether the the collection of scripts should be cleared before 156 // Indicates whether the the collection of scripts should be cleared before
157 // additions and removals on the next script load. 157 // additions and removals on the next script load.
158 bool clear_scripts_; 158 bool clear_scripts_;
159 159
160 // The IDs of the extensions which changed in the last update sent to the 160 // The IDs of the extensions which changed in the last update sent to the
161 // renderer. 161 // renderer.
162 std::set<HostID> changed_hosts_; 162 std::set<HostID> changed_hosts_;
163 163
(...skipping 16 matching lines...) Expand all
180 base::ObserverList<Observer> observers_; 180 base::ObserverList<Observer> observers_;
181 181
182 base::WeakPtrFactory<UserScriptLoader> weak_factory_; 182 base::WeakPtrFactory<UserScriptLoader> weak_factory_;
183 183
184 DISALLOW_COPY_AND_ASSIGN(UserScriptLoader); 184 DISALLOW_COPY_AND_ASSIGN(UserScriptLoader);
185 }; 185 };
186 186
187 } // namespace extensions 187 } // namespace extensions
188 188
189 #endif // EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_ 189 #endif // EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_
OLDNEW
« no previous file with comments | « extensions/browser/guest_view/web_view/web_view_content_script_manager.cc ('k') | extensions/browser/user_script_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698