diff options
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/api/public/WebScriptController.h | 44 | ||||
-rw-r--r-- | webkit/api/src/WebScriptController.cpp | 23 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.cc | 3 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_main.cc | 10 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_webkit_init.h | 8 |
5 files changed, 52 insertions, 36 deletions
diff --git a/webkit/api/public/WebScriptController.h b/webkit/api/public/WebScriptController.h index afed9be..8e2ebb4 100644 --- a/webkit/api/public/WebScriptController.h +++ b/webkit/api/public/WebScriptController.h @@ -40,27 +40,33 @@ namespace v8 { namespace WebKit { class WebString; - // Registers a v8 extension to be available on webpages. The three forms - // offer various restrictions on what types of contexts the extension is - // loaded into. If a scheme is provided, only pages whose URL has the given - // scheme will match. If extensionGroup is provided, the extension will only - // be loaded into scripts run via WebFrame::ExecuteInNewWorld with the - // matching group. - // Will only affect v8 contexts initialized after this call. Takes ownership - // of the v8::Extension object passed. - WEBKIT_API void registerExtension(v8::Extension*); - WEBKIT_API void registerExtension(v8::Extension*, - const WebString& schemeRestriction); - WEBKIT_API void registerExtension(v8::Extension*, int extensionGroup); + class WebScriptController { + public: + // Registers a v8 extension to be available on webpages. The three forms + // offer various restrictions on what types of contexts the extension is + // loaded into. If a scheme is provided, only pages whose URL has the given + // scheme will match. If extensionGroup is provided, the extension will only + // be loaded into scripts run via WebFrame::ExecuteInNewWorld with the + // matching group. + // Will only affect v8 contexts initialized after this call. Takes ownership + // of the v8::Extension object passed. + WEBKIT_API static void registerExtension(v8::Extension*); + WEBKIT_API static void registerExtension(v8::Extension*, + const WebString& schemeRestriction); + WEBKIT_API static void registerExtension(v8::Extension*, int extensionGroup); - // Enables special settings which are only applicable if V8 is executed - // in the single thread which must be the main thread. - // FIXME: make a try to dynamically detect when this condition is broken - // and automatically switch off single thread mode. - WEBKIT_API void enableV8SingleThreadMode(); + // Enables special settings which are only applicable if V8 is executed + // in the single thread which must be the main thread. + // FIXME: make a try to dynamically detect when this condition is broken + // and automatically switch off single thread mode. + WEBKIT_API static void enableV8SingleThreadMode(); - // Process any pending JavaScript console messages. - WEBKIT_API void flushConsoleMessages(); + // Process any pending JavaScript console messages. + WEBKIT_API static void flushConsoleMessages(); + + private: + WebScriptController(); + }; } // namespace WebKit diff --git a/webkit/api/src/WebScriptController.cpp b/webkit/api/src/WebScriptController.cpp index 4282030..9be47a8 100644 --- a/webkit/api/src/WebScriptController.cpp +++ b/webkit/api/src/WebScriptController.cpp @@ -36,30 +36,33 @@ #include "V8Binding.h" #include "V8Proxy.h" +using namespace WebCore; + namespace WebKit { -void registerExtension(v8::Extension* extension) +void WebScriptController::registerExtension(v8::Extension* extension) { - WebCore::V8Proxy::registerExtension(extension, WebString()); + V8Proxy::registerExtension(extension, WebString()); } -void registerExtension(v8::Extension* extension, - const WebString& schemeRestriction) +void WebScriptController::registerExtension(v8::Extension* extension, + const WebString& schemeRestriction) { - WebCore::V8Proxy::registerExtension(extension, schemeRestriction); + V8Proxy::registerExtension(extension, schemeRestriction); } -void registerExtension(v8::Extension* extension, int extensionGroup) +void WebScriptController::registerExtension(v8::Extension* extension, + int extensionGroup) { - WebCore::V8Proxy::registerExtension(extension, extensionGroup); + V8Proxy::registerExtension(extension, extensionGroup); } -void enableV8SingleThreadMode() +void WebScriptController::enableV8SingleThreadMode() { - WebCore::enableStringImplCache(); + enableStringImplCache(); } -void flushConsoleMessages() +void WebScriptController::flushConsoleMessages() { WebCore::V8Proxy::processConsoleMessages(); } diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 6691f85..a79f39b 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -54,6 +54,7 @@ using WebKit::WebCanvas; using WebKit::WebFrame; using WebKit::WebNavigationPolicy; using WebKit::WebRect; +using WebKit::WebScriptController; using WebKit::WebSize; using WebKit::WebURLRequest; using WebKit::WebView; @@ -195,7 +196,7 @@ void TestShell::Dump(TestShell* shell) { if ((shell == NULL) || ((params = shell->test_params()) == NULL)) return; - WebKit::flushConsoleMessages(); + WebScriptController::flushConsoleMessages(); // Echo the url in the output so we know we're not getting out of sync. printf("#URL:%s\n", params->test_url.c_str()); diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc index 8b716b1..9f2ae67 100644 --- a/webkit/tools/test_shell/test_shell_main.cc +++ b/webkit/tools/test_shell/test_shell_main.cc @@ -40,6 +40,8 @@ static const size_t kPathBufSize = 2048; +using WebKit::WebScriptController; + namespace { // StatsTable initialization parameters. @@ -215,10 +217,11 @@ int main(int argc, char* argv[]) { js_flags += L" --expose-gc"; webkit_glue::SetJavaScriptFlags(js_flags); // Expose GCController to JavaScript. - WebKit::registerExtension(extensions_v8::GCExtension::Get()); + WebScriptController::registerExtension(extensions_v8::GCExtension::Get()); if (parsed_command_line.HasSwitch(test_shell::kProfiler)) { - WebKit::registerExtension(extensions_v8::ProfilerExtension::Get()); + WebScriptController::registerExtension( + extensions_v8::ProfilerExtension::Get()); } // Load and initialize the stats table. Attempt to construct a somewhat @@ -235,7 +238,8 @@ int main(int argc, char* argv[]) { if (TestShell::CreateNewWindow(starting_url, &shell)) { if (record_mode || playback_mode) { platform.SetWindowPositionForRecording(shell); - WebKit::registerExtension(extensions_v8::PlaybackExtension::Get()); + WebScriptController::registerExtension( + extensions_v8::PlaybackExtension::Get()); } shell->Show(WebKit::WebNavigationPolicyNewWindow); diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h index 98b0602..4ec7c55 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.h +++ b/webkit/tools/test_shell/test_shell_webkit_init.h @@ -50,9 +50,11 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { ASCIIToUTF16(webkit_glue::GetUIResourceProtocol())); WebKit::WebSecurityPolicy::registerURLSchemeAsNoAccess( ASCIIToUTF16(webkit_glue::GetUIResourceProtocol())); - WebKit::enableV8SingleThreadMode(); - WebKit::registerExtension(extensions_v8::GearsExtension::Get()); - WebKit::registerExtension(extensions_v8::IntervalExtension::Get()); + WebKit::WebScriptController::enableV8SingleThreadMode(); + WebKit::WebScriptController::registerExtension( + extensions_v8::GearsExtension::Get()); + WebKit::WebScriptController::registerExtension( + extensions_v8::IntervalExtension::Get()); WebKit::enableWebSockets(); // Load libraries for media and enable the media player. |