This source file includes following definitions.
- openDatabase
#include "config.h"
#include "modules/webdatabase/DOMWindowWebDatabase.h"
#include "RuntimeEnabledFeatures.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
#include "core/frame/DOMWindow.h"
#include "modules/webdatabase/Database.h"
#include "modules/webdatabase/DatabaseCallback.h"
#include "modules/webdatabase/DatabaseManager.h"
#include "platform/weborigin/SecurityOrigin.h"
namespace WebCore {
PassRefPtrWillBeRawPtr<Database> DOMWindowWebDatabase::openDatabase(DOMWindow& window, const String& name, const String& version, const String& displayName, unsigned long estimatedSize, PassOwnPtr<DatabaseCallback> creationCallback, ExceptionState& exceptionState)
{
if (!window.isCurrentlyDisplayedInFrame())
return nullptr;
RefPtrWillBeRawPtr<Database> database = nullptr;
DatabaseManager& dbManager = DatabaseManager::manager();
DatabaseError error = DatabaseError::None;
if (RuntimeEnabledFeatures::databaseEnabled() && window.document()->securityOrigin()->canAccessDatabase()) {
String errorMessage;
database = dbManager.openDatabase(window.document(), name, version, displayName, estimatedSize, creationCallback, error, errorMessage);
ASSERT(database || error != DatabaseError::None);
if (error != DatabaseError::None)
DatabaseManager::throwExceptionForDatabaseError(error, errorMessage, exceptionState);
} else {
exceptionState.throwSecurityError("Access to the WebDatabase API is denied in this context.");
}
return database;
}
}