Convert bare new to base::MakeRefCounted<> in extensions directories

Converts all usages of bare new that:
(1) construct base::RefCounted objects,
(2) use public constructors,
(3) are in an extensions directory, and
(4) wouldn't cause changes in non-extensions directory
to use base::MakeRefCounted instead.

Bug: 919580
Change-Id: Ia6def2e499e5195640695b577004df2cd6d95300
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1772133
Commit-Queue: Matthew Denton <[email protected]>
Reviewed-by: Istiaque Ahmed <[email protected]>
Reviewed-by: Devlin <[email protected]>
Cr-Commit-Position: refs/heads/master@{#691910}
diff --git a/extensions/browser/extension_function_dispatcher.h b/extensions/browser/extension_function_dispatcher.h
index 92d3529..6721cee 100644
--- a/extensions/browser/extension_function_dispatcher.h
+++ b/extensions/browser/extension_function_dispatcher.h
@@ -28,9 +28,6 @@
 class ProcessMap;
 class WindowController;
 
-// A factory function for creating new ExtensionFunction instances.
-typedef ExtensionFunction* (*ExtensionFunctionFactory)();
-
 // ExtensionFunctionDispatcher receives requests to execute functions from
 // Chrome extensions running in a RenderFrameHost and dispatches them to the
 // appropriate handler. It lives entirely on the UI thread.
@@ -128,7 +125,7 @@
   // Helper to create an ExtensionFunction to handle the function given by
   // |params|. Can be called on any thread.
   // Does not set subclass properties, or include_incognito.
-  static ExtensionFunction* CreateExtensionFunction(
+  static scoped_refptr<ExtensionFunction> CreateExtensionFunction(
       const ExtensionHostMsg_Request_Params& params,
       const Extension* extension,
       int requesting_process_id,