//static
void LLFloaterWebContent::create( const std::string &url, const std::string& target, const std::string& uuid )
{
	lldebugs << "url = " << url << ", target = " << target << ", uuid = " << uuid << llendl;

	std::string tag = target;

	if(target.empty() || target == "_blank")
	{
		if(!uuid.empty())
		{
			tag = uuid;
		}
		else
		{
			// create a unique tag for this instance
			LLUUID id;
			id.generate();
			tag = id.asString();
		}
	}

	S32 browser_window_limit = gSavedSettings.getS32("WebContentWindowLimit");

	if(LLFloaterReg::findInstance("web_content", tag) != NULL)
	{
		// There's already a web browser for this tag, so we won't be opening a new window.
	}
	else if(browser_window_limit != 0)
	{
		// showInstance will open a new window.  Figure out how many web browsers are already open,
		// and close the least recently opened one if this will put us over the limit.

		LLFloaterReg::const_instance_list_t &instances = LLFloaterReg::getFloaterList("web_content");
		lldebugs << "total instance count is " << instances.size() << llendl;

		for(LLFloaterReg::const_instance_list_t::const_iterator iter = instances.begin(); iter != instances.end(); iter++)
		{
			lldebugs << "    " << (*iter)->getKey() << llendl;
		}

		if(instances.size() >= (size_t)browser_window_limit)
		{
			// Destroy the least recently opened instance
			(*instances.begin())->closeFloater();
		}
	}

	LLFloaterWebContent *browser = dynamic_cast<LLFloaterWebContent*> (LLFloaterReg::showInstance("web_content", tag));
	llassert(browser);
	if(browser)
	{
		browser->mUUID = uuid;

		// tell the browser instance to load the specified URL
		browser->open_media(url, target);
		LLViewerMedia::proxyWindowOpened(target, uuid);
	}
}
//static
void LLFloaterWebContent::create( const std::string &url, const std::string& target, const std::string& uuid,  bool show_chrome, const LLRect& preferred_media_size)
{
	lldebugs << "url = " << url << ", target = " << target << ", uuid = " << uuid << llendl;

	std::string tag = target;

	if(target.empty() || target == "_blank")
	{
		if(!uuid.empty())
		{
			tag = uuid;
		}
		else
		{
			// create a unique tag for this instance
			LLUUID id;
			id.generate();
			tag = id.asString();
		}
	}

	S32 browser_window_limit = gSavedSettings.getS32("WebContentWindowLimit");

	if(LLFloaterReg::findInstance("web_content", tag) != NULL)
	{
		// There's already a web browser for this tag, so we won't be opening a new window.
	}
	else if(browser_window_limit != 0)
	{
		// showInstance will open a new window.  Figure out how many web browsers are already open,
		// and close the least recently opened one if this will put us over the limit.

		LLFloaterReg::const_instance_list_t &instances = LLFloaterReg::getFloaterList("web_content");
		lldebugs << "total instance count is " << instances.size() << llendl;

		for(LLFloaterReg::const_instance_list_t::const_iterator iter = instances.begin(); iter != instances.end(); iter++)
		{
			lldebugs << "    " << (*iter)->getKey() << llendl;
		}

		if(instances.size() >= (size_t)browser_window_limit)
		{
			// Destroy the least recently opened instance
			(*instances.begin())->closeFloater();
		}
	}

	LLFloaterWebContent *browser = dynamic_cast<LLFloaterWebContent*> (LLFloaterReg::showInstance("web_content", tag));
	llassert(browser);
	if(browser)
	{
		browser->mUUID = uuid;

		// tell the browser instance to load the specified URL
		browser->open_media(url, target);
		LLViewerMedia::proxyWindowOpened(target, uuid);

		browser->getChild<LLLayoutPanel>("status_bar")->setVisible(show_chrome);
		browser->getChild<LLLayoutPanel>("nav_controls")->setVisible(show_chrome);

		if (!show_chrome)
		{
			browser->setResizeLimits(100, 100);
		}

		if (!preferred_media_size.isEmpty())
		{
			//ignore x, y for now
			browser->geometryChanged(browser->getRect().mLeft, browser->getRect().mBottom, preferred_media_size.getWidth(), preferred_media_size.getHeight());
		}
	}
}