0

Create MimeHandlerViewFrameContainer only once

Currently embedding a PDF creates a MimeHandlerViewFrameContainer which
then loads an extension that attaches another internal plugin element
to load the PDF plugin. This CL makes sure we do not create a second
MimeHandlerViewFrameContainer for that.

Bug: 659750
Change-Id: Iff71eee6d59b824572628f1ba68651d6be16138c
Reviewed-on: https://chromium-review.googlesource.com/c/1265502
Commit-Queue: Ehsan Karamad <ekaramad@chromium.org>
Reviewed-by: Ehsan Karamad <ekaramad@chromium.org>
Reviewed-by: James MacLean <wjmaclean@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597284}
This commit is contained in:
Ehsan Karamad
2018-10-05 20:45:35 +00:00
committed by Commit Bot
parent 27bc10f820
commit db49e76b13
2 changed files with 13 additions and 0 deletions
extensions
browser
guest_view
renderer
guest_view

@ -32,6 +32,7 @@
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "services/network/public/cpp/features.h"
#include "url/url_constants.h"
using extensions::ExtensionsAPIClient;
using extensions::MimeHandlerViewGuest;
@ -157,6 +158,11 @@ INSTANTIATE_TEST_CASE_P(/* no prefix */,
IN_PROC_BROWSER_TEST_P(MimeHandlerViewCrossProcessTest, Embedded) {
RunTest("test_embedded.html");
// Sanity check. Navigate the page and verify the guest goes away.
ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
auto* gv_manager = GetGuestViewManager();
gv_manager->WaitForAllGuestsDeleted();
EXPECT_EQ(1U, gv_manager->num_guests_created());
}
// The following tests will eventually converted into a parametric version which

@ -35,6 +35,13 @@ bool MimeHandlerViewFrameContainer::Create(
const std::string& mime_type,
const content::WebPluginInfo& plugin_info,
int32_t element_instance_id) {
if (plugin_info.type != content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN) {
// TODO(ekaramad): Rename this plugin type once https://crbug.com/659750 is
// fixed. We only create a MHVFC for the plugin types of BrowserPlugin
// (which used to create a MimeHandlerViewContainer).
return false;
}
if (!IsSupportedMimeType(mime_type))
return false;
// Life time is managed by the class itself: when the MimeHandlerViewGuest