Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBFactory.cpp

Issue 2818173003: Indexed DB: Remove nonstandard IDBFactory.webkitGetDatabaseNames() (Closed)
Patch Set: Remove content_browsertest for wGDN Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 static bool IsContextValid(ExecutionContext* context) { 57 static bool IsContextValid(ExecutionContext* context) {
58 DCHECK(context->IsDocument() || context->IsWorkerGlobalScope()); 58 DCHECK(context->IsDocument() || context->IsWorkerGlobalScope());
59 if (context->IsDocument()) { 59 if (context->IsDocument()) {
60 Document* document = ToDocument(context); 60 Document* document = ToDocument(context);
61 return document->GetFrame() && document->GetPage(); 61 return document->GetFrame() && document->GetPage();
62 } 62 }
63 return true; 63 return true;
64 } 64 }
65 65
66 IDBRequest* IDBFactory::getDatabaseNames(ScriptState* script_state, 66 IDBRequest* IDBFactory::GetDatabaseNames(ScriptState* script_state) {
67 ExceptionState& exception_state) {
68 IDB_TRACE("IDBFactory::getDatabaseNames");
69 if (!IsContextValid(ExecutionContext::From(script_state)))
70 return nullptr;
71 if (!ExecutionContext::From(script_state)
72 ->GetSecurityOrigin()
73 ->CanAccessDatabase()) {
74 exception_state.ThrowSecurityError(
75 "access to the Indexed Database API is denied in this context.");
76 return nullptr;
77 }
78
79 IDBRequest* request = 67 IDBRequest* request =
80 IDBRequest::Create(script_state, IDBAny::CreateNull(), nullptr); 68 IDBRequest::Create(script_state, IDBAny::CreateNull(), nullptr);
81
82 if (!IndexedDBClient::From(ExecutionContext::From(script_state))
83 ->AllowIndexedDB(ExecutionContext::From(script_state),
84 "Database Listing")) {
85 request->EnqueueResponse(
86 DOMException::Create(kUnknownError, kPermissionDeniedErrorMessage));
87 return request;
88 }
89
90 Platform::Current()->IdbFactory()->GetDatabaseNames( 69 Platform::Current()->IdbFactory()->GetDatabaseNames(
91 request->CreateWebCallbacks().release(), 70 request->CreateWebCallbacks().release(),
92 WebSecurityOrigin( 71 WebSecurityOrigin(
93 ExecutionContext::From(script_state)->GetSecurityOrigin())); 72 ExecutionContext::From(script_state)->GetSecurityOrigin()));
94 return request; 73 return request;
95 } 74 }
96 75
97 IDBOpenDBRequest* IDBFactory::open(ScriptState* script_state, 76 IDBOpenDBRequest* IDBFactory::open(ScriptState* script_state,
98 const String& name, 77 const String& name,
99 unsigned long long version, 78 unsigned long long version,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 const String& name, 125 const String& name,
147 ExceptionState& exception_state) { 126 ExceptionState& exception_state) {
148 IDB_TRACE("IDBFactory::open"); 127 IDB_TRACE("IDBFactory::open");
149 return OpenInternal(script_state, name, IDBDatabaseMetadata::kNoVersion, 128 return OpenInternal(script_state, name, IDBDatabaseMetadata::kNoVersion,
150 exception_state); 129 exception_state);
151 } 130 }
152 131
153 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* script_state, 132 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* script_state,
154 const String& name, 133 const String& name,
155 ExceptionState& exception_state) { 134 ExceptionState& exception_state) {
156 return DeleteDatabaseInternal(script_state, name, exception_state,
157 /*force_close=*/false);
158 }
159
160 IDBOpenDBRequest* IDBFactory::CloseConnectionsAndDeleteDatabase(
161 ScriptState* script_state,
162 const String& name,
163 ExceptionState& exception_state) {
164 return DeleteDatabaseInternal(script_state, name, exception_state,
165 /*force_close=*/true);
166 }
167
168 IDBOpenDBRequest* IDBFactory::DeleteDatabaseInternal(
169 ScriptState* script_state,
170 const String& name,
171 ExceptionState& exception_state,
172 bool force_close) {
173 IDB_TRACE("IDBFactory::deleteDatabase"); 135 IDB_TRACE("IDBFactory::deleteDatabase");
174 IDBDatabase::RecordApiCallsHistogram(kIDBDeleteDatabaseCall); 136 IDBDatabase::RecordApiCallsHistogram(kIDBDeleteDatabaseCall);
175 if (!IsContextValid(ExecutionContext::From(script_state))) 137 if (!IsContextValid(ExecutionContext::From(script_state)))
176 return nullptr; 138 return nullptr;
177 if (!ExecutionContext::From(script_state) 139 if (!ExecutionContext::From(script_state)
178 ->GetSecurityOrigin() 140 ->GetSecurityOrigin()
179 ->CanAccessDatabase()) { 141 ->CanAccessDatabase()) {
180 exception_state.ThrowSecurityError( 142 exception_state.ThrowSecurityError(
181 "access to the Indexed Database API is denied in this context."); 143 "access to the Indexed Database API is denied in this context.");
182 return nullptr; 144 return nullptr;
183 } 145 }
184 146
147 return DeleteDatabaseInternal(script_state, name, /*force_close=*/false);
148 }
149
150 IDBOpenDBRequest* IDBFactory::CloseConnectionsAndDeleteDatabase(
151 ScriptState* script_state,
152 const String& name) {
153 return DeleteDatabaseInternal(script_state, name, /*force_close=*/true);
154 }
155
156 IDBOpenDBRequest* IDBFactory::DeleteDatabaseInternal(ScriptState* script_state,
157 const String& name,
158 bool force_close) {
185 IDBOpenDBRequest* request = IDBOpenDBRequest::Create( 159 IDBOpenDBRequest* request = IDBOpenDBRequest::Create(
186 script_state, nullptr, 0, IDBDatabaseMetadata::kDefaultVersion); 160 script_state, nullptr, 0, IDBDatabaseMetadata::kDefaultVersion);
187 161
188 if (!IndexedDBClient::From(ExecutionContext::From(script_state)) 162 if (!IndexedDBClient::From(ExecutionContext::From(script_state))
189 ->AllowIndexedDB(ExecutionContext::From(script_state), name)) { 163 ->AllowIndexedDB(ExecutionContext::From(script_state), name)) {
190 request->EnqueueResponse( 164 request->EnqueueResponse(
191 DOMException::Create(kUnknownError, kPermissionDeniedErrorMessage)); 165 DOMException::Create(kUnknownError, kPermissionDeniedErrorMessage));
192 return request; 166 return request;
193 } 167 }
194 168
(...skipping 28 matching lines...) Expand all
223 if (!second->IsValid()) { 197 if (!second->IsValid()) {
224 exception_state.ThrowDOMException(kDataError, 198 exception_state.ThrowDOMException(kDataError,
225 IDBDatabase::kNotValidKeyErrorMessage); 199 IDBDatabase::kNotValidKeyErrorMessage);
226 return 0; 200 return 0;
227 } 201 }
228 202
229 return static_cast<short>(first->Compare(second)); 203 return static_cast<short>(first->Compare(second));
230 } 204 }
231 205
232 } // namespace blink 206 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/indexeddb/IDBFactory.h ('k') | third_party/WebKit/Source/modules/indexeddb/IDBFactory.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698