summaryrefslogtreecommitdiff
path: root/npapi-plugin
diff options
context:
space:
mode:
Diffstat (limited to 'npapi-plugin')
-rw-r--r--npapi-plugin/_locales/en/messages.json6
-rw-r--r--npapi-plugin/background.html9
-rw-r--r--npapi-plugin/content_script.js6
-rw-r--r--npapi-plugin/manifest.json13
-rw-r--r--npapi-plugin/plugin/Makefile19
-rw-r--r--npapi-plugin/plugin/base/basictypes.h397
-rw-r--r--npapi-plugin/plugin/base/port.h61
-rw-r--r--npapi-plugin/plugin/build/build_config.h69
-rw-r--r--npapi-plugin/plugin/np-zeitgeist.c328
-rw-r--r--npapi-plugin/plugin/third_party/npapi/bindings/npapi.h799
-rw-r--r--npapi-plugin/plugin/third_party/npapi/bindings/npruntime.h401
-rw-r--r--npapi-plugin/plugin/third_party/webkit/glue/plugins/nphostapi.h282
-rw-r--r--npapi-plugin/zeitgeist.js41
13 files changed, 2431 insertions, 0 deletions
diff --git a/npapi-plugin/_locales/en/messages.json b/npapi-plugin/_locales/en/messages.json
new file mode 100644
index 0000000..e6296d0
--- /dev/null
+++ b/npapi-plugin/_locales/en/messages.json
@@ -0,0 +1,6 @@
+{
+ "tooltip": {
+ "message": "Zeitgeist plugin",
+ "description": "Tooltip Text"
+ }
+}
diff --git a/npapi-plugin/background.html b/npapi-plugin/background.html
new file mode 100644
index 0000000..031d4db
--- /dev/null
+++ b/npapi-plugin/background.html
@@ -0,0 +1,9 @@
+<html>
+ <head>
+ <title>Zeitgeist NPAPI plugin</title>
+ </head>
+ <body>
+ <p><embed type="application/x-zeitgeist-plugin" id="zg-plugin" /></p>
+ <script type="text/javascript" src="zeitgeist.js"></script>
+ </body>
+</html>
diff --git a/npapi-plugin/content_script.js b/npapi-plugin/content_script.js
new file mode 100644
index 0000000..94715a5
--- /dev/null
+++ b/npapi-plugin/content_script.js
@@ -0,0 +1,6 @@
+var dict = {
+ "url": document.URL,
+ "mimeType": document.contentType,
+ "title": document.title
+};
+chrome.extension.sendRequest({name: "zgPlugin"}, dict);
diff --git a/npapi-plugin/manifest.json b/npapi-plugin/manifest.json
new file mode 100644
index 0000000..001f1bd
--- /dev/null
+++ b/npapi-plugin/manifest.json
@@ -0,0 +1,13 @@
+{
+ "name": "Zeitgeist Plugin",
+ "description": "Sends events to Zeitgeist about sites you visit",
+ "version": "1",
+ "background_page": "background.html",
+ "permissions": [
+ "tabs", "http://*/*"
+ ],
+ "plugins": [
+ { "path": "plugin/libzeitgeist-npapi-plugin.so" }
+ ],
+ "default_locale": "en"
+}
diff --git a/npapi-plugin/plugin/Makefile b/npapi-plugin/plugin/Makefile
new file mode 100644
index 0000000..d5b46a4
--- /dev/null
+++ b/npapi-plugin/plugin/Makefile
@@ -0,0 +1,19 @@
+# compiler and linker
+CC = g++
+
+# Customize below to fit your system
+
+INCS = `pkg-config --libs --cflags zeitgeist-1.0` -I./third_party -I./third_party/npapi -I./
+#INCS = `pkg-config --libs --cflags libxul nspr zeitgeist-1.0`
+CPPFLAGS = -DXULRUNNER_SDK
+CFLAGS = -g -pedantic -fPIC -Wall -std=c++0x -O2 ${INCS}
+
+OUTPUT = libzeitgeist-npapi-plugin.so
+
+all: $(OUTPUT)
+
+$(OUTPUT): np-zeitgeist.c
+ $(CC) -Wl,--no-undefined -shared -o $@ $(CFLAGS) $<
+
+clean:
+ rm -f $(OUTPUT)
diff --git a/npapi-plugin/plugin/base/basictypes.h b/npapi-plugin/plugin/base/basictypes.h
new file mode 100644
index 0000000..cd3ff09
--- /dev/null
+++ b/npapi-plugin/plugin/base/basictypes.h
@@ -0,0 +1,397 @@
+// 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.
+
+#ifndef BASE_BASICTYPES_H_
+#define BASE_BASICTYPES_H_
+
+#include <assert.h> // for use with down_cast<>
+#include <limits.h> // So we can set the bounds of our types
+#include <stddef.h> // For size_t
+#include <string.h> // for memcpy
+
+#include "base/port.h" // Types that only need exist on certain systems
+
+#ifndef COMPILER_MSVC
+// stdint.h is part of C99 but MSVC doesn't have it.
+#include <stdint.h> // For intptr_t.
+#endif
+
+typedef signed char schar;
+typedef signed char int8;
+typedef short int16;
+// TODO(mbelshe) Remove these type guards. These are
+// temporary to avoid conflicts with npapi.h.
+#ifndef _INT32
+#define _INT32
+typedef int int32;
+#endif
+typedef long long int64;
+
+// NOTE: unsigned types are DANGEROUS in loops and other arithmetical
+// places. Use the signed types unless your variable represents a bit
+// pattern (eg a hash value) or you really need the extra bit. Do NOT
+// use 'unsigned' to express "this value should always be positive";
+// use assertions for this.
+
+typedef unsigned char uint8;
+typedef unsigned short uint16;
+// TODO(mbelshe) Remove these type guards. These are
+// temporary to avoid conflicts with npapi.h.
+#ifndef _UINT32
+#define _UINT32
+typedef unsigned int uint32;
+#endif
+typedef unsigned long long uint64;
+
+// A type to represent a Unicode code-point value. As of Unicode 4.0,
+// such values require up to 21 bits.
+// (For type-checking on pointers, make this explicitly signed,
+// and it should always be the signed version of whatever int32 is.)
+typedef signed int char32;
+
+const uint8 kuint8max = (( uint8) 0xFF);
+const uint16 kuint16max = ((uint16) 0xFFFF);
+const uint32 kuint32max = ((uint32) 0xFFFFFFFF);
+const uint64 kuint64max = ((uint64) GG_LONGLONG(0xFFFFFFFFFFFFFFFF));
+const int8 kint8min = (( int8) 0x80);
+const int8 kint8max = (( int8) 0x7F);
+const int16 kint16min = (( int16) 0x8000);
+const int16 kint16max = (( int16) 0x7FFF);
+const int32 kint32min = (( int32) 0x80000000);
+const int32 kint32max = (( int32) 0x7FFFFFFF);
+const int64 kint64min = (( int64) GG_LONGLONG(0x8000000000000000));
+const int64 kint64max = (( int64) GG_LONGLONG(0x7FFFFFFFFFFFFFFF));
+
+// id for odp categories
+typedef uint32 CatId;
+const CatId kIllegalCatId = static_cast<CatId>(0);
+
+typedef uint32 TermId;
+const TermId kIllegalTermId = static_cast<TermId>(0);
+
+typedef uint32 HostId;
+const HostId kIllegalHostId = static_cast<HostId>(0);
+
+typedef uint32 DomainId;
+const DomainId kIllegalDomainId = static_cast<DomainId>(0);
+
+// A macro to disallow the copy constructor and operator= functions
+// This should be used in the private: declarations for a class
+#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
+ TypeName(const TypeName&); \
+ void operator=(const TypeName&)
+
+// An older, deprecated, politically incorrect name for the above.
+#define DISALLOW_EVIL_CONSTRUCTORS(TypeName) DISALLOW_COPY_AND_ASSIGN(TypeName)
+
+// A macro to disallow all the implicit constructors, namely the
+// default constructor, copy constructor and operator= functions.
+//
+// This should be used in the private: declarations for a class
+// that wants to prevent anyone from instantiating it. This is
+// especially useful for classes containing only static methods.
+#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
+ TypeName(); \
+ DISALLOW_COPY_AND_ASSIGN(TypeName)
+
+// The arraysize(arr) macro returns the # of elements in an array arr.
+// The expression is a compile-time constant, and therefore can be
+// used in defining new arrays, for example. If you use arraysize on
+// a pointer by mistake, you will get a compile-time error.
+//
+// One caveat is that arraysize() doesn't accept any array of an
+// anonymous type or a type defined inside a function. In these rare
+// cases, you have to use the unsafe ARRAYSIZE_UNSAFE() macro below. This is
+// due to a limitation in C++'s template system. The limitation might
+// eventually be removed, but it hasn't happened yet.
+
+// This template function declaration is used in defining arraysize.
+// Note that the function doesn't need an implementation, as we only
+// use its type.
+template <typename T, size_t N>
+char (&ArraySizeHelper(T (&array)[N]))[N];
+
+// That gcc wants both of these prototypes seems mysterious. VC, for
+// its part, can't decide which to use (another mystery). Matching of
+// template overloads: the final frontier.
+#ifndef _MSC_VER
+template <typename T, size_t N>
+char (&ArraySizeHelper(const T (&array)[N]))[N];
+#endif
+
+#define arraysize(array) (sizeof(ArraySizeHelper(array)))
+
+// ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize,
+// but can be used on anonymous types or types defined inside
+// functions. It's less safe than arraysize as it accepts some
+// (although not all) pointers. Therefore, you should use arraysize
+// whenever possible.
+//
+// The expression ARRAYSIZE_UNSAFE(a) is a compile-time constant of type
+// size_t.
+//
+// ARRAYSIZE_UNSAFE catches a few type errors. If you see a compiler error
+//
+// "warning: division by zero in ..."
+//
+// when using ARRAYSIZE_UNSAFE, you are (wrongfully) giving it a pointer.
+// You should only use ARRAYSIZE_UNSAFE on statically allocated arrays.
+//
+// The following comments are on the implementation details, and can
+// be ignored by the users.
+//
+// ARRAYSIZE_UNSAFE(arr) works by inspecting sizeof(arr) (the # of bytes in
+// the array) and sizeof(*(arr)) (the # of bytes in one array
+// element). If the former is divisible by the latter, perhaps arr is
+// indeed an array, in which case the division result is the # of
+// elements in the array. Otherwise, arr cannot possibly be an array,
+// and we generate a compiler error to prevent the code from
+// compiling.
+//
+// Since the size of bool is implementation-defined, we need to cast
+// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final
+// result has type size_t.
+//
+// This macro is not perfect as it wrongfully accepts certain
+// pointers, namely where the pointer size is divisible by the pointee
+// size. Since all our code has to go through a 32-bit compiler,
+// where a pointer is 4 bytes, this means all pointers to a type whose
+// size is 3 or greater than 4 will be (righteously) rejected.
+
+#define ARRAYSIZE_UNSAFE(a) \
+ ((sizeof(a) / sizeof(*(a))) / \
+ static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
+
+
+// Use implicit_cast as a safe version of static_cast or const_cast
+// for upcasting in the type hierarchy (i.e. casting a pointer to Foo
+// to a pointer to SuperclassOfFoo or casting a pointer to Foo to
+// a const pointer to Foo).
+// When you use implicit_cast, the compiler checks that the cast is safe.
+// Such explicit implicit_casts are necessary in surprisingly many
+// situations where C++ demands an exact type match instead of an
+// argument type convertable to a target type.
+//
+// The From type can be inferred, so the preferred syntax for using
+// implicit_cast is the same as for static_cast etc.:
+//
+// implicit_cast<ToType>(expr)
+//
+// implicit_cast would have been part of the C++ standard library,
+// but the proposal was submitted too late. It will probably make
+// its way into the language in the future.
+template<typename To, typename From>
+inline To implicit_cast(From const &f) {
+ return f;
+}
+
+
+// When you upcast (that is, cast a pointer from type Foo to type
+// SuperclassOfFoo), it's fine to use implicit_cast<>, since upcasts
+// always succeed. When you downcast (that is, cast a pointer from
+// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because
+// how do you know the pointer is really of type SubclassOfFoo? It
+// could be a bare Foo, or of type DifferentSubclassOfFoo. Thus,
+// when you downcast, you should use this macro. In debug mode, we
+// use dynamic_cast<> to double-check the downcast is legal (we die
+// if it's not). In normal mode, we do the efficient static_cast<>
+// instead. Thus, it's important to test in debug mode to make sure
+// the cast is legal!
+// This is the only place in the code we should use dynamic_cast<>.
+// In particular, you SHOULDN'T be using dynamic_cast<> in order to
+// do RTTI (eg code like this:
+// if (dynamic_cast<Subclass1>(foo)) HandleASubclass1Object(foo);
+// if (dynamic_cast<Subclass2>(foo)) HandleASubclass2Object(foo);
+// You should design the code some other way not to need this.
+
+template<typename To, typename From> // use like this: down_cast<T*>(foo);
+inline To down_cast(From* f) { // so we only accept pointers
+ // Ensures that To is a sub-type of From *. This test is here only
+ // for compile-time type checking, and has no overhead in an
+ // optimized build at run-time, as it will be optimized away
+ // completely.
+ if (false) {
+ implicit_cast<From*, To>(0);
+ }
+
+ assert(f == NULL || dynamic_cast<To>(f) != NULL); // RTTI: debug mode only!
+ return static_cast<To>(f);
+}
+
+// The COMPILE_ASSERT macro can be used to verify that a compile time
+// expression is true. For example, you could use it to verify the
+// size of a static array:
+//
+// COMPILE_ASSERT(ARRAYSIZE_UNSAFE(content_type_names) == CONTENT_NUM_TYPES,
+// content_type_names_incorrect_size);
+//
+// or to make sure a struct is smaller than a certain size:
+//
+// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large);
+//
+// The second argument to the macro is the name of the variable. If
+// the expression is false, most compilers will issue a warning/error
+// containing the name of the variable.
+
+template <bool>
+struct CompileAssert {
+};
+
+#undef COMPILE_ASSERT
+#define COMPILE_ASSERT(expr, msg) \
+ typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
+
+// Implementation details of COMPILE_ASSERT:
+//
+// - COMPILE_ASSERT works by defining an array type that has -1
+// elements (and thus is invalid) when the expression is false.
+//
+// - The simpler definition
+//
+// #define COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1]
+//
+// does not work, as gcc supports variable-length arrays whose sizes
+// are determined at run-time (this is gcc's extension and not part
+// of the C++ standard). As a result, gcc fails to reject the
+// following code with the simple definition:
+//
+// int foo;
+// COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is
+// // not a compile-time constant.
+//
+// - By using the type CompileAssert<(bool(expr))>, we ensures that
+// expr is a compile-time constant. (Template arguments must be
+// determined at compile-time.)
+//
+// - The outter parentheses in CompileAssert<(bool(expr))> are necessary
+// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written
+//
+// CompileAssert<bool(expr)>
+//
+// instead, these compilers will refuse to compile
+//
+// COMPILE_ASSERT(5 > 0, some_message);
+//
+// (They seem to think the ">" in "5 > 0" marks the end of the
+// template argument list.)
+//
+// - The array size is (bool(expr) ? 1 : -1), instead of simply
+//
+// ((expr) ? 1 : -1).
+//
+// This is to avoid running into a bug in MS VC 7.1, which
+// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.
+
+
+// MetatagId refers to metatag-id that we assign to
+// each metatag <name, value> pair..
+typedef uint32 MetatagId;
+
+// Argument type used in interfaces that can optionally take ownership
+// of a passed in argument. If TAKE_OWNERSHIP is passed, the called
+// object takes ownership of the argument. Otherwise it does not.
+enum Ownership {
+ DO_NOT_TAKE_OWNERSHIP,
+ TAKE_OWNERSHIP
+};
+
+// Use these as the mlock_bytes parameter to MLock and MLockGeneral
+enum { MLOCK_ALL = -1, MLOCK_NONE = 0 };
+
+// Helper routine to avoid buggy code like the following:
+// if (pos + N < end) ...
+// If pos is large enough, "pos + N" may overflow. For example,
+// pos==0xfffff000 and N==1MB.
+//
+// PointerRangeSize(a,b) returns the size of the range [a,b-1]
+inline size_t PointerRangeSize(const char* start, const char* end) {
+ assert(start <= end);
+ return end - start;
+}
+
+// bit_cast<Dest,Source> is a template function that implements the
+// equivalent of "*reinterpret_cast<Dest*>(&source)". We need this in
+// very low-level functions like the protobuf library and fast math
+// support.
+//
+// float f = 3.14159265358979;
+// int i = bit_cast<int32>(f);
+// // i = 0x40490fdb
+//
+// The classical address-casting method is:
+//
+// // WRONG
+// float f = 3.14159265358979; // WRONG
+// int i = * reinterpret_cast<int*>(&f); // WRONG
+//
+// The address-casting method actually produces undefined behavior
+// according to ISO C++ specification section 3.10 -15 -. Roughly, this
+// section says: if an object in memory has one type, and a program
+// accesses it with a different type, then the result is undefined
+// behavior for most values of "different type".
+//
+// This is true for any cast syntax, either *(int*)&f or
+// *reinterpret_cast<int*>(&f). And it is particularly true for
+// conversions betweeen integral lvalues and floating-point lvalues.
+//
+// The purpose of 3.10 -15- is to allow optimizing compilers to assume
+// that expressions with different types refer to different memory. gcc
+// 4.0.1 has an optimizer that takes advantage of this. So a
+// non-conforming program quietly produces wildly incorrect output.
+//
+// The problem is not the use of reinterpret_cast. The problem is type
+// punning: holding an object in memory of one type and reading its bits
+// back using a different type.
+//
+// The C++ standard is more subtle and complex than this, but that
+// is the basic idea.
+//
+// Anyways ...
+//
+// bit_cast<> calls memcpy() which is blessed by the standard,
+// especially by the example in section 3.9 . Also, of course,
+// bit_cast<> wraps up the nasty WEBDRIVER_LOGic in one place.
+//
+// Fortunately memcpy() is very fast. In optimized mode, with a
+// constant size, gcc 2.95.3, gcc 4.0.1, and msvc 7.1 produce inline
+// code with the minimal amount of data movement. On a 32-bit system,
+// memcpy(d,s,4) compiles to one load and one store, and memcpy(d,s,8)
+// compiles to two loads and two stores.
+//
+// I tested this code with gcc 2.95.3, gcc 4.0.1, icc 8.1, and msvc 7.1.
+//
+// WARNING: if Dest or Source is a non-POD type, the result of the memcpy
+// is likely to surprise you.
+
+template <class Dest, class Source>
+inline Dest bit_cast(const Source& source) {
+ // Compile time assertion: sizeof(Dest) == sizeof(Source)
+ // A compile error here means your Dest and Source have different sizes.
+ typedef char VerifySizesAreEqual [sizeof(Dest) == sizeof(Source) ? 1 : -1];
+
+ Dest dest;
+ memcpy(&dest, &source, sizeof(dest));
+ return dest;
+}
+
+// The following enum should be used only as a constructor argument to indicate
+// that the variable has static storage class, and that the constructor should
+// do nothing to its state. It indicates to the reader that it is legal to
+// declare a static instance of the class, provided the constructor is given
+// the base::LINKER_INITIALIZED argument. Normally, it is unsafe to declare a
+// static variable that has a constructor or a destructor because invocation
+// order is undefined. However, IF the type can be initialized by filling with
+// zeroes (which the loader does for static variables), AND the destructor also
+// does nothing to the storage, AND there are no virtual methods, then a
+// constructor declared as
+// explicit MyClass(base::LinkerInitialized x) {}
+// and invoked as
+// static MyClass my_variable_name(base::LINKER_INITIALIZED);
+namespace base {
+enum LinkerInitialized { LINKER_INITIALIZED };
+} // base
+
+
+#endif // BASE_BASICTYPES_H_
+
diff --git a/npapi-plugin/plugin/base/port.h b/npapi-plugin/plugin/base/port.h
new file mode 100644
index 0000000..0e873bb
--- /dev/null
+++ b/npapi-plugin/plugin/base/port.h
@@ -0,0 +1,61 @@
+// 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.
+
+#ifndef BASE_PORT_H_
+#define BASE_PORT_H_
+
+#include <stdarg.h>
+#include "build/build_config.h"
+
+#ifdef COMPILER_MSVC
+#define GG_LONGLONG(x) x##I64
+#define GG_ULONGLONG(x) x##UI64
+#else
+#define GG_LONGLONG(x) x##LL
+#define GG_ULONGLONG(x) x##ULL
+#endif
+
+// Per C99 7.8.14, define __STDC_CONSTANT_MACROS before including <stdint.h>
+// to get the INTn_C and UINTn_C macros for integer constants. It's difficult
+// to guarantee any specific ordering of header includes, so it's difficult to
+// guarantee that the INTn_C macros can be defined by including <stdint.h> at
+// any specific point. Provide GG_INTn_C macros instead.
+
+#define GG_INT8_C(x) (x)
+#define GG_INT16_C(x) (x)
+#define GG_INT32_C(x) (x)
+#define GG_INT64_C(x) GG_LONGLONG(x)
+
+#define GG_UINT8_C(x) (x ## U)
+#define GG_UINT16_C(x) (x ## U)
+#define GG_UINT32_C(x) (x ## U)
+#define GG_UINT64_C(x) GG_ULONGLONG(x)
+
+namespace base {
+
+// It's possible for functions that use a va_list, such as StringPrintf, to
+// invalidate the data in it upon use. The fix is to make a copy of the
+// structure before using it and use that copy instead. va_copy is provided
+// for this purpose. MSVC does not provide va_copy, so define an
+// implementation here. It is not guaranteed that assignment is a copy, so the
+// StringUtil.VariableArgsFunc unit test tests this capability.
+inline void va_copy(va_list& a, va_list& b) {
+#if defined(COMPILER_GCC)
+ ::va_copy(a, b);
+#elif defined(COMPILER_MSVC)
+ a = b;
+#endif
+}
+
+} // namespace base
+
+// Define an OS-neutral wrapper for shared library entry points
+#if defined(OS_WIN)
+#define API_CALL __stdcall
+#elif defined(OS_LINUX) || defined(OS_MACOSX)
+#define API_CALL
+#endif
+
+#endif // BASE_PORT_H_
+
diff --git a/npapi-plugin/plugin/build/build_config.h b/npapi-plugin/plugin/build/build_config.h
new file mode 100644
index 0000000..2b9efda
--- /dev/null
+++ b/npapi-plugin/plugin/build/build_config.h
@@ -0,0 +1,69 @@
+// 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.
+
+// This file adds defines about the platform we're currently building on.
+// Operating System:
+// OS_WIN / OS_MACOSX / OS_LINUX / OS_POSIX (MACOSX or LINUX)
+// Compiler:
+// COMPILER_MSVC / COMPILER_GCC
+// Processor:
+// ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64)
+// ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
+
+#ifndef BUILD_BUILD_CONFIG_H_
+#define BUILD_BUILD_CONFIG_H_
+
+// A set of macros to use for platform detection.
+#if defined(__APPLE__)
+#define OS_MACOSX 1
+#elif defined(__linux__)
+#define OS_LINUX 1
+#elif defined(_WIN32)
+#define OS_WIN 1
+#else
+#error Please add support for your platform in build/build_config.h
+#endif
+
+// For access to standard POSIX features, use OS_POSIX instead of a more
+// specific macro.
+#if defined(OS_MACOSX) || defined(OS_LINUX)
+#define OS_POSIX 1
+#endif
+
+// Compiler detection.
+#if defined(__GNUC__)
+#define COMPILER_GCC 1
+#elif defined(_MSC_VER)
+#define COMPILER_MSVC 1
+#else
+#error Please add support for your compiler in build/build_config.h
+#endif
+
+// Processor architecture detection. For more info on what's defined, see:
+// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
+// http://www.agner.org/optimize/calling_conventions.pdf
+#if defined(_M_X64) || defined(__x86_64__)
+#define ARCH_CPU_X86_FAMILY 1
+#define ARCH_CPU_X86_64 1
+#define ARCH_CPU_64_BITS 1
+#elif defined(_M_IX86) || defined(__i386__)
+#define ARCH_CPU_X86_FAMILY 1
+#define ARCH_CPU_X86 1
+#define ARCH_CPU_32_BITS 1
+#else
+#error Please add support for your architecture in build/build_config.h
+#endif
+
+// Type detection for wchar_t.
+#if defined(OS_WIN)
+#define WCHAR_T_IS_UTF16
+#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
+ defined(__WCHAR_MAX__) && __WCHAR_MAX__ == 0x7fffffff
+#define WCHAR_T_IS_UTF32
+#else
+#error Please add support for your compiler in build/build_config.h
+#endif
+
+#endif // BUILD_BUILD_CONFIG_H_
+
diff --git a/npapi-plugin/plugin/np-zeitgeist.c b/npapi-plugin/plugin/np-zeitgeist.c
new file mode 100644
index 0000000..39e189e
--- /dev/null
+++ b/npapi-plugin/plugin/np-zeitgeist.c
@@ -0,0 +1,328 @@
+/*
+ * np-zeitgeist.c
+ * This file is part of Zeitgeist dataprovider for Chrome.
+ *
+ * Copyright (C) 2010 - Michal Hruby <michal.mhr@gmail.com>
+ *
+ * Zeitgeist dataprovider for Chrome is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU Lesser
+ * General Public License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Zeitgeist dataprovider for Chrome is distributed in the hope that
+ * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "webkit/glue/plugins/nphostapi.h"
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#include <zeitgeist.h>
+
+/*
+#include <nspr.h>
+#include <npapi.h>
+#include <npruntime.h>
+#include <npfunctions.h>
+*/
+
+static NPObject *so = NULL;
+static NPNetscapeFuncs *npnfuncs = NULL;
+static NPP inst = NULL;
+static ZeitgeistLog *zg_log = NULL;
+static char *actor = NULL;
+
+static bool
+hasMethod(NPObject* obj, NPIdentifier methodName) {
+ char *name;
+ g_debug("np-zeitgeist: %s", __func__);
+
+ name = npnfuncs->utf8fromidentifier(methodName);
+ if (!strcmp(name, "insertEvent")) return true;
+ else if (!strcmp(name, "setActor")) return true;
+
+ return false;
+}
+
+static bool
+invokeInsertEvent (NPObject *obj, const NPVariant *args, uint32_t argCount, NPVariant *result)
+{
+ /* args should be: url, mimetype, title */
+ const NPString *url, *mimetype, *title;
+ ZeitgeistEvent *event;
+
+ if(argCount != 3)
+ {
+ npnfuncs->setexception(obj, "exception during invocation");
+ return false;
+ }
+
+ for (int i=0; i<3; i++)
+ {
+ if (!NPVARIANT_IS_STRING (args[i]))
+ {
+ npnfuncs->setexception(obj, "string argument expected");
+ g_debug ("argument #%d is not string", i);
+ return false;
+ }
+ }
+
+
+ url = &NPVARIANT_TO_STRING (args[0]);
+ mimetype = &NPVARIANT_TO_STRING (args[1]);
+ title = &NPVARIANT_TO_STRING (args[2]);
+
+ g_debug ("URL: %s, mimeType: %s, title: %s",
+ url->UTF8Characters,
+ mimetype->UTF8Characters,
+ title->UTF8Characters);
+
+ event = zeitgeist_event_new_full (
+ ZEITGEIST_ZG_ACCESS_EVENT,
+ ZEITGEIST_ZG_USER_ACTIVITY,
+ actor ? actor : "application://google-chrome.desktop",
+ zeitgeist_subject_new_full (
+ url->UTF8Characters,
+ ZEITGEIST_NFO_WEBSITE,
+ ZEITGEIST_NFO_REMOTE_DATA_OBJECT,
+ mimetype->UTF8Characters,
+ url->UTF8Characters,
+ title->UTF8Characters,
+ "net"),
+ NULL);
+
+ zeitgeist_log_insert_events_no_reply (zg_log, event, NULL);
+
+ VOID_TO_NPVARIANT (*result);
+
+ return true;
+}
+
+static bool
+invokeSetActor (NPObject *obj, const NPVariant *args, uint32_t argCount, NPVariant *result)
+{
+ const NPString *actorName;
+
+ if(argCount != 1 || !NPVARIANT_IS_STRING (args[0]))
+ {
+ npnfuncs->setexception(obj, "exception during invocation");
+ return false;
+ }
+
+ actorName = &NPVARIANT_TO_STRING (args[0]);
+
+ g_debug ("setting actor to: \"%s\"",
+ actorName->UTF8Characters);
+ actor = g_strdup(actorName->UTF8Characters);
+
+ VOID_TO_NPVARIANT (*result);
+
+ return true;
+}
+
+static bool
+invoke(NPObject* obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result) {
+ char *name;
+
+ g_debug("np-zeitgeist: %s", __func__);
+
+ name = npnfuncs->utf8fromidentifier(methodName);
+
+ if(name)
+ {
+ if (!strcmp (name, "insertEvent"))
+ {
+ g_debug("np-zeitgeist: invoke insertEvent");
+ return invokeInsertEvent(obj, args, argCount, result);
+ }
+ else if (!strcmp (name, "setActor"))
+ {
+ return invokeSetActor(obj, args, argCount, result);
+ }
+ }
+
+ npnfuncs->setexception(obj, "exception during invocation");
+ return false;
+}
+
+static bool
+hasProperty(NPObject *obj, NPIdentifier propertyName) {
+ g_debug("np-zeitgeist: %s", __func__);
+ return false;
+}
+
+static bool
+getProperty(NPObject *obj, NPIdentifier propertyName, NPVariant *result) {
+ g_debug("np-zeitgeist: %s", __func__);
+ return false;
+}
+
+static NPClass npcRefObject = {
+ NP_CLASS_STRUCT_VERSION,
+ NULL,
+ NULL,
+ NULL,
+ hasMethod,
+ invoke,
+ invokeInsertEvent,
+ hasProperty,
+ getProperty,
+ NULL,
+ NULL,
+};
+
+static NPError
+newInstance(NPMIMEType pluginType, NPP instance, uint16 mode,
+ int16 argc, char *argn[], char *argv[],
+ NPSavedData *saved)
+{
+ g_debug("np-zeitgeist: %s", __func__);
+ inst = instance;
+ // tell browser that we're windowless plugin
+ npnfuncs->setvalue(instance, NPPVpluginWindowBool, (void*)FALSE);
+
+ if(!zg_log)
+ {
+ zg_log = zeitgeist_log_new();
+ }
+ return NPERR_NO_ERROR;
+}
+
+static NPError
+destroyInstance(NPP instance, NPSavedData **save)
+{
+ g_debug("np-zeitgeist: %s", __func__);
+ if(so)
+ {
+ npnfuncs->releaseobject(so);
+ so = NULL;
+ }
+ if(zg_log)
+ {
+ g_object_unref(zg_log);
+ zg_log = NULL;
+ }
+ if(actor)
+ {
+ g_free(actor);
+ actor = NULL;
+ }
+ return NPERR_NO_ERROR;
+}
+
+static NPError
+getValue(NPP instance, NPPVariable variable, void *value)
+{
+ inst = instance;
+ switch(variable)
+ {
+ default:
+ g_debug("np-zeitgeist: getvalue - default");
+ return NPERR_GENERIC_ERROR;
+ case NPPVpluginNameString:
+ *((char **)value) = "Zeitgeist Plugin";
+ break;
+ case NPPVpluginDescriptionString:
+ *((char **)value) = "<a href=\"http://www.zeitgeist-project.com/\">Zeitgeist</a> NPAPI plugin.";
+ break;
+ case NPPVpluginScriptableNPObject:
+ if(!so)
+ so = npnfuncs->createobject(instance, &npcRefObject);
+ npnfuncs->retainobject(so);
+ *(NPObject **)value = so;
+ break;
+ case NPPVpluginNeedsXEmbed:
+ *((NPBool *)value) = FALSE;
+ break;
+ }
+ return NPERR_NO_ERROR;
+}
+
+static NPError /* expected by Safari on Darwin */
+handleEvent(NPP instance, void *ev) {
+ inst = instance;
+ g_debug("np-zeitgeist: %s", __func__);
+ return NPERR_NO_ERROR;
+}
+
+static NPError /* expected by Opera */
+setWindow(NPP instance, NPWindow* pNPWindow) {
+ inst = instance;
+ g_debug("np-zeitgeist: %s", __func__);
+ return NPERR_NO_ERROR;
+}
+
+/* EXPORT */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef OSCALL
+#define OSCALL
+#endif
+
+NPError OSCALL
+NP_GetEntryPoints(NPPluginFuncs *nppfuncs) {
+ g_debug("np-zeitgeist: %s", __func__);
+ nppfuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
+ nppfuncs->newp = newInstance;
+ nppfuncs->destroy = destroyInstance;
+ nppfuncs->getvalue = getValue;
+ nppfuncs->event = handleEvent;
+ nppfuncs->setwindow = setWindow;
+
+ return NPERR_NO_ERROR;
+}
+
+#ifndef HIBYTE
+#define HIBYTE(x) ((((uint32)(x)) & 0xff00) >> 8)
+#endif
+
+NPError OSCALL
+NP_Initialize(NPNetscapeFuncs *npnf,
+ NPPluginFuncs *nppfuncs)
+{
+ g_debug("np-zeitgeist: %s", __func__);
+ if(npnf == NULL)
+ return NPERR_INVALID_FUNCTABLE_ERROR;
+
+ if(HIBYTE(npnf->version) > NP_VERSION_MAJOR)
+ return NPERR_INCOMPATIBLE_VERSION_ERROR;
+
+ npnfuncs = npnf;
+ NP_GetEntryPoints(nppfuncs);
+ return NPERR_NO_ERROR;
+}
+
+NPError
+OSCALL NP_Shutdown() {
+ g_debug("np-zeitgeist: %s", __func__);
+ return NPERR_NO_ERROR;
+}
+
+char *
+NP_GetMIMEDescription(void) {
+ g_debug("np-zeitgeist: %s", __func__);
+ return "application/x-zeitgeist-plugin::Zeitgeist NPAPI plugin";
+}
+
+NPError OSCALL /* needs to be present for WebKit based browsers */
+NP_GetValue(void *npp, NPPVariable variable, void *value) {
+ inst = (NPP)npp;
+ return getValue((NPP)npp, variable, value);
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/npapi-plugin/plugin/third_party/npapi/bindings/npapi.h b/npapi-plugin/plugin/third_party/npapi/bindings/npapi.h
new file mode 100644
index 0000000..27492d7
--- /dev/null
+++ b/npapi-plugin/plugin/third_party/npapi/bindings/npapi.h
@@ -0,0 +1,799 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+/*
+ * npapi.h $Revision: 3.48 $
+ * Netscape client plug-in API spec
+ */
+
+#ifndef _NPAPI_H_
+#define _NPAPI_H_
+
+
+// BEGIN GOOGLE MODIFICATIONS
+
+#include "base/basictypes.h"
+
+// END GOOGLE MODIFICATIONS
+
+
+#ifdef __OS2__
+#pragma pack(1)
+#endif
+
+//#include "prtypes.h"
+/* Copied from xp_core.h */
+/* removed #ifdef for hpux defined in /usr/include/model.h */
+#ifndef _INT16
+#define _INT16
+#endif
+#ifndef _INT32
+#define _INT32
+#endif
+#ifndef _UINT16
+#define _UINT16
+#endif
+#ifndef _UINT32
+#define _UINT32
+#endif
+
+/*
+ * NO_NSPR_10_SUPPORT disables the inclusion
+ * of obsolete/protypes.h, whose int16, uint16,
+ * int32, and uint32 typedefs conflict with those
+ * in this file.
+ */
+#ifndef NO_NSPR_10_SUPPORT
+#define NO_NSPR_10_SUPPORT
+#endif
+#ifdef OJI
+#include "jri.h" /* Java Runtime Interface */
+#endif
+
+#if defined (__OS2__ ) || defined (OS2)
+# ifndef XP_OS2
+# define XP_OS2 1
+# endif /* XP_OS2 */
+#endif /* __OS2__ */
+
+#ifdef _WINDOWS
+// BEGIN GOOGLE MODIFICATIONS
+//#ifdef XP_WIN
+#include <windows.h>
+//#endif // XP_WIN
+// END GOOGLE MODIFICATIONS
+
+# ifndef XP_WIN
+# define XP_WIN 1
+# endif /* XP_WIN */
+#endif /* _WINDOWS */
+
+// BEGIN GOOGLE MODIFICATIONS
+// On Linux and Mac, be sure to set Mozilla-specific macros.
+#if defined(OS_LINUX)
+#define XP_UNIX 1
+#elif defined(OS_MACOSX)
+#ifndef XP_MACOSX
+#define XP_MACOSX 1
+#endif
+#endif
+// END GOOGLE MODIFICATIONS
+
+#ifdef __MWERKS__
+# define _declspec __declspec
+# ifdef __INTEL__
+# undef NULL
+# ifndef XP_WIN
+# define XP_WIN 1
+# endif /* XP_WIN */
+# endif /* __INTEL__ */
+#endif /* __MWERKS__ */
+
+#ifdef XP_MACOSX
+#include <Carbon/Carbon.h>
+#ifdef __LP64__
+#define NP_NO_QUICKDRAW
+#endif
+#endif
+
+#if defined(XP_UNIX)
+# include <stdio.h>
+# if defined(MOZ_X11)
+# include <X11/Xlib.h>
+# include <X11/Xutil.h>
+# endif
+#endif
+
+/*----------------------------------------------------------------------*/
+/* Plugin Version Constants */
+/*----------------------------------------------------------------------*/
+
+#define NP_VERSION_MAJOR 0
+#define NP_VERSION_MINOR 19
+
+
+/* The OS/2 version of Netscape uses RC_DATA to define the
+ mime types, file extensions, etc that are required.
+ Use a vertical bar to separate types, end types with \0.
+ FileVersion and ProductVersion are 32bit ints, all other
+ entries are strings the MUST be terminated wwith a \0.
+
+AN EXAMPLE:
+
+RCDATA NP_INFO_ProductVersion { 1,0,0,1,}
+
+RCDATA NP_INFO_MIMEType { "video/x-video|",
+ "video/x-flick\0" }
+RCDATA NP_INFO_FileExtents { "avi|",
+ "flc\0" }
+RCDATA NP_INFO_FileOpenName{ "MMOS2 video player(*.avi)|",
+ "MMOS2 Flc/Fli player(*.flc)\0" }
+
+RCDATA NP_INFO_FileVersion { 1,0,0,1 }
+RCDATA NP_INFO_CompanyName { "Netscape Communications\0" }
+RCDATA NP_INFO_FileDescription { "NPAVI32 Extension DLL\0"
+RCDATA NP_INFO_InternalName { "NPAVI32\0" )
+RCDATA NP_INFO_LegalCopyright { "Copyright Netscape Communications \251 1996\0"
+RCDATA NP_INFO_OriginalFilename { "NVAPI32.DLL" }
+RCDATA NP_INFO_ProductName { "NPAVI32 Dynamic Link Library\0" }
+
+*/
+
+
+/* RC_DATA types for version info - required */
+#define NP_INFO_ProductVersion 1
+#define NP_INFO_MIMEType 2
+#define NP_INFO_FileOpenName 3
+#define NP_INFO_FileExtents 4
+
+/* RC_DATA types for version info - used if found */
+#define NP_INFO_FileDescription 5
+#define NP_INFO_ProductName 6
+
+/* RC_DATA types for version info - optional */
+#define NP_INFO_CompanyName 7
+#define NP_INFO_FileVersion 8
+#define NP_INFO_InternalName 9
+#define NP_INFO_LegalCopyright 10
+#define NP_INFO_OriginalFilename 11
+
+#ifndef RC_INVOKED
+
+
+
+/*----------------------------------------------------------------------*/
+/* Definition of Basic Types */
+/*----------------------------------------------------------------------*/
+
+#ifndef _UINT16
+typedef unsigned short uint16;
+#endif
+
+#ifndef _UINT32
+# if defined(__alpha) || defined(__amd64__) || defined(__x86_64__)
+typedef unsigned int uint32;
+# else /* __alpha */
+typedef unsigned long uint32;
+# endif /* __alpha */
+#endif
+
+/*
+ * AIX defines these in sys/inttypes.h included from sys/types.h
+ */
+#ifndef AIX
+#ifndef _INT16
+typedef short int16;
+#endif
+
+#ifndef _INT32
+# if defined(__alpha) || defined(__amd64__) || defined(__x86_64__)
+typedef int int32;
+# else /* __alpha */
+typedef long int32;
+# endif /* __alpha */
+#endif
+#endif
+
+#ifndef FALSE
+#define FALSE (0)
+#endif
+#ifndef TRUE
+#define TRUE (1)
+#endif
+#ifndef NULL
+#define NULL (0L)
+#endif
+
+#ifdef XP_MACOSX
+typedef enum {
+#ifndef NP_NO_QUICKDRAW
+ NPDrawingModelQuickDraw = 0,
+#endif
+ NPDrawingModelCoreGraphics = 1
+} NPDrawingModel;
+#endif
+
+typedef unsigned char NPBool;
+typedef int16 NPError;
+typedef int16 NPReason;
+typedef char* NPMIMEType;
+
+
+
+/*----------------------------------------------------------------------*/
+/* Structures and definitions */
+/*----------------------------------------------------------------------*/
+
+/*
+ * NPP is a plug-in's opaque instance handle
+ */
+typedef struct _NPP
+{
+ void* pdata; /* plug-in private data */
+ void* ndata; /* netscape private data */
+} NPP_t;
+
+typedef NPP_t* NPP;
+
+
+typedef struct _NPStream
+{
+ void* pdata; /* plug-in private data */
+ void* ndata; /* netscape private data */
+ const char* url;
+ uint32 end;
+ uint32 lastmodified;
+ void* notifyData;
+ const char* headers; /* Response headers from host.
+ * Exists only for >= NPVERS_HAS_RESPONSE_HEADERS.
+ * Used for HTTP only; NULL for non-HTTP.
+ * Available from NPP_NewStream onwards.
+ * Plugin should copy this data before storing it.
+ * Includes HTTP status line and all headers,
+ * preferably verbatim as received from server,
+ * headers formatted as in HTTP ("Header: Value"),
+ * and newlines (\n, NOT \r\n) separating lines.
+ * Terminated by \n\0 (NOT \n\n\0). */
+} NPStream;
+
+
+typedef struct _NPByteRange
+{
+ int32 offset; /* negative offset means from the end */
+ uint32 length;
+ struct _NPByteRange* next;
+} NPByteRange;
+
+
+typedef struct _NPSavedData
+{
+ int32 len;
+ void* buf;
+} NPSavedData;
+
+
+typedef struct _NPRect
+{
+ uint16 top;
+ uint16 left;
+ uint16 bottom;
+ uint16 right;
+} NPRect;
+
+typedef struct _NPSize
+{
+ int32 width;
+ int32 height;
+} NPSize;
+
+#ifdef XP_UNIX
+/*
+ * Unix specific structures and definitions
+ */
+
+/*
+ * Callback Structures.
+ *
+ * These are used to pass additional platform specific information.
+ */
+enum {
+ NP_SETWINDOW = 1,
+ NP_PRINT
+};
+
+typedef struct
+{
+ int32 type;
+} NPAnyCallbackStruct;
+
+typedef struct
+{
+ int32 type;
+#ifdef MOZ_X11
+ Display* display;
+ Visual* visual;
+ Colormap colormap;
+ unsigned int depth;
+#endif
+} NPSetWindowCallbackStruct;
+
+typedef struct
+{
+ int32 type;
+ FILE* fp;
+} NPPrintCallbackStruct;
+
+#endif /* XP_UNIX */
+
+
+/*
+ * The following masks are applied on certain platforms to NPNV and
+ * NPPV selectors that pass around pointers to COM interfaces. Newer
+ * compilers on some platforms may generate vtables that are not
+ * compatible with older compilers. To prevent older plugins from
+ * not understanding a new browser's ABI, these masks change the
+ * values of those selectors on those platforms. To remain backwards
+ * compatible with differenet versions of the browser, plugins can
+ * use these masks to dynamically determine and use the correct C++
+ * ABI that the browser is expecting. This does not apply to Windows
+ * as Microsoft's COM ABI will likely not change.
+ */
+
+#define NP_ABI_GCC3_MASK 0x10000000
+/*
+ * gcc 3.x generated vtables on UNIX and OSX are incompatible with
+ * previous compilers.
+ */
+#if (defined (XP_UNIX) && defined(__GNUC__) && (__GNUC__ >= 3))
+#define _NP_ABI_MIXIN_FOR_GCC3 NP_ABI_GCC3_MASK
+#else
+#define _NP_ABI_MIXIN_FOR_GCC3 0
+#endif
+
+
+#define NP_ABI_MACHO_MASK 0x01000000
+/*
+ * On OSX, the Mach-O executable format is significantly
+ * different than CFM. In addition to having a different
+ * C++ ABI, it also has has different C calling convention.
+ * You must use glue code when calling between CFM and
+ * Mach-O C functions.
+ */
+#if (defined(TARGET_RT_MAC_MACHO))
+#define _NP_ABI_MIXIN_FOR_MACHO NP_ABI_MACHO_MASK
+#else
+#define _NP_ABI_MIXIN_FOR_MACHO 0
+#endif
+
+
+#define NP_ABI_MASK (_NP_ABI_MIXIN_FOR_GCC3 | _NP_ABI_MIXIN_FOR_MACHO)
+
+/*
+ * List of variable names for which NPP_GetValue shall be implemented
+ */
+typedef enum {
+ NPPVpluginNameString = 1,
+ NPPVpluginDescriptionString,
+ NPPVpluginWindowBool,
+ NPPVpluginTransparentBool,
+ NPPVjavaClass, /* Not implemented in Mozilla 1.0 */
+ NPPVpluginWindowSize,
+ NPPVpluginTimerInterval,
+
+ NPPVpluginScriptableInstance = (10 | NP_ABI_MASK),
+ NPPVpluginScriptableIID = 11,
+
+ /* Introduced in Mozilla 0.9.9 */
+ NPPVjavascriptPushCallerBool = 12,
+
+ /* Introduced in Mozilla 1.0 */
+ NPPVpluginKeepLibraryInMemory = 13,
+ NPPVpluginNeedsXEmbed = 14,
+
+ /* Get the NPObject for scripting the plugin. Introduced in Firefox
+ * 1.0 (NPAPI minor version 14).
+ */
+ NPPVpluginScriptableNPObject = 15,
+
+ /* Get the plugin value (as \0-terminated UTF-8 string data) for
+ * form submission if the plugin is part of a form. Use
+ * NPN_MemAlloc() to allocate memory for the string data. Introduced
+ * in Mozilla 1.8b2 (NPAPI minor version 15).
+ */
+ NPPVformValue = 16
+#ifdef XP_MACOSX
+ /* Used for negotiating drawing models */
+ , NPPVpluginDrawingModel = 1000
+#endif
+} NPPVariable;
+
+/*
+ * List of variable names for which NPN_GetValue is implemented by Mozilla
+ */
+typedef enum {
+ NPNVxDisplay = 1,
+ NPNVxtAppContext,
+ NPNVnetscapeWindow,
+ NPNVjavascriptEnabledBool,
+ NPNVasdEnabledBool,
+ NPNVisOfflineBool,
+
+ /* 10 and over are available on Mozilla builds starting with 0.9.4 */
+ NPNVserviceManager = (10 | NP_ABI_MASK),
+ NPNVDOMElement = (11 | NP_ABI_MASK), /* available in Mozilla 1.2 */
+ NPNVDOMWindow = (12 | NP_ABI_MASK),
+ NPNVToolkit = (13 | NP_ABI_MASK),
+ NPNVSupportsXEmbedBool = 14,
+
+ /* Get the NPObject wrapper for the browser window. */
+ NPNVWindowNPObject = 15,
+
+ /* Get the NPObject wrapper for the plugins DOM element. */
+ NPNVPluginElementNPObject = 16,
+
+ NPNVSupportsWindowless = 17
+
+#ifdef XP_MACOSX
+ /* Used for negotiating drawing models */
+ , NPNVpluginDrawingModel = 1000
+#ifndef NP_NO_QUICKDRAW
+ , NPNVsupportsQuickDrawBool = 2000
+#endif
+ , NPNVsupportsCoreGraphicsBool = 2001
+#endif
+} NPNVariable;
+
+/*
+ * The type of Tookkit the widgets use
+ */
+typedef enum {
+ NPNVGtk12 = 1,
+ NPNVGtk2
+} NPNToolkitType;
+
+/*
+ * The type of a NPWindow - it specifies the type of the data structure
+ * returned in the window field.
+ */
+typedef enum {
+ NPWindowTypeWindow = 1,
+ NPWindowTypeDrawable
+} NPWindowType;
+
+typedef struct _NPWindow
+{
+ void* window; /* Platform specific window handle */
+ /* OS/2: x - Position of bottom left corner */
+ /* OS/2: y - relative to visible netscape window */
+ int32 x; /* Position of top left corner relative */
+ int32 y; /* to a netscape page. */
+ uint32 width; /* Maximum window size */
+ uint32 height;
+ NPRect clipRect; /* Clipping rectangle in port coordinates */
+ /* Used by MAC only. */
+#if defined(XP_UNIX) && !defined(XP_MACOSX)
+ void * ws_info; /* Platform-dependent additonal data */
+#endif /* XP_UNIX */
+ NPWindowType type; /* Is this a window or a drawable? */
+} NPWindow;
+
+
+typedef struct _NPFullPrint
+{
+ NPBool pluginPrinted;/* Set TRUE if plugin handled fullscreen printing */
+ NPBool printOne; /* TRUE if plugin should print one copy to default printer */
+ void* platformPrint; /* Platform-specific printing info */
+} NPFullPrint;
+
+typedef struct _NPEmbedPrint
+{
+ NPWindow window;
+ void* platformPrint; /* Platform-specific printing info */
+} NPEmbedPrint;
+
+typedef struct _NPPrint
+{
+ uint16 mode; /* NP_FULL or NP_EMBED */
+ union
+ {
+ NPFullPrint fullPrint; /* if mode is NP_FULL */
+ NPEmbedPrint embedPrint; /* if mode is NP_EMBED */
+ } print;
+} NPPrint;
+
+// BEGIN GOOGLE MODIFICATIONS
+#ifdef XP_MACOSX
+typedef struct _NPNSMenu NPNSMenu;
+typedef NPNSMenu NPMenu;
+#else
+typedef void * NPMenu;
+#endif
+// END GOOGLE MODIFICATIONS
+
+#ifdef XP_MACOSX
+typedef EventRecord NPEvent;
+#elif defined(XP_WIN)
+typedef struct _NPEvent
+{
+ uint16 event;
+ uint32 wParam;
+ uint32 lParam;
+} NPEvent;
+#elif defined(XP_OS2)
+typedef struct _NPEvent
+{
+ uint32 event;
+ uint32 wParam;
+ uint32 lParam;
+} NPEvent;
+#elif defined (XP_UNIX) && defined(MOZ_X11)
+typedef XEvent NPEvent;
+#else
+typedef void* NPEvent;
+#endif /* XP_MACOSX */
+
+#ifdef XP_MACOSX
+typedef void* NPRegion;
+#ifndef NP_NO_QUICKDRAW
+typedef RgnHandle NPQDRegion;
+#endif
+typedef CGPathRef NPCGRegion;
+#elif defined(XP_WIN)
+typedef HRGN NPRegion;
+#elif defined(XP_UNIX) && defined(MOZ_X11)
+typedef Region NPRegion;
+#else
+typedef void *NPRegion;
+#endif /* XP_MACOSX */
+
+#ifdef XP_MACOSX
+/*
+ * Mac-specific structures and definitions.
+ */
+
+typedef struct NP_Port
+{
+ CGrafPtr port; /* Grafport */
+ int32 portx; /* position inside the topmost window */
+ int32 porty;
+} NP_Port;
+
+typedef struct NP_CGContext
+{
+ CGContextRef context;
+ WindowRef window;
+} NP_CGContext;
+
+/*
+ * Non-standard event types that can be passed to HandleEvent
+ */
+
+enum NPEventType {
+ NPEventType_GetFocusEvent = (osEvt + 16),
+ NPEventType_LoseFocusEvent,
+ NPEventType_AdjustCursorEvent,
+ NPEventType_MenuCommandEvent,
+ NPEventType_ClippingChangedEvent,
+ NPEventType_ScrollingBeginsEvent = 1000,
+ NPEventType_ScrollingEndsEvent
+};
+
+#ifdef OBSOLETE
+#define getFocusEvent (osEvt + 16)
+#define loseFocusEvent (osEvt + 17)
+#define adjustCursorEvent (osEvt + 18)
+#endif
+#endif /* XP_MACOSX */
+
+/*
+ * Values for mode passed to NPP_New:
+ */
+#define NP_EMBED 1
+#define NP_FULL 2
+
+/*
+ * Values for stream type passed to NPP_NewStream:
+ */
+#define NP_NORMAL 1
+#define NP_SEEK 2
+#define NP_ASFILE 3
+#define NP_ASFILEONLY 4
+
+#define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
+
+
+/*----------------------------------------------------------------------*/
+/* Error and Reason Code definitions */
+/*----------------------------------------------------------------------*/
+
+/*
+ * Values of type NPError:
+ */
+#define NPERR_BASE 0
+#define NPERR_NO_ERROR (NPERR_BASE + 0)
+#define NPERR_GENERIC_ERROR (NPERR_BASE + 1)
+#define NPERR_INVALID_INSTANCE_ERROR (NPERR_BASE + 2)
+#define NPERR_INVALID_FUNCTABLE_ERROR (NPERR_BASE + 3)
+#define NPERR_MODULE_LOAD_FAILED_ERROR (NPERR_BASE + 4)
+#define NPERR_OUT_OF_MEMORY_ERROR (NPERR_BASE + 5)
+#define NPERR_INVALID_PLUGIN_ERROR (NPERR_BASE + 6)
+#define NPERR_INVALID_PLUGIN_DIR_ERROR (NPERR_BASE + 7)
+#define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8)
+#define NPERR_INVALID_PARAM (NPERR_BASE + 9)
+#define NPERR_INVALID_URL (NPERR_BASE + 10)
+#define NPERR_FILE_NOT_FOUND (NPERR_BASE + 11)
+#define NPERR_NO_DATA (NPERR_BASE + 12)
+#define NPERR_STREAM_NOT_SEEKABLE (NPERR_BASE + 13)
+
+/*
+ * Values of type NPReason:
+ */
+#define NPRES_BASE 0
+#define NPRES_DONE (NPRES_BASE + 0)
+#define NPRES_NETWORK_ERR (NPRES_BASE + 1)
+#define NPRES_USER_BREAK (NPRES_BASE + 2)
+
+/*
+ * Don't use these obsolete error codes any more.
+ */
+#define NP_NOERR NP_NOERR_is_obsolete_use_NPERR_NO_ERROR
+#define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR
+#define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK
+
+/*
+ * Version feature information
+ */
+#define NPVERS_HAS_STREAMOUTPUT 8
+#define NPVERS_HAS_NOTIFICATION 9
+#define NPVERS_HAS_LIVECONNECT 9
+#define NPVERS_WIN16_HAS_LIVECONNECT 9
+#define NPVERS_68K_HAS_LIVECONNECT 11
+#define NPVERS_HAS_WINDOWLESS 11
+#define NPVERS_HAS_XPCONNECT_SCRIPTING 13
+#define NPVERS_HAS_NPRUNTIME_SCRIPTING 14
+#define NPVERS_HAS_FORM_VALUES 15
+#define NPVERS_HAS_POPUPS_ENABLED_STATE 16
+#define NPVERS_HAS_RESPONSE_HEADERS 17
+#define NPVERS_HAS_NPOBJECT_ENUM 18
+#define NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL 19
+
+/*----------------------------------------------------------------------*/
+/* Function Prototypes */
+/*----------------------------------------------------------------------*/
+
+#if defined(_WINDOWS) && !defined(WIN32)
+#define NP_LOADDS _loadds
+#else
+#if defined(__OS2__)
+#define NP_LOADDS _System
+#else
+#define NP_LOADDS
+#endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * NPP_* functions are provided by the plugin and called by the navigator.
+ */
+
+#ifdef XP_UNIX
+char* NPP_GetMIMEDescription(void);
+#endif /* XP_UNIX */
+
+NPError NP_LOADDS NPP_Initialize(void);
+void NP_LOADDS NPP_Shutdown(void);
+NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance,
+ uint16 mode, int16 argc, char* argn[],
+ char* argv[], NPSavedData* saved);
+NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save);
+NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window);
+NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type,
+ NPStream* stream, NPBool seekable,
+ uint16* stype);
+NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream,
+ NPReason reason);
+int32 NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream);
+int32 NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset,
+ int32 len, void* buffer);
+void NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream,
+ const char* fname);
+void NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint);
+int16 NP_LOADDS NPP_HandleEvent(NPP instance, void* event);
+void NP_LOADDS NPP_URLNotify(NPP instance, const char* url,
+ NPReason reason, void* notifyData);
+#ifdef OJI
+jref NP_LOADDS NPP_GetJavaClass(void);
+#endif
+NPError NP_LOADDS NPP_GetValue(NPP instance, NPPVariable variable, void *value);
+NPError NP_LOADDS NPP_SetValue(NPP instance, NPNVariable variable, void *value);
+
+/*
+ * NPN_* functions are provided by the navigator and called by the plugin.
+ */
+void NP_LOADDS NPN_Version(int* plugin_major, int* plugin_minor,
+ int* netscape_major, int* netscape_minor);
+NPError NP_LOADDS NPN_GetURLNotify(NPP instance, const char* url,
+ const char* target, void* notifyData);
+NPError NP_LOADDS NPN_GetURL(NPP instance, const char* url,
+ const char* target);
+NPError NP_LOADDS NPN_PostURLNotify(NPP instance, const char* url,
+ const char* target, uint32 len,
+ const char* buf, NPBool file,
+ void* notifyData);
+NPError NP_LOADDS NPN_PostURL(NPP instance, const char* url,
+ const char* target, uint32 len,
+ const char* buf, NPBool file);
+NPError NP_LOADDS NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
+NPError NP_LOADDS NPN_NewStream(NPP instance, NPMIMEType type,
+ const char* target, NPStream** stream);
+int32 NP_LOADDS NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer);
+NPError NP_LOADDS NPN_DestroyStream(NPP instance, NPStream* stream, NPReason reason);
+void NP_LOADDS NPN_Status(NPP instance, const char* message);
+const char* NP_LOADDS NPN_UserAgent(NPP instance);
+void* NP_LOADDS NPN_MemAlloc(uint32 size);
+void NP_LOADDS NPN_MemFree(void* ptr);
+uint32 NP_LOADDS NPN_MemFlush(uint32 size);
+void NP_LOADDS NPN_ReloadPlugins(NPBool reloadPages);
+#ifdef OJI
+JRIEnv* NP_LOADDS NPN_GetJavaEnv(void);
+jref NP_LOADDS NPN_GetJavaPeer(NPP instance);
+#endif
+NPError NP_LOADDS NPN_GetValue(NPP instance, NPNVariable variable, void *value);
+NPError NP_LOADDS NPN_SetValue(NPP instance, NPPVariable variable, void *value);
+void NP_LOADDS NPN_InvalidateRect(NPP instance, NPRect *invalidRect);
+void NP_LOADDS NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion);
+void NP_LOADDS NPN_ForceRedraw(NPP instance);
+void NP_LOADDS NPN_PushPopupsEnabledState(NPP instance, NPBool enabled);
+void NP_LOADDS NPN_PopPopupsEnabledState(NPP instance);
+void NP_LOADDS NPN_PluginThreadAsyncCall(NPP instance,
+ void (*func) (void *),
+ void *userData);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif /* RC_INVOKED */
+#ifdef __OS2__
+#pragma pack()
+#endif
+
+#endif /* _NPAPI_H_ */
diff --git a/npapi-plugin/plugin/third_party/npapi/bindings/npruntime.h b/npapi-plugin/plugin/third_party/npapi/bindings/npruntime.h
new file mode 100644
index 0000000..f7d3e05
--- /dev/null
+++ b/npapi-plugin/plugin/third_party/npapi/bindings/npruntime.h
@@ -0,0 +1,401 @@
+/*
+ * Copyright (C) 2004, Apple Computer, Inc. and The Mozilla Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of Apple Computer, Inc. ("Apple") or The Mozilla
+ * Foundation ("Mozilla") nor the names of their contributors may be used
+ * to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE, MOZILLA AND THEIR CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, MOZILLA OR
+ * THEIR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Revision 1 (March 4, 2004):
+ * Initial proposal.
+ *
+ * Revision 2 (March 10, 2004):
+ * All calls into script were made asynchronous. Results are
+ * provided via the NPScriptResultFunctionPtr callback.
+ *
+ * Revision 3 (March 10, 2004):
+ * Corrected comments to not refer to class retain/release FunctionPtrs.
+ *
+ * Revision 4 (March 11, 2004):
+ * Added additional convenience NPN_SetExceptionWithUTF8().
+ * Changed NPHasPropertyFunctionPtr and NPHasMethodFunctionPtr to take NPClass
+ * pointers instead of NPObject pointers.
+ * Added NPIsValidIdentifier().
+ *
+ * Revision 5 (March 17, 2004):
+ * Added context parameter to result callbacks from ScriptObject functions.
+ *
+ * Revision 6 (March 29, 2004):
+ * Renamed functions implemented by user agent to NPN_*. Removed _ from
+ * type names.
+ * Renamed "JavaScript" types to "Script".
+ *
+ * Revision 7 (April 21, 2004):
+ * NPIdentifier becomes a void*, was int32_t
+ * Remove NP_IsValidIdentifier, renamed NP_IdentifierFromUTF8 to NP_GetIdentifier
+ * Added NPVariant and modified functions to use this new type.
+ *
+ * Revision 8 (July 9, 2004):
+ * Updated to joint Apple-Mozilla license.
+ *
+ * Revision 9 (August 12, 2004):
+ * Changed NPVariantType enum values to form PVariantType_XXX
+ * Added NPP arguments to NPObject functions.
+ * Replaced NPVariant functions with macros.
+ */
+#ifndef _NP_RUNTIME_H_
+#define _NP_RUNTIME_H_
+
+
+// BEGIN GOOGLE MODIFICATIONS
+
+#include "base/basictypes.h"
+#include "bindings/npapi.h"
+
+typedef uint8 uint8_t;
+typedef int8 int8_t;
+typedef uint16 uint16_t;
+typedef int16 int16_t;
+typedef uint32 uint32_t;
+typedef int32 int32_t;
+/*
+// Seems to screw things up on 64bit systems
+typedef int64 int64_t;
+typedef uint64 uint64_t;
+*/
+
+// END GOOGLE MODIFICATIONS
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ This API is used to facilitate binding code written in C to script
+ objects. The API in this header does not assume the presence of a
+ user agent. That is, it can be used to bind C code to scripting
+ environments outside of the context of a user agent.
+
+ However, the normal use of the this API is in the context of a
+ scripting environment running in a browser or other user agent.
+ In particular it is used to support the extended Netscape
+ script-ability API for plugins (NP-SAP). NP-SAP is an extension
+ of the Netscape plugin API. As such we have adopted the use of
+ the "NP" prefix for this API.
+
+ The following NP{N|P}Variables were added to the Netscape plugin
+ API (in npapi.h):
+
+ NPNVWindowNPObject
+ NPNVPluginElementNPObject
+ NPPVpluginScriptableNPObject
+
+ These variables are exposed through NPN_GetValue() and
+ NPP_GetValue() (respectively) and are used to establish the
+ initial binding between the user agent and native code. The DOM
+ objects in the user agent can be examined and manipulated using
+ the NPN_ functions that operate on NPObjects described in this
+ header.
+
+ To the extent possible the assumptions about the scripting
+ language used by the scripting environment have been minimized.
+*/
+
+
+/*
+ Objects (non-primitive data) passed between 'C' and script is
+ always wrapped in an NPObject. The 'interface' of an NPObject is
+ described by an NPClass.
+*/
+typedef struct NPObject NPObject;
+typedef struct NPClass NPClass;
+
+typedef char NPUTF8;
+typedef struct _NPString {
+ const NPUTF8 *UTF8Characters;
+ uint32_t UTF8Length;
+} NPString;
+
+typedef enum {
+ NPVariantType_Void,
+ NPVariantType_Null,
+ NPVariantType_Bool,
+ NPVariantType_Int32,
+ NPVariantType_Double,
+ NPVariantType_String,
+ NPVariantType_Object
+} NPVariantType;
+
+typedef struct _NPVariant {
+ NPVariantType type;
+ union {
+ bool boolValue;
+ int32_t intValue;
+ double doubleValue;
+ NPString stringValue;
+ NPObject *objectValue;
+ } value;
+} NPVariant;
+
+/*
+ NPN_ReleaseVariantValue is called on all 'out' parameters references.
+ Specifically it is called on variants that are resultant out parameters
+ in NPGetPropertyFunctionPtr and NPInvokeFunctionPtr. Resultant variants
+ from these two functions should be initialized using the
+ NPN_InitializeVariantXXX() functions.
+
+ After calling NPReleaseVariantValue, the type of the variant will
+ be set to NPVariantUndefinedType.
+*/
+void NPN_ReleaseVariantValue (NPVariant *variant);
+
+#define NPVARIANT_IS_VOID(_v) ((_v).type == NPVariantType_Void)
+#define NPVARIANT_IS_NULL(_v) ((_v).type == NPVariantType_Null)
+#define NPVARIANT_IS_BOOLEAN(_v) ((_v).type == NPVariantType_Bool)
+#define NPVARIANT_IS_INT32(_v) ((_v).type == NPVariantType_Int32)
+#define NPVARIANT_IS_DOUBLE(_v) ((_v).type == NPVariantType_Double)
+#define NPVARIANT_IS_STRING(_v) ((_v).type == NPVariantType_String)
+#define NPVARIANT_IS_OBJECT(_v) ((_v).type == NPVariantType_Object)
+
+#define NPVARIANT_TO_BOOLEAN(_v) ((_v).value.boolValue)
+#define NPVARIANT_TO_INT32(_v) ((_v).value.intValue)
+#define NPVARIANT_TO_DOUBLE(_v) ((_v).value.doubleValue)
+#define NPVARIANT_TO_STRING(_v) ((_v).value.stringValue)
+#define NPVARIANT_TO_OBJECT(_v) ((_v).value.objectValue)
+
+#define NP_BEGIN_MACRO do {
+#define NP_END_MACRO } while (0)
+
+#define VOID_TO_NPVARIANT(_v) NP_BEGIN_MACRO (_v).type = NPVariantType_Void; (_v).value.objectValue = NULL; NP_END_MACRO
+#define NULL_TO_NPVARIANT(_v) NP_BEGIN_MACRO (_v).type = NPVariantType_Null; (_v).value.objectValue = NULL; NP_END_MACRO
+#define BOOLEAN_TO_NPVARIANT(_val, _v) NP_BEGIN_MACRO (_v).type = NPVariantType_Bool; (_v).value.boolValue = !!(_val); NP_END_MACRO
+#define INT32_TO_NPVARIANT(_val, _v) NP_BEGIN_MACRO (_v).type = NPVariantType_Int32; (_v).value.intValue = _val; NP_END_MACRO
+#define DOUBLE_TO_NPVARIANT(_val, _v) NP_BEGIN_MACRO (_v).type = NPVariantType_Double; (_v).value.doubleValue = _val; NP_END_MACRO
+#define STRINGZ_TO_NPVARIANT(_val, _v) NP_BEGIN_MACRO (_v).type = NPVariantType_String; NPString str = { _val, strlen(_val) }; (_v).value.stringValue = str; NP_END_MACRO
+#define STRINGN_TO_NPVARIANT(_val, _len, _v) NP_BEGIN_MACRO (_v).type = NPVariantType_String; NPString str = { _val, _len }; (_v).value.stringValue = str; NP_END_MACRO
+#define OBJECT_TO_NPVARIANT(_val, _v) NP_BEGIN_MACRO (_v).type = NPVariantType_Object; (_v).value.objectValue = _val; NP_END_MACRO
+
+/*
+ Type mappings (JavaScript types have been used for illustration
+ purposes):
+
+ JavaScript to C (NPVariant with type:)
+ undefined NPVariantType_Void
+ null NPVariantType_Null
+ Boolean NPVariantType_Bool
+ Number NPVariantType_Double or NPVariantType_Int32
+ String NPVariantType_String
+ Object NPVariantType_Object
+
+ C (NPVariant with type:) to JavaScript
+ NPVariantType_Void undefined
+ NPVariantType_Null null
+ NPVariantType_Bool Boolean
+ NPVariantType_Int32 Number
+ NPVariantType_Double Number
+ NPVariantType_String String
+ NPVariantType_Object Object
+*/
+
+typedef void *NPIdentifier;
+
+/*
+ NPObjects have methods and properties. Methods and properties are
+ identified with NPIdentifiers. These identifiers may be reflected
+ in script. NPIdentifiers can be either strings or integers, IOW,
+ methods and properties can be identified by either strings or
+ integers (i.e. foo["bar"] vs foo[1]). NPIdentifiers can be
+ compared using ==. In case of any errors, the requested
+ NPIdentifier(s) will be NULL.
+*/
+NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name);
+void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, NPIdentifier *identifiers);
+NPIdentifier NPN_GetIntIdentifier(int32_t intid);
+bool NPN_IdentifierIsString(NPIdentifier identifier);
+
+/*
+ The NPUTF8 returned from NPN_UTF8FromIdentifier SHOULD be freed.
+*/
+NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier);
+
+/*
+ Get the integer represented by identifier. If identifier is not an
+ integer identifier, the behaviour is undefined.
+*/
+int32_t NPN_IntFromIdentifier(NPIdentifier identifier);
+
+/*
+ NPObject behavior is implemented using the following set of
+ callback functions.
+
+ The NPVariant *result argument of these functions (where
+ applicable) should be released using NPN_ReleaseVariantValue().
+*/
+typedef NPObject *(*NPAllocateFunctionPtr)(NPP npp, NPClass *aClass);
+typedef void (*NPDeallocateFunctionPtr)(NPObject *obj);
+typedef void (*NPInvalidateFunctionPtr)(NPObject *obj);
+typedef bool (*NPHasMethodFunctionPtr)(NPObject *obj, NPIdentifier name);
+typedef bool (*NPInvokeFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result);
+typedef bool (*NPInvokeDefaultFunctionPtr)(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result);
+typedef bool (*NPHasPropertyFunctionPtr)(NPObject *obj, NPIdentifier name);
+typedef bool (*NPGetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, NPVariant *result);
+typedef bool (*NPSetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *value);
+typedef bool (*NPRemovePropertyFunctionPtr)(NPObject *npobj, NPIdentifier name);
+typedef bool (*NPEnumerationFunctionPtr)(NPObject *npobj, NPIdentifier **value, uint32_t *count);
+typedef bool (*NPConstructFunctionPtr)(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result);
+
+/*
+ NPObjects returned by create have a reference count of one. It is the caller's responsibility
+ to release the returned object.
+
+ NPInvokeFunctionPtr function may return false to indicate a the method could not be invoked.
+
+ NPGetPropertyFunctionPtr and NPSetPropertyFunctionPtr may return false to indicate a property doesn't
+ exist.
+
+ NPInvalidateFunctionPtr is called by the scripting environment when the native code is
+ shutdown. Any attempt to message a NPObject instance after the invalidate
+ callback has been called will result in undefined behavior, even if the
+ native code is still retaining those NPObject instances.
+ (The runtime will typically return immediately, with 0 or NULL, from an attempt to
+ dispatch to a NPObject, but this behavior should not be depended upon.)
+
+ The NPEnumerationFunctionPtr function may pass an array of
+ NPIdentifiers back to the caller. The callee allocs the memory of
+ the array using NPN_MemAlloc(), and it's the caller's responsibility
+ to release it using NPN_MemFree().
+*/
+struct NPClass
+{
+ uint32_t structVersion;
+ NPAllocateFunctionPtr allocate;
+ NPDeallocateFunctionPtr deallocate;
+ NPInvalidateFunctionPtr invalidate;
+ NPHasMethodFunctionPtr hasMethod;
+ NPInvokeFunctionPtr invoke;
+ NPInvokeDefaultFunctionPtr invokeDefault;
+ NPHasPropertyFunctionPtr hasProperty;
+ NPGetPropertyFunctionPtr getProperty;
+ NPSetPropertyFunctionPtr setProperty;
+ NPRemovePropertyFunctionPtr removeProperty;
+ NPEnumerationFunctionPtr enumerate;
+ NPConstructFunctionPtr construct;
+};
+
+#define NP_CLASS_STRUCT_VERSION 3
+#define NP_CLASS_STRUCT_VERSION_ENUM 2
+#define NP_CLASS_STRUCT_VERSION_CTOR 3
+
+#define NP_CLASS_STRUCT_VERSION_HAS_ENUM(npclass) \
+ ((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_ENUM)
+#define NP_CLASS_STRUCT_VERSION_HAS_CTOR(npclass) \
+ ((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_CTOR)
+
+struct NPObject {
+ NPClass *_class;
+ uint32_t referenceCount;
+ // Additional space may be allocated here by types of NPObjects
+};
+
+/*
+ If the class has an allocate function, NPN_CreateObject invokes that function,
+ otherwise a NPObject is allocated and returned. If a class has an allocate
+ function it is the responsibility of that implementation to set the initial retain
+ count to 1.
+*/
+NPObject *NPN_CreateObject(NPP npp, NPClass *aClass);
+
+/*
+ Increment the NPObject's reference count.
+*/
+NPObject *NPN_RetainObject (NPObject *obj);
+
+/*
+ Decremented the NPObject's reference count. If the reference
+ count goes to zero, the class's destroy function is invoke if
+ specified, otherwise the object is freed directly.
+*/
+void NPN_ReleaseObject (NPObject *obj);
+
+/*
+ Functions to access script objects represented by NPObject.
+
+ Calls to script objects are synchronous. If a function returns a
+ value, it will be supplied via the result NPVariant
+ argument. Successful calls will return true, false will be
+ returned in case of an error.
+
+ Calls made from plugin code to script must be made from the thread
+ on which the plugin was initialized.
+*/
+bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result);
+bool NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result);
+bool NPN_Evaluate(NPP npp, NPObject *npobj, NPString *script, NPVariant *result);
+bool NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, NPVariant *result);
+bool NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, const NPVariant *value);
+bool NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
+bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
+bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName);
+bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *count);
+bool NPN_Construct(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result);
+
+// Helper function for evaluating a script in the scope of the NPObject passed in.
+// Parameters
+// npp
+// The plugin's opaque instance handle (Can be NULL)
+// popups_allowed
+// Indicates if popups created in the context of the script being executed are
+// blocked or not.
+// npobj
+// The NPObject.
+// npscript
+// The script being executed.
+// result
+// On return contains the value returned by the script.
+// Returns true on success.
+bool NPN_EvaluateHelper(NPP npp, bool popups_allowed, NPObject* npobj,
+ NPString* npscript, NPVariant *result);
+
+// BEGIN GOOGLE MODIFICATIONS
+
+void* NPP_GetJavaClass(void);
+void* NPN_GetJavaEnv(void);
+void* NPN_GetJavaPeer(NPP instance);
+void NPN_PluginThreadAsyncCall(NPP id, void (*func)(void *), void *userData);
+
+// END GOOGLE MODIFICATIONS
+
+/*
+ NPN_SetException may be called to trigger a script exception upon return
+ from entry points into NPObjects.
+*/
+void NPN_SetException (NPObject *obj, const NPUTF8 *message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/npapi-plugin/plugin/third_party/webkit/glue/plugins/nphostapi.h b/npapi-plugin/plugin/third_party/webkit/glue/plugins/nphostapi.h
new file mode 100644
index 0000000..c9751c0
--- /dev/null
+++ b/npapi-plugin/plugin/third_party/webkit/glue/plugins/nphostapi.h
@@ -0,0 +1,282 @@
+// 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.
+
+// TODO: Did not implement JRIGlobalRef function yet. Not sure if this is used?
+
+#ifndef WEBKIT_GLUE_PLUGIN_NPHOSTAPI_H__
+#define WEBKIT_GLUE_PLUGIN_NPHOSTAPI_H__
+
+#include "base/port.h"
+#include "third_party/npapi/bindings/npapi.h"
+#include "third_party/npapi/bindings/npruntime.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//
+// NPAPI NPP Function Pointers
+//
+typedef NPError (*NPP_NewProcPtr)(NPMIMEType pluginType,
+ NPP instance,
+ uint16 mode,
+ int16 argc,
+ char* argn[],
+ char* argv[],
+ NPSavedData* saved);
+typedef NPError (*NPP_DestroyProcPtr)(NPP instance,
+ NPSavedData** save);
+typedef NPError (*NPP_SetWindowProcPtr)(NPP instance,
+ NPWindow* window);
+typedef NPError (*NPP_NewStreamProcPtr)(NPP instance,
+ NPMIMEType type,
+ NPStream* stream,
+ NPBool seekable,
+ uint16* stype);
+typedef NPError (*NPP_DestroyStreamProcPtr)(NPP instance,
+ NPStream* stream,
+ NPReason reason);
+typedef int32 (*NPP_WriteReadyProcPtr)(NPP instance,
+ NPStream* stream);
+typedef int32 (*NPP_WriteProcPtr)(NPP instance,
+ NPStream* stream,
+ int32 offset,
+ int32 len,
+ void* buffer);
+typedef void (*NPP_StreamAsFileProcPtr)(NPP instance,
+ NPStream* stream,
+ const char* fname);
+typedef void (*NPP_PrintProcPtr)(NPP instance,
+ NPPrint* platformPrint);
+typedef int16 (*NPP_HandleEventProcPtr)(NPP instance,
+ void* event);
+typedef void (*NPP_URLNotifyProcPtr)(NPP instance,
+ const char* url,
+ NPReason reason,
+ void* notifyData);
+typedef void* JRIGlobalRef; //not using this right now
+typedef NPError (*NPP_GetValueProcPtr)(NPP instance,
+ NPPVariable variable,
+ void *ret_alue);
+typedef NPError (*NPP_SetValueProcPtr)(NPP instance,
+ NPNVariable variable,
+ void *ret_alue);
+
+//
+// NPAPI NPN Function Pointers
+//
+typedef NPError (*NPN_GetURLProcPtr)(NPP instance,
+ const char* URL,
+ const char* window);
+typedef NPError (*NPN_PostURLProcPtr)(NPP instance,
+ const char* URL,
+ const char* window,
+ uint32 len,
+ const char* buf,
+ NPBool file);
+typedef NPError (*NPN_RequestReadProcPtr)(NPStream* stream,
+ NPByteRange* rangeList);
+typedef NPError (*NPN_NewStreamProcPtr)(NPP instance,
+ NPMIMEType type,
+ const char* window,
+ NPStream** stream);
+typedef int32 (*NPN_WriteProcPtr)(NPP instance,
+ NPStream* stream,
+ int32 len,
+ void* buffer);
+typedef NPError (*NPN_DestroyStreamProcPtr)(NPP instance,
+ NPStream* stream,
+ NPReason reason);
+typedef void (*NPN_StatusProcPtr)(NPP instance,
+ const char* message);
+typedef const char* (*NPN_UserAgentProcPtr)(NPP instance);
+typedef void* (*NPN_MemAllocProcPtr)(uint32 size);
+typedef void (*NPN_MemFreeProcPtr)(void* ptr);
+typedef uint32 (*NPN_MemFlushProcPtr)(uint32 size);
+typedef void (*NPN_ReloadPluginsProcPtr)(NPBool reloadPages);
+
+typedef void* (*NPN_GetJavaEnvProcPtr)(void);
+typedef void* (*NPN_GetJavaPeerProcPtr)(NPP instance);
+
+typedef NPError (*NPN_GetURLNotifyProcPtr)(NPP instance,
+ const char* URL,
+ const char* window,
+ void* notifyData);
+typedef NPError (*NPN_PostURLNotifyProcPtr)(NPP instance,
+ const char* URL,
+ const char* window,
+ uint32 len,
+ const char* buf,
+ NPBool file,
+ void* notifyData);
+typedef NPError (*NPN_GetValueProcPtr)(NPP instance,
+ NPNVariable variable,
+ void *ret_value);
+typedef NPError (*NPN_SetValueProcPtr)(NPP instance,
+ NPPVariable variable,
+ void *value);
+typedef void (*NPN_InvalidateRectProcPtr)(NPP instance,
+ NPRect *rect);
+typedef void (*NPN_InvalidateRegionProcPtr)(NPP instance,
+ NPRegion region);
+typedef void (*NPN_ForceRedrawProcPtr)(NPP instance);
+
+typedef void (*NPN_ReleaseVariantValueProcPtr) (NPVariant *variant);
+
+typedef NPIdentifier (*NPN_GetStringIdentifierProcPtr) (const NPUTF8 *name);
+typedef void (*NPN_GetStringIdentifiersProcPtr) (const NPUTF8 **names,
+ int32_t nameCount,
+ NPIdentifier *identifiers);
+typedef NPIdentifier (*NPN_GetIntIdentifierProcPtr) (int32_t intid);
+typedef int32_t (*NPN_IntFromIdentifierProcPtr) (NPIdentifier identifier);
+typedef bool (*NPN_IdentifierIsStringProcPtr) (NPIdentifier identifier);
+typedef NPUTF8 * (*NPN_UTF8FromIdentifierProcPtr) (NPIdentifier identifier);
+
+typedef NPObject* (*NPN_CreateObjectProcPtr) (NPP,
+ NPClass *aClass);
+typedef NPObject* (*NPN_RetainObjectProcPtr) (NPObject *obj);
+typedef void (*NPN_ReleaseObjectProcPtr) (NPObject *obj);
+typedef bool (*NPN_InvokeProcPtr) (NPP npp,
+ NPObject *obj,
+ NPIdentifier methodName,
+ const NPVariant *args,
+ unsigned argCount,
+ NPVariant *result);
+typedef bool (*NPN_InvokeDefaultProcPtr) (NPP npp,
+ NPObject *obj,
+ const NPVariant *args,
+ unsigned argCount,
+ NPVariant *result);
+typedef bool (*NPN_EvaluateProcPtr) (NPP npp,
+ NPObject *obj,
+ NPString *script,
+ NPVariant *result);
+typedef bool (*NPN_GetPropertyProcPtr) (NPP npp,
+ NPObject *obj,
+ NPIdentifier propertyName,
+ NPVariant *result);
+typedef bool (*NPN_SetPropertyProcPtr) (NPP npp,
+ NPObject *obj,
+ NPIdentifier propertyName,
+ const NPVariant *value);
+typedef bool (*NPN_HasPropertyProcPtr) (NPP,
+ NPObject *npobj,
+ NPIdentifier propertyName);
+typedef bool (*NPN_HasMethodProcPtr) (NPP npp,
+ NPObject *npobj,
+ NPIdentifier methodName);
+typedef bool (*NPN_RemovePropertyProcPtr) (NPP npp,
+ NPObject *obj,
+ NPIdentifier propertyName);
+typedef void (*NPN_SetExceptionProcPtr) (NPObject *obj,
+ const NPUTF8 *message);
+typedef void (*NPN_PushPopupsEnabledStateProcPtr)(NPP npp,
+ NPBool enabled);
+typedef void (*NPN_PopPopupsEnabledStateProcPtr)(NPP npp);
+typedef bool (*NPN_EnumerateProcPtr)(NPP npp,
+ NPObject *obj,
+ NPIdentifier **identifier,
+ uint32_t *count);
+typedef void (*NPN_PluginThreadAsyncCallProcPtr)(NPP instance,
+ void (*func)(void *),
+ void *userData);
+typedef bool (*NPN_ConstructProcPtr)(NPP npp,
+ NPObject* obj,
+ const NPVariant *args,
+ uint32_t argCount,
+ NPVariant *result);
+
+//
+// NPAPI Function table of NPP functions (functions provided by plugin to host)
+//
+typedef struct _NPPluginFuncs {
+ unsigned short size;
+ unsigned short version;
+ NPP_NewProcPtr newp;
+ NPP_DestroyProcPtr destroy;
+ NPP_SetWindowProcPtr setwindow;
+ NPP_NewStreamProcPtr newstream;
+ NPP_DestroyStreamProcPtr destroystream;
+ NPP_StreamAsFileProcPtr asfile;
+ NPP_WriteReadyProcPtr writeready;
+ NPP_WriteProcPtr write;
+ NPP_PrintProcPtr print;
+ NPP_HandleEventProcPtr event;
+ NPP_URLNotifyProcPtr urlnotify;
+ JRIGlobalRef javaClass;
+ NPP_GetValueProcPtr getvalue;
+ NPP_SetValueProcPtr setvalue;
+} NPPluginFuncs;
+
+//
+// NPAPI Function table NPN functions (functions provided by host to plugin)
+//
+typedef struct _NPNetscapeFuncs {
+ uint16 size;
+ uint16 version;
+ NPN_GetURLProcPtr geturl;
+ NPN_PostURLProcPtr posturl;
+ NPN_RequestReadProcPtr requestread;
+ NPN_NewStreamProcPtr newstream;
+ NPN_WriteProcPtr write;
+ NPN_DestroyStreamProcPtr destroystream;
+ NPN_StatusProcPtr status;
+ NPN_UserAgentProcPtr uagent;
+ NPN_MemAllocProcPtr memalloc;
+ NPN_MemFreeProcPtr memfree;
+ NPN_MemFlushProcPtr memflush;
+ NPN_ReloadPluginsProcPtr reloadplugins;
+ NPN_GetJavaEnvProcPtr getJavaEnv;
+ NPN_GetJavaPeerProcPtr getJavaPeer;
+ NPN_GetURLNotifyProcPtr geturlnotify;
+ NPN_PostURLNotifyProcPtr posturlnotify;
+ NPN_GetValueProcPtr getvalue;
+ NPN_SetValueProcPtr setvalue;
+ NPN_InvalidateRectProcPtr invalidaterect;
+ NPN_InvalidateRegionProcPtr invalidateregion;
+ NPN_ForceRedrawProcPtr forceredraw;
+
+ NPN_GetStringIdentifierProcPtr getstringidentifier;
+ NPN_GetStringIdentifiersProcPtr getstringidentifiers;
+ NPN_GetIntIdentifierProcPtr getintidentifier;
+ NPN_IdentifierIsStringProcPtr identifierisstring;
+ NPN_UTF8FromIdentifierProcPtr utf8fromidentifier;
+ NPN_IntFromIdentifierProcPtr intfromidentifier;
+ NPN_CreateObjectProcPtr createobject;
+ NPN_RetainObjectProcPtr retainobject;
+ NPN_ReleaseObjectProcPtr releaseobject;
+ NPN_InvokeProcPtr invoke;
+ NPN_InvokeDefaultProcPtr invokeDefault;
+ NPN_EvaluateProcPtr evaluate;
+ NPN_GetPropertyProcPtr getproperty;
+ NPN_SetPropertyProcPtr setproperty;
+ NPN_RemovePropertyProcPtr removeproperty;
+ NPN_HasPropertyProcPtr hasproperty;
+ NPN_HasMethodProcPtr hasmethod;
+ NPN_ReleaseVariantValueProcPtr releasevariantvalue;
+ NPN_SetExceptionProcPtr setexception;
+ NPN_PushPopupsEnabledStateProcPtr pushpopupsenabledstate;
+ NPN_PopPopupsEnabledStateProcPtr poppopupsenabledstate;
+ NPN_EnumerateProcPtr enumerate;
+ NPN_PluginThreadAsyncCallProcPtr pluginthreadasynccall;
+ NPN_ConstructProcPtr construct;
+} NPNetscapeFuncs;
+
+//
+// NPAPI library entry points
+//
+#if defined(OS_LINUX)
+typedef NPError (API_CALL * NP_InitializeFunc)(NPNetscapeFuncs* pNFuncs,
+ NPPluginFuncs* pPFuncs);
+#else
+typedef NPError (API_CALL * NP_InitializeFunc)(NPNetscapeFuncs* pFuncs);
+typedef NPError (API_CALL * NP_GetEntryPointsFunc)(NPPluginFuncs* pFuncs);
+#endif
+typedef NPError (API_CALL * NP_ShutdownFunc)(void);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // WEBKIT_GLUE_PLUGIN_NPHOSTAPI_H__
diff --git a/npapi-plugin/zeitgeist.js b/npapi-plugin/zeitgeist.js
new file mode 100644
index 0000000..0e50ef4
--- /dev/null
+++ b/npapi-plugin/zeitgeist.js
@@ -0,0 +1,41 @@
+var plugin = document.embeds[0];
+
+function onTabCreated (tab) {
+}
+
+function onTabRemoved (tabid) {
+ // TODO: unfocus event?
+}
+
+function onTabUpdated (tabid, changeInfo, tab) {
+ if (changeInfo.status == "complete") {
+ /* FIXME:
+ * What is this good for when it can't give us more info
+ * than what we already have here in 'tab'?
+ *
+ * At least we can try to use it to get rid of multiple events
+ * for just one webpage...
+ */
+ chrome.tabs.executeScript(tabid, {file: "content_script.js"});
+ }
+}
+
+function onExtensionConnect (port) {
+ port.onMessage.addListener(
+ function(message) {
+ var url = message.url;
+ var mimetype = message.mimeType;
+ var title = message.title;
+ plugin.insertEvent(url,
+ mimetype ? mimetype : "text/html",
+ title);
+ }
+ );
+}
+
+chrome.tabs.onUpdated.addListener (onTabUpdated);
+chrome.tabs.onCreated.addListener (onTabCreated);
+chrome.tabs.onRemoved.addListener (onTabRemoved);
+chrome.extension.onConnect.addListener (onExtensionConnect);
+
+plugin.setActor("application://google-chrome.desktop");