Browser Plugin: Fixed browser process crash on embedder reload.

The browser process crashed because a CHECK that verifies that an existing browser_plugin_embedder_ does not yet exist fails.

This happens because CreateGuest should only be handled in WebContentsImpl on the first call to CreateGuest. On all subsequent calls, CreateGuest should be handled in BrowserPluginEmbedderHelper.

This patch makes this change.

I've also cleaned up some dead code.

I've also written a test that verifies that reloading the embedder
doesn't cause the browser plugin to misbehave.


BUG=153561
Test=BrowserPluginHostTest.ReloadEmbedder


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159854 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 9291e9f..beeed5e6 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2378,8 +2378,13 @@
   // plugin renderer prior to CreateGuest will be ignored.
   // For more info, see comment above classes BrowserPluginEmbedder and
   // BrowserPluginGuest.
+  // The first BrowserPluginHostMsg_CreateGuest message from this WebContents'
+  // embedder render process is handled here. Once BrowserPluginEmbedder is
+  // created, all subsequent BrowserPluginHostMsg_CreateGuest messages are
+  // intercepted by the BrowserPluginEmbedderHelper and handled by the
+  // BrowserPluginEmbedder. Thus, this code will not be executed if a
+  // BrowserPluginEmbedder exists for this WebContents.
   CHECK(!browser_plugin_embedder_.get());
-
   browser_plugin_embedder_.reset(
       content::BrowserPluginEmbedder::Create(this, GetRenderViewHost()));
   browser_plugin_embedder_->CreateGuest(GetRenderViewHost(),
@@ -2388,16 +2393,6 @@
                                         persist_storage);
 }
 
-void WebContentsImpl::OnBrowserPluginNavigateGuest(
-    int instance_id,
-    const std::string& src,
-    const BrowserPluginHostMsg_ResizeGuest_Params& resize_params) {
-  browser_plugin_embedder_->NavigateGuest(GetRenderViewHost(),
-                                          instance_id,
-                                          src,
-                                          resize_params);
-}
-
 // Notifies the RenderWidgetHost instance about the fact that the page is
 // loading, or done loading and calls the base implementation.
 void WebContentsImpl::SetIsLoading(bool is_loading,