Esempio n. 1
0
// static
void LLFloaterWebContent::preCreate(LLFloaterWebContent::Params& p)
{
	lldebugs << "url = " << p.url() << ", target = " << p.target() << ", uuid = " << p.id() << llendl;

	if (!p.id.isProvided())
	{
		p.id = LLUUID::generateNewID().asString();
	}

	if(p.target().empty() || p.target() == "_blank")
	{
		p.target = p.id();
	}

	S32 browser_window_limit = gSavedSettings.getS32("WebContentWindowLimit");
	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(p.window_class);
		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()["target"] << llendl;
		}

		if(instances.size() >= (size_t)browser_window_limit)
		{
			// Destroy the least recently opened instance
			(*instances.begin())->closeFloater();
		}
	}
}
// static
void LLFloaterWebContent::preCreate(LLFloaterWebContent::Params& p)
{
    LL_DEBUGS() << "url = " << p.url() << ", target = " << p.target() << ", uuid = " << p.id() << LL_ENDL;

    if (!p.id.isProvided())
    {
        p.id = LLUUID::generateNewID().asString();
    }

    if(p.target().empty() || p.target() == "_blank")
    {
        p.target = p.id();
    }

    S32 browser_window_limit = gSavedSettings.getS32("WebContentWindowLimit");
    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.

        std::vector<LLFloaterWebContent*> instances;
        instances.reserve(instanceCount());
        for(instance_iter it(beginInstances()), it_end(endInstances()); it != it_end; ++it)
        {
            if(it->mKey["window_class"].asString() == p.window_class.getValue())
                instances.push_back(&*it);
        }

        std::sort(instances.begin(), instances.end(), CompareAgeDescending());

        //LLFloaterReg::const_instance_list_t &instances = LLFloaterReg::getFloaterList(p.window_class);
        LL_DEBUGS() << "total instance count is " << instances.size() << LL_ENDL;

        for(std::vector<LLFloaterWebContent*>::const_iterator iter = instances.begin(); iter != instances.end(); iter++)
        {
            LL_DEBUGS() << "    " << (*iter)->mKey["target"] << LL_ENDL;
        }

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