def RestartBrowserHost(self, clearCache=False):
        self._browserHost = None
        self.liveBrowserViews = []
        ccpBrowserHost.BrowserShutdown(True)
        blue.pyos.synchro.Yield()
        if clearCache:
            cachePath = self.AppGetBrowserCachePath()
            if cachePath is not None:
                cachePath = cachePath.strip()
                if cachePath != '':
                    if os.path.exists(cachePath):
                        successfullyDeleted = False
                        errorText = ''
                        try:
                            filePath = os.path.join(cachePath, 'Files')
                            cookiePath = os.path.join(cachePath, 'Cookies')
                            if os.path.exists(filePath):
                                shutil.rmtree(filePath)
                            if os.path.exists(cookiePath):
                                shutil.rmtree(cookiePath)
                            successfullyDeleted = True
                        except WindowsError as e:
                            self.LogError('Error occurred clearing cache', e)
                            sys.exc_clear()

                        if successfullyDeleted:
                            uicore.Message('BrowserCacheCleared')
                        else:
                            raise UserError('BrowserCacheClearFailed')
        self._InitializeCCPBrowser()
 def ReleaseBrowserView(self, browserView):
     if browserView is None:
         return
     if self._browserHost is None:
         self.LogWarn('Attempting to release browserView object', browserView, 'but Browser Host is already dead')
         return
     if browserView not in self.liveBrowserViews:
         self.LogWarn('Attempting to release browserView object', browserView, 'which is not managed by BrowserHostManager')
         del browserView
         return
     self.liveBrowserViews.remove(browserView)
     del browserView
     if len(self.liveBrowserViews) < 1:
         self.LogInfo('BrowserHostManager is shutting down CCPBrowserHost as all active views have been closed')
         self._browserHost = None
         ccpBrowserHost.BrowserShutdown()
 def Stop(self, *args):
     service.Service.Stop(self, args)
     if self._browserHost is not None:
         self._browserHost = None
         self.liveBrowserViews = []
         ccpBrowserHost.BrowserShutdown()