size_t Notification::maxActions() { // Returns a fixed number for unit tests, which run without the availability of the Platform object. if (!notificationManager()) return 2; return notificationManager()->maxActions(); }
WebNotificationPermission Notification::checkPermission(ExecutionContext* context) { SecurityOrigin* origin = context->securityOrigin(); ASSERT(origin); return notificationManager()->checkPermission(WebSecurityOrigin(origin)); }
void Notification::stop() { notificationManager()->notifyDelegateDestroyed(this); m_state = NotificationStateClosed; m_asyncRunner.stop(); }
Notification::Notification(ExecutionContext* context, const WebNotificationData& data) : ActiveDOMObject(context) , m_data(data) , m_persistentId(kInvalidPersistentId) , m_state(NotificationStateIdle) , m_asyncRunner(this, &Notification::show) { ASSERT(notificationManager()); }
Notification::Notification(ExecutionContext* context, Type type, const WebNotificationData& data) : ActiveScriptWrappable(this), ActiveDOMObject(context), m_type(type), m_state(State::Loading), m_data(data) { DCHECK(notificationManager()); }
void Notification::close() { if (m_state != NotificationStateShowing) return; if (m_persistentId == kInvalidPersistentId) { // Fire the close event asynchronously. executionContext()->postTask(BLINK_FROM_HERE, createSameThreadTask(&Notification::dispatchCloseEvent, this)); m_state = NotificationStateClosing; notificationManager()->close(this); } else { m_state = NotificationStateClosed; SecurityOrigin* origin = executionContext()->securityOrigin(); ASSERT(origin); notificationManager()->closePersistent(WebSecurityOrigin(origin), m_persistentId); } }
void Notification::contextDestroyed() { notificationManager()->notifyDelegateDestroyed(this); m_state = State::Closed; if (m_prepareShowMethodRunner) m_prepareShowMethodRunner->stop(); if (m_loader) m_loader->stop(); }
void Notification::didLoadResources(NotificationResourcesLoader* loader) { DCHECK_EQ(loader, m_loader.get()); SecurityOrigin* origin = getExecutionContext()->getSecurityOrigin(); DCHECK(origin); notificationManager()->show(WebSecurityOrigin(origin), m_data, loader->getResources(), this); m_loader.clear(); m_state = State::Showing; }
void Notification::show() { ASSERT(m_state == NotificationStateIdle); if (Notification::checkPermission(executionContext()) != WebNotificationPermissionAllowed) { dispatchErrorEvent(); return; } SecurityOrigin* origin = executionContext()->securityOrigin(); ASSERT(origin); notificationManager()->show(WebSecurityOrigin(origin), m_data, this); m_state = NotificationStateShowing; }
void Notification::close() { if (m_state != State::Showing) return; // Schedule the "close" event to be fired for non-persistent notifications. // Persistent notifications won't get such events for programmatic closes. if (m_type == Type::NonPersistent) { getExecutionContext()->postTask( BLINK_FROM_HERE, createSameThreadTask(&Notification::dispatchCloseEvent, wrapPersistent(this))); m_state = State::Closing; notificationManager()->close(this); return; } m_state = State::Closed; SecurityOrigin* origin = getExecutionContext()->getSecurityOrigin(); DCHECK(origin); notificationManager()->closePersistent(WebSecurityOrigin(origin), m_data.tag, m_notificationId); }
//! @brief Initializes the application. //! //! It will open the main window and connect default to server or open the connect window. bool SpringLobbyApp::OnInit() { wxSetEnv( _T("UBUNTU_MENUPROXY"), _T("0") ); //this triggers the Cli Parser amongst other stuff if (!wxApp::OnInit()) return false; SetAppName( m_appname ); if (!m_crash_handle_disable) { #if wxUSE_ON_FATAL_EXCEPTION wxHandleFatalExceptions( true ); #endif #if defined(__WXMSW__) && defined(ENABLE_DEBUG_REPORT) //this undocumented function acts as a workaround for the dysfunctional // wxUSE_ON_FATAL_EXCEPTION on msw when mingw is used (or any other non SEH-capable compiler ) SetUnhandledExceptionFilter(filter); #endif } //initialize all loggers, we'll use the returned pointer to set correct parent window later wxLogChain* logchain = 0; wxLogWindow *loggerwin = InitializeLoggingTargets( 0, m_log_console, m_log_file_path, m_log_window_show, !m_crash_handle_disable, m_log_verbosity, logchain ); //this needs to called _before_ mainwindow instance is created wxInitAllImageHandlers(); wxFileSystem::AddHandler(new wxZipFSHandler); wxSocketBase::Initialize(); #ifdef __WXMSW__ wxString path = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) + wxFileName::GetPathSeparator() + _T("locale"); #else #if defined(LOCALE_INSTALL_DIR) wxString path ( _T(LOCALE_INSTALL_DIR) ); #else // use a dummy name here, we're only interested in the base path wxString path = wxStandardPaths::Get().GetLocalizedResourcesDir(_T("noneWH"),wxStandardPaths::ResourceCat_Messages); path = path.Left( path.First(_T("noneWH") ) ); #endif #endif m_translationhelper = new wxTranslationHelper( *( (wxApp*)this ), path ); m_translationhelper->Load(); if ( !wxDirExists( GetConfigfileDir() ) ) wxMkdir( GetConfigfileDir() ); #ifdef __WXMSW__ sett().SetSearchSpringOnlyInSLPath( sett().GetSearchSpringOnlyInSLPath() ); #endif sett().SetSpringBinary( sett().GetCurrentUsedSpringIndex(), sett().GetCurrentUsedSpringBinary() ); sett().SetUnitSync( sett().GetCurrentUsedSpringIndex(), sett().GetCurrentUsedUnitSync() ); if ( sett().DoResetPerspectives() ) { //we do this early on and reset the config var a little later so we can save a def. perps once mw is created sett().RemoveLayouts(); sett().SetDoResetPerspectives( false ); ui().mw().SavePerspectives( _T("SpringLobby-default") ); } sett().RefreshSpringVersionList(); //this should take off the firstload time considerably *ie nil it :P ) mapSelectDialog(); if ( !m_customizer_archive_name.IsEmpty() ) {//this needsto happen before usync load sett().SetForcedSpringConfigFilePath( GetCustomizedEngineConfigFilePath() ); } //unitsync first load, NEEDS to be blocking const bool usync_loaded = usync().ReloadUnitSyncLib(); if ( !sett().IsFirstRun() && !usync_loaded ) { customMessageBox( SL_MAIN_ICON, _("Please check that the file given in Preferences->Spring is a proper, readable unitsync library"), _("Coulnd't load required unitsync library"), wxOK ); } #ifndef DISABLE_SOUND //sound sources/buffer init sound(); #endif CacheAndSettingsSetup(); if ( !m_customizer_archive_name.IsEmpty() ) { if ( SLcustomizations().Init( m_customizer_archive_name ) ) { ui().mw().SetIcons( SLcustomizations().GetAppIconBundle() ); } else { customMessageBox( SL_MAIN_ICON, _("Couldn't load customizations for ") + m_customizer_archive_name + _("\nPlease check that that is the correct name, passed in qoutation"), _("Fatal error"), wxOK ); // wxLogError( _("Couldn't load customizations for ") + m_customizer_archive_name + _("\nPlease check that that is the correct name, passed in qoutation"), _("Fatal error") ); exit( OnExit() );//for some twisted reason returning false here does not terminate the app } } notificationManager(); //needs to be initialized too ui().ShowMainWindow(); SetTopWindow( &ui().mw() ); if ( sett().DoResetPerspectives() ) { //now that mainwindow is shown, we can save what is the default layout and remove the flag to reset sett().SetDoResetPerspectives( false ); ui().mw().SavePerspectives( _T("SpringLobby-default") ); } //interim fix for resize crashes on metacity and kwin #ifdef __WXMSW__ mapSelectDialog().Reparent( &ui().mw() ); #endif ui().FirstRunWelcome(); m_timer->Start( TIMER_INTERVAL ); ui().mw().SetLogWin( loggerwin, logchain ); #ifndef NO_TORRENT_SYSTEM plasmaInterface(); // plasmaInterface().InitResourceList(); // plasmaInterface().FetchResourceList(); #endif return true; }
//! @brief Initializes the application. //! //! It will open the main window and connect default to server or open the connect window. bool SpringLobbyApp::OnInit() { wxSetEnv(_T("UBUNTU_MENUPROXY"), _T("0")); //this triggers the Cli Parser amongst other stuff if (!wxApp::OnInit()) return false; SetAppName(m_appname); #if wxUSE_ON_FATAL_EXCEPTION wxHandleFatalExceptions(!m_crash_handle_disable); #else try { #endif const wxString m_log_file_path = SlPaths::GetLobbyWriteDir() + "springlobby.log"; //initialize all loggers, we'll use the returned pointer to set correct parent window later wxLogWindow* loggerwin = Logger::InitializeLoggingTargets(0, m_log_console, m_log_file_path, m_log_window_show, m_log_verbosity); wxLogMessage(_T("%s started"), TowxString(GetSpringlobbyAgent()).c_str()); //this needs to called _before_ mainwindow instance is created wxInitAllImageHandlers(); wxFileSystem::AddHandler(new wxZipFSHandler); wxSocketBase::Initialize(); m_translationhelper = new wxTranslationHelper(GetAppName().Lower(), getLocalePath()); const std::string configdir = SlPaths::GetConfigfileDir(); wxLogMessage("Config dir: %s", configdir.c_str()); SlPaths::mkDir(configdir); if (cfg().ReadBool(_T("/ResetLayout"))) { wxLogMessage("Resetting Layout..."); //we do this early on and reset the config var a little later so we can save a def. perps once mw is created sett().RemoveLayouts(); cfg().Write(_T( "/ResetLayout" ), false); ui().mw().SavePerspectives(_T("SpringLobby-default")); } if (SlPaths::IsPortableMode()) { // change write path for downloader if in portable mode fileSystem->setWritePath(SlPaths::GetExecutableFolder()); } else { // only search if not in portable mode SlPaths::SetSpringBinary(SlPaths::GetCurrentUsedSpringIndex(), SlPaths::GetSpringBinary()); SlPaths::SetUnitSync(SlPaths::GetCurrentUsedSpringIndex(), SlPaths::GetUnitSync()); } wxLogMessage("Configuring Unitsync..."); // configure unitsync paths before trying to load SlPaths::ReconfigureUnitsync(); sett().Setup(m_translationhelper); notificationManager(); //needs to be initialized too wxLogMessage("Showing Main Window"); ui().ShowMainWindow(); SetTopWindow(&ui().mw()); ui().mw().SetLogWin(loggerwin); //unitsync first load, FIXME move to a thread! wxLogMessage("Refreshing Spring Version List..."); SlPaths::RefreshSpringVersionList(); if (LSL::usync().ReloadUnitSyncLib()) { GlobalEventManager::Instance()->Send(GlobalEventManager::OnUnitsyncReloaded); } else { wxLogWarning("Couldn't load unitsync"); } wxLogWarning("%s", TowxString(GetSpringlobbyInfo()).c_str()); ui().OnInit(); #if !wxUSE_ON_FATAL_EXCEPTION } catch (std::exception& ex) { wxLogError(_T("Error had happened: " + wxString(ex.what()))); } #endif return true; }