Commit 52263318 authored by fsamuel@chromium.org's avatar fsamuel@chromium.org

GuestView: Lazy registration and once for all profiles

GuestViews are registered and re-registered on a per-profile basis.
This would cause a DCHECK to fire. Make registration lazy and once on first
GuestView creation.

BUG=none
TBR=fsamuel@chromium.org

Review URL: https://codereview.chromium.org/409133002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284723 0039d316-1c4b-4281-b951-d872f2087c98
parent 9e936e16
......@@ -142,12 +142,6 @@ void GuestViewBase::InitWithWebContents(
DidInitialize();
}
// static
void GuestViewBase::RegisterGuestViewTypes() {
GuestView<WebViewGuest>::Register();
GuestView<AppViewGuest>::Register();
}
// static
void GuestViewBase::RegisterGuestViewType(
const std::string& view_type,
......@@ -163,6 +157,9 @@ GuestViewBase* GuestViewBase::Create(
content::BrowserContext* browser_context,
int guest_instance_id,
const std::string& view_type) {
if (guest_view_registry.Get().empty())
RegisterGuestViewTypes();
GuestViewCreationMap::iterator it =
guest_view_registry.Get().find(view_type);
if (it == guest_view_registry.Get().end()) {
......@@ -386,3 +383,9 @@ void GuestViewBase::CompleteInit(const std::string& embedder_extension_id,
guest_web_contents);
callback.Run(guest_web_contents);
}
// static
void GuestViewBase::RegisterGuestViewTypes() {
AppViewGuest::Register();
WebViewGuest::Register();
}
......@@ -52,8 +52,6 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
return NULL;
}
static void RegisterGuestViewTypes();
typedef base::Callback<GuestViewBase*(
content::BrowserContext*, int)> GuestCreationCallback;
static void RegisterGuestViewType(const std::string& view_type,
......@@ -236,6 +234,8 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
const WebContentsCreatedCallback& callback,
content::WebContents* guest_web_contents);
static void RegisterGuestViewTypes();
// WebContentsObserver implementation.
virtual void DidStopLoading(
content::RenderViewHost* render_view_host) OVERRIDE FINAL;
......
......@@ -30,7 +30,6 @@ GuestViewManagerFactory* GuestViewManager::factory_ = NULL;
GuestViewManager::GuestViewManager(content::BrowserContext* context)
: current_instance_id_(0), last_instance_id_removed_(0), context_(context) {
GuestViewBase::RegisterGuestViewTypes();
}
GuestViewManager::~GuestViewManager() {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment