Merge lp:~webapps/unity-chromium-extension/staging into lp:unity-chromium-extension

Proposed by David Barth on 2014-06-17
Status: Merged
Approved by: Alexandre Abreu on 2014-07-09
Approved revision: 261
Merged at revision: 248
Proposed branch: lp:~webapps/unity-chromium-extension/staging
Merge into: lp:unity-chromium-extension
Diff against target: 25660 lines (+2595/-21107)
227 files modified
.bzrignore (+22/-1)
INSTALL (+0/-370)
Makefile.am (+0/-9)
Makefile.am.coverage (+0/-32)
README (+0/-1)
autogen.sh (+0/-157)
chromium-extension/Makefile.am (+0/-44)
chromium-extension/background-page.html (+0/-15)
chromium-extension/background-page.js (+251/-432)
chromium-extension/base-content-script.js (+1/-1)
chromium-extension/browser.js (+0/-154)
chromium-extension/chromium-extension.pro (+66/-0)
chromium-extension/infobar.js (+22/-18)
chromium-extension/manifest.json.in (+31/-41)
chromium-extension/unity-api-page-proxy-builder-gen.js (+0/-384)
chromium-extension/unity-api-page-proxy.js (+0/-146)
chromium-extension/unity-webapps.json.in (+2/-2)
chromium-extension/unity_api_page_proxy_generator.py (+0/-96)
common-project-config.pri (+41/-0)
common-vars.pri (+6/-0)
configure.ac (+0/-62)
coverage.pri (+49/-0)
debian/changelog (+6/-0)
debian/compat (+1/-1)
debian/control (+6/-10)
debian/copyright (+0/-45)
debian/rules (+6/-8)
debian/unity-chromium-extension.install (+4/-0)
m4/gcov.m4 (+0/-79)
messaging-host/Makefile.am (+2/-0)
messaging-host/com.canonical.webapp.installer.json.in (+9/-0)
messaging-host/connection.cpp (+152/-0)
messaging-host/connection.h (+52/-0)
messaging-host/inactivity-timer.cpp (+65/-0)
messaging-host/inactivity-timer.h (+56/-0)
messaging-host/main.cpp (+91/-0)
messaging-host/messaging-host.pro (+42/-0)
messaging-host/service.cpp (+120/-0)
messaging-host/service.h (+56/-0)
messaging-host/webapps-handler.cpp (+324/-0)
messaging-host/webapps-handler.h (+59/-0)
messaging-host/webapps-process.cpp (+28/-0)
messaging-host/webapps-process.h (+37/-0)
npapi-binding-gen/bindinggen.py (+0/-203)
npapi-binding-gen/common_gen.py (+0/-9)
npapi-binding-gen/get_functions_to_generate.sh (+0/-5)
npapi-binding-gen/header_generator.py (+0/-23)
npapi-binding-gen/header_generator_test.py (+0/-18)
npapi-binding-gen/headers.py (+0/-25)
npapi-binding-gen/npapi_meta.py (+0/-104)
npapi-binding-gen/parser.py (+0/-168)
npapi-binding-gen/parser_test.py (+0/-25)
npapi-binding-gen/prepasses.py (+0/-42)
npapi-binding-gen/prepasses_test.py (+0/-13)
npapi-binding-gen/source_generator.py (+0/-213)
npapi-binding-gen/sources_gen_test.py (+0/-25)
npapi-binding-gen/tests/data/header-gen-data-1 (+0/-135)
npapi-binding-gen/tests/data/parser-data-1 (+0/-135)
npapi-binding-gen/tests/data/parser-data-1.result (+0/-50)
npapi-binding-gen/tests/data/pre-pass-cleanup-data-1 (+0/-62)
npapi-binding-gen/tests/data/pre-pass-cleanup-data-1.result (+0/-44)
npapi-binding-gen/tests/data/pre-pass-cleanup-data-2 (+0/-176)
npapi-binding-gen/tests/data/pre-pass-cleanup-data-2.result (+0/-143)
npapi-binding-gen/tests/data/source-gen-data-1 (+0/-135)
npapi-binding-gen/unittest_gen.py (+0/-126)
npapi-plugin/Makefile.am (+0/-7)
npapi-plugin/src/Makefile.am (+0/-68)
npapi-plugin/src/libunity_npapi_plugin-0.1.pc.in (+0/-13)
npapi-plugin/src/notify-binding.c (+0/-222)
npapi-plugin/src/notify-binding.h (+0/-36)
npapi-plugin/src/npapi-headers/headers/npapi.h (+0/-895)
npapi-plugin/src/npapi-headers/headers/npfunctions.h (+0/-322)
npapi-plugin/src/npapi-headers/headers/npruntime.h (+0/-393)
npapi-plugin/src/npapi-headers/headers/nptypes.h (+0/-121)
npapi-plugin/src/unity-npapi-binding-utils.c (+0/-81)
npapi-plugin/src/unity-npapi-binding-utils.h (+0/-76)
npapi-plugin/src/unity-npapi-common.h (+0/-61)
npapi-plugin/src/unity-npapi-debug.h (+0/-36)
npapi-plugin/src/unity-npapi-plugin-entry-funcs.c (+0/-118)
npapi-plugin/src/unity-npapi-plugin-entry-funcs.h (+0/-41)
npapi-plugin/src/unity-npapi-plugin-npn-funcs.c (+0/-426)
npapi-plugin/src/unity-npapi-plugin-npn-funcs.h (+0/-32)
npapi-plugin/src/unity-npapi-plugin-pp-funcs.c (+0/-283)
npapi-plugin/src/unity-npapi-plugin-pp-funcs.h (+0/-81)
npapi-plugin/src/unity-npapi-plugin.c (+0/-188)
npapi-plugin/src/unity-npapi-plugin.h (+0/-72)
npapi-plugin/src/unity-npapi-tools.c (+0/-97)
npapi-plugin/src/unity-npapi-tools.h (+0/-30)
npapi-plugin/src/unity-webapps-base-js-object.c (+0/-564)
npapi-plugin/src/unity-webapps-base-js-object.h (+0/-84)
npapi-plugin/src/unity-webapps-binding-dispatcher.c (+0/-368)
npapi-plugin/src/unity-webapps-binding-dispatcher.h (+0/-47)
npapi-plugin/src/unity-webapps-binding-test.c (+0/-27)
npapi-plugin/src/unity-webapps-binding-test.h (+0/-11)
npapi-plugin/src/unity-webapps-binding.c (+0/-3127)
npapi-plugin/src/unity-webapps-binding.h (+0/-424)
npapi-plugin/src/unity-webapps-repository-binding.c (+0/-541)
npapi-plugin/src/unity-webapps-repository-binding.h (+0/-89)
npapi-plugin/src/unity-webapps-scriptable-object.c (+0/-91)
npapi-plugin/src/unity-webapps-scriptable-object.h (+0/-46)
npapi-plugin/src/wrapped-callback-type.c (+0/-174)
npapi-plugin/src/wrapped-callback-type.h (+0/-53)
npapi-plugin/src/wrapped-ptr-type.c (+0/-215)
npapi-plugin/src/wrapped-ptr-type.h (+0/-45)
tests/Makefile.am (+0/-1)
tests/functional/npapi/context_new_lazy_test/background-page.html (+0/-72)
tests/functional/npapi/context_new_lazy_test/manifest.json (+0/-21)
tests/functional/npapi/driver.py (+0/-32)
tests/tests.pro (+3/-0)
tests/unit/Makefile.am (+0/-1)
tests/unit/messaging-host/connection-host.cpp (+71/-0)
tests/unit/messaging-host/messaging-host.pri (+9/-0)
tests/unit/messaging-host/messaging-host.pro (+12/-0)
tests/unit/messaging-host/tst_connection.cpp (+112/-0)
tests/unit/messaging-host/tst_connection.pro (+14/-0)
tests/unit/messaging-host/tst_connection_host.pro (+14/-0)
tests/unit/messaging-host/tst_inactivity_timer.cpp (+125/-0)
tests/unit/messaging-host/tst_inactivity_timer.pro (+18/-0)
tests/unit/messaging-host/tst_service.cpp (+189/-0)
tests/unit/messaging-host/tst_service.pro (+18/-0)
tests/unit/messaging-host/tst_webapps-handler.cpp (+354/-0)
tests/unit/messaging-host/tst_webapps-handler.pro (+32/-0)
tests/unit/npapi/Makefile.am (+0/-528)
tests/unit/npapi/context-add-application-actions-test.c (+0/-149)
tests/unit/npapi/context-add-application-actions-test.h (+0/-6)
tests/unit/npapi/context-add-icon-test.c (+0/-149)
tests/unit/npapi/context-add-icon-test.h (+0/-6)
tests/unit/npapi/context-destroy-test.c (+0/-116)
tests/unit/npapi/context-destroy-test.h (+0/-6)
tests/unit/npapi/context-get-domain-test.c (+0/-102)
tests/unit/npapi/context-get-domain-test.h (+0/-6)
tests/unit/npapi/context-get-interest-id-test.c (+0/-102)
tests/unit/npapi/context-get-interest-id-test.h (+0/-6)
tests/unit/npapi/context-get-name-test.c (+0/-102)
tests/unit/npapi/context-get-name-test.h (+0/-6)
tests/unit/npapi/context-new-lazy-test.c (+0/-175)
tests/unit/npapi/context-new-lazy-test.h (+0/-6)
tests/unit/npapi/context-on-close-callback-test.c (+0/-149)
tests/unit/npapi/context-on-close-callback-test.h (+0/-6)
tests/unit/npapi/context-on-raise-callback-test.c (+0/-149)
tests/unit/npapi/context-on-raise-callback-test.h (+0/-6)
tests/unit/npapi/context-prepare-test.c (+0/-149)
tests/unit/npapi/context-prepare-test.h (+0/-6)
tests/unit/npapi/context-remove-application-action-test.c (+0/-125)
tests/unit/npapi/context-remove-application-action-test.h (+0/-6)
tests/unit/npapi/context-remove-application-actions-test.c (+0/-102)
tests/unit/npapi/context-remove-application-actions-test.h (+0/-6)
tests/unit/npapi/context-set-homepage-test.c (+0/-125)
tests/unit/npapi/context-set-homepage-test.h (+0/-6)
tests/unit/npapi/context-set-preview-requested-callback-test.c (+0/-149)
tests/unit/npapi/context-set-preview-requested-callback-test.h (+0/-6)
tests/unit/npapi/context-set-view-is-active-test.c (+0/-125)
tests/unit/npapi/context-set-view-is-active-test.h (+0/-6)
tests/unit/npapi/context-set-view-location-test.c (+0/-125)
tests/unit/npapi/context-set-view-location-test.h (+0/-6)
tests/unit/npapi/indicator-add-action-test.c (+0/-174)
tests/unit/npapi/indicator-add-action-test.h (+0/-6)
tests/unit/npapi/indicator-clear-indicator-test.c (+0/-125)
tests/unit/npapi/indicator-clear-indicator-test.h (+0/-6)
tests/unit/npapi/indicator-clear-indicators-test.c (+0/-102)
tests/unit/npapi/indicator-clear-indicators-test.h (+0/-6)
tests/unit/npapi/indicator-set-callback-test.c (+0/-174)
tests/unit/npapi/indicator-set-callback-test.h (+0/-6)
tests/unit/npapi/indicator-set-property-icon-test.c (+0/-174)
tests/unit/npapi/indicator-set-property-icon-test.h (+0/-6)
tests/unit/npapi/indicator-set-property-test.c (+0/-174)
tests/unit/npapi/indicator-set-property-test.h (+0/-6)
tests/unit/npapi/indicator-show-indicator-test.c (+0/-125)
tests/unit/npapi/indicator-show-indicator-test.h (+0/-6)
tests/unit/npapi/launcher-add-action-test.c (+0/-174)
tests/unit/npapi/launcher-add-action-test.h (+0/-6)
tests/unit/npapi/launcher-add-static-action-test.c (+0/-149)
tests/unit/npapi/launcher-add-static-action-test.h (+0/-6)
tests/unit/npapi/launcher-clear-count-test.c (+0/-102)
tests/unit/npapi/launcher-clear-count-test.h (+0/-6)
tests/unit/npapi/launcher-clear-progress-test.c (+0/-102)
tests/unit/npapi/launcher-clear-progress-test.h (+0/-6)
tests/unit/npapi/launcher-remove-action-test.c (+0/-125)
tests/unit/npapi/launcher-remove-action-test.h (+0/-6)
tests/unit/npapi/launcher-remove-actions-test.c (+0/-102)
tests/unit/npapi/launcher-remove-actions-test.h (+0/-6)
tests/unit/npapi/launcher-remove-static-actions-test.c (+0/-102)
tests/unit/npapi/launcher-remove-static-actions-test.h (+0/-6)
tests/unit/npapi/launcher-set-count-test.c (+0/-125)
tests/unit/npapi/launcher-set-count-test.h (+0/-6)
tests/unit/npapi/launcher-set-progress-test.c (+0/-125)
tests/unit/npapi/launcher-set-progress-test.h (+0/-6)
tests/unit/npapi/launcher-set-urgent-test.c (+0/-102)
tests/unit/npapi/launcher-set-urgent-test.h (+0/-6)
tests/unit/npapi/music-player-get-can-go-next-test.c (+0/-102)
tests/unit/npapi/music-player-get-can-go-next-test.h (+0/-6)
tests/unit/npapi/music-player-get-can-go-previous-test.c (+0/-102)
tests/unit/npapi/music-player-get-can-go-previous-test.h (+0/-6)
tests/unit/npapi/music-player-get-can-pause-test.c (+0/-102)
tests/unit/npapi/music-player-get-can-pause-test.h (+0/-6)
tests/unit/npapi/music-player-get-can-play-test.c (+0/-102)
tests/unit/npapi/music-player-get-can-play-test.h (+0/-6)
tests/unit/npapi/music-player-get-playback-state-test.c (+0/-102)
tests/unit/npapi/music-player-get-playback-state-test.h (+0/-6)
tests/unit/npapi/music-player-init-test.c (+0/-125)
tests/unit/npapi/music-player-init-test.h (+0/-6)
tests/unit/npapi/music-player-on-next-callback-test.c (+0/-149)
tests/unit/npapi/music-player-on-next-callback-test.h (+0/-6)
tests/unit/npapi/music-player-on-play-pause-callback-test.c (+0/-149)
tests/unit/npapi/music-player-on-play-pause-callback-test.h (+0/-6)
tests/unit/npapi/music-player-on-previous-callback-test.c (+0/-149)
tests/unit/npapi/music-player-on-previous-callback-test.h (+0/-6)
tests/unit/npapi/music-player-set-can-go-next-test.c (+0/-125)
tests/unit/npapi/music-player-set-can-go-next-test.h (+0/-6)
tests/unit/npapi/music-player-set-can-go-previous-test.c (+0/-125)
tests/unit/npapi/music-player-set-can-go-previous-test.h (+0/-6)
tests/unit/npapi/music-player-set-can-pause-test.c (+0/-125)
tests/unit/npapi/music-player-set-can-pause-test.h (+0/-6)
tests/unit/npapi/music-player-set-can-play-test.c (+0/-125)
tests/unit/npapi/music-player-set-can-play-test.h (+0/-6)
tests/unit/npapi/music-player-set-playback-state-test.c (+0/-125)
tests/unit/npapi/music-player-set-playback-state-test.h (+0/-6)
tests/unit/npapi/music-player-set-track-test.c (+0/-200)
tests/unit/npapi/music-player-set-track-test.h (+0/-6)
tests/unit/npapi/notification-show-notification-test.c (+0/-174)
tests/unit/npapi/notification-show-notification-test.h (+0/-6)
tests/unit/npapi/permissions-is-integration-allowed-test.c (+0/-80)
tests/unit/npapi/permissions-is-integration-allowed-test.h (+0/-6)
tests/unit/npapi/test_common.c (+0/-27)
tests/unit/npapi/test_common.h (+0/-23)
tests/unit/unit.pro (+3/-0)
unity-chromium-extension.pro (+14/-0)
To merge this branch: bzr merge lp:~webapps/unity-chromium-extension/staging
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve on 2014-07-09
Robert Bruce Park (community) packaging 2014-06-17 Approve on 2014-06-18
Review via email: mp+223349@code.launchpad.net

Commit message

Port of the Unity Chrome Extension to the new Native Messaging API (the old NPAPI interface has now been deprecated by Chromium upstream)

Description of the change

Port of the Unity Chrome Extension to the new Native Messaging API (the old NPAPI interface has now been deprecated by Chromium upstream)

To post a comment you must log in.
257. By Justin McPherson on 2014-06-18

Fixup build-depends

Robert Bruce Park (robru) wrote :

See inline comments below.

review: Needs Fixing
258. By Justin McPherson on 2014-06-18

Changed version of debhelper

Robert Bruce Park (robru) wrote :

Ok, diff looks good to me now, we'll see how it builds.

review: Approve (packaging)
Robert Bruce Park (robru) wrote :

(well, you can delete the FIXME comment ;-)

259. By Justin McPherson on 2014-06-18

Remove no longer relevant comment

260. By Alberto Mardegan on 2014-06-26

Make sure the webapp indexing process is run

261. By Alexandre Abreu on 2014-07-09

add back chromium browser deps as way to make sure that we only build on archs that have chromium as an install package

262. By Justin McPherson on 2014-07-22

Change to no-argument form of toJson().

Other form not available in 5.0.x.

263. By Justin McPherson <justin@phablet-dev> on 2014-11-18

Match changes in extension API.

264. By Justin McPherson <justin@phablet-dev> on 2014-11-18

Match changes in extension API (fix).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2012-03-16 12:42:18 +0000
+++ .bzrignore 2014-11-18 07:07:55 +0000
@@ -1,2 +1,23 @@
1*.log
2*.moc
3*.substvars
1Makefile4Makefile
2Makefile.in5Makefile.*
6moc_*.cpp
7/chromium-extension/build/
8/chromium-extension/buildstamp
9/chromium-extension/manifest.json
10/chromium-extension/res/
11/chromium-extension/unity-webapps/
12/chromium-extension/unity-webapps.crx
13/chromium-extension/unity-webapps.json
14/chromium-extension/unity-webapps.pem
15/debian/files
16/debian/tmp
17/debian/unity-chromium-extension/
18/messaging-host/com.canonical.webapp.installer.json
19/messaging-host/unity-webapps-messaging-host
20/tests/unit/messaging-host/connection-host
21/tests/unit/messaging-host/tst_connection
22/tests/unit/messaging-host/tst_inactivity_timer
23/tests/unit/messaging-host/tst_service
324
=== removed file 'AUTHORS'
=== removed file 'ChangeLog'
=== removed file 'INSTALL'
--- INSTALL 2012-06-02 00:56:28 +0000
+++ INSTALL 1970-01-01 00:00:00 +0000
@@ -1,370 +0,0 @@
1Installation Instructions
2*************************
3
4Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation,
5Inc.
6
7 Copying and distribution of this file, with or without modification,
8are permitted in any medium without royalty provided the copyright
9notice and this notice are preserved. This file is offered as-is,
10without warranty of any kind.
11
12Basic Installation
13==================
14
15 Briefly, the shell commands `./configure; make; make install' should
16configure, build, and install this package. The following
17more-detailed instructions are generic; see the `README' file for
18instructions specific to this package. Some packages provide this
19`INSTALL' file but do not implement all of the features documented
20below. The lack of an optional feature in a given package is not
21necessarily a bug. More recommendations for GNU packages can be found
22in *note Makefile Conventions: (standards)Makefile Conventions.
23
24 The `configure' shell script attempts to guess correct values for
25various system-dependent variables used during compilation. It uses
26those values to create a `Makefile' in each directory of the package.
27It may also create one or more `.h' files containing system-dependent
28definitions. Finally, it creates a shell script `config.status' that
29you can run in the future to recreate the current configuration, and a
30file `config.log' containing compiler output (useful mainly for
31debugging `configure').
32
33 It can also use an optional file (typically called `config.cache'
34and enabled with `--cache-file=config.cache' or simply `-C') that saves
35the results of its tests to speed up reconfiguring. Caching is
36disabled by default to prevent problems with accidental use of stale
37cache files.
38
39 If you need to do unusual things to compile the package, please try
40to figure out how `configure' could check whether to do them, and mail
41diffs or instructions to the address given in the `README' so they can
42be considered for the next release. If you are using the cache, and at
43some point `config.cache' contains results you don't want to keep, you
44may remove or edit it.
45
46 The file `configure.ac' (or `configure.in') is used to create
47`configure' by a program called `autoconf'. You need `configure.ac' if
48you want to change it or regenerate `configure' using a newer version
49of `autoconf'.
50
51 The simplest way to compile this package is:
52
53 1. `cd' to the directory containing the package's source code and type
54 `./configure' to configure the package for your system.
55
56 Running `configure' might take a while. While running, it prints
57 some messages telling which features it is checking for.
58
59 2. Type `make' to compile the package.
60
61 3. Optionally, type `make check' to run any self-tests that come with
62 the package, generally using the just-built uninstalled binaries.
63
64 4. Type `make install' to install the programs and any data files and
65 documentation. When installing into a prefix owned by root, it is
66 recommended that the package be configured and built as a regular
67 user, and only the `make install' phase executed with root
68 privileges.
69
70 5. Optionally, type `make installcheck' to repeat any self-tests, but
71 this time using the binaries in their final installed location.
72 This target does not install anything. Running this target as a
73 regular user, particularly if the prior `make install' required
74 root privileges, verifies that the installation completed
75 correctly.
76
77 6. You can remove the program binaries and object files from the
78 source code directory by typing `make clean'. To also remove the
79 files that `configure' created (so you can compile the package for
80 a different kind of computer), type `make distclean'. There is
81 also a `make maintainer-clean' target, but that is intended mainly
82 for the package's developers. If you use it, you may have to get
83 all sorts of other programs in order to regenerate files that came
84 with the distribution.
85
86 7. Often, you can also type `make uninstall' to remove the installed
87 files again. In practice, not all packages have tested that
88 uninstallation works correctly, even though it is required by the
89 GNU Coding Standards.
90
91 8. Some packages, particularly those that use Automake, provide `make
92 distcheck', which can by used by developers to test that all other
93 targets like `make install' and `make uninstall' work correctly.
94 This target is generally not run by end users.
95
96Compilers and Options
97=====================
98
99 Some systems require unusual options for compilation or linking that
100the `configure' script does not know about. Run `./configure --help'
101for details on some of the pertinent environment variables.
102
103 You can give `configure' initial values for configuration parameters
104by setting variables in the command line or in the environment. Here
105is an example:
106
107 ./configure CC=c99 CFLAGS=-g LIBS=-lposix
108
109 *Note Defining Variables::, for more details.
110
111Compiling For Multiple Architectures
112====================================
113
114 You can compile the package for more than one kind of computer at the
115same time, by placing the object files for each architecture in their
116own directory. To do this, you can use GNU `make'. `cd' to the
117directory where you want the object files and executables to go and run
118the `configure' script. `configure' automatically checks for the
119source code in the directory that `configure' is in and in `..'. This
120is known as a "VPATH" build.
121
122 With a non-GNU `make', it is safer to compile the package for one
123architecture at a time in the source code directory. After you have
124installed the package for one architecture, use `make distclean' before
125reconfiguring for another architecture.
126
127 On MacOS X 10.5 and later systems, you can create libraries and
128executables that work on multiple system types--known as "fat" or
129"universal" binaries--by specifying multiple `-arch' options to the
130compiler but only a single `-arch' option to the preprocessor. Like
131this:
132
133 ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
134 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
135 CPP="gcc -E" CXXCPP="g++ -E"
136
137 This is not guaranteed to produce working output in all cases, you
138may have to build one architecture at a time and combine the results
139using the `lipo' tool if you have problems.
140
141Installation Names
142==================
143
144 By default, `make install' installs the package's commands under
145`/usr/local/bin', include files under `/usr/local/include', etc. You
146can specify an installation prefix other than `/usr/local' by giving
147`configure' the option `--prefix=PREFIX', where PREFIX must be an
148absolute file name.
149
150 You can specify separate installation prefixes for
151architecture-specific files and architecture-independent files. If you
152pass the option `--exec-prefix=PREFIX' to `configure', the package uses
153PREFIX as the prefix for installing programs and libraries.
154Documentation and other data files still use the regular prefix.
155
156 In addition, if you use an unusual directory layout you can give
157options like `--bindir=DIR' to specify different values for particular
158kinds of files. Run `configure --help' for a list of the directories
159you can set and what kinds of files go in them. In general, the
160default for these options is expressed in terms of `${prefix}', so that
161specifying just `--prefix' will affect all of the other directory
162specifications that were not explicitly provided.
163
164 The most portable way to affect installation locations is to pass the
165correct locations to `configure'; however, many packages provide one or
166both of the following shortcuts of passing variable assignments to the
167`make install' command line to change installation locations without
168having to reconfigure or recompile.
169
170 The first method involves providing an override variable for each
171affected directory. For example, `make install
172prefix=/alternate/directory' will choose an alternate location for all
173directory configuration variables that were expressed in terms of
174`${prefix}'. Any directories that were specified during `configure',
175but not in terms of `${prefix}', must each be overridden at install
176time for the entire installation to be relocated. The approach of
177makefile variable overrides for each directory variable is required by
178the GNU Coding Standards, and ideally causes no recompilation.
179However, some platforms have known limitations with the semantics of
180shared libraries that end up requiring recompilation when using this
181method, particularly noticeable in packages that use GNU Libtool.
182
183 The second method involves providing the `DESTDIR' variable. For
184example, `make install DESTDIR=/alternate/directory' will prepend
185`/alternate/directory' before all installation names. The approach of
186`DESTDIR' overrides is not required by the GNU Coding Standards, and
187does not work on platforms that have drive letters. On the other hand,
188it does better at avoiding recompilation issues, and works well even
189when some directory options were not specified in terms of `${prefix}'
190at `configure' time.
191
192Optional Features
193=================
194
195 If the package supports it, you can cause programs to be installed
196with an extra prefix or suffix on their names by giving `configure' the
197option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
198
199 Some packages pay attention to `--enable-FEATURE' options to
200`configure', where FEATURE indicates an optional part of the package.
201They may also pay attention to `--with-PACKAGE' options, where PACKAGE
202is something like `gnu-as' or `x' (for the X Window System). The
203`README' should mention any `--enable-' and `--with-' options that the
204package recognizes.
205
206 For packages that use the X Window System, `configure' can usually
207find the X include and library files automatically, but if it doesn't,
208you can use the `configure' options `--x-includes=DIR' and
209`--x-libraries=DIR' to specify their locations.
210
211 Some packages offer the ability to configure how verbose the
212execution of `make' will be. For these packages, running `./configure
213--enable-silent-rules' sets the default to minimal output, which can be
214overridden with `make V=1'; while running `./configure
215--disable-silent-rules' sets the default to verbose, which can be
216overridden with `make V=0'.
217
218Particular systems
219==================
220
221 On HP-UX, the default C compiler is not ANSI C compatible. If GNU
222CC is not installed, it is recommended to use the following options in
223order to use an ANSI C compiler:
224
225 ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
226
227and if that doesn't work, install pre-built binaries of GCC for HP-UX.
228
229 HP-UX `make' updates targets which have the same time stamps as
230their prerequisites, which makes it generally unusable when shipped
231generated files such as `configure' are involved. Use GNU `make'
232instead.
233
234 On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
235parse its `<wchar.h>' header file. The option `-nodtk' can be used as
236a workaround. If GNU CC is not installed, it is therefore recommended
237to try
238
239 ./configure CC="cc"
240
241and if that doesn't work, try
242
243 ./configure CC="cc -nodtk"
244
245 On Solaris, don't put `/usr/ucb' early in your `PATH'. This
246directory contains several dysfunctional programs; working variants of
247these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
248in your `PATH', put it _after_ `/usr/bin'.
249
250 On Haiku, software installed for all users goes in `/boot/common',
251not `/usr/local'. It is recommended to use the following options:
252
253 ./configure --prefix=/boot/common
254
255Specifying the System Type
256==========================
257
258 There may be some features `configure' cannot figure out
259automatically, but needs to determine by the type of machine the package
260will run on. Usually, assuming the package is built to be run on the
261_same_ architectures, `configure' can figure that out, but if it prints
262a message saying it cannot guess the machine type, give it the
263`--build=TYPE' option. TYPE can either be a short name for the system
264type, such as `sun4', or a canonical name which has the form:
265
266 CPU-COMPANY-SYSTEM
267
268where SYSTEM can have one of these forms:
269
270 OS
271 KERNEL-OS
272
273 See the file `config.sub' for the possible values of each field. If
274`config.sub' isn't included in this package, then this package doesn't
275need to know the machine type.
276
277 If you are _building_ compiler tools for cross-compiling, you should
278use the option `--target=TYPE' to select the type of system they will
279produce code for.
280
281 If you want to _use_ a cross compiler, that generates code for a
282platform different from the build platform, you should specify the
283"host" platform (i.e., that on which the generated programs will
284eventually be run) with `--host=TYPE'.
285
286Sharing Defaults
287================
288
289 If you want to set default values for `configure' scripts to share,
290you can create a site shell script called `config.site' that gives
291default values for variables like `CC', `cache_file', and `prefix'.
292`configure' looks for `PREFIX/share/config.site' if it exists, then
293`PREFIX/etc/config.site' if it exists. Or, you can set the
294`CONFIG_SITE' environment variable to the location of the site script.
295A warning: not all `configure' scripts look for a site script.
296
297Defining Variables
298==================
299
300 Variables not defined in a site shell script can be set in the
301environment passed to `configure'. However, some packages may run
302configure again during the build, and the customized values of these
303variables may be lost. In order to avoid this problem, you should set
304them in the `configure' command line, using `VAR=value'. For example:
305
306 ./configure CC=/usr/local2/bin/gcc
307
308causes the specified `gcc' to be used as the C compiler (unless it is
309overridden in the site shell script).
310
311Unfortunately, this technique does not work for `CONFIG_SHELL' due to
312an Autoconf bug. Until the bug is fixed you can use this workaround:
313
314 CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
315
316`configure' Invocation
317======================
318
319 `configure' recognizes the following options to control how it
320operates.
321
322`--help'
323`-h'
324 Print a summary of all of the options to `configure', and exit.
325
326`--help=short'
327`--help=recursive'
328 Print a summary of the options unique to this package's
329 `configure', and exit. The `short' variant lists options used
330 only in the top level, while the `recursive' variant lists options
331 also present in any nested packages.
332
333`--version'
334`-V'
335 Print the version of Autoconf used to generate the `configure'
336 script, and exit.
337
338`--cache-file=FILE'
339 Enable the cache: use and save the results of the tests in FILE,
340 traditionally `config.cache'. FILE defaults to `/dev/null' to
341 disable caching.
342
343`--config-cache'
344`-C'
345 Alias for `--cache-file=config.cache'.
346
347`--quiet'
348`--silent'
349`-q'
350 Do not print messages saying which checks are being made. To
351 suppress all normal output, redirect it to `/dev/null' (any error
352 messages will still be shown).
353
354`--srcdir=DIR'
355 Look for the package's source code in directory DIR. Usually
356 `configure' can determine that directory automatically.
357
358`--prefix=DIR'
359 Use DIR as the installation prefix. *note Installation Names::
360 for more details, including other options available for fine-tuning
361 the installation locations.
362
363`--no-create'
364`-n'
365 Run the configure checks, but stop before creating any output
366 files.
367
368`configure' also accepts some other, not widely useful, options. Run
369`configure --help' for more details.
370
3710
=== removed file 'Makefile.am'
--- Makefile.am 2012-10-01 23:03:21 +0000
+++ Makefile.am 1970-01-01 00:00:00 +0000
@@ -1,9 +0,0 @@
1SUBDIRS = npapi-plugin chromium-extension tests po
2
3CLEANFILES = unity-webapps.pem
4
5DISTCHECK_CONFIGURE_FLAGS=--enable-tests=yes
6
7EXTRA_DIST = autogen.sh
8
9include $(top_srcdir)/Makefile.am.coverage
100
=== removed file 'Makefile.am.coverage'
--- Makefile.am.coverage 2012-11-29 17:44:47 +0000
+++ Makefile.am.coverage 1970-01-01 00:00:00 +0000
@@ -1,32 +0,0 @@
1
2# Coverage targets
3
4if HAVE_GCOV
5
6.PHONY: clean-gcda
7clean-gcda:
8 @echo Removing old coverage results
9 -find -name '*.gcda' -print | xargs -r rm
10
11.PHONY: coverage-html generate-coverage-html clean-coverage-html
12coverage-html: clean-gcda
13 -$(MAKE) $(AM_MAKEFLAGS) -k check
14 $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html
15
16coverage-xml: clean-gcda
17 -$(MAKE) $(AM_MAKEFLAGS) -k check
18 gcovr --xml -r $(top_builddir) -o "$(top_builddir)/coverage.xml" --exclude='.*tests.*'
19
20generate-coverage-html:
21 @echo Collecting coverage data
22 $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool
23 $(LCOV) --extract coverage.info "`pwd`/npapi-plugin/src/*" --output-file coverage-src.info
24 LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coverage-html --title "Code Coverage" --legend --show-details coverage-src.info
25
26clean-coverage-html: clean-gcda
27 -$(LCOV) --directory $(top_builddir) -z
28 -rm -rf coverage.info coverage-src.info coverage-html
29
30clean-local: clean-coverage-html
31
32endif # HAVE_GCOV
330
=== removed file 'NEWS'
=== removed file 'README'
--- README 2012-11-14 20:26:07 +0000
+++ README 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1+
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'autogen.sh'
--- autogen.sh 2012-03-08 15:11:24 +0000
+++ autogen.sh 1970-01-01 00:00:00 +0000
@@ -1,157 +0,0 @@
1#!/bin/sh
2# Run this to generate all the initial makefiles, etc.
3
4srcdir=`dirname $0`
5test -z "$srcdir" && srcdir=.
6
7DIE=0
8
9if [ -n "$GNOME2_DIR" ]; then
10 ACLOCAL_FLAGS="-I $GNOME2_DIR/share/aclocal $ACLOCAL_FLAGS"
11 LD_LIBRARY_PATH="$GNOME2_DIR/lib:$LD_LIBRARY_PATH"
12 PATH="$GNOME2_DIR/bin:$PATH"
13 export PATH
14 export LD_LIBRARY_PATH
15fi
16
17(test -f $srcdir/configure.ac) || {
18 echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
19 echo " top-level package directory"
20 exit 1
21}
22
23(autoconf --version) < /dev/null > /dev/null 2>&1 || {
24 echo
25 echo "**Error**: You must have \`autoconf' installed."
26 echo "Download the appropriate package for your distribution,"
27 echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
28 DIE=1
29}
30
31(grep "^IT_PROG_INTLTOOL" $srcdir/configure.ac >/dev/null) && {
32 (intltoolize --version) < /dev/null > /dev/null 2>&1 || {
33 echo
34 echo "**Error**: You must have \`intltool' installed."
35 echo "You can get it from:"
36 echo " ftp://ftp.gnome.org/pub/GNOME/"
37 DIE=1
38 }
39}
40
41(grep "^AM_PROG_XML_I18N_TOOLS" $srcdir/configure.ac >/dev/null) && {
42 (xml-i18n-toolize --version) < /dev/null > /dev/null 2>&1 || {
43 echo
44 echo "**Error**: You must have \`xml-i18n-toolize' installed."
45 echo "You can get it from:"
46 echo " ftp://ftp.gnome.org/pub/GNOME/"
47 DIE=1
48 }
49}
50
51(grep "^LT_INIT" $srcdir/configure.ac >/dev/null) && {
52 (libtool --version) < /dev/null > /dev/null 2>&1 || {
53 echo
54 echo "**Error**: You must have \`libtool' installed."
55 echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/"
56 DIE=1
57 }
58}
59
60(grep "^AM_GLIB_GNU_GETTEXT" $srcdir/configure.ac >/dev/null) && {
61 (grep "sed.*POTFILES" $srcdir/configure.ac) > /dev/null || \
62 (glib-gettextize --version) < /dev/null > /dev/null 2>&1 || {
63 echo
64 echo "**Error**: You must have \`glib' installed."
65 echo "You can get it from: ftp://ftp.gtk.org/pub/gtk"
66 DIE=1
67 }
68}
69
70(automake --version) < /dev/null > /dev/null 2>&1 || {
71 echo
72 echo "**Error**: You must have \`automake' installed."
73 echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/"
74 DIE=1
75 NO_AUTOMAKE=yes
76}
77
78
79# if no automake, don't bother testing for aclocal
80test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || {
81 echo
82 echo "**Error**: Missing \`aclocal'. The version of \`automake'"
83 echo "installed doesn't appear recent enough."
84 echo "You can get automake from ftp://ftp.gnu.org/pub/gnu/"
85 DIE=1
86}
87
88if test "$DIE" -eq 1; then
89 exit 1
90fi
91
92if test -z "$*"; then
93 echo "**Warning**: I am going to run \`configure' with no arguments."
94 echo "If you wish to pass any to it, please specify them on the"
95 echo \`$0\'" command line."
96 echo
97fi
98
99case $CC in
100xlc )
101 am_opt=--include-deps;;
102esac
103
104for coin in `find $srcdir -path $srcdir/CVS -prune -o -name configure.ac -print`
105do
106 dr=`dirname $coin`
107 if test -f $dr/NO-AUTO-GEN; then
108 echo skipping $dr -- flagged as no auto-gen
109 else
110 echo processing $dr
111 ( cd $dr
112
113 aclocalinclude="$ACLOCAL_FLAGS"
114
115 if grep "^AM_GLIB_GNU_GETTEXT" configure.ac >/dev/null; then
116 echo "Creating $dr/aclocal.m4 ..."
117 test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
118 echo "Running glib-gettextize... Ignore non-fatal messages."
119 echo "no" | glib-gettextize --force --copy
120 echo "Making $dr/aclocal.m4 writable ..."
121 test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
122 fi
123 if grep "^IT_PROG_INTLTOOL" configure.ac >/dev/null; then
124 echo "Running intltoolize..."
125 intltoolize --copy --force --automake
126 fi
127 if grep "^AM_PROG_XML_I18N_TOOLS" configure.ac >/dev/null; then
128 echo "Running xml-i18n-toolize..."
129 xml-i18n-toolize --copy --force --automake
130 fi
131 if grep "^LT_INIT" configure.ac >/dev/null; then
132 if test -z "$NO_LIBTOOLIZE" ; then
133 echo "Running libtoolize..."
134 libtoolize --force --copy
135 fi
136 fi
137 echo "Running aclocal $aclocalinclude ..."
138 aclocal $aclocalinclude
139 if grep "^A[CM]_CONFIG_HEADER" configure.ac >/dev/null; then
140 echo "Running autoheader..."
141 autoheader
142 fi
143 echo "Running automake --gnu $am_opt ..."
144 automake --add-missing --gnu $am_opt
145 echo "Running autoconf ..."
146 autoconf
147 )
148 fi
149done
150
151if test x$NOCONFIGURE = x; then
152 echo Running $srcdir/configure "$@" ...
153 $srcdir/configure "$@" \
154 && echo Now type \`make\' to compile. || exit 1
155else
156 echo Skipping configure process.
157fi
1580
=== removed file 'chromium-extension/Makefile.am'
--- chromium-extension/Makefile.am 2013-12-16 07:15:32 +0000
+++ chromium-extension/Makefile.am 1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
1CLEANFILES = res/*
2EXTRA_DIST =
3
4extensiondir = $(libdir)/libunity-chromium
5extension_DATA=res/unity-webapps.crx
6
7
8clean-extension-package:
9 rm -f $(CLEANFILES)
10
11SCRIPT_FILES = \
12 $(shell ls *.css) \
13 $(shell ls *.html) \
14 $(shell ls *.js) \
15 $(shell ls skin/*) \
16 $(shell ls _locales/*/*)
17
18res/unity-webapps.crx: $(SCRIPT_FILES) unity-webapps.json manifest.json
19 cp -f $(top_builddir)/npapi-plugin/src/.libs/libunity_npapi_plugin.so .
20 if [ ! -f ../unity-webapps.pem ]; \
21 then \
22 openssl genrsa 1024 > ../unity-webapps.pem; \
23 fi
24 $(srcdir)/crxmake.sh $(abs_builddir) ../unity-webapps.pem
25 mv res/chromium-extension.crx res/unity-webapps.crx
26
27manifestdir = $(datadir)/chromium/extensions/
28manifest_DATA = $(shell ls $(top_builddir)/chromium-extension/res/*.json)
29
30%.json: %.json.in
31 sed -e "s|\@EXTDIR\@|$(extensiondir)/unity-webapps.crx|" $< | sed -e "s|\@VERSION\@|$(VERSION)|"> $@
32
33
34CLEANFILES += \
35 unity-webapps.json \
36 manifest.json \
37 libunity_npapi_plugin.so \
38 chromium-extension.crx
39
40EXTRA_DIST += \
41 unity-webapps.json.in \
42 manifest.json.in \
43 crxmake.sh \
44 $(SCRIPT_FILES)
450
=== added file 'chromium-extension/background-page.html'
--- chromium-extension/background-page.html 1970-01-01 00:00:00 +0000
+++ chromium-extension/background-page.html 2014-11-18 07:07:55 +0000
@@ -0,0 +1,15 @@
1<!doctype html>
2<html>
3 <head>
4
5 <title>Unity Webapps Extension Background Page</title>
6 <embed type="application/x-unity-webapps-npapi" id="unityChromiumExtensionId"/>
7
8 <script src="background-page.js"></script>
9
10 </head>
11
12 <body>
13 </body>
14
15</html>
016
=== removed file 'chromium-extension/background-page.html'
--- chromium-extension/background-page.html 2012-11-09 17:28:56 +0000
+++ chromium-extension/background-page.html 1970-01-01 00:00:00 +0000
@@ -1,15 +0,0 @@
1<!doctype html>
2<html>
3 <head>
4
5 <title>Unity Webapps Extension Background Page</title>
6 <embed type="application/x-unity-webapps-npapi" id="unityChromiumExtensionId"/>
7
8 <script src="background-page.js"></script>
9
10 </head>
11
12 <body>
13 </body>
14
15</html>
160
=== modified file 'chromium-extension/background-page.js'
--- chromium-extension/background-page.js 2014-02-20 00:33:36 +0000
+++ chromium-extension/background-page.js 2014-11-18 07:07:55 +0000
@@ -6,7 +6,7 @@
6 * under the terms of the GNU General Public License version 3, as published 6 * under the terms of the GNU General Public License version 3, as published
7 * by the Free Software Foundation.7 * by the Free Software Foundation.
8 *8 *
9 * This program is distributed in the hope that it will be useful, but 9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranties of 10 * WITHOUT ANY WARRANTY; without even the implied warranties of
11 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 11 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the GNU General Public License for more details.12 * PURPOSE. See the GNU General Public License for more details.
@@ -16,440 +16,259 @@
16 **/16 **/
1717
18var background_page = (function () {18var background_page = (function () {
1919 // Native messaging support
20 // TODO extract based on logging settings20 var HOST_ADDRESS = 'com.canonical.webapp.installer';
21 var log = {21 var port = null;
22 info: function (msg) {22 var host_callbacks = [];
23 if (msg) {23
24 console.log ('Info: ' + msg);24 var portListener = function (msg) {
25 }25 callback = host_callbacks.pop();
26 }26 if (callback === undefined) {
27 ,27 return;
28 error: function (msg) {28 }
29 if (msg) {29 callback(msg);
30 console.log ('Error: ' + msg);30 };
31 }31
32 }32 var portDisconnecter = function () {
33 };33 console.log('UCX: port disconnected');
3434 port = null
35 // connection & init w/ plugin NPAPI layer35 };
36 var plugin = document.getElementById ('unityChromiumExtensionId');36
37 if ( ! plugin) {37 var sendNativeMessage = function (msg, callback) {
38 log.error ("Unable to retrieve the Unity Chromium plugin");38 console.log("UCX: sendnativemessage: port=" + port);
39 return null;39 if (port === null) {
40 }40 port = chrome.runtime.connectNative(HOST_ADDRESS);
41 var service = plugin.service_new ();41 port.onMessage.addListener(portListener);
42 if (! service) {42 port.onDisconnect.addListener(portDisconnecter);
43 log.error ("Unable to retrieve a connection to Unity Webapps service");43 }
44 return null;44 host_callbacks.push(callback || function(m) {});
45 }45 port.postMessage(msg);
4646 };
4747
48 /////////////////////////////////////////////////////////48 // Wake server to catalogue webapps
49 // 49 sendNativeMessage({"method":"ping"});
50 // Handle login & connection to online-accounts project's50
51 // extension51
52 // 52 /////////////////////////////////////////////////////////
53 ////////////////////////////////////////////////////////53 //
54 var loginListeners = [];54 // Scafolding to keep track of data associated w/ infobar requests
55 var onLoginListenerRequest = function (request, sender, sendResponse) {55 // (Chromium's structure imposes some kind of state being maintained
56 if (request.action == "registerLoginListener") {56 // in order to communicate data)
57 log.info ("Login listener request from " + sender.id);57 //
58 loginListeners.push (sender.id);58 ////////////////////////////////////////////////////////
59 }59 //
60 };60 // list of callback that are to be called asynchronously
61 chrome.runtime.onMessageExternal.addListener (onLoginListenerRequest);61 // per tab. Used in the user integration/installation resquests context.
6262 //
63 var onLoginEvent = function (request, sender, sendResponse) {63 // One thing to keep in mind is that one constraint, that bring some amount of
64 if (request.action == "loginEvent") {64 // 'soundness' is that there is a hard limit (provided by the browser) of one infobar per tab.
65 log.info ("Login on " + request.domain + ": " + request.login);65
66 var len = loginListeners.length;66 var user_infobar_request_callbacks = {};
67 for (var i = 0; i < len; i++) {67 var addInfobarRequestCallbackFor = function (infobarRequestId, callback, message, details) {
68 var extensionId = loginListeners[i];68 user_infobar_request_callbacks[infobarRequestId] = {
69 log.info("Notifying login listener: " + extensionId);69 callback: callback,
70 chrome.runtime.sendMessage (extensionId, {70 message: message,
71 type: "login",71 details: details
72 login: request.login,72 };
73 domain: request.domain73 };
74 });74
75 }75 var getDataIfAnyFor = function (infobarRequestId) {
76 }76 if (user_infobar_request_callbacks[infobarRequestId] === undefined) {
77 };77 return "";
78 chrome.runtime.onMessage.addListener (onLoginEvent);78 }
7979 return {
8080 message: user_infobar_request_callbacks[infobarRequestId].message,
81 /////////////////////////////////////////////////////////81 details: user_infobar_request_callbacks[infobarRequestId].details
82 // 82 };
83 // Scafolding to keep track of data associated w/ infobar requests 83 };
84 // (Chromium's structure imposes some kind of state being maintained84
85 // in order to communicate data) 85 var invokeAndRemoveCallbackIfAnyFor = function (infobarRequestId, arguments) {
86 // 86 if (user_infobar_request_callbacks[infobarRequestId] === undefined) {
87 ////////////////////////////////////////////////////////87 return;
88 // 88 }
89 // list of callback that are to be called asynchronously89 var callback = user_infobar_request_callbacks[infobarRequestId].callback;
90 // per tab. Used in the user integration/installation resquests context.90 user_infobar_request_callbacks[infobarRequestId] = undefined;
91 // 91 if (typeof(callback) === 'function') {
92 // One thing to keep in mind is that one constraint, that bring some amount of92 callback(arguments);
93 // 'soundness' is that there is a hard limit (provided by the browser) of one infobar per tab.93 }
9494 };
95 var user_infobar_request_callbacks = {};95
96 var addInfobarRequestCallbackFor = function (infobarRequestId, callback, message, details) {96
97 user_infobar_request_callbacks[infobarRequestId] = {callback: callback97 /**
98 , message: message98 * Performs a match on the list of loaded integration scripts
99 , details: details99 * given a url.
100 };100 *
101 };101 */
102 var getDataIfAnyFor = function (infobarRequestId) {102 var matchesIntegrationScripts = function (plugin, url, repo, windowInfos, callback) {
103 if (user_infobar_request_callbacks[infobarRequestId] === undefined) {103 sendNativeMessage({
104 return "";104 "method" : "url_loaded",
105 }105 "url" : url
106 return { message: user_infobar_request_callbacks[infobarRequestId].message,106 },
107 details: user_infobar_request_callbacks[infobarRequestId].details };107 function (response) {
108 };108 if (response.available) {
109 var invokeAndRemoveCallbackIfAnyFor = function (infobarRequestId, arguments) {109 addInfobarRequestCallbackFor(
110 if (user_infobar_request_callbacks[infobarRequestId] === undefined) {110 windowInfos.tabId,
111 return;111 function (result) {
112 }112 if (result && result.integrate) {
113 var callback = user_infobar_request_callbacks[infobarRequestId].callback;113 sendNativeMessage({
114 user_infobar_request_callbacks[infobarRequestId] = undefined;114 "method" : "install",
115 if (typeof(callback) === 'function') {115 "url" : url
116 callback(arguments);116 })
117 }117 } else {
118 };118 sendNativeMessage({
119119 "method" : "dont_ask",
120120 "url" : url
121 /////////////////////////////////////////////////////////121 })
122 // 122 }
123 // Extract installed userscripts & webapps info123 },
124 // 124 chrome.i18n.getMessage("integration_copy", [ response.appName, response.appDomain ]),
125 ////////////////////////////////////////////////////////125 null);
126 var initializeIntegrationScriptRepositoryAccess = function (plugin) {126
127127 chrome.infobars.show({ tabId: windowInfos.tabId, path: "infobar.html" });
128 var repo = plugin.application_repository_new_default ();128 }
129 plugin.application_repository_prepare (repo);129 });
130 return repo;130 };
131 };131
132 var repo_ = initializeIntegrationScriptRepositoryAccess(plugin);132
133 var repo_install_request_stamps = {};133 // {{{ main request handler
134
135 /**
136 * Performs a match on the list of loaded integration scripts
137 * given a url.
138 *
139 */
140 var matchesIntegrationScripts = function (plugin, url, repo, windowInfos, callback) {
141 function askForApplicationInstallation(plugin, appPackageName, appDomain, url, installationCallback) {
142
143 if (plugin.permissions_get_domain_dontask(appDomain)) {
144 log.info ("WebApp domain was found in the 'dont ask' list, won't install: " + appPackageName);
145 installationCallback ();
146 return;
147 }
148 if (repo_install_request_stamps[appPackageName] !== undefined) {
149 log.info ('WebApp not being considered for install (request is only issues once per session): ' + appPackageName);
150 installationCallback ();
151 return;
152 }
153 repo_install_request_stamps[appPackageName] = true;
154
155 function installApp() {
156 log.info ('Installing application: ' + appPackageName);
157 plugin.permissions_allow_domain(appDomain);
158 plugin.application_repository_install_application(repo, appPackageName, installationCallback, null);
159 }
160 function addToIgnoreList() {
161 plugin.permissions_dontask_domain(appDomain);
162 }
163 var isInstallationConfirmed = function (response) {
164 return response && response.integrate;
165 };
166
167 if (!plugin.permissions_get_domain_preauthorized(appDomain)) {
168 var appName = plugin.application_repository_get_resolved_application_name(repo, appPackageName);
169 addInfobarRequestCallbackFor (windowInfos.tabId,
170 function (result) {
171 log.info ('Asking for installation : ' + windowInfos.tabId);
172 if (result === undefined) {
173 installationCallback();
174 }
175 if (isInstallationConfirmed(result))
176 installApp();
177 else
178 addToIgnoreList();
179 },
180 chrome.i18n.getMessage("integration_copy", [appName, appDomain]),
181 null);
182 chrome.infobars.show ({tabId: windowInfos.tabId, path: "infobar.html"});
183 }
184 else {
185 plugin.permissions_allow_domain(appDomain);
186 installApp();
187 }
188
189 } // function askForApplicationInstallation
190
191 var APPLICATION_STATUS_AVAILABLE = 0;
192 var APPLICATION_STATUS_INSTALLED = 1;
193 var APPLICATION_STATUS_UNRESOLVED = 2;
194
195 var formatMatchedWebAppInfo = function (packageName, appName, appDomain, src) {
196 return {
197 packageName: packageName,
198 appName: appName,
199 appDomain: appDomain,
200 content: src,
201 requires: null,
202 includes: null
203 };
204 };
205
206 /**
207 * Gathers the lists of installed and (if any) available apps for a given list of app names
208 * (available for a given url).
209 *
210 * @returns object with "installed" and "available" list properties
211 */
212 var gatherApplicationsStatuses = function (packageNames) {
213 var installed = [];
214 var available = [];
215 for (var i = 0; i < packageNames.length; ++i) {
216 var packageName = packageNames[i];
217
218 var status = plugin.application_repository_get_resolved_application_status (repo, packageName);
219 var appName = plugin.application_repository_get_resolved_application_name (repo, packageName);
220 var appDomain = plugin.application_repository_get_resolved_application_domain (repo, packageName);
221
222 log.info ('A WebApp application has been found: ' + appName + ', status: ' + status);
223
224 switch (status) {
225 case APPLICATION_STATUS_INSTALLED:
226 // we have found an installed application, use it directly
227 var src = plugin.application_repository_get_userscript_contents (repo, packageName);
228 installed.push (formatMatchedWebAppInfo(packageName, appName, appDomain, src));
229 break;
230 case APPLICATION_STATUS_AVAILABLE:
231 // we have found an application that can apply and be installed
232 available.push (formatMatchedWebAppInfo(packageName, appName, appDomain));
233 break;
234 }
235 }
236 return {
237 installed: installed,
238 available: available
239 };
240 };
241
242 var packageNames = JSON.parse(plugin.application_repository_resolve_url_as_json(repo_, url));
243 if (null != packageNames) {
244 var appStatuses = gatherApplicationsStatuses(packageNames);
245
246 if (appStatuses && appStatuses.installed && appStatuses.installed.length > 0) {
247 var app = appStatuses.installed[0];
248 if (repo_install_request_stamps[app.packageName] == undefined
249 && ! plugin.permissions_get_domain_dontask(app.appDomain)
250 && ! plugin.permissions_get_domain_allowed(app.appDomain)) {
251 // requesting for install
252 addInfobarRequestCallbackFor (windowInfos.tabId,
253 function (result) {
254 if (result && result.integrate) {
255 plugin.application_repository_add_desktop_to_launcher(app.appName, app.appDomain);
256 plugin.permissions_allow_domain(app.appDomain);
257 }
258 else {
259 plugin.permissions_dontask_domain(app.appDomain);
260 }
261 },
262 chrome.i18n.getMessage("integration_copy", [app.appName, app.appDomain]),
263 null);
264 chrome.infobars.show ({tabId: windowInfos.tabId, path: "infobar.html"});
265 }
266 return;
267 }
268
269 // we should have at most one script for a given app
270 if (appStatuses && appStatuses.available && appStatuses.available.length > 0) {
271 var app = appStatuses.available[0];
272 askForApplicationInstallation (plugin,
273 app.packageName,
274 app.appDomain,
275 url,
276 function (_repository, name, status, data) {
277 log.info ('Application installed: ' + name + ', (status ' + status + ')');
278
279 if (name !== undefined && status == APPLICATION_STATUS_INSTALLED) {
280 callback (true, app.packageName, app.appName, app.appDomain);
281 }
282 }
283 );
284 }
285 else
286 callback (false);
287 } // if (null != names) {
288
289 }; // var matchesIntegrationScripts = function (plugin, url, repo, windowInfos, callback) {
290
291
292 ////////////////////////////////////////
293 //
294 // main request handler
295 //
296 ///////////////////////////////////////
297 134
298 /**135 /**
299 * Handles & responds to content script requests.136 * Handles & responds to content script requests.
300 * 137 *
301 */138 */
302 var init_requested_stamps = {};139 var init_requested_stamps = {};
303 var contentScriptsRequestHandler = function (request, sender, callback) {140 var contentScriptsRequestHandler = function (request, sender, callback) {
304 141 var handlers = {
305 var handlers = {142 get_extension_settings: function (request, sender, callback) {
306 get_extension_settings: function (request, sender, callback) {143 var settings = {
307 144 logging: false,
308 var settings = {145 incognito: sender.tab.incognito
309 logging: false,146 };
310 incognito: sender.tab.incognito147
311 };148 try {
312 149 if (window.localStorage) {
313 try {150 settings.logging = localStorage['logging'];
314 if (window.localStorage) {151 }
315 settings.logging = localStorage['logging'];152 }
316 }153 catch (e) {
317 }154 console.log("Error while trying to retrieve logging information: " + str(e));
318 catch (e) {155 }
319 log.error ("Error while trying to retrieve logging information: " + str(e));156
320 }157 callback (settings);
321 158 },
322 callback (settings);159 on_user_infobar_request_result: function (request, sender, callback) {
323 }160 invokeAndRemoveCallbackIfAnyFor (request.tabId, request);
324 ,161 },
325 on_user_infobar_request_result: function (request, sender, callback) {162 init_requested: function (request, sender, callback) {
326 163 sendNativeMessage({
327 invokeAndRemoveCallbackIfAnyFor (request.tabId, request);164 "method" : "url_loaded",
328 }165 "url" : request.options.url
329 ,166 },
330 init_requested: function (request, sender, callback) {167 function (response) {
331 var name = request.options.name;168 if (response.available) {
332 var domain = request.options.domain;169 addInfobarRequestCallbackFor(
333 var iconUrl = request.options.iconUrl + '';170 sender.tab.id,
334 var homepage = request.options.homepage || request.options.url;171 function (result) {
335172 if (result && result.integrate) {
336 if (! domain || ! name || typeof(domain) !== 'string' || typeof(name) !== 'string')173 sendNativeMessage({
337 return;174 "method" : "install",
338175 "url" : request.options.url
339 var islocal = request.options.protocol && request.options.protocol === 'file:';176 })
340 var host = request.options.hostname || request.options.host;177 } else {
341 if ( ! islocal && (! host || typeof(host) !== 'string'))178 sendNativeMessage({
342 return;179 "method" : "dont_ask",
343180 "url" : request.options.url
344 if (-1 === homepage.indexOf(domain) || -1 === host.indexOf(domain)) {181 })
345 log.error('Invalid call to init(), homepage, domain and host are not consistent');182 }
346 return;183 },
347 }184 chrome.i18n.getMessage("integration_copy", [ response.appName, response.appDomain ]),
348 log.info('init_requested() called for ' + name + ' domain: ' + domain);185 null);
349186
350 if (plugin.permissions_get_domain_dontask(domain) || plugin.permissions_get_domain_allowed(domain)) {187 chrome.infobars.show({ tabId: windowInfos.tabId, path: "infobar.html" });
351 log.info('Domain already listed in allow or dont ask lists');188 }
352 return;189 });
353 }190 }
354191 };
355 var stampname = name + domain;192
356 if (init_requested_stamps[stampname] == undefined) {193 // validate request
357 addInfobarRequestCallbackFor (sender.tab.id,194 if (!request || !request.method) {
358 function (result) {195 callback({ error: "Invalid request structure" });
359 if (result && result.integrate) {196 return true;
360 plugin.application_repository_generate_desktop_for_url_launch(name, domain, homepage, iconUrl);197 }
361 plugin.application_repository_add_desktop_to_launcher(name, domain);198 if (!sender) {
362 plugin.permissions_allow_domain(domain);199 callback({ error: "Invalid sender" });
363 }200 return true;
364 else {201 }
365 plugin.permissions_dontask_domain(domain);202
366 }203 if (typeof(request.method) != 'string' || request.method.length == 0) {
367 },204 callback({ error: "Invalid request method" });
368 chrome.i18n.getMessage("integration_copy", [name, domain]),205 return true;
369 null);206 }
370 init_requested_stamps[stampname] = true;207
371 chrome.infobars.show ({tabId: sender.tab.id, path: "infobar.html"});208 console.log('Got request: ' + request.method);
372 }209
373 }210 var handler = handlers [request.method];
374 }; // handlers211 if (handler !== undefined && typeof(handler) == 'function') {
375 212 handler(request, sender, callback);
376 213 return true;
377 // validate request214 }
378 if ( ! request || ! request.method) {215 return false;
379 callback ({error: "Invalid request structure"});216 }
380 return true;217
381 }218 // Main event handler and communication link
382 if ( ! sender) {219 // w/ content scripts
383 callback ({error: "Invalid sender"});220 chrome.runtime.onMessage.addListener (contentScriptsRequestHandler);
384 return true;221 // }}}
385 }222
386 if ( typeof (request.method) != 'string' || request.method.length == 0) {223 ///////////////////////////////////////////////////////////////////////
387 callback ({error: "Invalid request method"});224 //
388 return true;225 // Window management related functions. In chromeless mode, we have specific
389 }226 // rules for tab management to make webapps feel more "native" than plain
390227 // web applications.
391 log.info ('Got request: ' + request.method);228 //
392229 ///////////////////////////////////////////////////////////////////////
393 var handler = handlers [request.method];230
394 231 var onTabChanged = function (tabId, windowId, url) {
395 if (handler !== undefined && typeof(handler) == 'function') {232 var onInstalled = function (installed, packageName, appName, appDomain) { };
396 233
397 log.info ('Calling handler for: ' + request.method);234 console.log("onTabChanged: " + url);
398 235
399 handler (request, sender, callback);236 matchesIntegrationScripts(
400 237 null, //plugin,
401 return true;238 url,
402 }239 null, // repo_,
403 return false;240 {
404 } // var contentScriptsRequestHandler =241 windowId: windowId,
405242 tabId: tabId
406 // Main event handler and communication link243 },
407 // w/ content scripts244 onInstalled
408 chrome.runtime.onMessage.addListener (contentScriptsRequestHandler);245 );
409246 };
410247
411 ///////////////////////////////////////////////////////////////////////248 chrome.tabs.onCreated.addListener(
412 // 249 function(tab) {
413 // Window management related functions. In chromeless mode, we have specific250 if (tab && tab.url) {
414 // rules for tab management to make webapps feel more "native" than plain251 onTabChanged(tab.id, tab.windowId, tab.url);
415 // web applications.252 }
416 // 253 }
417 ///////////////////////////////////////////////////////////////////////254 );
418255
419 var onTabChanged = function (tabId, windowId, url) {256 chrome.tabs.onUpdated.addListener(
420 var onInstalled = function (installed, packageName, appName, appDomain) { };257 function(tabId, changeInfo, tab) {
421 matchesIntegrationScripts (plugin,258 console.log("onUpdated " + changeInfo.url);
422 url,259 if (changeInfo && changeInfo.url) {
423 repo_,260 onTabChanged(tabId, tab.windowId, changeInfo.url);
424 {261 }
425 windowId: windowId,262 }
426 tabId: tabId263 );
427 },264
428 onInstalled265 /*
429 );266 * Returns a potential message associated with a tab id (infobar)
430 };267 */
431 chrome.tabs.onCreated.addListener(268 return {
432 function(tab) {269 getMessageForTabId: function (tabId) {
433 if (tab && tab.url) {270 return getDataIfAnyFor(tabId).message;
434 onTabChanged(tab.id, tab.windowId, tab.url);271 }
435 } // if (tab && tab.url) {272 };
436 }273})();
437 );
438 chrome.tabs.onUpdated.addListener (
439 function(tabId, changeInfo, tab) {
440 if (changeInfo && changeInfo.url) {
441 onTabChanged(tabId, tab.windowId, changeInfo.url);
442 }
443 }
444 );
445
446 return {
447 /*
448 * Returns a potential message associated with a tab id (infobar)
449 */
450 getMessageForTabId: function (tabId) {
451 return getDataIfAnyFor (tabId).message;
452 }
453 };
454 }) ();
455274
456275
=== modified file 'chromium-extension/base-content-script.js'
--- chromium-extension/base-content-script.js 2013-12-16 07:15:32 +0000
+++ chromium-extension/base-content-script.js 2014-11-18 07:07:55 +0000
@@ -6,7 +6,7 @@
6 * under the terms of the GNU General Public License version 3, as published 6 * under the terms of the GNU General Public License version 3, as published
7 * by the Free Software Foundation.7 * by the Free Software Foundation.
8 *8 *
9 * This program is distributed in the hope that it will be useful, but 9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranties of 10 * WITHOUT ANY WARRANTY; without even the implied warranties of
11 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 11 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the GNU General Public License for more details.12 * PURPOSE. See the GNU General Public License for more details.
1313
=== added file 'chromium-extension/browser.js'
--- chromium-extension/browser.js 1970-01-01 00:00:00 +0000
+++ chromium-extension/browser.js 2014-11-18 07:07:55 +0000
@@ -0,0 +1,154 @@
1/**
2 * Handles all the related work to injecting the 'external' extension into the
3 * content script (well, more precisely the current environment), and the proxy
4 * responsbile for handling the API requests in a webapplication.
5 *
6 */
7(function (currentWindow) {
8 var aWindow = currentWindow;
9 var plugin = null;
10 var service = null;
11 var api = {
12 init: function (options) {
13 options.url = window.location.href;
14 options.hostname = window.location.hostname;
15 options.host = window.location.host;
16 options.protocol = window.location.protocol;
17 chrome.runtime.sendMessage (
18 {method: "init_requested", options: options}
19 , function (response) {});
20 }
21 };
22
23 /**
24 * Inserts a given script in the webpage.
25 * Needs chrome.extension functionality.
26 *
27 * @param path of file to be injected (part of the extension)
28 */
29 var insertScriptIntoWebpage = function (path) {
30 var script = document.createElement ('script');
31 script.type = 'text/javascript';
32 script.src = chrome.runtime.getURL (path);
33 document.getElementsByTagName("head")[0].appendChild (script);
34 };
35
36 var injectApiProxy = function () {
37
38 // 1. inject a piece of javascript proxying all the requests
39 // to the unity webapps api
40 insertScriptIntoWebpage('unity-api-page-proxy-builder-gen.js');
41 insertScriptIntoWebpage('unity-api-page-proxy.js');
42
43 function makeWebpageCallback (id) {
44 // TODO/FIXME: add support for callback params (needed for DnD)
45 return function () {
46 var d = document.createElement ("textarea");
47 var e = document.createEvent ("Events");
48 d.style.cssText = "display:none;";
49 d.value = id;
50 d.addEventListener ("unity-webapps-chromium-api-com-link-callback-called-ack"
51 , function() { d.parentNode.removeChild (d); }
52 , true);
53 document.body.appendChild (d);
54 e.initEvent ("unity-webapps-chromium-api-com-link-callback-called", false, true);
55 d.dispatchEvent (e);
56 };
57 };
58
59 // TODO: should be shared / generated w/ web page code
60 var isIterableObject = function(obj) {
61 if (obj === undefined || obj === null) {
62 return false;
63 }
64 var t = typeof(obj);
65 var types = {'string': 0, 'function': 0, 'number': 0, 'undefined': 0, 'boolean': 0};
66 return types[t] === undefined;
67 };
68
69 /**
70 * Wraps callback ids in proper callback that dispatch to the
71 * webpage thru a proper event
72 *
73 */
74 function wrapCallbackIds (obj) {
75 if ( ! isIterableObject(obj)) {
76 return obj;
77 }
78 if (obj
79 && obj.hasOwnProperty('callbackid')
80 && obj.callbackid != null) {
81 return makeWebpageCallback (obj.callbackid);
82 }
83
84 var ret = (obj instanceof Array) ? [] : {};
85 for (var key in obj) {
86 if (obj.hasOwnProperty(key)) {
87
88 if (isIterableObject (obj[key])) {
89
90 if (obj[key].callbackid != null) {
91 ret[key] = makeWebpageCallback (obj[key].callbackid);
92 }
93 else {
94 ret[key] = wrapCallbackIds (obj[key]);
95 }
96 }
97 else {
98 ret[key] = obj[key];
99 }
100 }
101 }
102 return ret;
103 };
104
105 // 2. open the communication mean between the two
106
107 // TODO has the implicit knowledge of who's behind ...
108 var dispatchActualFunctionCall = function (funcname, args) {
109 var funcnames = funcname.split('.');
110 var reducetarget = api;
111
112 // a bit hacky
113 try {
114 // Assumes that we are calling a 'callable' from a succession of objects
115 funcnames.reduce (
116 function (prev, cur) {
117 return typeof prev[cur] == "function" ? prev[cur].bind(prev) : prev[cur];
118 }, reducetarget).apply (null, args);
119 } catch (err) {
120 console.log ('Error while dispatching call to ' + funcnames.join('.') + ': ' + err);
121 }
122 };
123
124 document.addEventListener("unity-webapps-chromium-api-com-link"
125 , function(event) {
126 var from = event.target;
127 if (from) {
128 var type = from.getAttribute("data-eventType");
129
130 var args = JSON.parse(from.value);
131 args = args.map (function (arg) { return wrapCallbackIds (arg); });
132
133 // Actuall call, e.g. 'Notification.showNotification("a","b")
134 // being reduces to successive calls to associated objects:
135 // Notification, showNotification
136 //
137 // TODO add proper error handling
138 dispatchActualFunctionCall(type, args);
139 }
140
141 // send ack event to allow cleanup
142 var ret = document.createEvent('Events');
143 ret.initEvent('unity-webapps-chromium-api-com-link-ack', true, false);
144 from.dispatchEvent(ret);
145 }
146 , true);
147 };
148
149 // handle the proxy side of the api which is being injected on the
150 // webpage
151 injectApiProxy();
152 }
153)(window);
154
0155
=== removed file 'chromium-extension/browser.js'
--- chromium-extension/browser.js 2013-12-16 07:15:32 +0000
+++ chromium-extension/browser.js 1970-01-01 00:00:00 +0000
@@ -1,154 +0,0 @@
1/**
2 * Handles all the related work to injecting the 'external' extension into the
3 * content script (well, more precisely the current environment), and the proxy
4 * responsbile for handling the API requests in a webapplication.
5 *
6 */
7(function (currentWindow) {
8 var aWindow = currentWindow;
9 var plugin = null;
10 var service = null;
11 var api = {
12 init: function (options) {
13 options.url = window.location.href;
14 options.hostname = window.location.hostname;
15 options.host = window.location.host;
16 options.protocol = window.location.protocol;
17 chrome.runtime.sendMessage (
18 {method: "init_requested", options: options}
19 , function (response) {});
20 }
21 };
22
23 /**
24 * Inserts a given script in the webpage.
25 * Needs chrome.extension functionality.
26 *
27 * @param path of file to be injected (part of the extension)
28 */
29 var insertScriptIntoWebpage = function (path) {
30 var script = document.createElement ('script');
31 script.type = 'text/javascript';
32 script.src = chrome.runtime.getURL (path);
33 document.getElementsByTagName("head")[0].appendChild (script);
34 };
35
36 var injectApiProxy = function () {
37
38 // 1. inject a piece of javascript proxying all the requests
39 // to the unity webapps api
40 insertScriptIntoWebpage('unity-api-page-proxy-builder-gen.js');
41 insertScriptIntoWebpage('unity-api-page-proxy.js');
42
43 function makeWebpageCallback (id) {
44 // TODO/FIXME: add support for callback params (needed for DnD)
45 return function () {
46 var d = document.createElement ("textarea");
47 var e = document.createEvent ("Events");
48 d.style.cssText = "display:none;";
49 d.value = id;
50 d.addEventListener ("unity-webapps-chromium-api-com-link-callback-called-ack"
51 , function() { d.parentNode.removeChild (d); }
52 , true);
53 document.body.appendChild (d);
54 e.initEvent ("unity-webapps-chromium-api-com-link-callback-called", false, true);
55 d.dispatchEvent (e);
56 };
57 };
58
59 // TODO: should be shared / generated w/ web page code
60 var isIterableObject = function(obj) {
61 if (obj === undefined || obj === null) {
62 return false;
63 }
64 var t = typeof(obj);
65 var types = {'string': 0, 'function': 0, 'number': 0, 'undefined': 0, 'boolean': 0};
66 return types[t] === undefined;
67 };
68
69 /**
70 * Wraps callback ids in proper callback that dispatch to the
71 * webpage thru a proper event
72 *
73 */
74 function wrapCallbackIds (obj) {
75 if ( ! isIterableObject(obj)) {
76 return obj;
77 }
78 if (obj
79 && obj.hasOwnProperty('callbackid')
80 && obj.callbackid != null) {
81 return makeWebpageCallback (obj.callbackid);
82 }
83
84 var ret = (obj instanceof Array) ? [] : {};
85 for (var key in obj) {
86 if (obj.hasOwnProperty(key)) {
87
88 if (isIterableObject (obj[key])) {
89
90 if (obj[key].callbackid != null) {
91 ret[key] = makeWebpageCallback (obj[key].callbackid);
92 }
93 else {
94 ret[key] = wrapCallbackIds (obj[key]);
95 }
96 }
97 else {
98 ret[key] = obj[key];
99 }
100 }
101 }
102 return ret;
103 };
104
105 // 2. open the communication mean between the two
106
107 // TODO has the implicit knowledge of who's behind ...
108 var dispatchActualFunctionCall = function (funcname, args) {
109 var funcnames = funcname.split('.');
110 var reducetarget = api;
111
112 // a bit hacky
113 try {
114 // Assumes that we are calling a 'callable' from a succession of objects
115 funcnames.reduce (
116 function (prev, cur) {
117 return typeof prev[cur] == "function" ? prev[cur].bind(prev) : prev[cur];
118 }, reducetarget).apply (null, args);
119 } catch (err) {
120 console.log ('Error while dispatching call to ' + funcnames.join('.') + ': ' + err);
121 }
122 };
123
124 document.addEventListener("unity-webapps-chromium-api-com-link"
125 , function(event) {
126 var from = event.target;
127 if (from) {
128 var type = from.getAttribute("data-eventType");
129
130 var args = JSON.parse(from.value);
131 args = args.map (function (arg) { return wrapCallbackIds (arg); });
132
133 // Actuall call, e.g. 'Notification.showNotification("a","b")
134 // being reduces to successive calls to associated objects:
135 // Notification, showNotification
136 //
137 // TODO add proper error handling
138 dispatchActualFunctionCall(type, args);
139 }
140
141 // send ack event to allow cleanup
142 var ret = document.createEvent('Events');
143 ret.initEvent('unity-webapps-chromium-api-com-link-ack', true, false);
144 from.dispatchEvent(ret);
145 }
146 , true);
147 };
148
149 // handle the proxy side of the api which is being injected on the
150 // webpage
151 injectApiProxy();
152 }
153)(window);
154
1550
=== added file 'chromium-extension/chromium-extension.pro'
--- chromium-extension/chromium-extension.pro 1970-01-01 00:00:00 +0000
+++ chromium-extension/chromium-extension.pro 2014-11-18 07:07:55 +0000
@@ -0,0 +1,66 @@
1include(../common-project-config.pri)
2include($${TOP_SRC_DIR}/common-vars.pri)
3
4TEMPLATE = aux
5
6EXTENSION_DIR = $${INSTALL_LIBDIR}/libunity-chromium
7EXTENSION_NAME = unity-webapps
8EXTENSION_FILE = $${EXTENSION_NAME}.crx
9
10STATIC_EXTENSION_FILES = \
11 background-page.html \
12 background-page.js \
13 base-content-script.js \
14 browser.js \
15 infobar.css \
16 infobar.html \
17 infobar.js \
18 _locales \
19 options.html \
20 options.js \
21 skin \
22 unity-api-page-proxy-builder-gen.js \
23 unity-api-page-proxy.js \
24
25SCRIPT_FILES = \
26 $${STATIC_EXTENSION_FILES} \
27 manifest.json \
28 unity-webapps.json
29
30QMAKE_SUBSTITUTES += \
31 manifest.json.in \
32 unity-webapps.json.in
33
34pemfile.target = unity-webapps.pem
35pemfile.commands = "openssl genrsa 1024 > $${pemfile.target}"
36
37static_files.depends = \
38 $${SCRIPT_FILES}
39static_files.commands = mkdir -p $${OUT_PWD}/$${EXTENSION_NAME} && ${COPY_DIR} $${SCRIPT_FILES} $${OUT_PWD}/$${EXTENSION_NAME}
40
41static_files_stamp.target = buildstamp
42static_files_stamp.depends = static_files
43static_files_stamp.commands = touch $${static_files_stamp.target}
44
45extension.target = res/$${EXTENSION_NAME}.crx
46extension.commands = $${TOP_SRC_DIR}/chromium-extension/crxmake.sh $${OUT_PWD}/$${EXTENSION_NAME} $${pemfile.target}
47extension.depends = pemfile static_files_stamp
48
49QMAKE_EXTRA_TARGETS += \
50 extension \
51 pemfile \
52 static_files \
53 static_files_stamp
54
55PRE_TARGETDEPS = $${extension.target}
56
57manifest.files = \
58 $${OUT_PWD}/res/*.json
59manifest.path = $${INSTALL_PREFIX}/share/chromium/extensions/
60manifest.CONFIG = no_check_exist
61INSTALLS += manifest
62
63crx.files = res/$${EXTENSION_NAME}.crx
64crx.path = $${EXTENSION_DIR}
65crx.CONFIG = no_check_exist
66INSTALLS += crx
067
=== modified file 'chromium-extension/infobar.js'
--- chromium-extension/infobar.js 2013-07-10 18:12:23 +0000
+++ chromium-extension/infobar.js 2014-11-18 07:07:55 +0000
@@ -1,29 +1,33 @@
1var doIntegrate = function (integrate) {1var doIntegrate = function (integrate) {
2 chrome.tabs.getCurrent (function (tab) {2 chrome.tabs.query({currentWindow: true, active: true}, function (tabs) {
3 chrome.runtime.sendMessage ({tabId: tab.id, method: "on_user_infobar_request_result", integrate: integrate}3 chrome.runtime.sendMessage({tabId: tabs[0].id, method: "on_user_infobar_request_result", integrate: integrate}
4 , function (response) {});4 , function (response) {});
5 window.close();5 window.close();
6 });6 });
7};7};
88
9window.onload = function () {9window.onload = function () {
10 chrome.runtime.getBackgroundPage(function (bg) {10 chrome.runtime.getBackgroundPage(function (bg) {
11 document.getElementById('notintegrate').onclick = function () { doIntegrate(false); };11 document.getElementById('notintegrate').onclick = function () { doIntegrate(false); };
12 document.getElementById('integrate').onclick = function () { doIntegrate(true); };12 document.getElementById('integrate').onclick = function () { doIntegrate(true); };
1313
14 chrome.tabs.getCurrent (function (tab) {14 chrome.tabs.query({currentWindow: true, active: true}, function (tabs) {
15 if (!bg|| !bg.background_page) {15 if (tabs.length === 0) {
16 window.close();16 window.close();
17 return;17 return;
18 }18 }
19 var msg = bg.background_page.getMessageForTabId(tab.id);19 if (!bg || !bg.background_page) {
20 if (msg == null) {20 window.close();
21 window.close();21 return;
22 return;22 }
23 }23 var msg = bg.background_page.getMessageForTabId(tabs[0].id);
24 document.getElementById ('content').style.display = "block";24 if (msg == null) {
25 document.getElementById ('message').innerHTML = msg || "";25 window.close();
26 });26 return;
27 }
28 document.getElementById ('content').style.display = "block";
29 document.getElementById ('message').innerHTML = msg || "";
30 });
27 });31 });
28};32};
2933
3034
=== modified file 'chromium-extension/manifest.json.in'
--- chromium-extension/manifest.json.in 2013-12-16 07:15:32 +0000
+++ chromium-extension/manifest.json.in 2014-11-18 07:07:55 +0000
@@ -1,51 +1,41 @@
1{1{
2 "name": "Unity WebApps Chromium extension",2 '"name": "Unity WebApps Chromium extension"',
3 "manifest_version": 2,3 '"manifest_version"': 2,
4 "minimum_chrome_version": "20.0",4 '"minimum_chrome_version": "34.0"',
5 "content_security_policy": "script-src 'self' chrome-extension://infobar.js 'unsafe-eval'; object-src 'self'",5 '"content_security_policy"': '"script-src \'self\' chrome-extension://infobar.js \'unsafe-eval\'; object-src \'self\'"',
66
7 "version": "@VERSION@",7 '"version": "$${PROJECT_VERSION}"',
88
9 "description": "Unity Webapps Chromium integration",9 '"description": "Unity Webapps Chromium integration"',
1010
11 "web_accessible_resources": [11 '"web_accessible_resources"': [
12 "browser.js",12 '"browser.js"',
13 "unity-api-page-proxy-builder-gen.js",13 '"unity-api-page-proxy-builder-gen.js"',
14 "unity-api-page-proxy.js",14 '"unity-api-page-proxy.js"',
15 "infobar.js",15 '"infobar.js"',
16 "options.js"16 '"options.js"'
17 ],17 ],
1818
19 "icons": {19 '"icons"': {
20 "16": "skin/cof-16.png",20 '"16": "skin/cof-16.png"',
21 "48": "skin/cof-48.png"21 '"48": "skin/cof-48.png"'
22 }, 22 },
2323
24 "default_locale": "en",24 '"default_locale": "en"',
2525
26 "background": {26 '"background"': {
27 "page": "background-page.html"27 '"page"': '"background-page.html"'
28 }, 28 },
2929
30 "permissions": ["tabs", "http://*/*", "infobars"],30 '"permissions": ["tabs", "http://*/*", "infobars", "nativeMessaging"]',
31 "options_page": "options.html",31 '"options_page": "options.html"',
32 32
33 "plugins": [33 '"content_scripts"': [
34
35 /** The "path" property specifies the path to your plugin, relative to the manifest file.
36 * The "public" property specifies whether your plugin can be accessed by regular web pages;
37 * the default is false, meaning only your extension can load the plugin.
38 */
39 { "path": "libunity_npapi_plugin.so", "public": false }
40
41 ],
42
43 "content_scripts": [
44 {34 {
45 "all_frames": true,35 '"all_frames"': true,
46 "matches": [ "<all_urls>" ],36 '"matches": [ "<all_urls>" ]',
47 "js": ["base-content-script.js"],37 '"js": ["base-content-script.js"]',
48 "run_at": "document_end" 38 '"run_at": "document_end"'
49 }39 }
50 ]40 ]
51}41}
5242
=== added file 'chromium-extension/unity-api-page-proxy-builder-gen.js'
--- chromium-extension/unity-api-page-proxy-builder-gen.js 1970-01-01 00:00:00 +0000
+++ chromium-extension/unity-api-page-proxy-builder-gen.js 2014-11-18 07:07:55 +0000
@@ -0,0 +1,384 @@
1var UnityWebappsApiPageProxyBuilder = function(backend) {
2
3 var dummy = true;
4 var unity = { context: dummy, contextReady: dummy };
5 var uwa = { ContextActionCallbackType: null };
6
7 var CallbackManager = {
8 makeCallback: function (dumd, func) {
9 return func;
10 }
11 };
12
13 function checkString(str, allowUndef) {
14 if (allowUndef && str == undefined) {
15 return;
16 }
17 if (!str || typeof(str) !== 'string') {
18 throw new TypeError("incorrect argument");
19 }
20 }
21
22 var findName = function (func, prefix, obj) {
23
24 if (!prefix) {
25 return findName(func, 'Unity.', api);
26 }
27 var keys = Object.keys(obj);
28 for (var i = 0; i < keys.length; i++) {
29 if (typeof(keys[i]) !== 'string') {
30 continue;
31 }
32 var descr = Object.getOwnPropertyDescriptor(obj, keys[i]);
33 if (descr.value === func) {
34 return prefix + keys[i];
35 }
36 if (descr.value instanceof Object) {
37 var res = findName(func, prefix + keys[i] + '.', obj[keys[i]]);
38 if (res)
39 return res;
40 }
41 if (obj.__lookupGetter__(keys[i]) === func) {
42 return prefix + keys[i];
43 }
44 if (obj.__lookupSetter__(keys[i]) === func) {
45 return prefix + keys[i];
46 }
47 }
48 return null;
49
50 };
51
52
53 var stringify = function (obj) {
54
55 if (obj === undefined)
56 return obj;
57 if (obj === null)
58 return obj;
59 if (typeof(obj) == 'string')
60 return obj;
61 if (typeof(obj) == 'number')
62 return obj;
63 if (typeof(obj) == 'function')
64 return String(obj);
65 var dump = {};
66 for (var i in obj) {
67 if (obj.hasOwnProperty(i))
68 dump[i] = stringify(obj[i]);
69 }
70 return dump;
71
72 };
73
74
75 var stringifyArgs = function (obj) {
76
77 var args = [];
78 for (var i = 0; i < obj.length; i++) {
79 args.push(stringify(obj[i]));
80 }
81 var res = JSON.stringify(args);
82 return res.substr(1, res.length - 2);
83 };
84
85 var createArgumentsSanitaizer = function (func, argsDesc, callback) {
86
87 return function () {
88 var realArgs = arguments;
89 var name = findName(arguments.callee);
90
91 var k = 0;
92 function argumentSanitaizer(desc, arg) {
93 if (!desc) {
94 throw new InternalError("argument description is null");
95 }
96 if (desc.dummy) {
97 k--;
98 return null;
99 }
100 if (desc.array) {
101 if (!(desc.array instanceof Object) || !(desc.array.element instanceof Object)) {
102 throw new InternalError("invalid argument description");
103 }
104
105 try {
106 for (var j = 0; j < arg.length; j++) {
107 argumentSanitaizer(desc.array.element, arg[j]);
108 }
109 } catch (x) {
110 throw new TypeError("incorrect argument");
111 }
112
113 return arg;
114 }
115 if (desc.obj) {
116 if (!(desc.obj instanceof Object)) {
117 throw new InternalError("invalid argument description");
118 }
119 var res = {}, i;
120 for (i in desc.obj) {
121 if (desc.obj.hasOwnProperty(i)) {
122 res[i] = argumentSanitaizer(desc.obj[i], arg[i]);
123 }
124 }
125 return res;
126 }
127 if (desc.str) {
128 if (desc.allowNull && !arg) {
129 return null;
130 }
131 checkString(arg, false);
132 return arg;
133 }
134 if (desc.number) {
135 if (typeof(arg) !== 'number' && typeof(arg) !== 'boolean')
136 throw new TypeError("incorrect argument");
137 return arg;
138 }
139 if (!desc.type) {
140 throw new InternalError("argument description miss required parameter");
141 }
142 if ((arg instanceof desc.type) || (desc.type === Function && ((typeof arg) === 'function'))
143 || (arg === null && desc.allowNull)) {
144 if (desc.type === Function) {
145 if (!arg) {
146 return null;
147 }
148
149 var id;
150 if (desc.argAsCallbackId !== undefined) {
151 id = realArgs[desc.argAsCallbackId];
152 }
153 return CallbackManager.makeCallback(uwa.ContextActionCallbackType,
154 function (context, user_data) {
155 arg();
156 }, name, id);
157 }
158 return arg;
159 } else {
160 throw new TypeError("incorrect argument");
161 }
162 throw new InternalError("unreacheable");
163 }
164 var args = [unity.context], i;
165 for (i = 0; i < argsDesc.length; i++) {
166 if (k >= realArgs.length && k > 0 && !argsDesc[i].dummy) {
167 throw new Error("not enough arguments");
168 }
169 var value = argumentSanitaizer(argsDesc[i], realArgs[k]);
170 k++;
171
172 if (argsDesc[i].obj) {
173 args = args.concat(value);
174 } else {
175 args.push(value);
176 }
177 }
178
179 if (k < realArgs.length) {
180 throw new Error("too much arguments");
181 }
182
183 if (callback)
184 callback.apply(uwa, args);
185 if (func)
186 return Function.apply.apply(func, [uwa, args]);
187
188 return null;
189 };
190
191 };
192 var api = {
193 init: function(props) {
194 checkString(props.name, false);
195 checkString(props.iconUrl, true);
196 checkString(props.domain, true);
197 checkString(props.login, true);
198 checkString(props.mimeTypes, true);
199 checkString(props.homepage, true);
200 if (props.homepage && !/^(http|https|file):\/\//.test(props.homepage)) {
201 throw new TypeError("incorrect argument");
202 }
203 backend("init", [props]);
204 }
205 ,
206 acceptData: createArgumentsSanitaizer(null,
207 [{ array: { element: { str: true } } }, { type: Function, js: true }],
208 function (context, mimeTypes, callback) {
209 backend('acceptData', [mimeTypes, callback]);
210 })
211 ,
212 addAction: createArgumentsSanitaizer(null,
213 [{ str: true }, { type: Function, argAsCallbackId: 0 }],
214 function (context, name, callback) {
215 backend('addAction', [name, callback]);
216 })
217 ,
218 clearAction: createArgumentsSanitaizer(null,
219 [{ str: true }]
220 , function (context, name) {
221 backend('clearAction', [name]);
222 })
223 ,
224 clearActions: createArgumentsSanitaizer(null,
225 [],
226 function (context) {
227 backend('clearActions', []);
228 })
229 ,
230 MediaPlayer: {
231 init: createArgumentsSanitaizer(null,
232 [{ str: true }],
233 function (context, name) {
234 backend('MediaPlayer.init', [name]);
235 })
236 ,
237 onPlayPause: createArgumentsSanitaizer(null,
238 [{ type: Function, allowNull: true }, { dummy: true }],
239 function (context, callback) {
240 backend('MediaPlayer.onPlayPause', [callback]);
241 }
242 )
243 ,
244 onPrevious: createArgumentsSanitaizer(null,
245 [{ type: Function, allowNull: true }, { dummy: true }],
246 function (context, callback) {
247 backend('MediaPlayer.onPrevious', [callback]);
248 })
249 ,
250 onNext: createArgumentsSanitaizer(null,
251 [{ type: Function, allowNull: true }, { dummy: true }],
252 function (context, callback) {
253 backend('MediaPlayer.onNext', [callback]);
254 }
255 )
256 ,
257 setTrack: createArgumentsSanitaizer(null,
258 [{ obj: { artist: { str: true, place: 0, allowNull: true },
259 album: { str: true, place: 1, allowNull: true },
260 title: { str: true, place: 2 },
261 artLocation: { str: true, place: 3, allowNull: true } } }],
262 function (context, trackinfos) {
263 backend('MediaPlayer.setTrack', [trackinfos]);
264 })
265 ,
266 setCanGoNext: createArgumentsSanitaizer(null,
267 [{ number: true }],
268 function (context, v) {
269 backend('MediaPlayer.setCanGoNext', [v]);
270 }
271 )
272 ,
273 setCanGoPrevious: createArgumentsSanitaizer(null,
274 [{ number: true }],
275 function (context, v) {
276 backend('MediaPlayer.setCanGoPrevious', [v]);
277 }
278 )
279 ,
280 setCanPlay: createArgumentsSanitaizer(null,
281 [{ number: true }],
282 function (context, v) { backend('MediaPlayer.setCanPlay', [v]); }
283 )
284 ,
285 setCanPause: createArgumentsSanitaizer(null,
286 [{ number: true }],
287 function (context, v) { backend('MediaPlayer.setCanPause', [v]); }
288 )
289 ,
290 setPlaybackState: createArgumentsSanitaizer(null,
291 [{ number: true }],
292 function (context, v) { backend('MediaPlayer.setPlaybackState', [v]); }
293 )
294 ,
295 getPlaybackState: createArgumentsSanitaizer(null
296 , [{ type: Function }]
297 , function (context, callback) {
298 backend('MediaPlayer.getPlaybackState', [callback]);
299 }
300 )
301 ,
302 PlaybackState: {PLAYING: 0, PAUSED:1}
303 },
304
305 Notification: {
306 showNotification: createArgumentsSanitaizer(null,
307 [{ str: true }, { str: true }, { str: true, allowNull: true }],
308 function (context, title, name, dummy) {
309 backend('Notification.showNotification', [title, name, dummy]);
310 }
311 )
312 },
313
314 Launcher: {
315 setCount: createArgumentsSanitaizer(null,
316 [{ number: true }],
317 function (context, count) {
318 backend('Launcher.setCount', [count]);
319 }
320 )
321 ,
322 clearCount: createArgumentsSanitaizer(null,
323 [],
324 function (context) {
325 backend('Launcher.clearCount', []);
326 }),
327 setProgress: createArgumentsSanitaizer(null,
328 [{ number: true }],
329 function (context, progress) {
330 backend('Launcher.setProgress', [progress]);
331 }
332 )
333 ,
334 clearProgress: createArgumentsSanitaizer(null,
335 [],
336 function (context) {
337 backend('Launcher.clearProgress', []);
338 }
339 )
340 ,
341 setUrgent: createArgumentsSanitaizer(null,
342 [],
343 function (context) {
344 backend('Launcher.setUrgent', []);
345 }
346 )
347 ,
348 addAction: function(arg1, arg2) {
349 backend('Launcher.addAction', [arg1, arg2]);
350 }
351 ,
352 removeAction: createArgumentsSanitaizer(null,
353 [{ str: true }],
354 function (context, name) {
355 backend('Launcher.removeAction', [name]);
356 }
357 )
358 ,
359 removeActions: createArgumentsSanitaizer(null,
360 [],
361 function (context) {
362 backend('Launcher.removeActions', []);
363 }
364 )
365 },
366 MessagingIndicator: {
367 addAction: createArgumentsSanitaizer(null,
368 [{ str: true }, { type: Function, argAsCallbackId: 0 }, { dummy: true }],
369 function (context, name, callback, dummy) {
370 backend('MessagingIndicator.addAction', [name, callback, dummy]);
371 }
372 )
373 ,
374 showIndicator: function(name, properties) {
375 backend('MessagingIndicator.showIndicator', [name, properties]);
376 }
377 ,
378 clearIndicator: createArgumentsSanitaizer(null, [{ str: true }], function(context, name) { backend('MessagingIndicator.clearIndicator', [name]); }),
379 clearIndicators: createArgumentsSanitaizer(null, [], function (context) { backend('MessagingIndicator.clearIndicators', []); })
380 }
381 };
382 return api;
383};
384
0385
=== removed file 'chromium-extension/unity-api-page-proxy-builder-gen.js'
--- chromium-extension/unity-api-page-proxy-builder-gen.js 2013-11-01 06:37:07 +0000
+++ chromium-extension/unity-api-page-proxy-builder-gen.js 1970-01-01 00:00:00 +0000
@@ -1,384 +0,0 @@
1var UnityWebappsApiPageProxyBuilder = function(backend) {
2
3 var dummy = true;
4 var unity = { context: dummy, contextReady: dummy };
5 var uwa = { ContextActionCallbackType: null };
6
7 var CallbackManager = {
8 makeCallback: function (dumd, func) {
9 return func;
10 }
11 };
12
13 function checkString(str, allowUndef) {
14 if (allowUndef && str == undefined) {
15 return;
16 }
17 if (!str || typeof(str) !== 'string') {
18 throw new TypeError("incorrect argument");
19 }
20 }
21
22 var findName = function (func, prefix, obj) {
23
24 if (!prefix) {
25 return findName(func, 'Unity.', api);
26 }
27 var keys = Object.keys(obj);
28 for (var i = 0; i < keys.length; i++) {
29 if (typeof(keys[i]) !== 'string') {
30 continue;
31 }
32 var descr = Object.getOwnPropertyDescriptor(obj, keys[i]);
33 if (descr.value === func) {
34 return prefix + keys[i];
35 }
36 if (descr.value instanceof Object) {
37 var res = findName(func, prefix + keys[i] + '.', obj[keys[i]]);
38 if (res)
39 return res;
40 }
41 if (obj.__lookupGetter__(keys[i]) === func) {
42 return prefix + keys[i];
43 }
44 if (obj.__lookupSetter__(keys[i]) === func) {
45 return prefix + keys[i];
46 }
47 }
48 return null;
49
50 };
51
52
53 var stringify = function (obj) {
54
55 if (obj === undefined)
56 return obj;
57 if (obj === null)
58 return obj;
59 if (typeof(obj) == 'string')
60 return obj;
61 if (typeof(obj) == 'number')
62 return obj;
63 if (typeof(obj) == 'function')
64 return String(obj);
65 var dump = {};
66 for (var i in obj) {
67 if (obj.hasOwnProperty(i))
68 dump[i] = stringify(obj[i]);
69 }
70 return dump;
71
72 };
73
74
75 var stringifyArgs = function (obj) {
76
77 var args = [];
78 for (var i = 0; i < obj.length; i++) {
79 args.push(stringify(obj[i]));
80 }
81 var res = JSON.stringify(args);
82 return res.substr(1, res.length - 2);
83 };
84
85 var createArgumentsSanitaizer = function (func, argsDesc, callback) {
86
87 return function () {
88 var realArgs = arguments;
89 var name = findName(arguments.callee);
90
91 var k = 0;
92 function argumentSanitaizer(desc, arg) {
93 if (!desc) {
94 throw new InternalError("argument description is null");
95 }
96 if (desc.dummy) {
97 k--;
98 return null;
99 }
100 if (desc.array) {
101 if (!(desc.array instanceof Object) || !(desc.array.element instanceof Object)) {
102 throw new InternalError("invalid argument description");
103 }
104
105 try {
106 for (var j = 0; j < arg.length; j++) {
107 argumentSanitaizer(desc.array.element, arg[j]);
108 }
109 } catch (x) {
110 throw new TypeError("incorrect argument");
111 }
112
113 return arg;
114 }
115 if (desc.obj) {
116 if (!(desc.obj instanceof Object)) {
117 throw new InternalError("invalid argument description");
118 }
119 var res = {}, i;
120 for (i in desc.obj) {
121 if (desc.obj.hasOwnProperty(i)) {
122 res[i] = argumentSanitaizer(desc.obj[i], arg[i]);
123 }
124 }
125 return res;
126 }
127 if (desc.str) {
128 if (desc.allowNull && !arg) {
129 return null;
130 }
131 checkString(arg, false);
132 return arg;
133 }
134 if (desc.number) {
135 if (typeof(arg) !== 'number' && typeof(arg) !== 'boolean')
136 throw new TypeError("incorrect argument");
137 return arg;
138 }
139 if (!desc.type) {
140 throw new InternalError("argument description miss required parameter");
141 }
142 if ((arg instanceof desc.type) || (desc.type === Function && ((typeof arg) === 'function'))
143 || (arg === null && desc.allowNull)) {
144 if (desc.type === Function) {
145 if (!arg) {
146 return null;
147 }
148
149 var id;
150 if (desc.argAsCallbackId !== undefined) {
151 id = realArgs[desc.argAsCallbackId];
152 }
153 return CallbackManager.makeCallback(uwa.ContextActionCallbackType,
154 function (context, user_data) {
155 arg();
156 }, name, id);
157 }
158 return arg;
159 } else {
160 throw new TypeError("incorrect argument");
161 }
162 throw new InternalError("unreacheable");
163 }
164 var args = [unity.context], i;
165 for (i = 0; i < argsDesc.length; i++) {
166 if (k >= realArgs.length && k > 0 && !argsDesc[i].dummy) {
167 throw new Error("not enough arguments");
168 }
169 var value = argumentSanitaizer(argsDesc[i], realArgs[k]);
170 k++;
171
172 if (argsDesc[i].obj) {
173 args = args.concat(value);
174 } else {
175 args.push(value);
176 }
177 }
178
179 if (k < realArgs.length) {
180 throw new Error("too much arguments");
181 }
182
183 if (callback)
184 callback.apply(uwa, args);
185 if (func)
186 return Function.apply.apply(func, [uwa, args]);
187
188 return null;
189 };
190
191 };
192 var api = {
193 init: function(props) {
194 checkString(props.name, false);
195 checkString(props.iconUrl, true);
196 checkString(props.domain, true);
197 checkString(props.login, true);
198 checkString(props.mimeTypes, true);
199 checkString(props.homepage, true);
200 if (props.homepage && !/^(http|https|file):\/\//.test(props.homepage)) {
201 throw new TypeError("incorrect argument");
202 }
203 backend("init", [props]);
204 }
205 ,
206 acceptData: createArgumentsSanitaizer(null,
207 [{ array: { element: { str: true } } }, { type: Function, js: true }],
208 function (context, mimeTypes, callback) {
209 backend('acceptData', [mimeTypes, callback]);
210 })
211 ,
212 addAction: createArgumentsSanitaizer(null,
213 [{ str: true }, { type: Function, argAsCallbackId: 0 }],
214 function (context, name, callback) {
215 backend('addAction', [name, callback]);
216 })
217 ,
218 clearAction: createArgumentsSanitaizer(null,
219 [{ str: true }]
220 , function (context, name) {
221 backend('clearAction', [name]);
222 })
223 ,
224 clearActions: createArgumentsSanitaizer(null,
225 [],
226 function (context) {
227 backend('clearActions', []);
228 })
229 ,
230 MediaPlayer: {
231 init: createArgumentsSanitaizer(null,
232 [{ str: true }],
233 function (context, name) {
234 backend('MediaPlayer.init', [name]);
235 })
236 ,
237 onPlayPause: createArgumentsSanitaizer(null,
238 [{ type: Function, allowNull: true }, { dummy: true }],
239 function (context, callback) {
240 backend('MediaPlayer.onPlayPause', [callback]);
241 }
242 )
243 ,
244 onPrevious: createArgumentsSanitaizer(null,
245 [{ type: Function, allowNull: true }, { dummy: true }],
246 function (context, callback) {
247 backend('MediaPlayer.onPrevious', [callback]);
248 })
249 ,
250 onNext: createArgumentsSanitaizer(null,
251 [{ type: Function, allowNull: true }, { dummy: true }],
252 function (context, callback) {
253 backend('MediaPlayer.onNext', [callback]);
254 }
255 )
256 ,
257 setTrack: createArgumentsSanitaizer(null,
258 [{ obj: { artist: { str: true, place: 0, allowNull: true },
259 album: { str: true, place: 1, allowNull: true },
260 title: { str: true, place: 2 },
261 artLocation: { str: true, place: 3, allowNull: true } } }],
262 function (context, trackinfos) {
263 backend('MediaPlayer.setTrack', [trackinfos]);
264 })
265 ,
266 setCanGoNext: createArgumentsSanitaizer(null,
267 [{ number: true }],
268 function (context, v) {
269 backend('MediaPlayer.setCanGoNext', [v]);
270 }
271 )
272 ,
273 setCanGoPrevious: createArgumentsSanitaizer(null,
274 [{ number: true }],
275 function (context, v) {
276 backend('MediaPlayer.setCanGoPrevious', [v]);
277 }
278 )
279 ,
280 setCanPlay: createArgumentsSanitaizer(null,
281 [{ number: true }],
282 function (context, v) { backend('MediaPlayer.setCanPlay', [v]); }
283 )
284 ,
285 setCanPause: createArgumentsSanitaizer(null,
286 [{ number: true }],
287 function (context, v) { backend('MediaPlayer.setCanPause', [v]); }
288 )
289 ,
290 setPlaybackState: createArgumentsSanitaizer(null,
291 [{ number: true }],
292 function (context, v) { backend('MediaPlayer.setPlaybackState', [v]); }
293 )
294 ,
295 getPlaybackState: createArgumentsSanitaizer(null
296 , [{ type: Function }]
297 , function (context, callback) {
298 backend('MediaPlayer.getPlaybackState', [callback]);
299 }
300 )
301 ,
302 PlaybackState: {PLAYING: 0, PAUSED:1}
303 },
304
305 Notification: {
306 showNotification: createArgumentsSanitaizer(null,
307 [{ str: true }, { str: true }, { str: true, allowNull: true }],
308 function (context, title, name, dummy) {
309 backend('Notification.showNotification', [title, name, dummy]);
310 }
311 )
312 },
313
314 Launcher: {
315 setCount: createArgumentsSanitaizer(null,
316 [{ number: true }],
317 function (context, count) {
318 backend('Launcher.setCount', [count]);
319 }
320 )
321 ,
322 clearCount: createArgumentsSanitaizer(null,
323 [],
324 function (context) {
325 backend('Launcher.clearCount', []);
326 }),
327 setProgress: createArgumentsSanitaizer(null,
328 [{ number: true }],
329 function (context, progress) {
330 backend('Launcher.setProgress', [progress]);
331 }
332 )
333 ,
334 clearProgress: createArgumentsSanitaizer(null,
335 [],
336 function (context) {
337 backend('Launcher.clearProgress', []);
338 }
339 )
340 ,
341 setUrgent: createArgumentsSanitaizer(null,
342 [],
343 function (context) {
344 backend('Launcher.setUrgent', []);
345 }
346 )
347 ,
348 addAction: function(arg1, arg2) {
349 backend('Launcher.addAction', [arg1, arg2]);
350 }
351 ,
352 removeAction: createArgumentsSanitaizer(null,
353 [{ str: true }],
354 function (context, name) {
355 backend('Launcher.removeAction', [name]);
356 }
357 )
358 ,
359 removeActions: createArgumentsSanitaizer(null,
360 [],
361 function (context) {
362 backend('Launcher.removeActions', []);
363 }
364 )
365 },
366 MessagingIndicator: {
367 addAction: createArgumentsSanitaizer(null,
368 [{ str: true }, { type: Function, argAsCallbackId: 0 }, { dummy: true }],
369 function (context, name, callback, dummy) {
370 backend('MessagingIndicator.addAction', [name, callback, dummy]);
371 }
372 )
373 ,
374 showIndicator: function(name, properties) {
375 backend('MessagingIndicator.showIndicator', [name, properties]);
376 }
377 ,
378 clearIndicator: createArgumentsSanitaizer(null, [{ str: true }], function(context, name) { backend('MessagingIndicator.clearIndicator', [name]); }),
379 clearIndicators: createArgumentsSanitaizer(null, [], function (context) { backend('MessagingIndicator.clearIndicators', []); })
380 }
381 };
382 return api;
383};
384
3850
=== added file 'chromium-extension/unity-api-page-proxy.js'
--- chromium-extension/unity-api-page-proxy.js 1970-01-01 00:00:00 +0000
+++ chromium-extension/unity-api-page-proxy.js 2014-11-18 07:07:55 +0000
@@ -0,0 +1,146 @@
1/**
2 *
3 *
4 */
5setTimeout (
6 function () {
7 var CallbackManagerBuilder = function () {
8 var prepend = 'unity-webapps-chromium-api';
9 var callbacks = {};
10 return {
11 store: function (callback) {
12 var gensym = function() { return prepend + Math.random(); };
13 var id = gensym();
14 while (undefined != callbacks[id]) {
15 id = gensym();
16 }
17 callbacks[id] = callback;
18 return id;
19 }
20 ,
21 get: function (id) {
22 return callbacks[id];
23 }
24 };
25 };
26 var callbackmanager = CallbackManagerBuilder();
27
28 /**
29 * Acknowledge that the API has been fully injected
30 */
31 var sendApiCreatedAcknowledge = function () {
32 var e = document.createEvent ("Events");
33 e.initEvent ("unity-webapps-api-ready", false, false);
34 document.dispatchEvent (e);
35 };
36
37 /**
38 *
39 *
40 */
41 function sendToApi (type, data) {
42 var callback = null;
43 var d = document.createElement ("textarea");
44 var e = document.createEvent ("Events");
45 d.style.cssText = "display:none;";
46
47 var isIterableObject = function(obj) {
48 if (obj === undefined || obj === null) {
49 return false;
50 }
51 var t = typeof(obj);
52 var types = {'string': 0, 'function': 0, 'boolean': 0, 'number': 0, 'undefined': 0};
53 return types[t] === undefined;
54 };
55
56 function transformToIdIfNecessary(obj) {
57 var ret = obj;
58 if (obj instanceof Function) {
59 var id = callbackmanager.store(obj);
60 ret = {callbackid: id};
61 }
62 return ret;
63 }
64 // map function callback (not serializable to a different world)
65 // to ids
66 function transformCallbacksToIds (obj) {
67 if ( ! isIterableObject(obj)) {
68 return transformToIdIfNecessary (obj);
69 }
70 var ret = (obj instanceof Array) ? [] : {};
71 for (var key in obj) {
72 if (obj.hasOwnProperty(key)) {
73 if (obj[key] instanceof Function) {
74 var id = callbackmanager.store(obj[key]);
75 ret[key] = {callbackid: id};
76 }
77 else if (isIterableObject (obj[key])) {
78 ret[key] = transformCallbacksToIds (obj[key]);
79 }
80 else {
81 ret[key] = obj[key];
82 }
83 }
84 }
85 return ret;
86 };
87
88 // TODO: assumes some structure, does not play well w/ arrays
89 // actually converts: [1,2,3] -> {'0': 1, '1': 2, '2': 3}
90 d.value = JSON.stringify (
91 data.map (
92 function (datum) {
93 return transformCallbacksToIds (datum);
94 }
95 )
96 );
97 d.addEventListener ("unity-webapps-chromium-api-com-link-ack"
98 ,
99 function() {
100 if (callback) callback (d.value);
101 d.parentNode.removeChild (d);
102 }
103 , true);
104
105 d.setAttribute ("data-eventType", type);
106 document.body.appendChild (d);
107 e.initEvent ("unity-webapps-chromium-api-com-link", false, true);
108 d.dispatchEvent (e);
109 };
110
111 document.addEventListener ("unity-webapps-chromium-api-com-link-callback-called"
112 ,
113 function(event) {
114 var from = event.target;
115 if (from) {
116 if (from.value) {
117 var callback = callbackmanager.get(from.value);
118 if (callback) {
119 callback ();
120 }
121 }
122 var ret = document.createEvent('Events');
123 ret.initEvent('unity-webapps-chromium-api-com-link-callback-called-ack', true, false);
124 from.dispatchEvent(ret);
125 }
126 }
127 , true);
128
129 var api = UnityWebappsApiPageProxyBuilder(sendToApi);
130
131 function unity() {
132 }
133 unity.prototype = {
134 __proto__: window.external,
135 getUnityObject: function (version) {
136 console.log ('Proxy: getUnityObject called with version ' + version);
137 if (version === 1)
138 return api;
139 throw new Error("incorrect version");
140 }
141 };
142 window.external = new unity();
143
144 sendApiCreatedAcknowledge();
145 }
146, 0);
0147
=== removed file 'chromium-extension/unity-api-page-proxy.js'
--- chromium-extension/unity-api-page-proxy.js 2013-12-16 07:15:32 +0000
+++ chromium-extension/unity-api-page-proxy.js 1970-01-01 00:00:00 +0000
@@ -1,146 +0,0 @@
1/**
2 *
3 *
4 */
5setTimeout (
6 function () {
7 var CallbackManagerBuilder = function () {
8 var prepend = 'unity-webapps-chromium-api';
9 var callbacks = {};
10 return {
11 store: function (callback) {
12 var gensym = function() { return prepend + Math.random(); };
13 var id = gensym();
14 while (undefined != callbacks[id]) {
15 id = gensym();
16 }
17 callbacks[id] = callback;
18 return id;
19 }
20 ,
21 get: function (id) {
22 return callbacks[id];
23 }
24 };
25 };
26 var callbackmanager = CallbackManagerBuilder();
27
28 /**
29 * Acknowledge that the API has been fully injected
30 */
31 var sendApiCreatedAcknowledge = function () {
32 var e = document.createEvent ("Events");
33 e.initEvent ("unity-webapps-api-ready", false, false);
34 document.dispatchEvent (e);
35 };
36
37 /**
38 *
39 *
40 */
41 function sendToApi (type, data) {
42 var callback = null;
43 var d = document.createElement ("textarea");
44 var e = document.createEvent ("Events");
45 d.style.cssText = "display:none;";
46
47 var isIterableObject = function(obj) {
48 if (obj === undefined || obj === null) {
49 return false;
50 }
51 var t = typeof(obj);
52 var types = {'string': 0, 'function': 0, 'boolean': 0, 'number': 0, 'undefined': 0};
53 return types[t] === undefined;
54 };
55
56 function transformToIdIfNecessary(obj) {
57 var ret = obj;
58 if (obj instanceof Function) {
59 var id = callbackmanager.store(obj);
60 ret = {callbackid: id};
61 }
62 return ret;
63 }
64 // map function callback (not serializable to a different world)
65 // to ids
66 function transformCallbacksToIds (obj) {
67 if ( ! isIterableObject(obj)) {
68 return transformToIdIfNecessary (obj);
69 }
70 var ret = (obj instanceof Array) ? [] : {};
71 for (var key in obj) {
72 if (obj.hasOwnProperty(key)) {
73 if (obj[key] instanceof Function) {
74 var id = callbackmanager.store(obj[key]);
75 ret[key] = {callbackid: id};
76 }
77 else if (isIterableObject (obj[key])) {
78 ret[key] = transformCallbacksToIds (obj[key]);
79 }
80 else {
81 ret[key] = obj[key];
82 }
83 }
84 }
85 return ret;
86 };
87
88 // TODO: assumes some structure, does not play well w/ arrays
89 // actually converts: [1,2,3] -> {'0': 1, '1': 2, '2': 3}
90 d.value = JSON.stringify (
91 data.map (
92 function (datum) {
93 return transformCallbacksToIds (datum);
94 }
95 )
96 );
97 d.addEventListener ("unity-webapps-chromium-api-com-link-ack"
98 ,
99 function() {
100 if (callback) callback (d.value);
101 d.parentNode.removeChild (d);
102 }
103 , true);
104
105 d.setAttribute ("data-eventType", type);
106 document.body.appendChild (d);
107 e.initEvent ("unity-webapps-chromium-api-com-link", false, true);
108 d.dispatchEvent (e);
109 };
110
111 document.addEventListener ("unity-webapps-chromium-api-com-link-callback-called"
112 ,
113 function(event) {
114 var from = event.target;
115 if (from) {
116 if (from.value) {
117 var callback = callbackmanager.get(from.value);
118 if (callback) {
119 callback ();
120 }
121 }
122 var ret = document.createEvent('Events');
123 ret.initEvent('unity-webapps-chromium-api-com-link-callback-called-ack', true, false);
124 from.dispatchEvent(ret);
125 }
126 }
127 , true);
128
129 var api = UnityWebappsApiPageProxyBuilder(sendToApi);
130
131 function unity() {
132 }
133 unity.prototype = {
134 __proto__: window.external,
135 getUnityObject: function (version) {
136 console.log ('Proxy: getUnityObject called with version ' + version);
137 if (version === 1)
138 return api;
139 throw new Error("incorrect version");
140 }
141 };
142 window.external = new unity();
143
144 sendApiCreatedAcknowledge();
145 }
146, 0);
1470
=== modified file 'chromium-extension/unity-webapps.json.in'
--- chromium-extension/unity-webapps.json.in 2012-04-30 15:39:21 +0000
+++ chromium-extension/unity-webapps.json.in 2014-11-18 07:07:55 +0000
@@ -1,4 +1,4 @@
1{1{
2 "external_crx": "@EXTDIR@",2 '"external_crx": "$${EXTENSION_DIR}/$${EXTENSION_FILE}"',
3 "external_version": "@VERSION@"3 '"external_version": "$${PROJECT_VERSION}"'
4}4}
55
=== removed file 'chromium-extension/unity_api_page_proxy_generator.py'
--- chromium-extension/unity_api_page_proxy_generator.py 2012-06-17 14:33:16 +0000
+++ chromium-extension/unity_api_page_proxy_generator.py 1970-01-01 00:00:00 +0000
@@ -1,96 +0,0 @@
1#!/usr/bin/python
2
3"""
4Generates a *.js file (defaults to unity-api-page-proxy-builder.js) by parsing & extracting expected
5information out of an input .js filename (defaults to unity-api.js). Extracts only the meaningful bits
6(mostly the argument sanitizer bits) and generates a proper web page side unity api w/ a proper validation
7layer (as exposed by unity-api.js)
8
9Takes an input filename as an argument.
10"""
11
12import sys
13
14class DEFAULTS:
15 input_api_filename = "unity-api.js"
16 output_api_filename = "unity-api-page-proxy-builder-gen-py.js"
17
18input_api_filename = DEFAULTS.input_api_filename
19output_api_filename = DEFAULTS.output_api_filename
20
21def extractFunctionDefinition (name, content):
22 import re
23 funcre = re.compile (r'([^\w_]|\s*)(' + name + r')\s*\((?P<params>.*?)\)\s*{', re.MULTILINE)
24 m = re.search (funcre, content)
25 if m:
26 s = ['{']
27 start = m.end(0)
28 end = start + 1
29 for idx in xrange (start, len(content)-1):
30 if content[idx] == '{':
31 s.append('{')
32 elif content[idx] == '}':
33 s.pop()
34 if s.count('{') == 0:
35 end = idx
36 break
37 return m.group('params'), content[start:end]
38 return None, None
39
40def untabify (body):
41 mintabs = min([len([c for c in line if c == ' ' or c == '\t']) for line in body.split('\n') if len(line.strip()) != 0])
42 return '\n'.join ([line[mintabs:] for line in body.split('\n')])
43
44def generateFunction (name, params, body):
45 return """
46var %s = function (%s) {
47 %s
48};
49""" % (name, params, untabify(body))
50
51def extractObjectDefinition(content, oname):
52 import re
53 apire = re.compile(oname + '\s*[=|:]\s*', re.MULTILINE)
54 m = re.search(apire, content)
55 s = []
56 start = m.end(0)
57 end = start
58 for idx in xrange (start, len(content)-1):
59 if content[idx] == '{':
60 s.append('{')
61 elif content[idx] == '}':
62 s.pop()
63 if s.count('{') == 0:
64 end = idx
65 break
66 return content[start:end]
67
68def extractApiDefinition(content):
69 return extractObjectDefinition(content, 'api')
70
71def generateUnityApiTargetFile (inputfilename, outputfilename):
72 content = open(inputfilename).read()
73 function_names = ['findName', 'stringify', 'stringifyArgs', 'createArgumentsSanitaizer']
74 extracted_data = [(function_name, extractFunctionDefinition(function_name, content)) for function_name in function_names]
75 extracted_functions = [{'name': extracted_datum[0], 'params': extracted_datum[1][0], 'body': extracted_datum[1][1]} for extracted_datum in extracted_data]
76
77 buildercontent = 'var UnityWebappsApiPageProxyBuilder = function(backend) {\n'
78 buildercontent += """
79 var dummy = true;
80 var unity = { context: dummy, contextReady: dummy };
81 var uwa = { ContextActionCallbackType: null };
82
83 var CallbackManager = {
84 makeCallback: function (dumd, func) {
85 return func;
86 }
87 };
88"""
89 buildercontent += '\n'.join([generateFunction(func['name'], func['params'], func['body']) for func in extracted_functions])
90 buildercontent += 'var api = {\n};\n'
91 buildercontent += '};\n\n'
92 open(outputfilename, "w+").write(buildercontent)
93
94generateUnityApiTargetFile (input_api_filename, output_api_filename)
95
96
970
=== added file 'common-project-config.pri'
--- common-project-config.pri 1970-01-01 00:00:00 +0000
+++ common-project-config.pri 2014-11-18 07:07:55 +0000
@@ -0,0 +1,41 @@
1#-----------------------------------------------------------------------------
2# Common configuration for all projects.
3#-----------------------------------------------------------------------------
4
5# we don't like warnings...
6QMAKE_CXXFLAGS += -Werror
7# Disable RTTI
8QMAKE_CXXFLAGS += -fno-exceptions -fno-rtti
9
10TOP_SRC_DIR = $$PWD
11TOP_BUILD_DIR = $${TOP_SRC_DIR}/$(BUILD_DIR)
12
13include(coverage.pri)
14
15#-----------------------------------------------------------------------------
16# setup the installation prefix
17#-----------------------------------------------------------------------------
18INSTALL_PREFIX = /usr # default installation prefix
19
20# default prefix can be overriden by defining PREFIX when running qmake
21isEmpty(PREFIX) {
22 message("====")
23 message("==== NOTE: To override the installation path run: `qmake PREFIX=/custom/path'")
24 message("==== (current installation path is `$${INSTALL_PREFIX}')")
25} else {
26 INSTALL_PREFIX = $${PREFIX}
27 message("====")
28 message("==== install prefix set to `$${INSTALL_PREFIX}'")
29}
30
31INSTALL_LIBDIR = $${INSTALL_PREFIX}/lib
32
33isEmpty(LIBDIR) {
34 message("====")
35 message("==== NOTE: To override the library installation path run: `qmake LIBDIR=/custom/path'")
36 message("==== (current installation path is `$${INSTALL_LIBDIR}')")
37} else {
38 INSTALL_LIBDIR = $${LIBDIR}
39 message("====")
40 message("==== install prefix set to `$${INSTALL_LIBDIR}'")
41}
042
=== added file 'common-vars.pri'
--- common-vars.pri 1970-01-01 00:00:00 +0000
+++ common-vars.pri 2014-11-18 07:07:55 +0000
@@ -0,0 +1,6 @@
1#-----------------------------------------------------------------------------
2# Common variables for all projects.
3#-----------------------------------------------------------------------------
4
5PROJECT_NAME = unity_webapps_chromium
6PROJECT_VERSION = 3.2
07
=== removed file 'configure.ac'
--- configure.ac 2014-03-07 15:22:55 +0000
+++ configure.ac 1970-01-01 00:00:00 +0000
@@ -1,62 +0,0 @@
1dnl Process this file with autoconf to produce a configure script.
2dnl Created by Anjuta application wizard.
3
4AC_INIT(unity_webapps_chromium, 3.1)
5AC_CONFIG_HEADERS([config.h])
6AM_INIT_AUTOMAKE([1.11])
7AM_SILENT_RULES([yes])
8AC_PROG_CC
9AC_PROG_CC_C99
10AM_PROG_CC_C_O
11
12AC_CONFIG_MACRO_DIR([m4])
13
14AC_DISABLE_STATIC
15LT_INIT
16
17PKG_CHECK_MODULES(UNITY_NPAPI_PLUGIN, [libunity_webapps-0.2 glib-2.0 libnotify libunity-webapps-repository libwnck-1.0])
18
19
20dnl ***************************************************************************
21dnl debug
22dnl ***************************************************************************
23
24AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging. [default=no]]), [enable_debug="yes"],[enable_debug="no"])
25
26if test "x$enable_debug" = "xyes"; then
27 NPAPI_DEBUG_CFLAGS="-DNPAPI_DEBUG_ENABLED"
28else
29 NPAPI_DEBUG_CFLAGS=""
30fi
31
32AC_SUBST(NPAPI_DEBUG_CFLAGS)
33
34dnl ========== Tests ==========
35
36AC_ARG_ENABLE(tests, AC_HELP_STRING([--enable-tests],
37 [Enable tests. [default=no]]),
38 [enable_tests="yes"], [enable_tests="no"])
39if test "x$enable_tests" = "xyes"; then
40 AC_DEFINE([ENABLE_TESTS], 1, [Enable tests.])
41 # Tests need debug to be enabled
42 enable_debug="yes"
43fi
44AM_CONDITIONAL([ENABLE_TESTS], [test "x$enable_tests" = "xyes"])
45
46dnl ===== gcov coverage reporting =====
47m4_include([m4/gcov.m4])
48AC_TDD_GCOV
49AC_SUBST(UNITY_NPAPI_PLUGIN_COVERAGE_CFLAGS)
50AC_SUBST(UNITY_NPAPI_PLUGIN_COVERAGE_CXXFLAGS)
51AC_SUBST(UNITY_NPAPI_PLUGIN_COVERAGE_LDFLAGS)
52
53AC_OUTPUT([
54Makefile
55chromium-extension/Makefile
56npapi-plugin/src/libunity_npapi_plugin-0.1.pc
57npapi-plugin/Makefile
58npapi-plugin/src/Makefile
59tests/Makefile
60tests/unit/Makefile
61tests/unit/npapi/Makefile
62po/Makefile])
630
=== added file 'coverage.pri'
--- coverage.pri 1970-01-01 00:00:00 +0000
+++ coverage.pri 2014-11-18 07:07:55 +0000
@@ -0,0 +1,49 @@
1# Coverage
2CONFIG(coverage) {
3 OBJECTS_DIR =
4 MOC_DIR =
5 TOP_SRC_DIR = $$PWD
6
7 LIBS += -lgcov
8 QMAKE_CXXFLAGS += --coverage
9 QMAKE_LDFLAGS += --coverage
10
11 QMAKE_EXTRA_TARGETS += coverage cov
12 QMAKE_EXTRA_TARGETS += clean-gcno clean-gcda coverage-html \
13 generate-coverage-html clean-coverage-html coverage-gcovr \
14 generate-gcovr generate-coverage-gcovr clean-coverage-gcovr
15
16 clean-gcno.commands = \
17 "@echo Removing old coverage instrumentation"; \
18 "find -name '*.gcno' -print | xargs -r rm"
19
20 clean-gcda.commands = \
21 "@echo Removing old coverage results"; \
22 "find -name '*.gcda' -print | xargs -r rm"
23
24 coverage-html.depends = clean-gcda check generate-coverage-html
25
26 generate-coverage-html.commands = \
27 "@echo Collecting coverage data"; \
28 "lcov --directory $${TOP_SRC_DIR} --capture --output-file coverage.info --no-checksum --compat-libtool"; \
29 "lcov --extract coverage.info \"*/messaging-host/*.cpp\" -o coverage.info"; \
30 "lcov --remove coverage.info \"moc_*.cpp\" --remove coverage.info \"tests/*.cpp\" -o coverage.info"; \
31 "LANG=C genhtml --prefix $${TOP_SRC_DIR} --output-directory coverage-html --title \"Code Coverage\" --legend --show-details coverage.info"
32
33 clean-coverage-html.depends = clean-gcda
34 clean-coverage-html.commands = \
35 "lcov --directory $${TOP_SRC_DIR} -z"; \
36 "rm -rf coverage.info coverage-html"
37
38 coverage-gcovr.depends = clean-gcda check generate-coverage-gcovr
39
40 generate-coverage-gcovr.commands = \
41 "@echo Generating coverage GCOVR report"; \
42 "gcovr -x -r $${TOP_SRC_DIR} -o $${TOP_SRC_DIR}/coverage.xml -e \".*/moc_.*\" -e \"tests/.*\" -e \".*\\.h\""
43
44 clean-coverage-gcovr.depends = clean-gcda
45 clean-coverage-gcovr.commands = \
46 "rm -rf $${TOP_SRC_DIR}/coverage.xml"
47
48 QMAKE_CLEAN += *.gcda *.gcno coverage.info coverage.xml
49}
050
=== modified file 'debian/changelog'
--- debian/changelog 2014-03-18 20:59:35 +0000
+++ debian/changelog 2014-11-18 07:07:55 +0000
@@ -1,3 +1,9 @@
1unity-chromium-extension (3.2.0+14.04.20140318-0ubuntu3) UNRELEASED; urgency=medium
2
3 * Support native messaging. (with Alberto Mardegan)
4
5 -- Justin McPherson <justin.mcpherson@canonical.com> Fri, 23 May 2014 20:31:14 +1000
6
1unity-chromium-extension (3.0.0+14.04.20140318-0ubuntu1) trusty; urgency=low7unity-chromium-extension (3.0.0+14.04.20140318-0ubuntu1) trusty; urgency=low
28
3 [ Ubuntu daily release ]9 [ Ubuntu daily release ]
410
=== modified file 'debian/compat'
--- debian/compat 2012-11-19 22:39:34 +0000
+++ debian/compat 2014-11-18 07:07:55 +0000
@@ -1,1 +1,1 @@
1819
22
=== modified file 'debian/control'
--- debian/control 2014-03-18 20:50:57 +0000
+++ debian/control 2014-11-18 07:07:55 +0000
@@ -1,22 +1,18 @@
1Source: unity-chromium-extension1Source: unity-chromium-extension
2Priority: optional2Priority: optional
3Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com>3Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com>
4# FIXME: We should be using debhelper 9, but that breaks the build4Build-Depends: chromium-browser (>= 34.0.1847.116-0ubuntu2),
5# for some currently unknown reason.5 debhelper (>= 9),
6Build-Depends: autotools-dev,
7 chromium-browser (>= 20.0.1132.47~r144678-0ubuntu4),
8 debhelper (>= 8),
9 dh-autoreconf,6 dh-autoreconf,
10 gnome-common,
11 libglib2.0-dev,7 libglib2.0-dev,
12 libgtest-dev,
13 libnotify-dev,
14 libunity-webapps-dev (>= 1.8.0),8 libunity-webapps-dev (>= 1.8.0),
15 libwnck-dev,
16 openssl,9 openssl,
17 pkg-config,10 pkg-config,
18 vim-common,11 vim-common,
19 zip,12 zip,
13 qt5-default,
14 qt5-qmake,
15 xvfb,
20Standards-Version: 3.9.516Standards-Version: 3.9.5
21Section: gnome17Section: gnome
22Homepage: https://launchpad.net/unity-chromium-extension18Homepage: https://launchpad.net/unity-chromium-extension
@@ -27,7 +23,7 @@
2723
28Package: unity-chromium-extension24Package: unity-chromium-extension
29Architecture: any25Architecture: any
30Depends: chromium-browser (>= 20.0.1132.47~r144678-0ubuntu4),26Depends: chromium-browser (>= 34.0.1847.116-0ubuntu2),
31 unity-webapps-service,27 unity-webapps-service,
32 webbrowser-app,28 webbrowser-app,
33 ${misc:Depends},29 ${misc:Depends},
3430
=== modified file 'debian/copyright'
--- debian/copyright 2012-11-19 19:26:58 +0000
+++ debian/copyright 2014-11-18 07:07:55 +0000
@@ -8,48 +8,3 @@
8 On Debian systems, the complete text of the GNU General8 On Debian systems, the complete text of the GNU General
9 Public License version 3 can be found in `/usr/share/common-licenses/GPL-3'.9 Public License version 3 can be found in `/usr/share/common-licenses/GPL-3'.
1010
11Files: npapi-plugin/*
12Copyright: 2012 Canonical Ltd
13License: GPL-2+
14
15Files: npapi-plugin/src/npapi-headers/headers/nptypes.h
16Copyright: 2004 mozilla.org
17License: GPL-2+
18
19Files: npapi-plugin/src/npapi-headers/headers/npapi.h
20 npapi-plugin/src/npapi-headers/headers/npfunctions.h
21Copyright: 1998 Netscape Communications Corporation
22License: GPL-2+
23
24Files: npapi-plugin/src/npapi-headers/headers/npruntime.h
25Copyright: 2004 Apple Computer, Inc.
26License:
27 Redistribution and use in source and binary forms, with or without
28 modification, are permitted provided that the following conditions are
29 met:
30 .
31 1. Redistributions of source code must retain the above copyright
32 notice, this list of conditions and the following disclaimer.
33 2. Redistributions in binary form must reproduce the above copyright
34 notice, this list of conditions and the following disclaimer in the
35 documentation and/or other materials provided with the distribution.
36 3. Neither the names of Apple Computer, Inc. ("Apple") or The Mozilla
37 Foundation ("Mozilla") nor the names of their contributors may be used
38 to endorse or promote products derived from this software without
39 specific prior written permission.
40 .
41 THIS SOFTWARE IS PROVIDED BY APPLE, MOZILLA AND THEIR CONTRIBUTORS "AS
42 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
43 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
44 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, MOZILLA OR
45 THEIR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
47 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
48 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
49 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
50 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
51 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52
53License: GPL-2+
54 On Debian systems, the complete text of the GNU General
55 Public License version 2 can be found in `/usr/share/common-licenses/GPL-2'.
5611
=== modified file 'debian/rules'
--- debian/rules 2013-09-20 19:12:01 +0000
+++ debian/rules 2014-11-18 07:07:55 +0000
@@ -4,17 +4,15 @@
4#export DH_VERBOSE=14#export DH_VERBOSE=1
5export DPKG_GENSYMBOLS_CHECK_LEVEL=45export DPKG_GENSYMBOLS_CHECK_LEVEL=4
66
7override_dh_autoreconf:
8 NOCONFIGURE=1 dh_autoreconf ./autogen.sh
9
10override_dh_auto_configure:7override_dh_auto_configure:
11 cp debian/unity-webapps.pem .8 cp debian/unity-webapps.pem chromium-extension/
12 dh_auto_configure -- --enable-tests=yes9 dh_auto_configure
10
11override_dh_auto_install:
12 dh_auto_install --destdir=debian/tmp
1313
14override_dh_install:14override_dh_install:
15 rm -rf debian/*/usr/lib/*npapi* debian/*/usr/lib/pkgconfig \
16 debian/*/usr/include
17 dh_install --fail-missing15 dh_install --fail-missing
1816
19%:17%:
20 dh $@ --with autoreconf --fail-missing18 dh $@
2119
=== added file 'debian/unity-chromium-extension.install'
--- debian/unity-chromium-extension.install 1970-01-01 00:00:00 +0000
+++ debian/unity-chromium-extension.install 2014-11-18 07:07:55 +0000
@@ -0,0 +1,4 @@
1etc/chromium/native-messaging-hosts/com.canonical.webapp.installer.json
2usr/lib/libunity-chromium/unity-webapps.crx
3usr/share/chromium/extensions/*.json
4usr/share/unity-webapps/bin/unity-webapps-messaging-host
05
=== removed directory 'm4'
=== removed file 'm4/gcov.m4'
--- m4/gcov.m4 2013-12-23 01:17:40 +0000
+++ m4/gcov.m4 1970-01-01 00:00:00 +0000
@@ -1,79 +0,0 @@
1# Checks for existence of coverage tools:
2# * gcov
3# * lcov
4# * genhtml
5# * gcovr
6#
7# Sets ac_cv_check_gcov to yes if tooling is present
8# and reports the executables to the variables LCOV, GCOVR and GENHTML.
9AC_DEFUN([AC_TDD_GCOV],
10[
11 AC_ARG_ENABLE(gcov,
12 AS_HELP_STRING([--enable-gcov],
13 [enable coverage testing with gcov]),
14 [use_gcov=yes], [use_gcov=no])
15
16 AM_CONDITIONAL(HAVE_GCOV, test "x$use_gcov" = "xyes")
17
18 if test "x$use_gcov" = "xyes"; then
19 # we need gcc:
20 if test "$GCC" != "yes"; then
21 AC_MSG_ERROR([GCC is required for --enable-gcov])
22 fi
23
24 # Check if ccache is being used
25 AC_CHECK_PROG(SHTOOL, shtool, shtool)
26 if test "$SHTOOL"; then
27 AS_CASE([`$SHTOOL path $CC`],
28 [*ccache*], [gcc_ccache=yes],
29 [gcc_ccache=no])
30 fi
31
32 if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
33 AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
34 fi
35
36 lcov_version_list="1.6 1.7 1.8 1.9 1.10"
37 AC_CHECK_PROG(LCOV, lcov, lcov)
38 AC_CHECK_PROG(GENHTML, genhtml, genhtml)
39
40 if test "$LCOV"; then
41 AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
42 glib_cv_lcov_version=invalid
43 lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
44 for lcov_check_version in $lcov_version_list; do
45 if test "$lcov_version" = "$lcov_check_version"; then
46 glib_cv_lcov_version="$lcov_check_version (ok)"
47 fi
48 done
49 ])
50 else
51 lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
52 AC_MSG_ERROR([$lcov_msg])
53 fi
54
55 case $glib_cv_lcov_version in
56 ""|invalid[)]
57 lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
58 AC_MSG_ERROR([$lcov_msg])
59 LCOV="exit 0;"
60 ;;
61 esac
62
63 if test -z "$GENHTML"; then
64 AC_MSG_ERROR([Could not find genhtml from the lcov package])
65 fi
66
67 # Remove all optimization flags from CFLAGS
68 changequote({,})
69 CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
70 changequote([,])
71
72 # Add the special gcc flags
73 UNITY_NPAPI_PLUGIN_COVERAGE_CFLAGS="--coverage"
74 UNITY_NPAPI_PLUGIN_COVERAGE_CXXFLAGS="--coverage"
75 UNITY_NPAPI_PLUGIN_COVERAGE_LDFLAGS="-lgcov"
76
77fi
78]) # AC_TDD_GCOV
79
800
=== added directory 'messaging-host'
=== added file 'messaging-host/Makefile.am'
--- messaging-host/Makefile.am 1970-01-01 00:00:00 +0000
+++ messaging-host/Makefile.am 2014-11-18 07:07:55 +0000
@@ -0,0 +1,2 @@
1EXTRA_DIST += \
2 installation-host
03
=== added file 'messaging-host/com.canonical.webapp.installer.json.in'
--- messaging-host/com.canonical.webapp.installer.json.in 1970-01-01 00:00:00 +0000
+++ messaging-host/com.canonical.webapp.installer.json.in 2014-11-18 07:07:55 +0000
@@ -0,0 +1,9 @@
1{
2 '"name": "com.canonical.webapp.installer"',
3 '"description": "Canonical WebApp Installation Host"',
4 '"path": "$${target.path}/$${TARGET}"',
5 '"type": "stdio"',
6 '"allowed_origins"': [
7 '"chrome-extension://pmoflmbbcfgacopiikdcpmbiellfihdg/"'
8 ]
9}
010
=== added file 'messaging-host/connection.cpp'
--- messaging-host/connection.cpp 1970-01-01 00:00:00 +0000
+++ messaging-host/connection.cpp 2014-11-18 07:07:55 +0000
@@ -0,0 +1,152 @@
1/*
2 * Copyright (C) 2014 Canonical Ltd.
3 *
4 * This file is part of unity-chromium-extension
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 3, as published
8 * by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranties of
12 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13 * PURPOSE. See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "connection.h"
20
21#include <QByteArray>
22#include <QDebug>
23#include <QFile>
24#include <QJsonDocument>
25#include <QSocketNotifier>
26#include <fcntl.h>
27#include <stdio.h>
28#include <unistd.h>
29
30using namespace UnityWebapps;
31
32namespace UnityWebapps {
33
34class ConnectionPrivate: public QObject
35{
36 Q_OBJECT
37 Q_DECLARE_PUBLIC(Connection)
38
39public:
40 inline ConnectionPrivate(Connection *connection);
41 inline ~ConnectionPrivate();
42
43 bool open();
44
45private Q_SLOTS:
46 void onReadyRead();
47
48private:
49 QFile m_readChannel;
50 QFile m_writeChannel;
51 QByteArray m_readBuffer;
52 int m_expectedLength;
53 mutable Connection *q_ptr;
54};
55
56} // namespace
57
58ConnectionPrivate::ConnectionPrivate(Connection *connection):
59 QObject(connection),
60 m_expectedLength(0),
61 q_ptr(connection)
62{
63}
64
65ConnectionPrivate::~ConnectionPrivate()
66{
67}
68
69bool ConnectionPrivate::open()
70{
71 bool ok;
72
73 int flag = fcntl(STDIN_FILENO, F_GETFL);
74 if (Q_UNLIKELY(flag == -1)) return false;
75
76 fcntl(STDIN_FILENO, F_SETFL, flag | O_NONBLOCK);
77
78 ok = m_readChannel.open(stdin, QIODevice::ReadOnly);
79 if (Q_UNLIKELY(!ok)) return false;
80
81 ok = m_writeChannel.open(stdout, QIODevice::WriteOnly);
82 if (Q_UNLIKELY(!ok)) return false;
83
84 QSocketNotifier *notifier = new QSocketNotifier(m_readChannel.handle(),
85 QSocketNotifier::Read,
86 this);
87 QObject::connect(notifier, SIGNAL(activated(int)),
88 this, SLOT(onReadyRead()));
89
90 // There might be already something to read
91 onReadyRead();
92
93 return true;
94}
95
96void ConnectionPrivate::onReadyRead()
97{
98 Q_Q(Connection);
99
100 while (true) {
101 if (m_expectedLength == 0) {
102 /* We are beginning a new read */
103
104 quint32 length;
105 int bytesRead = m_readChannel.read((char *)&length,
106 sizeof(length));
107 if (bytesRead < int(sizeof(length))) break;
108 m_expectedLength = length;
109 m_readBuffer.clear();
110 }
111
112 int neededBytes = m_expectedLength - m_readBuffer.length();
113 QByteArray buffer = m_readChannel.read(neededBytes);
114 m_readBuffer += buffer;
115 if (buffer.length() < neededBytes) break;
116 if (m_readBuffer.length() == m_expectedLength) {
117 QJsonDocument doc = QJsonDocument::fromJson(m_readBuffer);
118 Q_EMIT q->messageReceived(doc.toVariant().toMap());
119 m_expectedLength = 0;
120 }
121 }
122}
123
124Connection::Connection(QObject *parent):
125 QObject(parent),
126 d_ptr(new ConnectionPrivate(this))
127{
128}
129
130Connection::~Connection()
131{
132}
133
134bool Connection::open()
135{
136 Q_D(Connection);
137 return d->open();
138}
139
140void Connection::postMessage(const QVariantMap &message)
141{
142 Q_D(Connection);
143
144 QJsonDocument doc = QJsonDocument::fromVariant(message);
145 QByteArray json = doc.toJson();
146 quint32 length = json.length();
147 d->m_writeChannel.write((char *)&length, sizeof(length));
148 d->m_writeChannel.write(json);
149 d->m_writeChannel.flush();
150}
151
152#include "connection.moc"
0153
=== added file 'messaging-host/connection.h'
--- messaging-host/connection.h 1970-01-01 00:00:00 +0000
+++ messaging-host/connection.h 2014-11-18 07:07:55 +0000
@@ -0,0 +1,52 @@
1/*
2 * Copyright (C) 2014 Canonical Ltd.
3 *
4 * This file is part of unity-chromium-extension
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 3, as published
8 * by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranties of
12 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13 * PURPOSE. See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef UNITY_WEBAPPS_CONNECTION
20#define UNITY_WEBAPPS_CONNECTION
21
22#include <QObject>
23#include <QVariantMap>
24
25namespace UnityWebapps {
26
27class ConnectionPrivate;
28
29class Connection: public QObject
30{
31 Q_OBJECT
32
33public:
34 explicit Connection(QObject *parent = 0);
35 ~Connection();
36
37 bool open();
38
39public Q_SLOTS:
40 void postMessage(const QVariantMap &message);
41
42Q_SIGNALS:
43 void messageReceived(const QVariantMap &message);
44
45private:
46 ConnectionPrivate *d_ptr;
47 Q_DECLARE_PRIVATE(Connection)
48};
49
50} // namespace
51
52#endif // UNITY_WEBAPPS_CONNECTION
053
=== added file 'messaging-host/inactivity-timer.cpp'
--- messaging-host/inactivity-timer.cpp 1970-01-01 00:00:00 +0000
+++ messaging-host/inactivity-timer.cpp 2014-11-18 07:07:55 +0000
@@ -0,0 +1,65 @@
1/*
2 * Copyright (C) 2014 Canonical Ltd.
3 *
4 * This file is part of unity-chromium-extension
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 3, as published
8 * by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranties of
12 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13 * PURPOSE. See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "inactivity-timer.h"
20
21#include <QVariant>
22
23using namespace UnityWebapps;
24
25InactivityTimer::InactivityTimer(int interval, QObject *parent):
26 QObject(parent),
27 m_interval(interval)
28{
29 m_timer.setSingleShot(true);
30 QObject::connect(&m_timer, SIGNAL(timeout()),
31 this, SLOT(onTimeout()));
32}
33
34void InactivityTimer::watchObject(QObject *object)
35{
36 connect(object, SIGNAL(isIdleChanged()), SLOT(onIdleChanged()));
37 m_watchedObjects.append(object);
38
39 /* Force an initial check */
40 onIdleChanged();
41}
42
43void InactivityTimer::onIdleChanged()
44{
45 if (allObjectsAreIdle()) {
46 m_timer.start(m_interval);
47 }
48}
49
50void InactivityTimer::onTimeout()
51{
52 if (allObjectsAreIdle()) {
53 Q_EMIT timeout();
54 }
55}
56
57bool InactivityTimer::allObjectsAreIdle() const
58{