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

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

Issue 492133002: Renderer changes for wiring up shared memory with declarative injection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed up tests and responded to other comments Created 6 years, 3 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_MANAGER_H_ 5 #ifndef EXTENSIONS_RENDERER_USER_SCRIPT_SET_MANAGER_H_
6 #define EXTENSIONS_RENDERER_USER_SCRIPT_SET_MANAGER_H_ 6 #define EXTENSIONS_RENDERER_USER_SCRIPT_SET_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 const std::vector<UserScript*>& scripts) = 0; 49 const std::vector<UserScript*>& scripts) = 0;
50 }; 50 };
51 51
52 UserScriptSetManager(const ExtensionSet* extensions); 52 UserScriptSetManager(const ExtensionSet* extensions);
53 53
54 virtual ~UserScriptSetManager(); 54 virtual ~UserScriptSetManager();
55 55
56 void AddObserver(Observer* observer); 56 void AddObserver(Observer* observer);
57 void RemoveObserver(Observer* observer); 57 void RemoveObserver(Observer* observer);
58 58
59 const UserScriptSet* GetProgrammaticScriptsByExtension( 59 // Looks up the script injection associated with |script_id| and |extension|
60 const ExtensionId& extensionId); 60 // in the context of the given |web_frame|, |tab_id|, and |url|.
61 scoped_ptr<ScriptInjection> GetInjectionForDeclarativeScript(
62 int64 script_id,
Devlin 2014/08/27 23:01:12 not int64
Mark Dittmer 2014/08/28 13:02:42 Done.
63 blink::WebFrame* web_frame,
64 int tab_id,
65 const GURL& url,
66 const Extension* extension);
61 67
62 // Put all injections from |static_scripts| and each of 68 // Put all injections from |static_scripts| and each of
63 // |programmatic_scripts_| into |injections|. 69 // |programmatic_scripts_| into |injections|.
64 void GetAllInjections(ScopedVector<ScriptInjection>* injections, 70 void GetAllInjections(ScopedVector<ScriptInjection>* injections,
65 blink::WebFrame* web_frame, 71 blink::WebFrame* web_frame,
66 int tab_id, 72 int tab_id,
67 UserScript::RunLocation run_location); 73 UserScript::RunLocation run_location);
68 74
69 // Get active extension IDs from |static_scripts| and each of 75 // Get active extension IDs from |static_scripts| and each of
70 // |programmatic_scripts_|. 76 // |programmatic_scripts_|.
71 void GetAllActiveExtensionIds(std::set<std::string>* ids) const; 77 void GetAllActiveExtensionIds(std::set<std::string>* ids) const;
72 78
73 const UserScriptSet* static_scripts() const { return &static_scripts_; } 79 const UserScriptSet* static_scripts() const { return &static_scripts_; }
74 80
75 private: 81 private:
76 // Map for per-extension sets that may be defined programmatically. 82 // Map for per-extension sets that may be defined programmatically.
77 typedef std::map<ExtensionId, linked_ptr<UserScriptSet> > UserScriptSetMap; 83 typedef std::map<ExtensionId, linked_ptr<UserScriptSet> > UserScriptSetMap;
78 84
79 // content::RenderProcessObserver implementation. 85 // content::RenderProcessObserver implementation.
80 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; 86 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE;
81 87
88 UserScriptSet* GetProgrammaticScriptsByExtension(
89 const ExtensionId& extensionId);
90
82 // Handle the UpdateUserScripts extension message. 91 // Handle the UpdateUserScripts extension message.
83 void OnUpdateUserScripts(base::SharedMemoryHandle shared_memory, 92 void OnUpdateUserScripts(base::SharedMemoryHandle shared_memory,
84 const ExtensionId& extension_id, 93 const ExtensionId& extension_id,
85 const std::set<std::string>& changed_extensions); 94 const std::set<std::string>& changed_extensions);
86 95
87 // Scripts statically defined in extension manifests. 96 // Scripts statically defined in extension manifests.
88 UserScriptSet static_scripts_; 97 UserScriptSet static_scripts_;
89 98
90 // Scripts programmatically-defined through API calls (initialized and stored 99 // Scripts programmatically-defined through API calls (initialized and stored
91 // per-extension). 100 // per-extension).
92 UserScriptSetMap programmatic_scripts_; 101 UserScriptSetMap programmatic_scripts_;
93 102
94 // The set of all known extensions. Owned by the Dispatcher. 103 // The set of all known extensions. Owned by the Dispatcher.
95 const ExtensionSet* extensions_; 104 const ExtensionSet* extensions_;
96 105
97 // The associated observers. 106 // The associated observers.
98 ObserverList<Observer> observers_; 107 ObserverList<Observer> observers_;
99 108
100 DISALLOW_COPY_AND_ASSIGN(UserScriptSetManager); 109 DISALLOW_COPY_AND_ASSIGN(UserScriptSetManager);
101 }; 110 };
102 111
103 } // namespace extensions 112 } // namespace extensions
104 113
105 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_MANAGER_H_ 114 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698