diff options
author | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-28 00:58:32 +0000 |
---|---|---|
committer | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-28 00:58:32 +0000 |
commit | 3131a289c0edff9d58da46cae16beae6bd6c0650 (patch) | |
tree | 1604f160750d771ed32a21097d1f0c7e3e00f620 /webkit/port | |
parent | 87fde4a19ca045af34cc2582b405449541b2b0ca (diff) | |
download | chromium_src-3131a289c0edff9d58da46cae16beae6bd6c0650.zip chromium_src-3131a289c0edff9d58da46cae16beae6bd6c0650.tar.gz chromium_src-3131a289c0edff9d58da46cae16beae6bd6c0650.tar.bz2 |
Workaround for webkit change that broke Gears. The fix is to use a V8
extension to inject a getter into every page which loads the gears plugin when
accessed.
BUG=http://code.google.com/p/chromium/issues/detail?id=8209
Review URL: http://codereview.chromium.org/27294
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10663 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rwxr-xr-x | webkit/port/bindings/v8/extensions/Gears.cpp | 45 | ||||
-rwxr-xr-x | webkit/port/bindings/v8/extensions/Gears.h | 24 | ||||
-rw-r--r-- | webkit/port/bindings/v8/v8_proxy.cpp | 2 |
3 files changed, 71 insertions, 0 deletions
diff --git a/webkit/port/bindings/v8/extensions/Gears.cpp b/webkit/port/bindings/v8/extensions/Gears.cpp new file mode 100755 index 0000000..54787a8 --- /dev/null +++ b/webkit/port/bindings/v8/extensions/Gears.cpp @@ -0,0 +1,45 @@ +// 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 new file mode 100755 index 0000000..4e6c07d --- /dev/null +++ b/webkit/port/bindings/v8/extensions/Gears.h @@ -0,0 +1,24 @@ +// 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/v8_proxy.cpp b/webkit/port/bindings/v8/v8_proxy.cpp index 56f62e6..20c6ccf 100644 --- a/webkit/port/bindings/v8/v8_proxy.cpp +++ b/webkit/port/bindings/v8/v8_proxy.cpp @@ -206,6 +206,7 @@ #endif #include "extensions/GCController.h" +#include "extensions/Gears.h" #include "extensions/Interval.h" #include "extensions/Playback.h" @@ -2323,6 +2324,7 @@ void V8Proxy::InitContextIfNeeded() v8::V8::SetFailedAccessCheckCallbackFunction(ReportUnsafeJavaScriptAccess); // Register known extensions + RegisterExtension(GearsExtension::Get()); RegisterExtension(IntervalExtension::Get()); if (ScriptController::shouldExposeGCController()) RegisterExtension(GCExtension::Get()); |