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 if (!m_permissionClient->allowIndexedDB(context, "Database Listing")) { | 87 if (!m_permissionClient->allowIndexedDB(context, "Database Listing")) { |
89 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); | 88 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); |
90 return request; | 89 return request; |
91 } | 90 } |
92 | 91 |
(...skipping 15 matching lines...) Expand all Loading... |
108 { | 107 { |
109 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBOpenCall, IDBMethodsMax); | 108 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBOpenCall, IDBMethodsMax); |
110 ASSERT(version >= 1 || version == IDBDatabaseMetadata::NoIntVersion); | 109 ASSERT(version >= 1 || version == IDBDatabaseMetadata::NoIntVersion); |
111 if (name.isNull()) { | 110 if (name.isNull()) { |
112 exceptionState.throwUninformativeAndGenericTypeError(); | 111 exceptionState.throwUninformativeAndGenericTypeError(); |
113 return 0; | 112 return 0; |
114 } | 113 } |
115 if (!isContextValid(context)) | 114 if (!isContextValid(context)) |
116 return 0; | 115 return 0; |
117 if (!context->securityOrigin()->canAccessDatabase()) { | 116 if (!context->securityOrigin()->canAccessDatabase()) { |
118 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("op
en", "IDBFactory", "access to the Indexed Database API is denied in this context
.")); | 117 exceptionState.throwSecurityError("access to the Indexed Database API is
denied in this context."); |
119 return 0; | 118 return 0; |
120 } | 119 } |
121 | 120 |
122 RefPtr<IDBDatabaseCallbacks> databaseCallbacks = IDBDatabaseCallbacks::creat
e(); | 121 RefPtr<IDBDatabaseCallbacks> databaseCallbacks = IDBDatabaseCallbacks::creat
e(); |
123 int64_t transactionId = IDBDatabase::nextTransactionId(); | 122 int64_t transactionId = IDBDatabase::nextTransactionId(); |
124 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, databas
eCallbacks, transactionId, version); | 123 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, databas
eCallbacks, transactionId, version); |
125 | 124 |
126 if (!m_permissionClient->allowIndexedDB(context, name)) { | 125 if (!m_permissionClient->allowIndexedDB(context, name)) { |
127 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); | 126 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); |
128 return request; | 127 return request; |
(...skipping 13 matching lines...) Expand all Loading... |
142 { | 141 { |
143 IDB_TRACE("IDBFactory::deleteDatabase"); | 142 IDB_TRACE("IDBFactory::deleteDatabase"); |
144 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBDeleteDatabaseCall, IDBMethodsMax); | 143 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBDeleteDatabaseCall, IDBMethodsMax); |
145 if (name.isNull()) { | 144 if (name.isNull()) { |
146 exceptionState.throwUninformativeAndGenericTypeError(); | 145 exceptionState.throwUninformativeAndGenericTypeError(); |
147 return 0; | 146 return 0; |
148 } | 147 } |
149 if (!isContextValid(context)) | 148 if (!isContextValid(context)) |
150 return 0; | 149 return 0; |
151 if (!context->securityOrigin()->canAccessDatabase()) { | 150 if (!context->securityOrigin()->canAccessDatabase()) { |
152 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("de
leteDatabase", "IDBFactory", "access to the Indexed Database API is denied in th
is context.")); | 151 exceptionState.throwSecurityError("access to the Indexed Database API is
denied in this context."); |
153 return 0; | 152 return 0; |
154 } | 153 } |
155 | 154 |
156 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, 0, 0, I
DBDatabaseMetadata::DefaultIntVersion); | 155 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, 0, 0, I
DBDatabaseMetadata::DefaultIntVersion); |
157 | 156 |
158 if (!m_permissionClient->allowIndexedDB(context, name)) { | 157 if (!m_permissionClient->allowIndexedDB(context, name)) { |
159 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); | 158 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); |
160 return request; | 159 return request; |
161 } | 160 } |
162 | 161 |
(...skipping 12 matching lines...) Expand all Loading... |
175 | 174 |
176 if (!first->isValid() || !second->isValid()) { | 175 if (!first->isValid() || !second->isValid()) { |
177 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 176 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
178 return 0; | 177 return 0; |
179 } | 178 } |
180 | 179 |
181 return static_cast<short>(first->compare(second.get())); | 180 return static_cast<short>(first->compare(second.get())); |
182 } | 181 } |
183 | 182 |
184 } // namespace WebCore | 183 } // namespace WebCore |
OLD | NEW |