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

Side by Side Diff: extensions/renderer/user_script_set.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
« no previous file with comments | « extensions/renderer/user_script_injector.cc ('k') | extensions/renderer/user_script_set.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 14 matching lines...) Expand all
25 namespace extensions { 25 namespace extensions {
26 class ScriptInjection; 26 class ScriptInjection;
27 27
28 // The UserScriptSet is a collection of UserScripts which knows how to update 28 // The UserScriptSet is a collection of UserScripts which knows how to update
29 // itself from SharedMemory and create ScriptInjections for UserScripts to 29 // itself from SharedMemory and create ScriptInjections for UserScripts to
30 // inject on a page. 30 // inject on a page.
31 class UserScriptSet { 31 class UserScriptSet {
32 public: 32 public:
33 class Observer { 33 class Observer {
34 public: 34 public:
35 virtual void OnUserScriptsUpdated( 35 virtual void OnUserScriptsUpdated(const std::set<HostID>& changed_hosts,
36 const std::set<HostID>& changed_hosts, 36 const UserScriptList& scripts) = 0;
37 const std::vector<std::unique_ptr<UserScript>>& scripts) = 0;
38 }; 37 };
39 38
40 UserScriptSet(); 39 UserScriptSet();
41 ~UserScriptSet(); 40 ~UserScriptSet();
42 41
43 // Adds or removes observers. 42 // Adds or removes observers.
44 void AddObserver(Observer* observer); 43 void AddObserver(Observer* observer);
45 void RemoveObserver(Observer* observer); 44 void RemoveObserver(Observer* observer);
46 45
47 // Appends the ids of the extensions that have user scripts to |ids|. 46 // Appends the ids of the extensions that have user scripts to |ids|.
(...skipping 16 matching lines...) Expand all
64 UserScript::RunLocation run_location, 63 UserScript::RunLocation run_location,
65 const GURL& document_url, 64 const GURL& document_url,
66 bool log_activity); 65 bool log_activity);
67 66
68 // Updates scripts given the shared memory region containing user scripts. 67 // Updates scripts given the shared memory region containing user scripts.
69 // Returns true if the scripts were successfully updated. 68 // Returns true if the scripts were successfully updated.
70 bool UpdateUserScripts(base::SharedMemoryHandle shared_memory, 69 bool UpdateUserScripts(base::SharedMemoryHandle shared_memory,
71 const std::set<HostID>& changed_hosts, 70 const std::set<HostID>& changed_hosts,
72 bool whitelisted_only); 71 bool whitelisted_only);
73 72
74 const std::vector<std::unique_ptr<UserScript>>& scripts() const {
75 return scripts_;
76 }
77
78 private: 73 private:
79 // Returns a new ScriptInjection for the given |script| to execute in the 74 // Returns a new ScriptInjection for the given |script| to execute in the
80 // |render_frame|, or NULL if the script should not execute. 75 // |render_frame|, or NULL if the script should not execute.
81 std::unique_ptr<ScriptInjection> GetInjectionForScript( 76 std::unique_ptr<ScriptInjection> GetInjectionForScript(
82 const UserScript* script, 77 const UserScript* script,
83 content::RenderFrame* render_frame, 78 content::RenderFrame* render_frame,
84 int tab_id, 79 int tab_id,
85 UserScript::RunLocation run_location, 80 UserScript::RunLocation run_location,
86 const GURL& document_url, 81 const GURL& document_url,
87 bool is_declarative, 82 bool is_declarative,
88 bool log_activity); 83 bool log_activity);
89 84
90 // Shared memory containing raw script data. 85 // Shared memory containing raw script data.
91 std::unique_ptr<base::SharedMemory> shared_memory_; 86 std::unique_ptr<base::SharedMemory> shared_memory_;
92 87
93 // The UserScripts this injector manages. 88 // The UserScripts this injector manages.
94 std::vector<std::unique_ptr<UserScript>> scripts_; 89 UserScriptList scripts_;
95 90
96 // The associated observers. 91 // The associated observers.
97 base::ObserverList<Observer> observers_; 92 base::ObserverList<Observer> observers_;
98 93
99 DISALLOW_COPY_AND_ASSIGN(UserScriptSet); 94 DISALLOW_COPY_AND_ASSIGN(UserScriptSet);
100 }; 95 };
101 96
102 } // namespace extensions 97 } // namespace extensions
103 98
104 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ 99 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_
OLDNEW
« no previous file with comments | « extensions/renderer/user_script_injector.cc ('k') | extensions/renderer/user_script_set.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698