// static
void BrowserList::CloseAllBrowsers()
{
    bool session_ending =
        browser_shutdown::GetShutdownType() == browser_shutdown::END_SESSION;
    bool force_exit = false;
    // Tell everyone that we are shutting down.
    browser_shutdown::SetTryingToQuit(true);

    // Before we close the browsers shutdown all session services. That way an
    // exit can restore all browsers open before exiting.
    //ProfileManager::ShutdownSessionServices();

    // If there are no browsers, send the APP_TERMINATING action here. Otherwise,
    // it will be sent by RemoveBrowser() when the last browser has closed.
    if(force_exit || browsers_.empty())
    {
        NotifyAndTerminate(true);
        return;
    }
    for(BrowserList::const_iterator i=BrowserList::begin();
        i!=BrowserList::end();)
    {
        Browser* browser = *i;
        browser->window()->Close();
        if(!session_ending)
        {
            ++i;
        }
        else
        {
            // This path is hit during logoff/power-down. In this case we won't get
            // a final message and so we force the browser to be deleted.
            // Close doesn't immediately destroy the browser
            // (Browser::TabStripEmpty() uses invoke later) but when we're ending the
            // session we need to make sure the browser is destroyed now. So, invoke
            // DestroyBrowser to make sure the browser is deleted and cleanup can
            // happen.
            while(browser->tab_count())
            {
                delete browser->GetTabContentsWrapperAt(0);
            }
            browser->window()->DestroyBrowser();
            i = BrowserList::begin();
            if(i!=BrowserList::end() && browser==*i)
            {
                // Destroying the browser should have removed it from the browser list.
                // We should never get here.
                NOTREACHED();
                return;
            }
        }
    }
}
// static
Browser* BrowserList::FindBrowserWithWindow(HWND window)
{
    for(BrowserList::const_iterator it=BrowserList::begin();
        it!=BrowserList::end(); ++it)
    {
        Browser* browser = *it;
        if(browser->window() && browser->window()->GetNativeHandle()==window)
        {
            return browser;
        }
    }
    return NULL;
}
Beispiel #3
0
void ChromeMain::Run()
{
    base::EnableTerminationOnHeapCorruption();

    FilePath res_dll;
    PathService::Get(base::DIR_EXE, &res_dll);
    res_dll = res_dll.Append(L"wanui_res.dll");
    ui::ResourceBundle::InitSharedInstance(res_dll);

    MessageLoop main_message_loop(MessageLoop::TYPE_UI);
	
	process_init();
	CmdLineHandler::GetInstance()->handleCmd();

    // Show Main Window...
    Browser* chrome = Browser::Create();

	TabContentsWrapper* tabContent = 
		CmdLineHandler::GetInstance()->isLeaderStartWithCmd() ? chrome->AddTabWithGlobalCfg(true)
			: chrome->AddBlankTab(true);
    if (tabContent){
		chrome->window()->Show();
		view::AcceleratorHandler accelerator_handler;
		MessageLoopForUI::current()->Run(&accelerator_handler);
	}
	process_fini();
    ui::ResourceBundle::CleanupSharedInstance();
}
Beispiel #4
0
void ChromeMain::Run()
{
    base::EnableTerminationOnHeapCorruption();

    base::AtExitManager exit_manager;

    FilePath res_dll;
    PathService::Get(base::DIR_EXE, &res_dll);
    res_dll = res_dll.Append(L"wanui_res.dll");
    ui::ResourceBundle::InitSharedInstance(res_dll);

    MessageLoop main_message_loop(MessageLoop::TYPE_UI);

    // Show Main Window...
    Browser* chrome = Browser::Create();
    chrome->AddBlankTab(true);

    chrome->window()->Show();

    view::AcceleratorHandler accelerator_handler;
    MessageLoopForUI::current()->Run(&accelerator_handler);

    ui::ResourceBundle::CleanupSharedInstance();
}