Index: third_party/WebKit/Source/modules/indexeddb/IDBFactory.cpp |
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBFactory.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBFactory.cpp |
index 81fc62b8a997d232de02e9fb380237c7055bd233..b7faa3372f39b3d8a2e38623fa388a45d3867754 100644 |
--- a/third_party/WebKit/Source/modules/indexeddb/IDBFactory.cpp |
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBFactory.cpp |
@@ -63,9 +63,30 @@ static bool IsContextValid(ExecutionContext* context) { |
return true; |
} |
-IDBRequest* IDBFactory::GetDatabaseNames(ScriptState* script_state) { |
+IDBRequest* IDBFactory::GetDatabaseNames(ScriptState* script_state, |
+ ExceptionState& exception_state) { |
+ // TODO(jsbell): Used only by inspector; remove unneeded checks/exceptions? |
+ if (!IsContextValid(ExecutionContext::From(script_state))) |
+ return nullptr; |
+ if (!ExecutionContext::From(script_state) |
+ ->GetSecurityOrigin() |
+ ->CanAccessDatabase()) { |
+ exception_state.ThrowSecurityError( |
+ "access to the Indexed Database API is denied in this context."); |
+ return nullptr; |
+ } |
+ |
IDBRequest* request = |
IDBRequest::Create(script_state, IDBAny::CreateNull(), nullptr); |
+ |
+ if (!IndexedDBClient::From(ExecutionContext::From(script_state)) |
+ ->AllowIndexedDB(ExecutionContext::From(script_state), |
+ "Database Listing")) { |
+ request->EnqueueResponse( |
+ DOMException::Create(kUnknownError, kPermissionDeniedErrorMessage)); |
+ return request; |
+ } |
+ |
Platform::Current()->IdbFactory()->GetDatabaseNames( |
request->CreateWebCallbacks().release(), |
WebSecurityOrigin( |
@@ -132,6 +153,24 @@ IDBOpenDBRequest* IDBFactory::open(ScriptState* script_state, |
IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* script_state, |
const String& name, |
ExceptionState& exception_state) { |
+ return DeleteDatabaseInternal(script_state, name, exception_state, |
+ /*force_close=*/false); |
+} |
+ |
+IDBOpenDBRequest* IDBFactory::CloseConnectionsAndDeleteDatabase( |
+ ScriptState* script_state, |
+ const String& name, |
+ ExceptionState& exception_state) { |
+ // TODO(jsbell): Used only by inspector; remove unneeded checks/exceptions? |
+ return DeleteDatabaseInternal(script_state, name, exception_state, |
+ /*force_close=*/true); |
+} |
+ |
+IDBOpenDBRequest* IDBFactory::DeleteDatabaseInternal( |
+ ScriptState* script_state, |
+ const String& name, |
+ ExceptionState& exception_state, |
+ bool force_close) { |
IDB_TRACE("IDBFactory::deleteDatabase"); |
IDBDatabase::RecordApiCallsHistogram(kIDBDeleteDatabaseCall); |
if (!IsContextValid(ExecutionContext::From(script_state))) |
@@ -144,18 +183,6 @@ IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* script_state, |
return nullptr; |
} |
- return DeleteDatabaseInternal(script_state, name, /*force_close=*/false); |
-} |
- |
-IDBOpenDBRequest* IDBFactory::CloseConnectionsAndDeleteDatabase( |
- ScriptState* script_state, |
- const String& name) { |
- return DeleteDatabaseInternal(script_state, name, /*force_close=*/true); |
-} |
- |
-IDBOpenDBRequest* IDBFactory::DeleteDatabaseInternal(ScriptState* script_state, |
- const String& name, |
- bool force_close) { |
IDBOpenDBRequest* request = IDBOpenDBRequest::Create( |
script_state, nullptr, 0, IDBDatabaseMetadata::kDefaultVersion); |