Index: extensions/renderer/dispatcher.cc |
diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc |
index 687509d6e9af883d00b4d3976c8dc1d5d0258ac7..36bc1a46fa610a2c6fbf6b26039fccb29951b968 100644 |
--- a/extensions/renderer/dispatcher.cc |
+++ b/extensions/renderer/dispatcher.cc |
@@ -120,6 +120,9 @@ static const char kEventDispatchFunction[] = "dispatchEvent"; |
static const char kOnSuspendEvent[] = "runtime.onSuspend"; |
static const char kOnSuspendCanceledEvent[] = "runtime.onSuspendCanceled"; |
+// There is only ever one instance of the Dispatcher. |
+Dispatcher* g_dispatcher = nullptr; |
+ |
// Returns the global value for "chrome" from |context|. If one doesn't exist |
// creates a new object for it. |
// |
@@ -190,6 +193,8 @@ Dispatcher::Dispatcher(DispatcherDelegate* delegate) |
is_webkit_initialized_(false), |
user_script_set_manager_observer_(this), |
webrequest_used_(false) { |
+ DCHECK(!g_dispatcher); |
+ g_dispatcher = this; |
const base::CommandLine& command_line = |
*(base::CommandLine::ForCurrentProcess()); |
set_idle_notifications_ = |
@@ -214,6 +219,11 @@ Dispatcher::Dispatcher(DispatcherDelegate* delegate) |
} |
Dispatcher::~Dispatcher() { |
+ g_dispatcher = nullptr; |
+} |
+ |
+Dispatcher* Dispatcher::Get() { |
+ return g_dispatcher; |
} |
void Dispatcher::OnRenderFrameCreated(content::RenderFrame* render_frame) { |