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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "WebCommonWorkerClient.h" | 34 #include "WebCommonWorkerClient.h" |
35 #include "WebDatabase.h" | 35 #include "WebDatabase.h" |
36 #include "WebDatabaseObserver.h" | 36 #include "WebDatabaseObserver.h" |
37 #include "WebFrameClient.h" | 37 #include "WebFrameClient.h" |
38 #include "WebFrameImpl.h" | 38 #include "WebFrameImpl.h" |
39 #include "WebPermissionClient.h" | 39 #include "WebPermissionClient.h" |
40 #include "WebSecurityOrigin.h" | 40 #include "WebSecurityOrigin.h" |
41 #include "WebViewImpl.h" | 41 #include "WebViewImpl.h" |
42 #include "WebWorkerBase.h" | 42 #include "WebWorkerBase.h" |
43 #include "WorkerAllowMainThreadBridgeBase.h" | 43 #include "WorkerAllowMainThreadBridgeBase.h" |
| 44 #include "WorkerPermissionClient.h" |
44 #include "bindings/v8/WorkerScriptController.h" | 45 #include "bindings/v8/WorkerScriptController.h" |
45 #include "core/dom/CrossThreadTask.h" | 46 #include "core/dom/CrossThreadTask.h" |
46 #include "core/dom/Document.h" | 47 #include "core/dom/Document.h" |
47 #include "core/dom/ExecutionContext.h" | 48 #include "core/dom/ExecutionContext.h" |
48 #include "core/workers/WorkerGlobalScope.h" | 49 #include "core/workers/WorkerGlobalScope.h" |
49 #include "core/workers/WorkerLoaderProxy.h" | 50 #include "core/workers/WorkerLoaderProxy.h" |
50 #include "core/workers/WorkerThread.h" | 51 #include "core/workers/WorkerThread.h" |
51 #include "modules/webdatabase/DatabaseBackendBase.h" | 52 #include "modules/webdatabase/DatabaseBackendBase.h" |
52 #include "modules/webdatabase/DatabaseContext.h" | 53 #include "modules/webdatabase/DatabaseContext.h" |
53 #include "platform/CrossThreadCopier.h" | 54 #include "platform/CrossThreadCopier.h" |
54 | 55 |
55 using namespace WebKit; | 56 using namespace WebKit; |
56 | 57 |
57 namespace { | 58 namespace { |
58 | 59 |
59 static const char allowDatabaseMode[] = "allowDatabaseMode"; | 60 static const char allowDatabaseMode[] = "allowDatabaseMode"; |
60 | 61 |
| 62 // FIXME: Deprecate this. |
61 // This class is used to route the result of the WebWorkerBase::allowDatabase | 63 // This class is used to route the result of the WebWorkerBase::allowDatabase |
62 // call back to the worker context. | 64 // call back to the worker context. |
63 class AllowDatabaseMainThreadBridge : public WorkerAllowMainThreadBridgeBase { | 65 class AllowDatabaseMainThreadBridge : public WorkerAllowMainThreadBridgeBase { |
64 public: | 66 public: |
65 static PassRefPtr<AllowDatabaseMainThreadBridge> create(WebCore::WorkerGloba
lScope& workerGlobalScope, WebWorkerBase* webWorkerBase, const String& mode, Web
Frame* frame, const String& name, const String& displayName, unsigned long estim
atedSize) | 67 static PassRefPtr<AllowDatabaseMainThreadBridge> create(WebCore::WorkerGloba
lScope& workerGlobalScope, WebWorkerBase* webWorkerBase, const String& mode, Web
Frame* frame, const String& name, const String& displayName, unsigned long estim
atedSize) |
66 { | 68 { |
67 return adoptRef(new AllowDatabaseMainThreadBridge(workerGlobalScope, web
WorkerBase, mode, frame, name, displayName, estimatedSize)); | 69 return adoptRef(new AllowDatabaseMainThreadBridge(workerGlobalScope, web
WorkerBase, mode, frame, name, displayName, estimatedSize)); |
68 } | 70 } |
69 | 71 |
70 private: | 72 private: |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); | 139 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); |
138 if (!webFrame) | 140 if (!webFrame) |
139 return false; | 141 return false; |
140 WebViewImpl* webView = webFrame->viewImpl(); | 142 WebViewImpl* webView = webFrame->viewImpl(); |
141 if (!webView) | 143 if (!webView) |
142 return false; | 144 return false; |
143 if (webView->permissionClient()) | 145 if (webView->permissionClient()) |
144 return webView->permissionClient()->allowDatabase(webFrame, name, di
splayName, estimatedSize); | 146 return webView->permissionClient()->allowDatabase(webFrame, name, di
splayName, estimatedSize); |
145 } else { | 147 } else { |
146 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(executionCont
ext); | 148 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(executionCont
ext); |
| 149 WorkerPermissionClient* permissionClient = WorkerPermissionClient::from(
workerGlobalScope); |
| 150 if (permissionClient->proxy()) |
| 151 return permissionClient->allowDatabase(name, displayName, estimatedS
ize); |
| 152 |
| 153 // FIXME: Deprecate this bridge code when PermissionClientProxy is |
| 154 // implemented by the embedder. |
147 WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerGlobalScope
->thread()->workerLoaderProxy().toWebWorkerBase()); | 155 WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerGlobalScope
->thread()->workerLoaderProxy().toWebWorkerBase()); |
148 WebView* view = webWorker->view(); | 156 WebView* view = webWorker->view(); |
149 if (!view) | 157 if (!view) |
150 return false; | 158 return false; |
151 return allowDatabaseForWorker(view->mainFrame(), name, displayName, esti
matedSize); | 159 return allowDatabaseForWorker(view->mainFrame(), name, displayName, esti
matedSize); |
152 } | 160 } |
153 | 161 |
154 return true; | 162 return true; |
155 } | 163 } |
156 | 164 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 { | 204 { |
197 WebDatabase::observer()->reportExecuteStatementResult(WebDatabase(database),
errorSite, webSqlErrorCode, sqliteErrorCode); | 205 WebDatabase::observer()->reportExecuteStatementResult(WebDatabase(database),
errorSite, webSqlErrorCode, sqliteErrorCode); |
198 } | 206 } |
199 | 207 |
200 void DatabaseObserver::reportVacuumDatabaseResult(DatabaseBackendBase* database,
int sqliteErrorCode) | 208 void DatabaseObserver::reportVacuumDatabaseResult(DatabaseBackendBase* database,
int sqliteErrorCode) |
201 { | 209 { |
202 WebDatabase::observer()->reportVacuumDatabaseResult(WebDatabase(database), s
qliteErrorCode); | 210 WebDatabase::observer()->reportVacuumDatabaseResult(WebDatabase(database), s
qliteErrorCode); |
203 } | 211 } |
204 | 212 |
205 } // namespace WebCore | 213 } // namespace WebCore |
OLD | NEW |