summaryrefslogtreecommitdiffstats
path: root/webkit/port
diff options
context:
space:
mode:
authorasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-05 21:39:11 +0000
committerasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-05 21:39:11 +0000
commit06533c0b11ce14b45eb0205fdc28a217eeba763c (patch)
treec2209aab205a7b2216c61be7e1ae6b231b7cb148 /webkit/port
parent68acddb6ced1c8d29e84fb1465f331515217e50a (diff)
downloadchromium_src-06533c0b11ce14b45eb0205fdc28a217eeba763c.zip
chromium_src-06533c0b11ce14b45eb0205fdc28a217eeba763c.tar.gz
chromium_src-06533c0b11ce14b45eb0205fdc28a217eeba763c.tar.bz2
Refactor v8 extensions so that they aren't in the WebCore namespace, and can call functions in the rest of Chromium code without having to go through ChromiumBridge (which now lives upstream in the WebKit repository).
R=darin,mbelshe Review URL: http://codereview.chromium.org/40132 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11040 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rw-r--r--webkit/port/bindings/v8/ScriptController.cpp3
-rw-r--r--webkit/port/bindings/v8/ScriptController.h26
-rw-r--r--webkit/port/bindings/v8/extensions/GCController.cpp26
-rw-r--r--webkit/port/bindings/v8/extensions/GCController.h23
-rwxr-xr-xwebkit/port/bindings/v8/extensions/Gears.cpp45
-rwxr-xr-xwebkit/port/bindings/v8/extensions/Gears.h24
-rw-r--r--webkit/port/bindings/v8/extensions/Interval.cpp57
-rw-r--r--webkit/port/bindings/v8/extensions/Interval.h23
-rw-r--r--webkit/port/bindings/v8/extensions/Playback.cpp31
-rw-r--r--webkit/port/bindings/v8/extensions/Playback.h34
-rw-r--r--webkit/port/bindings/v8/v8_proxy.cpp13
11 files changed, 0 insertions, 305 deletions
diff --git a/webkit/port/bindings/v8/ScriptController.cpp b/webkit/port/bindings/v8/ScriptController.cpp
index 4da169b..9dff0b8 100644
--- a/webkit/port/bindings/v8/ScriptController.cpp
+++ b/webkit/port/bindings/v8/ScriptController.cpp
@@ -74,9 +74,6 @@ NPRuntimeFunctions npruntime_functions = {
namespace WebCore {
-bool ScriptController::m_recordPlaybackMode = false;
-bool ScriptController::m_shouldExposeGCController = false;
-
void ScriptController::setFlags(const char* str, int length)
{
v8::V8::SetFlagsFromString(str, length);
diff --git a/webkit/port/bindings/v8/ScriptController.h b/webkit/port/bindings/v8/ScriptController.h
index be4c6b4..1d580fe 100644
--- a/webkit/port/bindings/v8/ScriptController.h
+++ b/webkit/port/bindings/v8/ScriptController.h
@@ -211,29 +211,6 @@ public:
static void gcProtectJSWrapper(void* object);
static void gcUnprotectJSWrapper(void* object);
- // Get/Set RecordPlaybackMode flag.
- // This is a special mode where JS helps the browser implement
- // playback/record mode. Generally, in this mode, some functions
- // of client-side randomness are removed. For example, in
- // this mode Math.random() and Date.getTime() may not return
- // values which vary.
- static bool RecordPlaybackMode() { return m_recordPlaybackMode; }
- static void setRecordPlaybackMode(bool value) { m_recordPlaybackMode = value; }
-
- // Set/Get ShouldExposeGCController flag.
- // Some WebKit layout test need window.GCController.collect() to
- // trigger GC, this flag lets the binding code expose
- // window.GCController.collect() to the JavaScript code.
- //
- // GCController.collect() needs V8 engine expose gc() function by passing
- // '--expose-gc' flag to the engine.
- static bool shouldExposeGCController() {
- return m_shouldExposeGCController;
- }
- static void setShouldExposeGCController(bool value) {
- m_shouldExposeGCController = value;
- }
-
void finishedWithEvent(Event*);
void setEventHandlerLineno(int lineno);
@@ -259,9 +236,6 @@ public:
#endif
private:
- static bool m_recordPlaybackMode;
- static bool m_shouldExposeGCController;
-
Frame* m_frame;
const String* m_sourceURL;
diff --git a/webkit/port/bindings/v8/extensions/GCController.cpp b/webkit/port/bindings/v8/extensions/GCController.cpp
deleted file mode 100644
index 1074b15..0000000
--- a/webkit/port/bindings/v8/extensions/GCController.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "GCController.h"
-
-namespace WebCore {
-
-const char* kGCExtensionName = "v8/GCController";
-
-v8::Extension* GCExtension::Get() {
- v8::Extension* extension = new v8::Extension(
- kGCExtensionName,
- "(function () {"
- " var v8_gc;"
- " if (gc) v8_gc = gc;"
- " GCController = new Object();"
- " GCController.collect ="
- " function() {if (v8_gc) v8_gc(); };"
- " })()");
- return extension;
-}
-
-}
-
diff --git a/webkit/port/bindings/v8/extensions/GCController.h b/webkit/port/bindings/v8/extensions/GCController.h
deleted file mode 100644
index 3466f66..0000000
--- a/webkit/port/bindings/v8/extensions/GCController.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// The GCExtension is a v8 extension to expose a method into JS for triggering
-// garbage collection. This should only be used for debugging.
-
-#ifndef GC_EXTENSION_H__
-#define GC_EXTENSION_H__
-
-#include "v8.h"
-
-namespace WebCore {
-
-class GCExtension {
- public:
- static v8::Extension* Get();
-};
-
-}
-
-#endif // GC_EXTENSION_H__
-
diff --git a/webkit/port/bindings/v8/extensions/Gears.cpp b/webkit/port/bindings/v8/extensions/Gears.cpp
deleted file mode 100755
index 9d36707..0000000
--- a/webkit/port/bindings/v8/extensions/Gears.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "Gears.h"
-
-namespace WebCore {
-
-const char* kGearsExtensionName = "v8/Gears";
-
-// Note: when a page touches the "google.gears.factory" object, this script
-// touches the DOM. We expect the DOM to be available at that time.
-const char* kGearsExtensionScript =
- "var google;"
- "if (!google)"
- " google = {};"
- "if (!google.gears)"
- " google.gears = {};"
- "(function() {"
- " var factory = null;"
- " google.gears.__defineGetter__('factory', function() {"
- " if (!factory) {"
- " factory = document.createElement('object');"
- " factory.width = 0;"
- " factory.height = 0;"
- " factory.style.visibility = 'hidden';"
- " factory.type = 'application/x-googlegears';"
- " document.documentElement.appendChild(factory);"
- " }"
- " return factory;"
- " });"
- "})();";
-
-class GearsExtensionWrapper : public v8::Extension {
-public:
- GearsExtensionWrapper() :
- v8::Extension(kGearsExtensionName, kGearsExtensionScript) {}
-};
-
-v8::Extension* GearsExtension::Get() {
- return new GearsExtensionWrapper();
-}
-
-}
diff --git a/webkit/port/bindings/v8/extensions/Gears.h b/webkit/port/bindings/v8/extensions/Gears.h
deleted file mode 100755
index 4e6c07d..0000000
--- a/webkit/port/bindings/v8/extensions/Gears.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// The GearsExtension is a v8 extension to add a "google.gears.factory" getter
-// on the page, which, when accessed, lazily inserts the gears plugin into
-// the page and attaches it to the factory variable.
-
-#ifndef GEARS_EXTENSION_H__
-#define GEARS_EXTENSION_H__
-
-#include "v8.h"
-
-namespace WebCore {
-
-class GearsExtension {
- public:
- static v8::Extension* Get();
-};
-
-}
-
-#endif // GEARS_EXTENSION_H__
-
diff --git a/webkit/port/bindings/v8/extensions/Interval.cpp b/webkit/port/bindings/v8/extensions/Interval.cpp
deleted file mode 100644
index b09847c..0000000
--- a/webkit/port/bindings/v8/extensions/Interval.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "Interval.h"
-#include "wtf/CurrentTime.h"
-
-namespace WebCore {
-
-const char* kIntervalExtensionName = "v8/Interval";
-
-class IntervalExtensionWrapper : public v8::Extension {
-public:
- IntervalExtensionWrapper() :
- v8::Extension(kIntervalExtensionName,
- "var chromium;"
- "if (!chromium)"
- " chromium = {};"
- "chromium.Interval = function() {"
- " var start_ = 0;"
- " var stop_ = 0;"
- " native function HiResTime();"
- " this.start = function() {"
- " stop_ = 0;"
- " start_ = HiResTime();"
- " };"
- " this.stop = function() {"
- " stop_ = HiResTime();"
- " if (start_ == 0)"
- " stop_ = 0;"
- " };"
- " this.microseconds = function() {"
- " var stop = stop_;"
- " if (stop == 0 && start_ != 0)"
- " stop = HiResTime();"
- " return Math.ceil((stop - start_) * 1000000);"
- " };"
- "}") {};
-
- virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(v8::Handle<v8::String> name) {
- if (name->Equals(v8::String::New("HiResTime")))
- return v8::FunctionTemplate::New(HiResTime);
- return v8::Handle<v8::FunctionTemplate>();
- }
-
- static v8::Handle<v8::Value> HiResTime(const v8::Arguments& args) {
- return v8::Number::New(WTF::currentTime());
- }
-};
-
-v8::Extension* IntervalExtension::Get() {
- return new IntervalExtensionWrapper();
-}
-
-}
-
diff --git a/webkit/port/bindings/v8/extensions/Interval.h b/webkit/port/bindings/v8/extensions/Interval.h
deleted file mode 100644
index c009302..0000000
--- a/webkit/port/bindings/v8/extensions/Interval.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// The IntervalExtension is a v8 extension to implement a simple interval
-// class for measuring microsecond intervals.
-
-#ifndef INTERVAL_EXTENSION_H__
-#define INTERVAL_EXTENSION_H__
-
-#include "v8.h"
-
-namespace WebCore {
-
-class IntervalExtension {
- public:
- static v8::Extension* Get();
-};
-
-}
-
-#endif // INTERVAL_EXTENSION_H__
-
diff --git a/webkit/port/bindings/v8/extensions/Playback.cpp b/webkit/port/bindings/v8/extensions/Playback.cpp
deleted file mode 100644
index 4a50230..0000000
--- a/webkit/port/bindings/v8/extensions/Playback.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "Playback.h"
-
-namespace WebCore {
-
-const char* kPlaybackExtensionName = "v8/PlaybackMode";
-
-v8::Extension* PlaybackExtension::Get() {
- v8::Extension* extension = new v8::Extension(
- kPlaybackExtensionName,
- "(function () {"
- " var orig_date = Date;"
- " Math.random = function() {"
- " return 0.5;"
- " };"
- " Date.__proto__.now = function() {"
- " return new orig_date(1204251968254);"
- " };"
- " Date = function() {"
- " return Date.now();"
- " };"
- "})()");
- return extension;
-}
-
-}
-
diff --git a/webkit/port/bindings/v8/extensions/Playback.h b/webkit/port/bindings/v8/extensions/Playback.h
deleted file mode 100644
index a60079c..0000000
--- a/webkit/port/bindings/v8/extensions/Playback.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// The IntervalExtension is a v8 extension to implement a simple interval
-// class for measuring microsecond intervals.
-
-#ifndef PLAYBACK_EXTENSION_H__
-#define PLAYBACK_EXTENSION_H__
-
-#include "v8.h"
-
-namespace WebCore {
-
-// Inject code which overrides a few common JS functions for implementing
-// randomness. In order to implement effective record & playback of
-// websites, it is important that the URLs not change. Many popular web
-// based apps use randomness in URLs to unique-ify urls for proxies.
-// Unfortunately, this breaks playback.
-// To work around this, we take the two most common client-side randomness
-// generators and make them constant. They really need to be constant
-// (rather than a constant seed followed by constant change)
-// because the playback mode wants flexibility in how it plays them back
-// and cannot always guarantee that requests for randomness are played back
-// in exactly the same order in which they were recorded.
-class PlaybackExtension {
- public:
- static v8::Extension* Get();
-};
-
-}
-
-#endif // PLAYBACK_EXTENSION_H__
-
diff --git a/webkit/port/bindings/v8/v8_proxy.cpp b/webkit/port/bindings/v8/v8_proxy.cpp
index c303a08..aa2ecc6 100644
--- a/webkit/port/bindings/v8/v8_proxy.cpp
+++ b/webkit/port/bindings/v8/v8_proxy.cpp
@@ -205,11 +205,6 @@
#include "XPathEvaluator.h"
#endif
-#include "extensions/GCController.h"
-#include "extensions/Gears.h"
-#include "extensions/Interval.h"
-#include "extensions/Playback.h"
-
namespace WebCore {
@@ -2331,14 +2326,6 @@ void V8Proxy::InitContextIfNeeded()
v8::V8::SetFailedAccessCheckCallbackFunction(ReportUnsafeJavaScriptAccess);
- // Register known extensions
- RegisterExtension(GearsExtension::Get());
- RegisterExtension(IntervalExtension::Get());
- if (ScriptController::shouldExposeGCController())
- RegisterExtension(GCExtension::Get());
- if (ScriptController::RecordPlaybackMode())
- RegisterExtension(PlaybackExtension::Get());
-
v8_initialized = true;
}