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

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

Issue 988633003: Refactoring: de-couple Extensions from "script injection System" [render side]:4 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits. Created 5 years, 9 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 17 matching lines...) Expand all
28 class ScriptInjection; 28 class ScriptInjection;
29 29
30 // The UserScriptSet is a collection of UserScripts which knows how to update 30 // The UserScriptSet is a collection of UserScripts which knows how to update
31 // itself from SharedMemory and create ScriptInjections for UserScripts to 31 // itself from SharedMemory and create ScriptInjections for UserScripts to
32 // inject on a page. 32 // inject on a page.
33 class UserScriptSet { 33 class UserScriptSet {
34 public: 34 public:
35 class Observer { 35 class Observer {
36 public: 36 public:
37 virtual void OnUserScriptsUpdated( 37 virtual void OnUserScriptsUpdated(
38 const std::set<std::string>& changed_extensions, 38 const std::set<HostID>& changed_hosts,
39 const std::vector<UserScript*>& scripts) = 0; 39 const std::vector<UserScript*>& scripts) = 0;
40 }; 40 };
41 41
42 explicit UserScriptSet(const ExtensionSet* extensions); 42 explicit UserScriptSet(const ExtensionSet* extensions);
43 ~UserScriptSet(); 43 ~UserScriptSet();
44 44
45 // Adds or removes observers. 45 // Adds or removes observers.
46 void AddObserver(Observer* observer); 46 void AddObserver(Observer* observer);
47 void RemoveObserver(Observer* observer); 47 void RemoveObserver(Observer* observer);
48 48
(...skipping 12 matching lines...) Expand all
61 scoped_ptr<ScriptInjection> GetDeclarativeScriptInjection( 61 scoped_ptr<ScriptInjection> GetDeclarativeScriptInjection(
62 int script_id, 62 int script_id,
63 blink::WebFrame* web_frame, 63 blink::WebFrame* web_frame,
64 int tab_id, 64 int tab_id,
65 UserScript::RunLocation run_location, 65 UserScript::RunLocation run_location,
66 const GURL& document_url); 66 const GURL& document_url);
67 67
68 // Updates scripts given the shared memory region containing user scripts. 68 // Updates scripts given the shared memory region containing user scripts.
69 // Returns true if the scripts were successfully updated. 69 // Returns true if the scripts were successfully updated.
70 bool UpdateUserScripts(base::SharedMemoryHandle shared_memory, 70 bool UpdateUserScripts(base::SharedMemoryHandle shared_memory,
71 const std::set<std::string>& changed_extensions); 71 const std::set<HostID>& changed_hosts);
72 72
73 const std::vector<UserScript*>& scripts() const { return scripts_.get(); } 73 const std::vector<UserScript*>& scripts() const { return scripts_.get(); }
74 74
75 private: 75 private:
76 // 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
77 // |web_frame|, or NULL if the script should not execute. 77 // |web_frame|, or NULL if the script should not execute.
78 scoped_ptr<ScriptInjection> GetInjectionForScript( 78 scoped_ptr<ScriptInjection> GetInjectionForScript(
79 UserScript* script, 79 UserScript* script,
80 blink::WebFrame* web_frame, 80 blink::WebFrame* web_frame,
81 int tab_id, 81 int tab_id,
(...skipping 12 matching lines...) Expand all
94 94
95 // The associated observers. 95 // The associated observers.
96 ObserverList<Observer> observers_; 96 ObserverList<Observer> observers_;
97 97
98 DISALLOW_COPY_AND_ASSIGN(UserScriptSet); 98 DISALLOW_COPY_AND_ASSIGN(UserScriptSet);
99 }; 99 };
100 100
101 } // namespace extensions 101 } // namespace extensions
102 102
103 #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