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

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

Issue 1755343002: IndexedDB: Pass origin to platform/IPC, rather than DatabaseIdentifier (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 23 matching lines...) Expand all
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/dom/ExceptionCode.h" 35 #include "core/dom/ExceptionCode.h"
36 #include "modules/indexeddb/IDBDatabase.h" 36 #include "modules/indexeddb/IDBDatabase.h"
37 #include "modules/indexeddb/IDBDatabaseCallbacks.h" 37 #include "modules/indexeddb/IDBDatabaseCallbacks.h"
38 #include "modules/indexeddb/IDBKey.h" 38 #include "modules/indexeddb/IDBKey.h"
39 #include "modules/indexeddb/IDBTracing.h" 39 #include "modules/indexeddb/IDBTracing.h"
40 #include "modules/indexeddb/IndexedDBClient.h" 40 #include "modules/indexeddb/IndexedDBClient.h"
41 #include "modules/indexeddb/WebIDBCallbacksImpl.h" 41 #include "modules/indexeddb/WebIDBCallbacksImpl.h"
42 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h" 42 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h"
43 #include "platform/Histogram.h" 43 #include "platform/Histogram.h"
44 #include "platform/weborigin/DatabaseIdentifier.h"
45 #include "platform/weborigin/SecurityOrigin.h" 44 #include "platform/weborigin/SecurityOrigin.h"
46 #include "public/platform/Platform.h" 45 #include "public/platform/Platform.h"
46 #include "public/platform/WebSecurityOrigin.h"
47 #include "public/platform/modules/indexeddb/WebIDBFactory.h" 47 #include "public/platform/modules/indexeddb/WebIDBFactory.h"
48 48
49 namespace blink { 49 namespace blink {
50 50
51 static const char permissionDeniedErrorMessage[] = "The user denied permission t o access the database."; 51 static const char permissionDeniedErrorMessage[] = "The user denied permission t o access the database.";
52 52
53 IDBFactory::IDBFactory(IndexedDBClient* permissionClient) 53 IDBFactory::IDBFactory(IndexedDBClient* permissionClient)
54 : m_permissionClient(permissionClient) 54 : m_permissionClient(permissionClient)
55 { 55 {
56 } 56 }
(...skipping 23 matching lines...) Expand all
80 return nullptr; 80 return nullptr;
81 } 81 }
82 82
83 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::createNull(), nullptr); 83 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::createNull(), nullptr);
84 84
85 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), "Da tabase Listing")) { 85 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), "Da tabase Listing")) {
86 request->onError(DOMException::create(UnknownError, permissionDeniedErro rMessage)); 86 request->onError(DOMException::create(UnknownError, permissionDeniedErro rMessage));
87 return request; 87 return request;
88 } 88 }
89 89
90 Platform::current()->idbFactory()->getDatabaseNames(WebIDBCallbacksImpl::cre ate(request).leakPtr(), createDatabaseIdentifierFromSecurityOrigin(scriptState-> executionContext()->securityOrigin())); 90 Platform::current()->idbFactory()->getDatabaseNames(WebIDBCallbacksImpl::cre ate(request).leakPtr(), WebSecurityOrigin(scriptState->executionContext()->secur ityOrigin()));
91 return request; 91 return request;
92 } 92 }
93 93
94 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, unsigned long long version, ExceptionState& exceptionState) 94 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, unsigned long long version, ExceptionState& exceptionState)
95 { 95 {
96 IDB_TRACE("IDBFactory::open"); 96 IDB_TRACE("IDBFactory::open");
97 if (!version) { 97 if (!version) {
98 exceptionState.throwTypeError("The version provided must not be 0."); 98 exceptionState.throwTypeError("The version provided must not be 0.");
99 return nullptr; 99 return nullptr;
100 } 100 }
(...skipping 13 matching lines...) Expand all
114 114
115 IDBDatabaseCallbacks* databaseCallbacks = IDBDatabaseCallbacks::create(); 115 IDBDatabaseCallbacks* databaseCallbacks = IDBDatabaseCallbacks::create();
116 int64_t transactionId = IDBDatabase::nextTransactionId(); 116 int64_t transactionId = IDBDatabase::nextTransactionId();
117 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, databaseCa llbacks, transactionId, version); 117 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, databaseCa llbacks, transactionId, version);
118 118
119 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam e)) { 119 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam e)) {
120 request->onError(DOMException::create(UnknownError, permissionDeniedErro rMessage)); 120 request->onError(DOMException::create(UnknownError, permissionDeniedErro rMessage));
121 return request; 121 return request;
122 } 122 }
123 123
124 Platform::current()->idbFactory()->open(name, version, transactionId, WebIDB CallbacksImpl::create(request).leakPtr(), WebIDBDatabaseCallbacksImpl::create(da tabaseCallbacks).leakPtr(), createDatabaseIdentifierFromSecurityOrigin(scriptSta te->executionContext()->securityOrigin())); 124 Platform::current()->idbFactory()->open(name, version, transactionId, WebIDB CallbacksImpl::create(request).leakPtr(), WebIDBDatabaseCallbacksImpl::create(da tabaseCallbacks).leakPtr(), WebSecurityOrigin(scriptState->executionContext()->s ecurityOrigin()));
125 return request; 125 return request;
126 } 126 }
127 127
128 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, ExceptionState& exceptionState) 128 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, ExceptionState& exceptionState)
129 { 129 {
130 IDB_TRACE("IDBFactory::open"); 130 IDB_TRACE("IDBFactory::open");
131 return openInternal(scriptState, name, IDBDatabaseMetadata::NoVersion, excep tionState); 131 return openInternal(scriptState, name, IDBDatabaseMetadata::NoVersion, excep tionState);
132 } 132 }
133 133
134 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* scriptState, const Str ing& name, ExceptionState& exceptionState) 134 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* scriptState, const Str ing& name, ExceptionState& exceptionState)
135 { 135 {
136 IDB_TRACE("IDBFactory::deleteDatabase"); 136 IDB_TRACE("IDBFactory::deleteDatabase");
137 IDBDatabase::recordApiCallsHistogram(IDBDeleteDatabaseCall); 137 IDBDatabase::recordApiCallsHistogram(IDBDeleteDatabaseCall);
138 if (!isContextValid(scriptState->executionContext())) 138 if (!isContextValid(scriptState->executionContext()))
139 return nullptr; 139 return nullptr;
140 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase()) { 140 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase()) {
141 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context."); 141 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context.");
142 return nullptr; 142 return nullptr;
143 } 143 }
144 144
145 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, nullptr, 0 , IDBDatabaseMetadata::DefaultVersion); 145 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, nullptr, 0 , IDBDatabaseMetadata::DefaultVersion);
146 146
147 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam e)) { 147 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam e)) {
148 request->onError(DOMException::create(UnknownError, permissionDeniedErro rMessage)); 148 request->onError(DOMException::create(UnknownError, permissionDeniedErro rMessage));
149 return request; 149 return request;
150 } 150 }
151 151
152 Platform::current()->idbFactory()->deleteDatabase(name, WebIDBCallbacksImpl: :create(request).leakPtr(), createDatabaseIdentifierFromSecurityOrigin(scriptSta te->executionContext()->securityOrigin())); 152 Platform::current()->idbFactory()->deleteDatabase(name, WebIDBCallbacksImpl: :create(request).leakPtr(), WebSecurityOrigin(scriptState->executionContext()->s ecurityOrigin()));
153 return request; 153 return request;
154 } 154 }
155 155
156 short IDBFactory::cmp(ScriptState* scriptState, const ScriptValue& firstValue, c onst ScriptValue& secondValue, ExceptionState& exceptionState) 156 short IDBFactory::cmp(ScriptState* scriptState, const ScriptValue& firstValue, c onst ScriptValue& secondValue, ExceptionState& exceptionState)
157 { 157 {
158 IDBKey* first = ScriptValue::to<IDBKey*>(scriptState->isolate(), firstValue, exceptionState); 158 IDBKey* first = ScriptValue::to<IDBKey*>(scriptState->isolate(), firstValue, exceptionState);
159 if (exceptionState.hadException()) 159 if (exceptionState.hadException())
160 return 0; 160 return 0;
161 ASSERT(first); 161 ASSERT(first);
162 if (!first->isValid()) { 162 if (!first->isValid()) {
163 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage); 163 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage);
164 return 0; 164 return 0;
165 } 165 }
166 166
167 IDBKey* second = ScriptValue::to<IDBKey*>(scriptState->isolate(), secondValu e, exceptionState); 167 IDBKey* second = ScriptValue::to<IDBKey*>(scriptState->isolate(), secondValu e, exceptionState);
168 if (exceptionState.hadException()) 168 if (exceptionState.hadException())
169 return 0; 169 return 0;
170 ASSERT(second); 170 ASSERT(second);
171 if (!second->isValid()) { 171 if (!second->isValid()) {
172 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage); 172 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage);
173 return 0; 173 return 0;
174 } 174 }
175 175
176 return static_cast<short>(first->compare(second)); 176 return static_cast<short>(first->compare(second));
177 } 177 }
178 178
179 } // namespace blink 179 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698