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

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: Re-add missing Disptacher::content_watcher_ initialization 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 : public content::RenderProcessObserver {
Jeffrey Yasskin 2014/07/24 21:09:19 Stop inheriting from RenderProcessObserver if you
Mark Dittmer 2014/07/25 15:09:05 Done.
35 public: 35 public:
36 // Provide UserScriptSetManager with accesss to OnUpdateUserScripts and
37 // scripts_.
38 friend class UserScriptSetManager;
39
36 class Observer { 40 class Observer {
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 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.
64 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE;
65
66 // Handle the UpdateUserScripts extension message. 67 // Handle the UpdateUserScripts extension message.
67 void OnUpdateUserScripts(base::SharedMemoryHandle shared_memory, 68 bool OnUpdateUserScripts(base::SharedMemoryHandle shared_memory,
Jeffrey Yasskin 2014/07/24 21:09:19 Any time you return a value, you should document w
Mark Dittmer 2014/07/25 15:09:05 Done.
68 const std::set<std::string>& changed_extensions); 69 const std::set<std::string>& changed_extensions);
69 70
70 // Update the parsed scripts from |shared memory|. 71 // Update the parsed scripts from |shared memory|.
71 bool UpdateScripts(base::SharedMemoryHandle shared_memory); 72 bool UpdateScripts(base::SharedMemoryHandle shared_memory);
72 73
73 // 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
74 // |web_frame|, or NULL if the script should not execute. 75 // |web_frame|, or NULL if the script should not execute.
75 scoped_ptr<ScriptInjection> GetInjectionForScript( 76 scoped_ptr<ScriptInjection> GetInjectionForScript(
76 UserScript* script, 77 UserScript* script,
77 blink::WebFrame* web_frame, 78 blink::WebFrame* web_frame,
(...skipping 13 matching lines...) Expand all
91 92
92 // The associated observers. 93 // The associated observers.
93 ObserverList<Observer> observers_; 94 ObserverList<Observer> observers_;
94 95
95 DISALLOW_COPY_AND_ASSIGN(UserScriptSet); 96 DISALLOW_COPY_AND_ASSIGN(UserScriptSet);
96 }; 97 };
97 98
98 } // namespace extensions 99 } // namespace extensions
99 100
100 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ 101 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698