OLD | NEW |
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 26 matching lines...) Expand all Loading... |
37 #include "WebFrameImpl.h" | 37 #include "WebFrameImpl.h" |
38 #include "WebIDBCallbacksImpl.h" | 38 #include "WebIDBCallbacksImpl.h" |
39 #include "WebIDBDatabaseCallbacksImpl.h" | 39 #include "WebIDBDatabaseCallbacksImpl.h" |
40 #include "WebKit.h" | 40 #include "WebKit.h" |
41 #include "WebPermissionClient.h" | 41 #include "WebPermissionClient.h" |
42 #include "WebSecurityOrigin.h" | 42 #include "WebSecurityOrigin.h" |
43 #include "WebViewImpl.h" | 43 #include "WebViewImpl.h" |
44 #include "WebWorkerBase.h" | 44 #include "WebWorkerBase.h" |
45 #include "WebWorkerClientImpl.h" | 45 #include "WebWorkerClientImpl.h" |
46 #include "WorkerAllowMainThreadBridgeBase.h" | 46 #include "WorkerAllowMainThreadBridgeBase.h" |
| 47 #include "WorkerPermissionClient.h" |
47 #include "bindings/v8/WorkerScriptController.h" | 48 #include "bindings/v8/WorkerScriptController.h" |
48 #include "core/dom/CrossThreadTask.h" | 49 #include "core/dom/CrossThreadTask.h" |
49 #include "core/dom/DOMError.h" | 50 #include "core/dom/DOMError.h" |
50 #include "core/dom/ExceptionCode.h" | 51 #include "core/dom/ExceptionCode.h" |
51 #include "core/dom/ExecutionContext.h" | 52 #include "core/dom/ExecutionContext.h" |
52 #include "core/workers/WorkerGlobalScope.h" | 53 #include "core/workers/WorkerGlobalScope.h" |
53 #include "core/workers/WorkerLoaderProxy.h" | 54 #include "core/workers/WorkerLoaderProxy.h" |
54 #include "core/workers/WorkerThread.h" | 55 #include "core/workers/WorkerThread.h" |
55 #include "modules/indexeddb/IDBDatabaseCallbacks.h" | 56 #include "modules/indexeddb/IDBDatabaseCallbacks.h" |
56 #include "weborigin/SecurityOrigin.h" | 57 #include "weborigin/SecurityOrigin.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 bool allowed; | 115 bool allowed; |
115 ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument() || context->isWorkerG
lobalScope()); | 116 ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument() || context->isWorkerG
lobalScope()); |
116 if (context->isDocument()) { | 117 if (context->isDocument()) { |
117 Document* document = toDocument(context); | 118 Document* document = toDocument(context); |
118 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); | 119 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); |
119 WebViewImpl* webView = webFrame->viewImpl(); | 120 WebViewImpl* webView = webFrame->viewImpl(); |
120 // FIXME: webView->permissionClient() returns 0 in test_shell and conten
t_shell http://crbug.com/137269 | 121 // FIXME: webView->permissionClient() returns 0 in test_shell and conten
t_shell http://crbug.com/137269 |
121 allowed = !webView->permissionClient() || webView->permissionClient()->a
llowIndexedDB(webFrame, name, origin); | 122 allowed = !webView->permissionClient() || webView->permissionClient()->a
llowIndexedDB(webFrame, name, origin); |
122 } else { | 123 } else { |
123 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); | 124 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); |
| 125 WorkerPermissionClient* permissionClient = WorkerPermissionClient::from(
workerGlobalScope); |
| 126 if (permissionClient->proxy()) { |
| 127 allowed = permissionClient->allowIndexedDB(name); |
| 128 if (!allowed) |
| 129 callbacks->onError(WebIDBDatabaseError(UnknownError, "The user d
enied permission to access the database.")); |
| 130 |
| 131 return allowed; |
| 132 } |
| 133 |
| 134 // FIXME: Deprecate this bridge code when PermissionClientProxy is |
| 135 // implemented by the embedder. |
124 WebWorkerBase* webWorkerBase = static_cast<WebWorkerBase*>(workerGlobalS
cope->thread()->workerLoaderProxy().toWebWorkerBase()); | 136 WebWorkerBase* webWorkerBase = static_cast<WebWorkerBase*>(workerGlobalS
cope->thread()->workerLoaderProxy().toWebWorkerBase()); |
125 WorkerRunLoop& runLoop = workerGlobalScope->thread()->runLoop(); | 137 WorkerRunLoop& runLoop = workerGlobalScope->thread()->runLoop(); |
126 | 138 |
127 String mode = allowIndexedDBMode; | 139 String mode = allowIndexedDBMode; |
128 mode.append(String::number(runLoop.createUniqueId())); | 140 mode.append(String::number(runLoop.createUniqueId())); |
129 RefPtr<AllowIndexedDBMainThreadBridge> bridge = AllowIndexedDBMainThread
Bridge::create(workerGlobalScope, webWorkerBase, mode, name); | 141 RefPtr<AllowIndexedDBMainThreadBridge> bridge = AllowIndexedDBMainThread
Bridge::create(workerGlobalScope, webWorkerBase, mode, name); |
130 | 142 |
131 // Either the bridge returns, or the queue gets terminated. | 143 // Either the bridge returns, or the queue gets terminated. |
132 if (runLoop.runInMode(workerGlobalScope, mode) == MessageQueueTerminated
) { | 144 if (runLoop.runInMode(workerGlobalScope, mode) == MessageQueueTerminated
) { |
133 bridge->cancel(); | 145 bridge->cancel(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 { | 179 { |
168 RefPtr<IDBCallbacks> callbacks(prpCallbacks); | 180 RefPtr<IDBCallbacks> callbacks(prpCallbacks); |
169 WebSecurityOrigin origin(context->securityOrigin()); | 181 WebSecurityOrigin origin(context->securityOrigin()); |
170 if (!allowIndexedDB(context, name, origin, callbacks)) | 182 if (!allowIndexedDB(context, name, origin, callbacks)) |
171 return; | 183 return; |
172 | 184 |
173 m_webIDBFactory->deleteDatabase(name, new WebIDBCallbacksImpl(callbacks), da
tabaseIdentifier); | 185 m_webIDBFactory->deleteDatabase(name, new WebIDBCallbacksImpl(callbacks), da
tabaseIdentifier); |
174 } | 186 } |
175 | 187 |
176 } // namespace WebKit | 188 } // namespace WebKit |
OLD | NEW |