| OLD | NEW |
| 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 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #include "modules/indexeddb/IDBFactory.h" | 30 #include "modules/indexeddb/IDBFactory.h" |
| 31 | 31 |
| 32 #include "bindings/v8/ExceptionMessages.h" | |
| 33 #include "bindings/v8/ExceptionState.h" | 32 #include "bindings/v8/ExceptionState.h" |
| 34 #include "bindings/v8/IDBBindingUtilities.h" | 33 #include "bindings/v8/IDBBindingUtilities.h" |
| 35 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
| 36 #include "core/dom/ExceptionCode.h" | 35 #include "core/dom/ExceptionCode.h" |
| 37 #include "modules/indexeddb/IDBDatabase.h" | 36 #include "modules/indexeddb/IDBDatabase.h" |
| 38 #include "modules/indexeddb/IDBDatabaseCallbacks.h" | 37 #include "modules/indexeddb/IDBDatabaseCallbacks.h" |
| 39 #include "modules/indexeddb/IDBFactoryBackendInterface.h" | 38 #include "modules/indexeddb/IDBFactoryBackendInterface.h" |
| 40 #include "modules/indexeddb/IDBHistograms.h" | 39 #include "modules/indexeddb/IDBHistograms.h" |
| 41 #include "modules/indexeddb/IDBKey.h" | 40 #include "modules/indexeddb/IDBKey.h" |
| 42 #include "modules/indexeddb/IDBTracing.h" | 41 #include "modules/indexeddb/IDBTracing.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 72 } | 71 } |
| 73 return true; | 72 return true; |
| 74 } | 73 } |
| 75 | 74 |
| 76 PassRefPtr<IDBRequest> IDBFactory::getDatabaseNames(ExecutionContext* context, E
xceptionState& exceptionState) | 75 PassRefPtr<IDBRequest> IDBFactory::getDatabaseNames(ExecutionContext* context, E
xceptionState& exceptionState) |
| 77 { | 76 { |
| 78 IDB_TRACE("IDBFactory::getDatabaseNames"); | 77 IDB_TRACE("IDBFactory::getDatabaseNames"); |
| 79 if (!isContextValid(context)) | 78 if (!isContextValid(context)) |
| 80 return 0; | 79 return 0; |
| 81 if (!context->securityOrigin()->canAccessDatabase()) { | 80 if (!context->securityOrigin()->canAccessDatabase()) { |
| 82 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("ge
tDatabaseNames", "IDBFactory", "access to the Indexed Database API is denied in
this context.")); | 81 exceptionState.throwSecurityError("access to the Indexed Database API is
denied in this context."); |
| 83 return 0; | 82 return 0; |
| 84 } | 83 } |
| 85 | 84 |
| 86 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), 0); | 85 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), 0); |
| 87 | 86 |
| 88 | 87 |
| 89 if (!m_permissionClient->allowIndexedDB(context, "Database Listing")) { | 88 if (!m_permissionClient->allowIndexedDB(context, "Database Listing")) { |
| 90 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); | 89 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); |
| 91 return request; | 90 return request; |
| 92 } | 91 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 109 { | 108 { |
| 110 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBOpenCall, IDBMethodsMax); | 109 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBOpenCall, IDBMethodsMax); |
| 111 ASSERT(version >= 1 || version == IDBDatabaseMetadata::NoIntVersion); | 110 ASSERT(version >= 1 || version == IDBDatabaseMetadata::NoIntVersion); |
| 112 if (name.isNull()) { | 111 if (name.isNull()) { |
| 113 exceptionState.throwUninformativeAndGenericTypeError(); | 112 exceptionState.throwUninformativeAndGenericTypeError(); |
| 114 return 0; | 113 return 0; |
| 115 } | 114 } |
| 116 if (!isContextValid(context)) | 115 if (!isContextValid(context)) |
| 117 return 0; | 116 return 0; |
| 118 if (!context->securityOrigin()->canAccessDatabase()) { | 117 if (!context->securityOrigin()->canAccessDatabase()) { |
| 119 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("op
en", "IDBFactory", "access to the Indexed Database API is denied in this context
.")); | 118 exceptionState.throwSecurityError("access to the Indexed Database API is
denied in this context."); |
| 120 return 0; | 119 return 0; |
| 121 } | 120 } |
| 122 | 121 |
| 123 RefPtr<IDBDatabaseCallbacks> databaseCallbacks = IDBDatabaseCallbacks::creat
e(); | 122 RefPtr<IDBDatabaseCallbacks> databaseCallbacks = IDBDatabaseCallbacks::creat
e(); |
| 124 int64_t transactionId = IDBDatabase::nextTransactionId(); | 123 int64_t transactionId = IDBDatabase::nextTransactionId(); |
| 125 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, databas
eCallbacks, transactionId, version); | 124 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, databas
eCallbacks, transactionId, version); |
| 126 | 125 |
| 127 if (!m_permissionClient->allowIndexedDB(context, name)) { | 126 if (!m_permissionClient->allowIndexedDB(context, name)) { |
| 128 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); | 127 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); |
| 129 return request; | 128 return request; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 143 { | 142 { |
| 144 IDB_TRACE("IDBFactory::deleteDatabase"); | 143 IDB_TRACE("IDBFactory::deleteDatabase"); |
| 145 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBDeleteDatabaseCall, IDBMethodsMax); | 144 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBDeleteDatabaseCall, IDBMethodsMax); |
| 146 if (name.isNull()) { | 145 if (name.isNull()) { |
| 147 exceptionState.throwUninformativeAndGenericTypeError(); | 146 exceptionState.throwUninformativeAndGenericTypeError(); |
| 148 return 0; | 147 return 0; |
| 149 } | 148 } |
| 150 if (!isContextValid(context)) | 149 if (!isContextValid(context)) |
| 151 return 0; | 150 return 0; |
| 152 if (!context->securityOrigin()->canAccessDatabase()) { | 151 if (!context->securityOrigin()->canAccessDatabase()) { |
| 153 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("de
leteDatabase", "IDBFactory", "access to the Indexed Database API is denied in th
is context.")); | 152 exceptionState.throwSecurityError("access to the Indexed Database API is
denied in this context."); |
| 154 return 0; | 153 return 0; |
| 155 } | 154 } |
| 156 | 155 |
| 157 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, 0, 0, I
DBDatabaseMetadata::DefaultIntVersion); | 156 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, 0, 0, I
DBDatabaseMetadata::DefaultIntVersion); |
| 158 | 157 |
| 159 if (!m_permissionClient->allowIndexedDB(context, name)) { | 158 if (!m_permissionClient->allowIndexedDB(context, name)) { |
| 160 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); | 159 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); |
| 161 return request; | 160 return request; |
| 162 } | 161 } |
| 163 | 162 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 176 | 175 |
| 177 if (!first->isValid() || !second->isValid()) { | 176 if (!first->isValid() || !second->isValid()) { |
| 178 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 177 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
| 179 return 0; | 178 return 0; |
| 180 } | 179 } |
| 181 | 180 |
| 182 return static_cast<short>(first->compare(second.get())); | 181 return static_cast<short>(first->compare(second.get())); |
| 183 } | 182 } |
| 184 | 183 |
| 185 } // namespace WebCore | 184 } // namespace WebCore |
| OLD | NEW |