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

Unified Diff: extensions/renderer/dispatcher.h

Issue 321993003: Refactor renderer-side script injection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Latest master Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/extensions.gyp ('k') | extensions/renderer/dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/dispatcher.h
diff --git a/extensions/renderer/dispatcher.h b/extensions/renderer/dispatcher.h
index 8729cc2c27b2860d4fbe322e4cfa73fb0163a1bb..efb24f1eba60f16e0aba35156a81615017b035d4 100644
--- a/extensions/renderer/dispatcher.h
+++ b/extensions/renderer/dispatcher.h
@@ -10,7 +10,7 @@
#include <string>
#include <vector>
-#include "base/memory/shared_memory.h"
+#include "base/scoped_observer.h"
#include "base/timer/timer.h"
#include "content/public/renderer/render_process_observer.h"
#include "extensions/common/event_filter.h"
@@ -20,6 +20,7 @@
#include "extensions/renderer/resource_bundle_source_map.h"
#include "extensions/renderer/script_context.h"
#include "extensions/renderer/script_context_set.h"
+#include "extensions/renderer/user_script_set.h"
#include "extensions/renderer/v8_schema_registry.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebVector.h"
@@ -55,12 +56,13 @@ class FilteredEventRouter;
class ManifestPermissionSet;
class RequestSender;
class ScriptContext;
-class UserScriptSlave;
+class ScriptInjectionManager;
struct Message;
// Dispatches extension control messages sent to the renderer and stores
// renderer extension related state.
-class Dispatcher : public content::RenderProcessObserver {
+class Dispatcher : public content::RenderProcessObserver,
+ public UserScriptSet::Observer {
public:
explicit Dispatcher(DispatcherDelegate* delegate);
virtual ~Dispatcher();
@@ -81,10 +83,10 @@ class Dispatcher : public content::RenderProcessObserver {
ContentWatcher* content_watcher() { return content_watcher_.get(); }
- UserScriptSlave* user_script_slave() { return user_script_slave_.get(); }
-
RequestSender* request_sender() { return request_sender_.get(); }
+ void OnRenderViewCreated(content::RenderView* render_view);
+
bool IsExtensionActive(const std::string& extension_id) const;
// Finds the extension ID for the JavaScript context associated with the
@@ -180,10 +182,13 @@ class Dispatcher : public content::RenderProcessObserver {
int tab_id,
const std::string& extension_id,
const URLPatternSet& origin_set);
- void OnUpdateUserScripts(base::SharedMemoryHandle scripts,
- const std::set<std::string>& extension_ids);
void OnUsingWebRequestAPI(bool webrequest_used);
+ // UserScriptSet::Observer implementation.
+ virtual void OnUserScriptsUpdated(
+ const std::set<std::string>& changed_extensions,
+ const std::vector<UserScript*>& scripts) OVERRIDE;
+
void UpdateActiveExtensions();
// Sets up the host permissions for |extension|.
@@ -254,7 +259,9 @@ class Dispatcher : public content::RenderProcessObserver {
scoped_ptr<ContentWatcher> content_watcher_;
- scoped_ptr<UserScriptSlave> user_script_slave_;
+ scoped_ptr<UserScriptSet> user_script_set_;
+
+ scoped_ptr<ScriptInjectionManager> script_injection_manager_;
// Same as above, but on a longer timer and will run even if the process is
// not idle, to ensure that IdleHandle gets called eventually.
@@ -284,6 +291,11 @@ class Dispatcher : public content::RenderProcessObserver {
// True once WebKit has been initialized (and it is therefore safe to poke).
bool is_webkit_initialized_;
+ // It is important for this to come after the ScriptInjectionManager, so that
+ // the observer is destroyed before the UserScriptSet.
+ ScopedObserver<UserScriptSet, UserScriptSet::Observer>
+ user_script_set_observer_;
+
DISALLOW_COPY_AND_ASSIGN(Dispatcher);
};
« no previous file with comments | « extensions/extensions.gyp ('k') | extensions/renderer/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698