diff options
author | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-18 05:18:07 +0000 |
---|---|---|
committer | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-18 05:18:07 +0000 |
commit | c285cf2c3dc3eb128541f07065974010dae1b408 (patch) | |
tree | 65cdae9bce903f5a7717d1242e8d640d70ab51d0 /webkit | |
parent | d577853166fb4adbfd777c22e7e13562ca90bac1 (diff) | |
download | chromium_src-c285cf2c3dc3eb128541f07065974010dae1b408.zip chromium_src-c285cf2c3dc3eb128541f07065974010dae1b408.tar.gz chromium_src-c285cf2c3dc3eb128541f07065974010dae1b408.tar.bz2 |
Make worker constructor return error if it is enabled by the flag.
This is to move corresponding files out of http://codereview.chromium.org/48106/ so that this can be checked in before the change to enable worker. The reason for doing this is to avoid build break since the already checked-in third_party/WebKit/WebKit/chromium/src/WebKit.cpp has the ifdef guarded code depend on this.
Review URL: http://codereview.chromium.org/42313
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11952 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/port/bindings/v8/V8WorkerCustom.cpp | 6 | ||||
-rw-r--r-- | webkit/port/bindings/v8/WorkerContextExecutionProxy.cpp | 12 | ||||
-rw-r--r-- | webkit/port/bindings/v8/WorkerContextExecutionProxy.h | 4 |
3 files changed, 22 insertions, 0 deletions
diff --git a/webkit/port/bindings/v8/V8WorkerCustom.cpp b/webkit/port/bindings/v8/V8WorkerCustom.cpp index 7426383..1f7e5fe 100644 --- a/webkit/port/bindings/v8/V8WorkerCustom.cpp +++ b/webkit/port/bindings/v8/V8WorkerCustom.cpp @@ -42,12 +42,18 @@ #include "V8HTMLDocument.h" #include "V8ObjectEventListener.h" #include "Worker.h" +#include "WorkerContextExecutionProxy.h" namespace WebCore { CALLBACK_FUNC_DECL(WorkerConstructor) { INC_STATS(L"DOM.Worker.Constructor"); + if (!WorkerContextExecutionProxy::isWebWorkersEnabled()) { + V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Worker is not enabled."); + return v8::Undefined(); + } + if (!args.IsConstructCall()) { V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "DOM object constructor cannot be called as a function."); diff --git a/webkit/port/bindings/v8/WorkerContextExecutionProxy.cpp b/webkit/port/bindings/v8/WorkerContextExecutionProxy.cpp index c7e200f..a73d828 100644 --- a/webkit/port/bindings/v8/WorkerContextExecutionProxy.cpp +++ b/webkit/port/bindings/v8/WorkerContextExecutionProxy.cpp @@ -47,6 +47,18 @@ namespace WebCore { +static bool workerEnabled = false; + +bool WorkerContextExecutionProxy::isWebWorkersEnabled() +{ + return workerEnabled; +} + +void WorkerContextExecutionProxy::enableWebWorkers(bool value) +{ + workerEnabled = true; +} + WorkerContextExecutionProxy::WorkerContextExecutionProxy(WorkerContext* workerContext) : m_workerContext(workerContext) , m_recursion(0) diff --git a/webkit/port/bindings/v8/WorkerContextExecutionProxy.h b/webkit/port/bindings/v8/WorkerContextExecutionProxy.h index b34f92d..9fb3a0c 100644 --- a/webkit/port/bindings/v8/WorkerContextExecutionProxy.h +++ b/webkit/port/bindings/v8/WorkerContextExecutionProxy.h @@ -83,6 +83,10 @@ namespace WebCore { static v8::Handle<v8::Value> EventTargetToV8Object(EventTarget* target); static v8::Handle<v8::Value> WorkerContextToV8Object(WorkerContext* wc); + // Enables HTML5 worker support. + static void enableWebWorkers(bool); + static bool isWebWorkersEnabled(); + private: void initContextIfNeeded(); void dispose(); |