OLD | NEW |
| (Empty) |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "webkit/extensions/v8/gears_extension.h" | |
6 | |
7 namespace extensions_v8 { | |
8 | |
9 const char* const kGearsExtensionName = "v8/Gears"; | |
10 | |
11 // Note: when a page touches the "google.gears.factory" object, this script | |
12 // touches the DOM. We expect the DOM to be available at that time. | |
13 const char* const kGearsExtensionScript = | |
14 "var google;" | |
15 "if (!google)" | |
16 " google = {};" | |
17 "if (!google.gears)" | |
18 " google.gears = {};" | |
19 "(function() {" | |
20 " var factory = null;" | |
21 " google.gears.__defineGetter__('factory', function() {" | |
22 " if (!factory) {" | |
23 " factory = document.createElement('object');" | |
24 " factory.width = 0;" | |
25 " factory.height = 0;" | |
26 " factory.style.visibility = 'hidden';" | |
27 " factory.type = 'application/x-googlegears';" | |
28 " document.documentElement.appendChild(factory);" | |
29 " }" | |
30 " return factory;" | |
31 " });" | |
32 "})();"; | |
33 | |
34 class GearsExtensionWrapper : public v8::Extension { | |
35 public: | |
36 GearsExtensionWrapper() | |
37 : v8::Extension(kGearsExtensionName, kGearsExtensionScript) {} | |
38 }; | |
39 | |
40 v8::Extension* GearsExtension::Get() { | |
41 return new GearsExtensionWrapper(); | |
42 } | |
43 | |
44 } // namespace extensions_v8 | |
OLD | NEW |