Browser Plugin: Implement BrowserPluginGuestManager

This patch centralizes instance ID allocation and routing to a per-profile object called BrowserPluginGuestManager.

This patch minimizes BrowserPluginEmbedder's responsibilities without entirely removing it.

BrowserPluginEmbedder lives for the lifetime of an embedder WebContents. It handles IPC messages that are not directed at any particular guest process, currently those are:

BrowserPluginHostMsg_AllocateInstanceID
BrowserPluginHostMsg_CreateGuest,
BrowserPluginHostMsg_PluginAtPositionResponse

These message handlers were kept in BrowserPluginEmbedder because they either operate on the embedder (as with PluginAtPosition), or they need to reply back to the correct BrowserPluginManager. This requires an understanding of the  process ID and routing ID of the origin of the message. This information does not seem particularly appropriate in BrowserPluginGuestManager because that object spans multiple embedders and potentially multiple processes (outside of Chrome Apps).

BUG=174673, 140316
Test=BrowserPluginHostTest.*

Review URL: https://chromiumcodereview.appspot.com/12253046

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186338 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index a9deb1ab..e15395e 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -37,6 +37,7 @@
 namespace content {
 class BrowserPluginEmbedder;
 class BrowserPluginGuest;
+class BrowserPluginGuestManager;
 class ColorChooser;
 class DateTimeChooserAndroid;
 class DownloadItem;
@@ -85,11 +86,10 @@
   WebContentsImpl* opener() const { return opener_; }
 
   // Creates a WebContents to be used as a browser plugin guest.
-  static void CreateGuest(
+  static BrowserPluginGuest* CreateGuest(
       BrowserContext* browser_context,
       content::SiteInstance* site_instance,
       int routing_id,
-      WebContentsImpl* embedder_web_contents,
       WebContentsImpl* opener_web_contents,
       int guest_instance_id,
       const BrowserPluginHostMsg_CreateGuest_Params& params);
@@ -166,6 +166,9 @@
   // Returns embedder browser plugin object, or NULL if this WebContents is not
   // an embedder.
   BrowserPluginEmbedder* GetBrowserPluginEmbedder() const;
+  // Returns the BrowserPluginGuestManager object, or NULL if this web contents
+  // does not have a BrowserPluginGuestManager.
+  BrowserPluginGuestManager* GetBrowserPluginGuestManager() const;
 
   // Gets the current fullscreen render widget's routing ID. Returns
   // MSG_ROUTING_NONE when there is no fullscreen render widget.