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

Side by Side Diff: extensions/renderer/user_script_set.h

Issue 404613006: Declarative content scripts: Renderer-side: per-extension shared memory regions (lazily loaded) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix use of scoped and linked ptrs, better documentation Created 6 years, 5 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_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 13 matching lines...) Expand all
24 } 24 }
25 25
26 namespace extensions { 26 namespace extensions {
27 class Extension; 27 class Extension;
28 class ExtensionSet; 28 class ExtensionSet;
29 class ScriptInjection; 29 class ScriptInjection;
30 30
31 // The UserScriptSet is a collection of UserScripts which knows how to update 31 // The UserScriptSet is a collection of UserScripts which knows how to update
32 // itself from SharedMemory and create ScriptInjections for UserScripts to 32 // itself from SharedMemory and create ScriptInjections for UserScripts to
33 // inject on a page. 33 // inject on a page.
34 class UserScriptSet : public content::RenderProcessObserver { 34 class UserScriptSet {
35 public: 35 public:
36 // Provide UserScriptSetManager with accesss to OnUpdateUserScripts and
Jeffrey Yasskin 2014/07/28 17:47:16 s/accesss/access/
Mark Dittmer 2014/07/28 22:21:28 Done.
37 // scripts_.
38 friend class UserScriptSetManager;
Devlin 2014/07/28 18:15:27 nit: We usually put friend classes in the private:
Mark Dittmer 2014/07/28 22:21:28 Done, but this required an accessor for scripts_ a
39
36 class Observer { 40 class Observer {
Devlin 2014/07/28 18:15:27 Is this class still needed for anything?
Mark Dittmer 2014/07/28 22:21:28 Yes. The UserScriptInjector still observes each Us
37 public: 41 public:
38 virtual void OnUserScriptsUpdated( 42 virtual void OnUserScriptsUpdated(
39 const std::set<std::string>& changed_extensions, 43 const std::set<std::string>& changed_extensions,
40 const std::vector<UserScript*>& scripts) = 0; 44 const std::vector<UserScript*>& scripts) = 0;
41 }; 45 };
42 46
43 UserScriptSet(const ExtensionSet* extensions); 47 explicit UserScriptSet(const ExtensionSet* extensions);
44 virtual ~UserScriptSet(); 48 virtual ~UserScriptSet();
45 49
46 // Adds or removes observers. 50 // Adds or removes observers.
47 void AddObserver(Observer* observer); 51 void AddObserver(Observer* observer);
48 void RemoveObserver(Observer* observer); 52 void RemoveObserver(Observer* observer);
49 53
50 // Appends the ids of the extensions that have user scripts to |ids|. 54 // Appends the ids of the extensions that have user scripts to |ids|.
51 void GetActiveExtensionIds(std::set<std::string>* ids) const; 55 void GetActiveExtensionIds(std::set<std::string>* ids) const;
52 56
53 // Populate |injections| with any ScriptInjections that should run on the 57 // Populate |injections| with any ScriptInjections that should run on the
54 // given |web_frame| and |tab_id|, at the given |run_location|. 58 // given |web_frame| and |tab_id|, at the given |run_location|.
55 // |extensions| is passed in to verify the corresponding extension is still 59 // |extensions| is passed in to verify the corresponding extension is still
56 // valid. 60 // valid.
57 void GetInjections(ScopedVector<ScriptInjection>* injections, 61 void GetInjections(ScopedVector<ScriptInjection>* injections,
58 blink::WebFrame* web_frame, 62 blink::WebFrame* web_frame,
59 int tab_id, 63 int tab_id,
60 UserScript::RunLocation run_location); 64 UserScript::RunLocation run_location);
61 65
62 private: 66 private:
63 // content::RenderProcessObserver implementation. 67 // Handle the UpdateUserScripts extension message. Return true if the
64 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; 68 // method follows through on notifying observers of the change, or false if
65 69 // an error occurred.
66 // Handle the UpdateUserScripts extension message. 70 bool OnUpdateUserScripts(base::SharedMemoryHandle shared_memory,
67 void OnUpdateUserScripts(base::SharedMemoryHandle shared_memory,
68 const std::set<std::string>& changed_extensions); 71 const std::set<std::string>& changed_extensions);
69 72
70 // Update the parsed scripts from |shared memory|. 73 // Update the parsed scripts from |shared memory|.
71 bool UpdateScripts(base::SharedMemoryHandle shared_memory); 74 bool UpdateScripts(base::SharedMemoryHandle shared_memory);
72 75
73 // Returns a new ScriptInjection for the given |script| to execute in the 76 // Returns a new ScriptInjection for the given |script| to execute in the
74 // |web_frame|, or NULL if the script should not execute. 77 // |web_frame|, or NULL if the script should not execute.
75 scoped_ptr<ScriptInjection> GetInjectionForScript( 78 scoped_ptr<ScriptInjection> GetInjectionForScript(
76 UserScript* script, 79 UserScript* script,
77 blink::WebFrame* web_frame, 80 blink::WebFrame* web_frame,
(...skipping 13 matching lines...) Expand all
91 94
92 // The associated observers. 95 // The associated observers.
93 ObserverList<Observer> observers_; 96 ObserverList<Observer> observers_;
94 97
95 DISALLOW_COPY_AND_ASSIGN(UserScriptSet); 98 DISALLOW_COPY_AND_ASSIGN(UserScriptSet);
96 }; 99 };
97 100
98 } // namespace extensions 101 } // namespace extensions
99 102
100 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ 103 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698