bool DatabaseObserver::canEstablishDatabase(ExecutionContext* executionContext, const String& name, const String& displayName, unsigned long estimatedSize) { ASSERT(executionContext->isContextThread()); ASSERT(executionContext->isDocument() || executionContext->isWorkerGlobalScope()); if (executionContext->isDocument()) { Document* document = toDocument(executionContext); WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); if (!webFrame) return false; WebViewImpl* webView = webFrame->viewImpl(); if (!webView) return false; if (webView->permissionClient()) return webView->permissionClient()->allowDatabase(webFrame, name, displayName, estimatedSize); } else { WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(executionContext); WorkerPermissionClient* permissionClient = WorkerPermissionClient::from(workerGlobalScope); if (permissionClient->proxy()) return permissionClient->allowDatabase(name, displayName, estimatedSize); // FIXME: Deprecate this bridge code when PermissionClientProxy is // implemented by the embedder. WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerGlobalScope->thread()->workerLoaderProxy().toWebWorkerBase()); WebView* view = webWorker->view(); if (!view) return false; return allowDatabaseForWorker(view->mainFrame(), name, displayName, estimatedSize); } return true; }
bool DatabaseObserver::canEstablishDatabase(ScriptExecutionContext* scriptExecutionContext, const String& name, const String& displayName, unsigned long estimatedSize) { ASSERT(scriptExecutionContext->isContextThread()); ASSERT(scriptExecutionContext->isDocument() || scriptExecutionContext->isWorkerContext()); if (scriptExecutionContext->isDocument()) { Document* document = static_cast<Document*>(scriptExecutionContext); WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); if (!webFrame) return false; WebViewImpl* webView = webFrame->viewImpl(); if (!webView) return false; if (webView->permissionClient()) return webView->permissionClient()->allowDatabase(webFrame, name, displayName, estimatedSize); } else { #if ENABLE(WORKERS) WorkerContext* workerContext = static_cast<WorkerContext*>(scriptExecutionContext); WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy(); NewWebWorkerBase* webWorker = static_cast<NewWebWorkerBase*>(workerLoaderProxy); return allowDatabaseForWorker(webWorker->newCommonClient(), webWorker->view()->mainFrame(), name, displayName, estimatedSize); #else ASSERT_NOT_REACHED(); #endif } return true; }
bool DatabaseObserver::canEstablishDatabase(ScriptExecutionContext* scriptExecutionContext, const String& name, const String& displayName, unsigned long estimatedSize) { ASSERT(scriptExecutionContext->isContextThread()); ASSERT(scriptExecutionContext->isDocument() || scriptExecutionContext->isWorkerGlobalScope()); if (scriptExecutionContext->isDocument()) { Document* document = toDocument(scriptExecutionContext); WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); if (!webFrame) return false; WebViewImpl* webView = webFrame->viewImpl(); if (!webView) return false; if (webView->permissionClient()) return webView->permissionClient()->allowDatabase(webFrame, name, displayName, estimatedSize); } else { WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(scriptExecutionContext); WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerGlobalScope->thread()->workerLoaderProxy().toWebWorkerBase()); WebView* view = webWorker->view(); if (!view) return false; return allowDatabaseForWorker(view->mainFrame(), name, displayName, estimatedSize); } return true; }