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

Side by Side Diff: Source/web/IDBFactoryBackendProxy.cpp

Issue 67463006: IndexedDB: Simplify WebIDBCallbacks exports, strip IDBFactoryBackend (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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
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 "IDBFactoryBackendProxy.h" 30 #include "IDBFactoryBackendProxy.h"
31 31
32 #include "public/platform/WebIDBCallbacks.h"
33 #include "public/platform/WebIDBDatabase.h"
34 #include "public/platform/WebIDBDatabaseCallbacks.h"
35 #include "public/platform/WebIDBDatabaseError.h"
36 #include "public/platform/WebIDBFactory.h"
37 #include "public/platform/WebVector.h"
38 #include "WebFrameImpl.h" 32 #include "WebFrameImpl.h"
39 #include "WebKit.h" 33 #include "WebKit.h"
40 #include "WebPermissionClient.h" 34 #include "WebPermissionClient.h"
41 #include "WebSecurityOrigin.h" 35 #include "WebSecurityOrigin.h"
42 #include "WebViewImpl.h" 36 #include "WebViewImpl.h"
43 #include "WebWorkerClientImpl.h" 37 #include "WebWorkerClientImpl.h"
44 #include "WorkerPermissionClient.h" 38 #include "WorkerPermissionClient.h"
45 #include "bindings/v8/WorkerScriptController.h" 39 #include "bindings/v8/WorkerScriptController.h"
46 #include "core/dom/DOMError.h"
47 #include "core/dom/ExceptionCode.h"
48 #include "core/dom/ExecutionContext.h"
49 #include "core/workers/WorkerGlobalScope.h" 40 #include "core/workers/WorkerGlobalScope.h"
50 #include "platform/weborigin/SecurityOrigin.h" 41 #include "platform/weborigin/SecurityOrigin.h"
51 42
52 43
53 using namespace WebCore; 44 using namespace WebCore;
54 45
55 namespace blink { 46 namespace blink {
56 47
57 PassRefPtr<IDBFactoryBackendInterface> IDBFactoryBackendProxy::create() 48 PassRefPtr<IDBFactoryBackendInterface> IDBFactoryBackendProxy::create()
58 { 49 {
59 return adoptRef(new IDBFactoryBackendProxy()); 50 return adoptRef(new IDBFactoryBackendProxy());
60 } 51 }
61 52
62 IDBFactoryBackendProxy::IDBFactoryBackendProxy() 53 bool IDBFactoryBackendProxy::allowIndexedDB(ExecutionContext* context, const Str ing& name)
63 {
64 m_webIDBFactory = blink::Platform::current()->idbFactory();
65 }
66
67 IDBFactoryBackendProxy::~IDBFactoryBackendProxy()
68 {
69 }
70
71 bool IDBFactoryBackendProxy::allowIndexedDB(ExecutionContext* context, const Str ing& name, const WebSecurityOrigin& origin, PassRefPtr<IDBRequest> callbacks)
72 { 54 {
73 bool allowed; 55 bool allowed;
74 ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument() || context->isWorkerG lobalScope()); 56 ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument() || context->isWorkerG lobalScope());
57 WebSecurityOrigin origin(context->securityOrigin());
75 if (context->isDocument()) { 58 if (context->isDocument()) {
76 Document* document = toDocument(context); 59 Document* document = toDocument(context);
77 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); 60 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
78 WebViewImpl* webView = webFrame->viewImpl(); 61 WebViewImpl* webView = webFrame->viewImpl();
79 // FIXME: webView->permissionClient() returns 0 in test_shell and conten t_shell http://crbug.com/137269 62 // FIXME: webView->permissionClient() returns 0 in test_shell and conten t_shell http://crbug.com/137269
80 allowed = !webView->permissionClient() || webView->permissionClient()->a llowIndexedDB(webFrame, name, origin); 63 allowed = !webView->permissionClient() || webView->permissionClient()->a llowIndexedDB(webFrame, name, origin);
81 } else { 64 } else {
82 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); 65 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
83 allowed = WorkerPermissionClient::from(workerGlobalScope)->allowIndexedD B(name); 66 allowed = WorkerPermissionClient::from(workerGlobalScope)->allowIndexedD B(name);
84 } 67 }
85 68
86 if (!allowed)
87 callbacks->onError(WebIDBDatabaseError(UnknownError, "The user denied pe rmission to access the database."));
88
89 return allowed; 69 return allowed;
90 } 70 }
91 71
92 void IDBFactoryBackendProxy::getDatabaseNames(PassRefPtr<IDBRequest> prpCallback s, const String& databaseIdentifier, ExecutionContext* context)
93 {
94 RefPtr<IDBRequest> callbacks(prpCallbacks);
95 WebSecurityOrigin origin(context->securityOrigin());
96 if (!allowIndexedDB(context, "Database Listing", origin, callbacks))
97 return;
98
99 m_webIDBFactory->getDatabaseNames(new WebIDBCallbacks(callbacks), databaseId entifier);
100 }
101
102 void IDBFactoryBackendProxy::open(const String& name, int64_t version, int64_t t ransactionId, PassRefPtr<IDBRequest> prpCallbacks, PassOwnPtr<WebIDBDatabaseCal lbacks> databaseCallbacks, const String& databaseIdentifier, ExecutionContext* c ontext)
103 {
104 RefPtr<IDBRequest> callbacks(prpCallbacks);
105 WebSecurityOrigin origin(context->securityOrigin());
106 if (!allowIndexedDB(context, name, origin, callbacks))
107 return;
108
109 m_webIDBFactory->open(name, version, transactionId, new WebIDBCallbacks(call backs), databaseCallbacks.leakPtr(), databaseIdentifier);
110 }
111
112 void IDBFactoryBackendProxy::deleteDatabase(const String& name, PassRefPtr<IDBRe quest> prpCallbacks, const String& databaseIdentifier, ExecutionContext* context )
113 {
114 RefPtr<IDBRequest> callbacks(prpCallbacks);
115 WebSecurityOrigin origin(context->securityOrigin());
116 if (!allowIndexedDB(context, name, origin, callbacks))
117 return;
118
119 m_webIDBFactory->deleteDatabase(name, new WebIDBCallbacks(callbacks), databa seIdentifier);
120 }
121
122 } // namespace blink 72 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698