Merge lp:~webapps/unity-chromium-extension/staging into lp:unity-chromium-extension
- staging
- Merge into 14.04
Status: | Merged |
---|---|
Approved by: | Alexandre Abreu |
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Robert Bruce Park (community) | packaging | Approve | |
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)
PS Jenkins bot (ps-jenkins) wrote : | # |
- 257. By Justin McPherson
-
Fixup build-depends
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:257
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Robert Bruce Park (robru) wrote : | # |
See inline comments below.
Justin McPherson (justinmcp) : | # |
- 258. By Justin McPherson
-
Changed version of debhelper
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:258
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Robert Bruce Park (robru) wrote : | # |
Ok, diff looks good to me now, we'll see how it builds.
Robert Bruce Park (robru) wrote : | # |
(well, you can delete the FIXME comment ;-)
- 259. By Justin McPherson
-
Remove no longer relevant comment
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:259
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 260. By Alberto Mardegan
-
Make sure the webapp indexing process is run
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:260
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 261. By Alexandre Abreu
-
add back chromium browser deps as way to make sure that we only build on archs that have chromium as an install package
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:261
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 262. By Justin McPherson
-
Change to no-argument form of toJson().
Other form not available in 5.0.x.
- 263. By Justin McPherson <justin@phablet-dev>
-
Match changes in extension API.
- 264. By Justin McPherson <justin@phablet-dev>
-
Match changes in extension API (fix).
Preview Diff
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2012-03-16 12:42:18 +0000 |
3 | +++ .bzrignore 2014-11-18 07:07:55 +0000 |
4 | @@ -1,2 +1,23 @@ |
5 | +*.log |
6 | +*.moc |
7 | +*.substvars |
8 | Makefile |
9 | -Makefile.in |
10 | +Makefile.* |
11 | +moc_*.cpp |
12 | +/chromium-extension/build/ |
13 | +/chromium-extension/buildstamp |
14 | +/chromium-extension/manifest.json |
15 | +/chromium-extension/res/ |
16 | +/chromium-extension/unity-webapps/ |
17 | +/chromium-extension/unity-webapps.crx |
18 | +/chromium-extension/unity-webapps.json |
19 | +/chromium-extension/unity-webapps.pem |
20 | +/debian/files |
21 | +/debian/tmp |
22 | +/debian/unity-chromium-extension/ |
23 | +/messaging-host/com.canonical.webapp.installer.json |
24 | +/messaging-host/unity-webapps-messaging-host |
25 | +/tests/unit/messaging-host/connection-host |
26 | +/tests/unit/messaging-host/tst_connection |
27 | +/tests/unit/messaging-host/tst_inactivity_timer |
28 | +/tests/unit/messaging-host/tst_service |
29 | |
30 | === removed file 'AUTHORS' |
31 | === removed file 'ChangeLog' |
32 | === removed file 'INSTALL' |
33 | --- INSTALL 2012-06-02 00:56:28 +0000 |
34 | +++ INSTALL 1970-01-01 00:00:00 +0000 |
35 | @@ -1,370 +0,0 @@ |
36 | -Installation Instructions |
37 | -************************* |
38 | - |
39 | -Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation, |
40 | -Inc. |
41 | - |
42 | - Copying and distribution of this file, with or without modification, |
43 | -are permitted in any medium without royalty provided the copyright |
44 | -notice and this notice are preserved. This file is offered as-is, |
45 | -without warranty of any kind. |
46 | - |
47 | -Basic Installation |
48 | -================== |
49 | - |
50 | - Briefly, the shell commands `./configure; make; make install' should |
51 | -configure, build, and install this package. The following |
52 | -more-detailed instructions are generic; see the `README' file for |
53 | -instructions specific to this package. Some packages provide this |
54 | -`INSTALL' file but do not implement all of the features documented |
55 | -below. The lack of an optional feature in a given package is not |
56 | -necessarily a bug. More recommendations for GNU packages can be found |
57 | -in *note Makefile Conventions: (standards)Makefile Conventions. |
58 | - |
59 | - The `configure' shell script attempts to guess correct values for |
60 | -various system-dependent variables used during compilation. It uses |
61 | -those values to create a `Makefile' in each directory of the package. |
62 | -It may also create one or more `.h' files containing system-dependent |
63 | -definitions. Finally, it creates a shell script `config.status' that |
64 | -you can run in the future to recreate the current configuration, and a |
65 | -file `config.log' containing compiler output (useful mainly for |
66 | -debugging `configure'). |
67 | - |
68 | - It can also use an optional file (typically called `config.cache' |
69 | -and enabled with `--cache-file=config.cache' or simply `-C') that saves |
70 | -the results of its tests to speed up reconfiguring. Caching is |
71 | -disabled by default to prevent problems with accidental use of stale |
72 | -cache files. |
73 | - |
74 | - If you need to do unusual things to compile the package, please try |
75 | -to figure out how `configure' could check whether to do them, and mail |
76 | -diffs or instructions to the address given in the `README' so they can |
77 | -be considered for the next release. If you are using the cache, and at |
78 | -some point `config.cache' contains results you don't want to keep, you |
79 | -may remove or edit it. |
80 | - |
81 | - The file `configure.ac' (or `configure.in') is used to create |
82 | -`configure' by a program called `autoconf'. You need `configure.ac' if |
83 | -you want to change it or regenerate `configure' using a newer version |
84 | -of `autoconf'. |
85 | - |
86 | - The simplest way to compile this package is: |
87 | - |
88 | - 1. `cd' to the directory containing the package's source code and type |
89 | - `./configure' to configure the package for your system. |
90 | - |
91 | - Running `configure' might take a while. While running, it prints |
92 | - some messages telling which features it is checking for. |
93 | - |
94 | - 2. Type `make' to compile the package. |
95 | - |
96 | - 3. Optionally, type `make check' to run any self-tests that come with |
97 | - the package, generally using the just-built uninstalled binaries. |
98 | - |
99 | - 4. Type `make install' to install the programs and any data files and |
100 | - documentation. When installing into a prefix owned by root, it is |
101 | - recommended that the package be configured and built as a regular |
102 | - user, and only the `make install' phase executed with root |
103 | - privileges. |
104 | - |
105 | - 5. Optionally, type `make installcheck' to repeat any self-tests, but |
106 | - this time using the binaries in their final installed location. |
107 | - This target does not install anything. Running this target as a |
108 | - regular user, particularly if the prior `make install' required |
109 | - root privileges, verifies that the installation completed |
110 | - correctly. |
111 | - |
112 | - 6. You can remove the program binaries and object files from the |
113 | - source code directory by typing `make clean'. To also remove the |
114 | - files that `configure' created (so you can compile the package for |
115 | - a different kind of computer), type `make distclean'. There is |
116 | - also a `make maintainer-clean' target, but that is intended mainly |
117 | - for the package's developers. If you use it, you may have to get |
118 | - all sorts of other programs in order to regenerate files that came |
119 | - with the distribution. |
120 | - |
121 | - 7. Often, you can also type `make uninstall' to remove the installed |
122 | - files again. In practice, not all packages have tested that |
123 | - uninstallation works correctly, even though it is required by the |
124 | - GNU Coding Standards. |
125 | - |
126 | - 8. Some packages, particularly those that use Automake, provide `make |
127 | - distcheck', which can by used by developers to test that all other |
128 | - targets like `make install' and `make uninstall' work correctly. |
129 | - This target is generally not run by end users. |
130 | - |
131 | -Compilers and Options |
132 | -===================== |
133 | - |
134 | - Some systems require unusual options for compilation or linking that |
135 | -the `configure' script does not know about. Run `./configure --help' |
136 | -for details on some of the pertinent environment variables. |
137 | - |
138 | - You can give `configure' initial values for configuration parameters |
139 | -by setting variables in the command line or in the environment. Here |
140 | -is an example: |
141 | - |
142 | - ./configure CC=c99 CFLAGS=-g LIBS=-lposix |
143 | - |
144 | - *Note Defining Variables::, for more details. |
145 | - |
146 | -Compiling For Multiple Architectures |
147 | -==================================== |
148 | - |
149 | - You can compile the package for more than one kind of computer at the |
150 | -same time, by placing the object files for each architecture in their |
151 | -own directory. To do this, you can use GNU `make'. `cd' to the |
152 | -directory where you want the object files and executables to go and run |
153 | -the `configure' script. `configure' automatically checks for the |
154 | -source code in the directory that `configure' is in and in `..'. This |
155 | -is known as a "VPATH" build. |
156 | - |
157 | - With a non-GNU `make', it is safer to compile the package for one |
158 | -architecture at a time in the source code directory. After you have |
159 | -installed the package for one architecture, use `make distclean' before |
160 | -reconfiguring for another architecture. |
161 | - |
162 | - On MacOS X 10.5 and later systems, you can create libraries and |
163 | -executables that work on multiple system types--known as "fat" or |
164 | -"universal" binaries--by specifying multiple `-arch' options to the |
165 | -compiler but only a single `-arch' option to the preprocessor. Like |
166 | -this: |
167 | - |
168 | - ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ |
169 | - CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ |
170 | - CPP="gcc -E" CXXCPP="g++ -E" |
171 | - |
172 | - This is not guaranteed to produce working output in all cases, you |
173 | -may have to build one architecture at a time and combine the results |
174 | -using the `lipo' tool if you have problems. |
175 | - |
176 | -Installation Names |
177 | -================== |
178 | - |
179 | - By default, `make install' installs the package's commands under |
180 | -`/usr/local/bin', include files under `/usr/local/include', etc. You |
181 | -can specify an installation prefix other than `/usr/local' by giving |
182 | -`configure' the option `--prefix=PREFIX', where PREFIX must be an |
183 | -absolute file name. |
184 | - |
185 | - You can specify separate installation prefixes for |
186 | -architecture-specific files and architecture-independent files. If you |
187 | -pass the option `--exec-prefix=PREFIX' to `configure', the package uses |
188 | -PREFIX as the prefix for installing programs and libraries. |
189 | -Documentation and other data files still use the regular prefix. |
190 | - |
191 | - In addition, if you use an unusual directory layout you can give |
192 | -options like `--bindir=DIR' to specify different values for particular |
193 | -kinds of files. Run `configure --help' for a list of the directories |
194 | -you can set and what kinds of files go in them. In general, the |
195 | -default for these options is expressed in terms of `${prefix}', so that |
196 | -specifying just `--prefix' will affect all of the other directory |
197 | -specifications that were not explicitly provided. |
198 | - |
199 | - The most portable way to affect installation locations is to pass the |
200 | -correct locations to `configure'; however, many packages provide one or |
201 | -both of the following shortcuts of passing variable assignments to the |
202 | -`make install' command line to change installation locations without |
203 | -having to reconfigure or recompile. |
204 | - |
205 | - The first method involves providing an override variable for each |
206 | -affected directory. For example, `make install |
207 | -prefix=/alternate/directory' will choose an alternate location for all |
208 | -directory configuration variables that were expressed in terms of |
209 | -`${prefix}'. Any directories that were specified during `configure', |
210 | -but not in terms of `${prefix}', must each be overridden at install |
211 | -time for the entire installation to be relocated. The approach of |
212 | -makefile variable overrides for each directory variable is required by |
213 | -the GNU Coding Standards, and ideally causes no recompilation. |
214 | -However, some platforms have known limitations with the semantics of |
215 | -shared libraries that end up requiring recompilation when using this |
216 | -method, particularly noticeable in packages that use GNU Libtool. |
217 | - |
218 | - The second method involves providing the `DESTDIR' variable. For |
219 | -example, `make install DESTDIR=/alternate/directory' will prepend |
220 | -`/alternate/directory' before all installation names. The approach of |
221 | -`DESTDIR' overrides is not required by the GNU Coding Standards, and |
222 | -does not work on platforms that have drive letters. On the other hand, |
223 | -it does better at avoiding recompilation issues, and works well even |
224 | -when some directory options were not specified in terms of `${prefix}' |
225 | -at `configure' time. |
226 | - |
227 | -Optional Features |
228 | -================= |
229 | - |
230 | - If the package supports it, you can cause programs to be installed |
231 | -with an extra prefix or suffix on their names by giving `configure' the |
232 | -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. |
233 | - |
234 | - Some packages pay attention to `--enable-FEATURE' options to |
235 | -`configure', where FEATURE indicates an optional part of the package. |
236 | -They may also pay attention to `--with-PACKAGE' options, where PACKAGE |
237 | -is something like `gnu-as' or `x' (for the X Window System). The |
238 | -`README' should mention any `--enable-' and `--with-' options that the |
239 | -package recognizes. |
240 | - |
241 | - For packages that use the X Window System, `configure' can usually |
242 | -find the X include and library files automatically, but if it doesn't, |
243 | -you can use the `configure' options `--x-includes=DIR' and |
244 | -`--x-libraries=DIR' to specify their locations. |
245 | - |
246 | - Some packages offer the ability to configure how verbose the |
247 | -execution of `make' will be. For these packages, running `./configure |
248 | ---enable-silent-rules' sets the default to minimal output, which can be |
249 | -overridden with `make V=1'; while running `./configure |
250 | ---disable-silent-rules' sets the default to verbose, which can be |
251 | -overridden with `make V=0'. |
252 | - |
253 | -Particular systems |
254 | -================== |
255 | - |
256 | - On HP-UX, the default C compiler is not ANSI C compatible. If GNU |
257 | -CC is not installed, it is recommended to use the following options in |
258 | -order to use an ANSI C compiler: |
259 | - |
260 | - ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" |
261 | - |
262 | -and if that doesn't work, install pre-built binaries of GCC for HP-UX. |
263 | - |
264 | - HP-UX `make' updates targets which have the same time stamps as |
265 | -their prerequisites, which makes it generally unusable when shipped |
266 | -generated files such as `configure' are involved. Use GNU `make' |
267 | -instead. |
268 | - |
269 | - On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot |
270 | -parse its `<wchar.h>' header file. The option `-nodtk' can be used as |
271 | -a workaround. If GNU CC is not installed, it is therefore recommended |
272 | -to try |
273 | - |
274 | - ./configure CC="cc" |
275 | - |
276 | -and if that doesn't work, try |
277 | - |
278 | - ./configure CC="cc -nodtk" |
279 | - |
280 | - On Solaris, don't put `/usr/ucb' early in your `PATH'. This |
281 | -directory contains several dysfunctional programs; working variants of |
282 | -these programs are available in `/usr/bin'. So, if you need `/usr/ucb' |
283 | -in your `PATH', put it _after_ `/usr/bin'. |
284 | - |
285 | - On Haiku, software installed for all users goes in `/boot/common', |
286 | -not `/usr/local'. It is recommended to use the following options: |
287 | - |
288 | - ./configure --prefix=/boot/common |
289 | - |
290 | -Specifying the System Type |
291 | -========================== |
292 | - |
293 | - There may be some features `configure' cannot figure out |
294 | -automatically, but needs to determine by the type of machine the package |
295 | -will run on. Usually, assuming the package is built to be run on the |
296 | -_same_ architectures, `configure' can figure that out, but if it prints |
297 | -a message saying it cannot guess the machine type, give it the |
298 | -`--build=TYPE' option. TYPE can either be a short name for the system |
299 | -type, such as `sun4', or a canonical name which has the form: |
300 | - |
301 | - CPU-COMPANY-SYSTEM |
302 | - |
303 | -where SYSTEM can have one of these forms: |
304 | - |
305 | - OS |
306 | - KERNEL-OS |
307 | - |
308 | - See the file `config.sub' for the possible values of each field. If |
309 | -`config.sub' isn't included in this package, then this package doesn't |
310 | -need to know the machine type. |
311 | - |
312 | - If you are _building_ compiler tools for cross-compiling, you should |
313 | -use the option `--target=TYPE' to select the type of system they will |
314 | -produce code for. |
315 | - |
316 | - If you want to _use_ a cross compiler, that generates code for a |
317 | -platform different from the build platform, you should specify the |
318 | -"host" platform (i.e., that on which the generated programs will |
319 | -eventually be run) with `--host=TYPE'. |
320 | - |
321 | -Sharing Defaults |
322 | -================ |
323 | - |
324 | - If you want to set default values for `configure' scripts to share, |
325 | -you can create a site shell script called `config.site' that gives |
326 | -default values for variables like `CC', `cache_file', and `prefix'. |
327 | -`configure' looks for `PREFIX/share/config.site' if it exists, then |
328 | -`PREFIX/etc/config.site' if it exists. Or, you can set the |
329 | -`CONFIG_SITE' environment variable to the location of the site script. |
330 | -A warning: not all `configure' scripts look for a site script. |
331 | - |
332 | -Defining Variables |
333 | -================== |
334 | - |
335 | - Variables not defined in a site shell script can be set in the |
336 | -environment passed to `configure'. However, some packages may run |
337 | -configure again during the build, and the customized values of these |
338 | -variables may be lost. In order to avoid this problem, you should set |
339 | -them in the `configure' command line, using `VAR=value'. For example: |
340 | - |
341 | - ./configure CC=/usr/local2/bin/gcc |
342 | - |
343 | -causes the specified `gcc' to be used as the C compiler (unless it is |
344 | -overridden in the site shell script). |
345 | - |
346 | -Unfortunately, this technique does not work for `CONFIG_SHELL' due to |
347 | -an Autoconf bug. Until the bug is fixed you can use this workaround: |
348 | - |
349 | - CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash |
350 | - |
351 | -`configure' Invocation |
352 | -====================== |
353 | - |
354 | - `configure' recognizes the following options to control how it |
355 | -operates. |
356 | - |
357 | -`--help' |
358 | -`-h' |
359 | - Print a summary of all of the options to `configure', and exit. |
360 | - |
361 | -`--help=short' |
362 | -`--help=recursive' |
363 | - Print a summary of the options unique to this package's |
364 | - `configure', and exit. The `short' variant lists options used |
365 | - only in the top level, while the `recursive' variant lists options |
366 | - also present in any nested packages. |
367 | - |
368 | -`--version' |
369 | -`-V' |
370 | - Print the version of Autoconf used to generate the `configure' |
371 | - script, and exit. |
372 | - |
373 | -`--cache-file=FILE' |
374 | - Enable the cache: use and save the results of the tests in FILE, |
375 | - traditionally `config.cache'. FILE defaults to `/dev/null' to |
376 | - disable caching. |
377 | - |
378 | -`--config-cache' |
379 | -`-C' |
380 | - Alias for `--cache-file=config.cache'. |
381 | - |
382 | -`--quiet' |
383 | -`--silent' |
384 | -`-q' |
385 | - Do not print messages saying which checks are being made. To |
386 | - suppress all normal output, redirect it to `/dev/null' (any error |
387 | - messages will still be shown). |
388 | - |
389 | -`--srcdir=DIR' |
390 | - Look for the package's source code in directory DIR. Usually |
391 | - `configure' can determine that directory automatically. |
392 | - |
393 | -`--prefix=DIR' |
394 | - Use DIR as the installation prefix. *note Installation Names:: |
395 | - for more details, including other options available for fine-tuning |
396 | - the installation locations. |
397 | - |
398 | -`--no-create' |
399 | -`-n' |
400 | - Run the configure checks, but stop before creating any output |
401 | - files. |
402 | - |
403 | -`configure' also accepts some other, not widely useful, options. Run |
404 | -`configure --help' for more details. |
405 | - |
406 | |
407 | === removed file 'Makefile.am' |
408 | --- Makefile.am 2012-10-01 23:03:21 +0000 |
409 | +++ Makefile.am 1970-01-01 00:00:00 +0000 |
410 | @@ -1,9 +0,0 @@ |
411 | -SUBDIRS = npapi-plugin chromium-extension tests po |
412 | - |
413 | -CLEANFILES = unity-webapps.pem |
414 | - |
415 | -DISTCHECK_CONFIGURE_FLAGS=--enable-tests=yes |
416 | - |
417 | -EXTRA_DIST = autogen.sh |
418 | - |
419 | -include $(top_srcdir)/Makefile.am.coverage |
420 | |
421 | === removed file 'Makefile.am.coverage' |
422 | --- Makefile.am.coverage 2012-11-29 17:44:47 +0000 |
423 | +++ Makefile.am.coverage 1970-01-01 00:00:00 +0000 |
424 | @@ -1,32 +0,0 @@ |
425 | - |
426 | -# Coverage targets |
427 | - |
428 | -if HAVE_GCOV |
429 | - |
430 | -.PHONY: clean-gcda |
431 | -clean-gcda: |
432 | - @echo Removing old coverage results |
433 | - -find -name '*.gcda' -print | xargs -r rm |
434 | - |
435 | -.PHONY: coverage-html generate-coverage-html clean-coverage-html |
436 | -coverage-html: clean-gcda |
437 | - -$(MAKE) $(AM_MAKEFLAGS) -k check |
438 | - $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html |
439 | - |
440 | -coverage-xml: clean-gcda |
441 | - -$(MAKE) $(AM_MAKEFLAGS) -k check |
442 | - gcovr --xml -r $(top_builddir) -o "$(top_builddir)/coverage.xml" --exclude='.*tests.*' |
443 | - |
444 | -generate-coverage-html: |
445 | - @echo Collecting coverage data |
446 | - $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool |
447 | - $(LCOV) --extract coverage.info "`pwd`/npapi-plugin/src/*" --output-file coverage-src.info |
448 | - LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coverage-html --title "Code Coverage" --legend --show-details coverage-src.info |
449 | - |
450 | -clean-coverage-html: clean-gcda |
451 | - -$(LCOV) --directory $(top_builddir) -z |
452 | - -rm -rf coverage.info coverage-src.info coverage-html |
453 | - |
454 | -clean-local: clean-coverage-html |
455 | - |
456 | -endif # HAVE_GCOV |
457 | |
458 | === removed file 'NEWS' |
459 | === removed file 'README' |
460 | --- README 2012-11-14 20:26:07 +0000 |
461 | +++ README 1970-01-01 00:00:00 +0000 |
462 | @@ -1,1 +0,0 @@ |
463 | -+ |
464 | \ No newline at end of file |
465 | |
466 | === removed file 'autogen.sh' |
467 | --- autogen.sh 2012-03-08 15:11:24 +0000 |
468 | +++ autogen.sh 1970-01-01 00:00:00 +0000 |
469 | @@ -1,157 +0,0 @@ |
470 | -#!/bin/sh |
471 | -# Run this to generate all the initial makefiles, etc. |
472 | - |
473 | -srcdir=`dirname $0` |
474 | -test -z "$srcdir" && srcdir=. |
475 | - |
476 | -DIE=0 |
477 | - |
478 | -if [ -n "$GNOME2_DIR" ]; then |
479 | - ACLOCAL_FLAGS="-I $GNOME2_DIR/share/aclocal $ACLOCAL_FLAGS" |
480 | - LD_LIBRARY_PATH="$GNOME2_DIR/lib:$LD_LIBRARY_PATH" |
481 | - PATH="$GNOME2_DIR/bin:$PATH" |
482 | - export PATH |
483 | - export LD_LIBRARY_PATH |
484 | -fi |
485 | - |
486 | -(test -f $srcdir/configure.ac) || { |
487 | - echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" |
488 | - echo " top-level package directory" |
489 | - exit 1 |
490 | -} |
491 | - |
492 | -(autoconf --version) < /dev/null > /dev/null 2>&1 || { |
493 | - echo |
494 | - echo "**Error**: You must have \`autoconf' installed." |
495 | - echo "Download the appropriate package for your distribution," |
496 | - echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" |
497 | - DIE=1 |
498 | -} |
499 | - |
500 | -(grep "^IT_PROG_INTLTOOL" $srcdir/configure.ac >/dev/null) && { |
501 | - (intltoolize --version) < /dev/null > /dev/null 2>&1 || { |
502 | - echo |
503 | - echo "**Error**: You must have \`intltool' installed." |
504 | - echo "You can get it from:" |
505 | - echo " ftp://ftp.gnome.org/pub/GNOME/" |
506 | - DIE=1 |
507 | - } |
508 | -} |
509 | - |
510 | -(grep "^AM_PROG_XML_I18N_TOOLS" $srcdir/configure.ac >/dev/null) && { |
511 | - (xml-i18n-toolize --version) < /dev/null > /dev/null 2>&1 || { |
512 | - echo |
513 | - echo "**Error**: You must have \`xml-i18n-toolize' installed." |
514 | - echo "You can get it from:" |
515 | - echo " ftp://ftp.gnome.org/pub/GNOME/" |
516 | - DIE=1 |
517 | - } |
518 | -} |
519 | - |
520 | -(grep "^LT_INIT" $srcdir/configure.ac >/dev/null) && { |
521 | - (libtool --version) < /dev/null > /dev/null 2>&1 || { |
522 | - echo |
523 | - echo "**Error**: You must have \`libtool' installed." |
524 | - echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/" |
525 | - DIE=1 |
526 | - } |
527 | -} |
528 | - |
529 | -(grep "^AM_GLIB_GNU_GETTEXT" $srcdir/configure.ac >/dev/null) && { |
530 | - (grep "sed.*POTFILES" $srcdir/configure.ac) > /dev/null || \ |
531 | - (glib-gettextize --version) < /dev/null > /dev/null 2>&1 || { |
532 | - echo |
533 | - echo "**Error**: You must have \`glib' installed." |
534 | - echo "You can get it from: ftp://ftp.gtk.org/pub/gtk" |
535 | - DIE=1 |
536 | - } |
537 | -} |
538 | - |
539 | -(automake --version) < /dev/null > /dev/null 2>&1 || { |
540 | - echo |
541 | - echo "**Error**: You must have \`automake' installed." |
542 | - echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/" |
543 | - DIE=1 |
544 | - NO_AUTOMAKE=yes |
545 | -} |
546 | - |
547 | - |
548 | -# if no automake, don't bother testing for aclocal |
549 | -test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || { |
550 | - echo |
551 | - echo "**Error**: Missing \`aclocal'. The version of \`automake'" |
552 | - echo "installed doesn't appear recent enough." |
553 | - echo "You can get automake from ftp://ftp.gnu.org/pub/gnu/" |
554 | - DIE=1 |
555 | -} |
556 | - |
557 | -if test "$DIE" -eq 1; then |
558 | - exit 1 |
559 | -fi |
560 | - |
561 | -if test -z "$*"; then |
562 | - echo "**Warning**: I am going to run \`configure' with no arguments." |
563 | - echo "If you wish to pass any to it, please specify them on the" |
564 | - echo \`$0\'" command line." |
565 | - echo |
566 | -fi |
567 | - |
568 | -case $CC in |
569 | -xlc ) |
570 | - am_opt=--include-deps;; |
571 | -esac |
572 | - |
573 | -for coin in `find $srcdir -path $srcdir/CVS -prune -o -name configure.ac -print` |
574 | -do |
575 | - dr=`dirname $coin` |
576 | - if test -f $dr/NO-AUTO-GEN; then |
577 | - echo skipping $dr -- flagged as no auto-gen |
578 | - else |
579 | - echo processing $dr |
580 | - ( cd $dr |
581 | - |
582 | - aclocalinclude="$ACLOCAL_FLAGS" |
583 | - |
584 | - if grep "^AM_GLIB_GNU_GETTEXT" configure.ac >/dev/null; then |
585 | - echo "Creating $dr/aclocal.m4 ..." |
586 | - test -r $dr/aclocal.m4 || touch $dr/aclocal.m4 |
587 | - echo "Running glib-gettextize... Ignore non-fatal messages." |
588 | - echo "no" | glib-gettextize --force --copy |
589 | - echo "Making $dr/aclocal.m4 writable ..." |
590 | - test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4 |
591 | - fi |
592 | - if grep "^IT_PROG_INTLTOOL" configure.ac >/dev/null; then |
593 | - echo "Running intltoolize..." |
594 | - intltoolize --copy --force --automake |
595 | - fi |
596 | - if grep "^AM_PROG_XML_I18N_TOOLS" configure.ac >/dev/null; then |
597 | - echo "Running xml-i18n-toolize..." |
598 | - xml-i18n-toolize --copy --force --automake |
599 | - fi |
600 | - if grep "^LT_INIT" configure.ac >/dev/null; then |
601 | - if test -z "$NO_LIBTOOLIZE" ; then |
602 | - echo "Running libtoolize..." |
603 | - libtoolize --force --copy |
604 | - fi |
605 | - fi |
606 | - echo "Running aclocal $aclocalinclude ..." |
607 | - aclocal $aclocalinclude |
608 | - if grep "^A[CM]_CONFIG_HEADER" configure.ac >/dev/null; then |
609 | - echo "Running autoheader..." |
610 | - autoheader |
611 | - fi |
612 | - echo "Running automake --gnu $am_opt ..." |
613 | - automake --add-missing --gnu $am_opt |
614 | - echo "Running autoconf ..." |
615 | - autoconf |
616 | - ) |
617 | - fi |
618 | -done |
619 | - |
620 | -if test x$NOCONFIGURE = x; then |
621 | - echo Running $srcdir/configure "$@" ... |
622 | - $srcdir/configure "$@" \ |
623 | - && echo Now type \`make\' to compile. || exit 1 |
624 | -else |
625 | - echo Skipping configure process. |
626 | -fi |
627 | |
628 | === removed file 'chromium-extension/Makefile.am' |
629 | --- chromium-extension/Makefile.am 2013-12-16 07:15:32 +0000 |
630 | +++ chromium-extension/Makefile.am 1970-01-01 00:00:00 +0000 |
631 | @@ -1,44 +0,0 @@ |
632 | -CLEANFILES = res/* |
633 | -EXTRA_DIST = |
634 | - |
635 | -extensiondir = $(libdir)/libunity-chromium |
636 | -extension_DATA=res/unity-webapps.crx |
637 | - |
638 | - |
639 | -clean-extension-package: |
640 | - rm -f $(CLEANFILES) |
641 | - |
642 | -SCRIPT_FILES = \ |
643 | - $(shell ls *.css) \ |
644 | - $(shell ls *.html) \ |
645 | - $(shell ls *.js) \ |
646 | - $(shell ls skin/*) \ |
647 | - $(shell ls _locales/*/*) |
648 | - |
649 | -res/unity-webapps.crx: $(SCRIPT_FILES) unity-webapps.json manifest.json |
650 | - cp -f $(top_builddir)/npapi-plugin/src/.libs/libunity_npapi_plugin.so . |
651 | - if [ ! -f ../unity-webapps.pem ]; \ |
652 | - then \ |
653 | - openssl genrsa 1024 > ../unity-webapps.pem; \ |
654 | - fi |
655 | - $(srcdir)/crxmake.sh $(abs_builddir) ../unity-webapps.pem |
656 | - mv res/chromium-extension.crx res/unity-webapps.crx |
657 | - |
658 | -manifestdir = $(datadir)/chromium/extensions/ |
659 | -manifest_DATA = $(shell ls $(top_builddir)/chromium-extension/res/*.json) |
660 | - |
661 | -%.json: %.json.in |
662 | - sed -e "s|\@EXTDIR\@|$(extensiondir)/unity-webapps.crx|" $< | sed -e "s|\@VERSION\@|$(VERSION)|"> $@ |
663 | - |
664 | - |
665 | -CLEANFILES += \ |
666 | - unity-webapps.json \ |
667 | - manifest.json \ |
668 | - libunity_npapi_plugin.so \ |
669 | - chromium-extension.crx |
670 | - |
671 | -EXTRA_DIST += \ |
672 | - unity-webapps.json.in \ |
673 | - manifest.json.in \ |
674 | - crxmake.sh \ |
675 | - $(SCRIPT_FILES) |
676 | |
677 | === added file 'chromium-extension/background-page.html' |
678 | --- chromium-extension/background-page.html 1970-01-01 00:00:00 +0000 |
679 | +++ chromium-extension/background-page.html 2014-11-18 07:07:55 +0000 |
680 | @@ -0,0 +1,15 @@ |
681 | +<!doctype html> |
682 | +<html> |
683 | + <head> |
684 | + |
685 | + <title>Unity Webapps Extension Background Page</title> |
686 | + <embed type="application/x-unity-webapps-npapi" id="unityChromiumExtensionId"/> |
687 | + |
688 | + <script src="background-page.js"></script> |
689 | + |
690 | + </head> |
691 | + |
692 | + <body> |
693 | + </body> |
694 | + |
695 | +</html> |
696 | |
697 | === removed file 'chromium-extension/background-page.html' |
698 | --- chromium-extension/background-page.html 2012-11-09 17:28:56 +0000 |
699 | +++ chromium-extension/background-page.html 1970-01-01 00:00:00 +0000 |
700 | @@ -1,15 +0,0 @@ |
701 | -<!doctype html> |
702 | -<html> |
703 | - <head> |
704 | - |
705 | - <title>Unity Webapps Extension Background Page</title> |
706 | - <embed type="application/x-unity-webapps-npapi" id="unityChromiumExtensionId"/> |
707 | - |
708 | - <script src="background-page.js"></script> |
709 | - |
710 | - </head> |
711 | - |
712 | - <body> |
713 | - </body> |
714 | - |
715 | -</html> |
716 | |
717 | === modified file 'chromium-extension/background-page.js' |
718 | --- chromium-extension/background-page.js 2014-02-20 00:33:36 +0000 |
719 | +++ chromium-extension/background-page.js 2014-11-18 07:07:55 +0000 |
720 | @@ -6,7 +6,7 @@ |
721 | * under the terms of the GNU General Public License version 3, as published |
722 | * by the Free Software Foundation. |
723 | * |
724 | - * This program is distributed in the hope that it will be useful, but |
725 | + * This program is distributed in the hope that it will be useful, but |
726 | * WITHOUT ANY WARRANTY; without even the implied warranties of |
727 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
728 | * PURPOSE. See the GNU General Public License for more details. |
729 | @@ -16,440 +16,259 @@ |
730 | **/ |
731 | |
732 | var background_page = (function () { |
733 | - |
734 | - // TODO extract based on logging settings |
735 | - var log = { |
736 | - info: function (msg) { |
737 | - if (msg) { |
738 | - console.log ('Info: ' + msg); |
739 | - } |
740 | - } |
741 | - , |
742 | - error: function (msg) { |
743 | - if (msg) { |
744 | - console.log ('Error: ' + msg); |
745 | - } |
746 | - } |
747 | - }; |
748 | - |
749 | - // connection & init w/ plugin NPAPI layer |
750 | - var plugin = document.getElementById ('unityChromiumExtensionId'); |
751 | - if ( ! plugin) { |
752 | - log.error ("Unable to retrieve the Unity Chromium plugin"); |
753 | - return null; |
754 | - } |
755 | - var service = plugin.service_new (); |
756 | - if (! service) { |
757 | - log.error ("Unable to retrieve a connection to Unity Webapps service"); |
758 | - return null; |
759 | - } |
760 | - |
761 | - |
762 | - ///////////////////////////////////////////////////////// |
763 | - // |
764 | - // Handle login & connection to online-accounts project's |
765 | - // extension |
766 | - // |
767 | - //////////////////////////////////////////////////////// |
768 | - var loginListeners = []; |
769 | - var onLoginListenerRequest = function (request, sender, sendResponse) { |
770 | - if (request.action == "registerLoginListener") { |
771 | - log.info ("Login listener request from " + sender.id); |
772 | - loginListeners.push (sender.id); |
773 | - } |
774 | - }; |
775 | - chrome.runtime.onMessageExternal.addListener (onLoginListenerRequest); |
776 | - |
777 | - var onLoginEvent = function (request, sender, sendResponse) { |
778 | - if (request.action == "loginEvent") { |
779 | - log.info ("Login on " + request.domain + ": " + request.login); |
780 | - var len = loginListeners.length; |
781 | - for (var i = 0; i < len; i++) { |
782 | - var extensionId = loginListeners[i]; |
783 | - log.info("Notifying login listener: " + extensionId); |
784 | - chrome.runtime.sendMessage (extensionId, { |
785 | - type: "login", |
786 | - login: request.login, |
787 | - domain: request.domain |
788 | - }); |
789 | - } |
790 | - } |
791 | - }; |
792 | - chrome.runtime.onMessage.addListener (onLoginEvent); |
793 | - |
794 | - |
795 | - ///////////////////////////////////////////////////////// |
796 | - // |
797 | - // Scafolding to keep track of data associated w/ infobar requests |
798 | - // (Chromium's structure imposes some kind of state being maintained |
799 | - // in order to communicate data) |
800 | - // |
801 | - //////////////////////////////////////////////////////// |
802 | - // |
803 | - // list of callback that are to be called asynchronously |
804 | - // per tab. Used in the user integration/installation resquests context. |
805 | - // |
806 | - // One thing to keep in mind is that one constraint, that bring some amount of |
807 | - // 'soundness' is that there is a hard limit (provided by the browser) of one infobar per tab. |
808 | - |
809 | - var user_infobar_request_callbacks = {}; |
810 | - var addInfobarRequestCallbackFor = function (infobarRequestId, callback, message, details) { |
811 | - user_infobar_request_callbacks[infobarRequestId] = {callback: callback |
812 | - , message: message |
813 | - , details: details |
814 | - }; |
815 | - }; |
816 | - var getDataIfAnyFor = function (infobarRequestId) { |
817 | - if (user_infobar_request_callbacks[infobarRequestId] === undefined) { |
818 | - return ""; |
819 | - } |
820 | - return { message: user_infobar_request_callbacks[infobarRequestId].message, |
821 | - details: user_infobar_request_callbacks[infobarRequestId].details }; |
822 | - }; |
823 | - var invokeAndRemoveCallbackIfAnyFor = function (infobarRequestId, arguments) { |
824 | - if (user_infobar_request_callbacks[infobarRequestId] === undefined) { |
825 | - return; |
826 | - } |
827 | - var callback = user_infobar_request_callbacks[infobarRequestId].callback; |
828 | - user_infobar_request_callbacks[infobarRequestId] = undefined; |
829 | - if (typeof(callback) === 'function') { |
830 | - callback(arguments); |
831 | - } |
832 | - }; |
833 | - |
834 | - |
835 | - ///////////////////////////////////////////////////////// |
836 | - // |
837 | - // Extract installed userscripts & webapps info |
838 | - // |
839 | - //////////////////////////////////////////////////////// |
840 | - var initializeIntegrationScriptRepositoryAccess = function (plugin) { |
841 | - |
842 | - var repo = plugin.application_repository_new_default (); |
843 | - plugin.application_repository_prepare (repo); |
844 | - return repo; |
845 | - }; |
846 | - var repo_ = initializeIntegrationScriptRepositoryAccess(plugin); |
847 | - var repo_install_request_stamps = {}; |
848 | - |
849 | - /** |
850 | - * Performs a match on the list of loaded integration scripts |
851 | - * given a url. |
852 | - * |
853 | - */ |
854 | - var matchesIntegrationScripts = function (plugin, url, repo, windowInfos, callback) { |
855 | - function askForApplicationInstallation(plugin, appPackageName, appDomain, url, installationCallback) { |
856 | - |
857 | - if (plugin.permissions_get_domain_dontask(appDomain)) { |
858 | - log.info ("WebApp domain was found in the 'dont ask' list, won't install: " + appPackageName); |
859 | - installationCallback (); |
860 | - return; |
861 | - } |
862 | - if (repo_install_request_stamps[appPackageName] !== undefined) { |
863 | - log.info ('WebApp not being considered for install (request is only issues once per session): ' + appPackageName); |
864 | - installationCallback (); |
865 | - return; |
866 | - } |
867 | - repo_install_request_stamps[appPackageName] = true; |
868 | - |
869 | - function installApp() { |
870 | - log.info ('Installing application: ' + appPackageName); |
871 | - plugin.permissions_allow_domain(appDomain); |
872 | - plugin.application_repository_install_application(repo, appPackageName, installationCallback, null); |
873 | - } |
874 | - function addToIgnoreList() { |
875 | - plugin.permissions_dontask_domain(appDomain); |
876 | - } |
877 | - var isInstallationConfirmed = function (response) { |
878 | - return response && response.integrate; |
879 | - }; |
880 | - |
881 | - if (!plugin.permissions_get_domain_preauthorized(appDomain)) { |
882 | - var appName = plugin.application_repository_get_resolved_application_name(repo, appPackageName); |
883 | - addInfobarRequestCallbackFor (windowInfos.tabId, |
884 | - function (result) { |
885 | - log.info ('Asking for installation : ' + windowInfos.tabId); |
886 | - if (result === undefined) { |
887 | - installationCallback(); |
888 | - } |
889 | - if (isInstallationConfirmed(result)) |
890 | - installApp(); |
891 | - else |
892 | - addToIgnoreList(); |
893 | - }, |
894 | - chrome.i18n.getMessage("integration_copy", [appName, appDomain]), |
895 | - null); |
896 | - chrome.infobars.show ({tabId: windowInfos.tabId, path: "infobar.html"}); |
897 | - } |
898 | - else { |
899 | - plugin.permissions_allow_domain(appDomain); |
900 | - installApp(); |
901 | - } |
902 | - |
903 | - } // function askForApplicationInstallation |
904 | - |
905 | - var APPLICATION_STATUS_AVAILABLE = 0; |
906 | - var APPLICATION_STATUS_INSTALLED = 1; |
907 | - var APPLICATION_STATUS_UNRESOLVED = 2; |
908 | - |
909 | - var formatMatchedWebAppInfo = function (packageName, appName, appDomain, src) { |
910 | - return { |
911 | - packageName: packageName, |
912 | - appName: appName, |
913 | - appDomain: appDomain, |
914 | - content: src, |
915 | - requires: null, |
916 | - includes: null |
917 | - }; |
918 | - }; |
919 | - |
920 | - /** |
921 | - * Gathers the lists of installed and (if any) available apps for a given list of app names |
922 | - * (available for a given url). |
923 | - * |
924 | - * @returns object with "installed" and "available" list properties |
925 | - */ |
926 | - var gatherApplicationsStatuses = function (packageNames) { |
927 | - var installed = []; |
928 | - var available = []; |
929 | - for (var i = 0; i < packageNames.length; ++i) { |
930 | - var packageName = packageNames[i]; |
931 | - |
932 | - var status = plugin.application_repository_get_resolved_application_status (repo, packageName); |
933 | - var appName = plugin.application_repository_get_resolved_application_name (repo, packageName); |
934 | - var appDomain = plugin.application_repository_get_resolved_application_domain (repo, packageName); |
935 | - |
936 | - log.info ('A WebApp application has been found: ' + appName + ', status: ' + status); |
937 | - |
938 | - switch (status) { |
939 | - case APPLICATION_STATUS_INSTALLED: |
940 | - // we have found an installed application, use it directly |
941 | - var src = plugin.application_repository_get_userscript_contents (repo, packageName); |
942 | - installed.push (formatMatchedWebAppInfo(packageName, appName, appDomain, src)); |
943 | - break; |
944 | - case APPLICATION_STATUS_AVAILABLE: |
945 | - // we have found an application that can apply and be installed |
946 | - available.push (formatMatchedWebAppInfo(packageName, appName, appDomain)); |
947 | - break; |
948 | - } |
949 | - } |
950 | - return { |
951 | - installed: installed, |
952 | - available: available |
953 | - }; |
954 | - }; |
955 | - |
956 | - var packageNames = JSON.parse(plugin.application_repository_resolve_url_as_json(repo_, url)); |
957 | - if (null != packageNames) { |
958 | - var appStatuses = gatherApplicationsStatuses(packageNames); |
959 | - |
960 | - if (appStatuses && appStatuses.installed && appStatuses.installed.length > 0) { |
961 | - var app = appStatuses.installed[0]; |
962 | - if (repo_install_request_stamps[app.packageName] == undefined |
963 | - && ! plugin.permissions_get_domain_dontask(app.appDomain) |
964 | - && ! plugin.permissions_get_domain_allowed(app.appDomain)) { |
965 | - // requesting for install |
966 | - addInfobarRequestCallbackFor (windowInfos.tabId, |
967 | - function (result) { |
968 | - if (result && result.integrate) { |
969 | - plugin.application_repository_add_desktop_to_launcher(app.appName, app.appDomain); |
970 | - plugin.permissions_allow_domain(app.appDomain); |
971 | - } |
972 | - else { |
973 | - plugin.permissions_dontask_domain(app.appDomain); |
974 | - } |
975 | - }, |
976 | - chrome.i18n.getMessage("integration_copy", [app.appName, app.appDomain]), |
977 | - null); |
978 | - chrome.infobars.show ({tabId: windowInfos.tabId, path: "infobar.html"}); |
979 | - } |
980 | - return; |
981 | - } |
982 | - |
983 | - // we should have at most one script for a given app |
984 | - if (appStatuses && appStatuses.available && appStatuses.available.length > 0) { |
985 | - var app = appStatuses.available[0]; |
986 | - askForApplicationInstallation (plugin, |
987 | - app.packageName, |
988 | - app.appDomain, |
989 | - url, |
990 | - function (_repository, name, status, data) { |
991 | - log.info ('Application installed: ' + name + ', (status ' + status + ')'); |
992 | - |
993 | - if (name !== undefined && status == APPLICATION_STATUS_INSTALLED) { |
994 | - callback (true, app.packageName, app.appName, app.appDomain); |
995 | - } |
996 | - } |
997 | - ); |
998 | - } |
999 | - else |
1000 | - callback (false); |
1001 | - } // if (null != names) { |
1002 | - |
1003 | - }; // var matchesIntegrationScripts = function (plugin, url, repo, windowInfos, callback) { |
1004 | - |
1005 | - |
1006 | - //////////////////////////////////////// |
1007 | - // |
1008 | - // main request handler |
1009 | - // |
1010 | - /////////////////////////////////////// |
1011 | + // Native messaging support |
1012 | + var HOST_ADDRESS = 'com.canonical.webapp.installer'; |
1013 | + var port = null; |
1014 | + var host_callbacks = []; |
1015 | + |
1016 | + var portListener = function (msg) { |
1017 | + callback = host_callbacks.pop(); |
1018 | + if (callback === undefined) { |
1019 | + return; |
1020 | + } |
1021 | + callback(msg); |
1022 | + }; |
1023 | + |
1024 | + var portDisconnecter = function () { |
1025 | + console.log('UCX: port disconnected'); |
1026 | + port = null |
1027 | + }; |
1028 | + |
1029 | + var sendNativeMessage = function (msg, callback) { |
1030 | + console.log("UCX: sendnativemessage: port=" + port); |
1031 | + if (port === null) { |
1032 | + port = chrome.runtime.connectNative(HOST_ADDRESS); |
1033 | + port.onMessage.addListener(portListener); |
1034 | + port.onDisconnect.addListener(portDisconnecter); |
1035 | + } |
1036 | + host_callbacks.push(callback || function(m) {}); |
1037 | + port.postMessage(msg); |
1038 | + }; |
1039 | + |
1040 | + // Wake server to catalogue webapps |
1041 | + sendNativeMessage({"method":"ping"}); |
1042 | + |
1043 | + |
1044 | + ///////////////////////////////////////////////////////// |
1045 | + // |
1046 | + // Scafolding to keep track of data associated w/ infobar requests |
1047 | + // (Chromium's structure imposes some kind of state being maintained |
1048 | + // in order to communicate data) |
1049 | + // |
1050 | + //////////////////////////////////////////////////////// |
1051 | + // |
1052 | + // list of callback that are to be called asynchronously |
1053 | + // per tab. Used in the user integration/installation resquests context. |
1054 | + // |
1055 | + // One thing to keep in mind is that one constraint, that bring some amount of |
1056 | + // 'soundness' is that there is a hard limit (provided by the browser) of one infobar per tab. |
1057 | + |
1058 | + var user_infobar_request_callbacks = {}; |
1059 | + var addInfobarRequestCallbackFor = function (infobarRequestId, callback, message, details) { |
1060 | + user_infobar_request_callbacks[infobarRequestId] = { |
1061 | + callback: callback, |
1062 | + message: message, |
1063 | + details: details |
1064 | + }; |
1065 | + }; |
1066 | + |
1067 | + var getDataIfAnyFor = function (infobarRequestId) { |
1068 | + if (user_infobar_request_callbacks[infobarRequestId] === undefined) { |
1069 | + return ""; |
1070 | + } |
1071 | + return { |
1072 | + message: user_infobar_request_callbacks[infobarRequestId].message, |
1073 | + details: user_infobar_request_callbacks[infobarRequestId].details |
1074 | + }; |
1075 | + }; |
1076 | + |
1077 | + var invokeAndRemoveCallbackIfAnyFor = function (infobarRequestId, arguments) { |
1078 | + if (user_infobar_request_callbacks[infobarRequestId] === undefined) { |
1079 | + return; |
1080 | + } |
1081 | + var callback = user_infobar_request_callbacks[infobarRequestId].callback; |
1082 | + user_infobar_request_callbacks[infobarRequestId] = undefined; |
1083 | + if (typeof(callback) === 'function') { |
1084 | + callback(arguments); |
1085 | + } |
1086 | + }; |
1087 | + |
1088 | + |
1089 | + /** |
1090 | + * Performs a match on the list of loaded integration scripts |
1091 | + * given a url. |
1092 | + * |
1093 | + */ |
1094 | + var matchesIntegrationScripts = function (plugin, url, repo, windowInfos, callback) { |
1095 | + sendNativeMessage({ |
1096 | + "method" : "url_loaded", |
1097 | + "url" : url |
1098 | + }, |
1099 | + function (response) { |
1100 | + if (response.available) { |
1101 | + addInfobarRequestCallbackFor( |
1102 | + windowInfos.tabId, |
1103 | + function (result) { |
1104 | + if (result && result.integrate) { |
1105 | + sendNativeMessage({ |
1106 | + "method" : "install", |
1107 | + "url" : url |
1108 | + }) |
1109 | + } else { |
1110 | + sendNativeMessage({ |
1111 | + "method" : "dont_ask", |
1112 | + "url" : url |
1113 | + }) |
1114 | + } |
1115 | + }, |
1116 | + chrome.i18n.getMessage("integration_copy", [ response.appName, response.appDomain ]), |
1117 | + null); |
1118 | + |
1119 | + chrome.infobars.show({ tabId: windowInfos.tabId, path: "infobar.html" }); |
1120 | + } |
1121 | + }); |
1122 | + }; |
1123 | + |
1124 | + |
1125 | + // {{{ main request handler |
1126 | |
1127 | /** |
1128 | * Handles & responds to content script requests. |
1129 | * |
1130 | */ |
1131 | - var init_requested_stamps = {}; |
1132 | - var contentScriptsRequestHandler = function (request, sender, callback) { |
1133 | - |
1134 | - var handlers = { |
1135 | - get_extension_settings: function (request, sender, callback) { |
1136 | - |
1137 | - var settings = { |
1138 | - logging: false, |
1139 | - incognito: sender.tab.incognito |
1140 | - }; |
1141 | - |
1142 | - try { |
1143 | - if (window.localStorage) { |
1144 | - settings.logging = localStorage['logging']; |
1145 | - } |
1146 | - } |
1147 | - catch (e) { |
1148 | - log.error ("Error while trying to retrieve logging information: " + str(e)); |
1149 | - } |
1150 | - |
1151 | - callback (settings); |
1152 | - } |
1153 | - , |
1154 | - on_user_infobar_request_result: function (request, sender, callback) { |
1155 | - |
1156 | - invokeAndRemoveCallbackIfAnyFor (request.tabId, request); |
1157 | - } |
1158 | - , |
1159 | - init_requested: function (request, sender, callback) { |
1160 | - var name = request.options.name; |
1161 | - var domain = request.options.domain; |
1162 | - var iconUrl = request.options.iconUrl + ''; |
1163 | - var homepage = request.options.homepage || request.options.url; |
1164 | - |
1165 | - if (! domain || ! name || typeof(domain) !== 'string' || typeof(name) !== 'string') |
1166 | - return; |
1167 | - |
1168 | - var islocal = request.options.protocol && request.options.protocol === 'file:'; |
1169 | - var host = request.options.hostname || request.options.host; |
1170 | - if ( ! islocal && (! host || typeof(host) !== 'string')) |
1171 | - return; |
1172 | - |
1173 | - if (-1 === homepage.indexOf(domain) || -1 === host.indexOf(domain)) { |
1174 | - log.error('Invalid call to init(), homepage, domain and host are not consistent'); |
1175 | - return; |
1176 | - } |
1177 | - log.info('init_requested() called for ' + name + ' domain: ' + domain); |
1178 | - |
1179 | - if (plugin.permissions_get_domain_dontask(domain) || plugin.permissions_get_domain_allowed(domain)) { |
1180 | - log.info('Domain already listed in allow or dont ask lists'); |
1181 | - return; |
1182 | - } |
1183 | - |
1184 | - var stampname = name + domain; |
1185 | - if (init_requested_stamps[stampname] == undefined) { |
1186 | - addInfobarRequestCallbackFor (sender.tab.id, |
1187 | - function (result) { |
1188 | - if (result && result.integrate) { |
1189 | - plugin.application_repository_generate_desktop_for_url_launch(name, domain, homepage, iconUrl); |
1190 | - plugin.application_repository_add_desktop_to_launcher(name, domain); |
1191 | - plugin.permissions_allow_domain(domain); |
1192 | - } |
1193 | - else { |
1194 | - plugin.permissions_dontask_domain(domain); |
1195 | - } |
1196 | - }, |
1197 | - chrome.i18n.getMessage("integration_copy", [name, domain]), |
1198 | - null); |
1199 | - init_requested_stamps[stampname] = true; |
1200 | - chrome.infobars.show ({tabId: sender.tab.id, path: "infobar.html"}); |
1201 | - } |
1202 | - } |
1203 | - }; // handlers |
1204 | - |
1205 | - |
1206 | - // validate request |
1207 | - if ( ! request || ! request.method) { |
1208 | - callback ({error: "Invalid request structure"}); |
1209 | - return true; |
1210 | - } |
1211 | - if ( ! sender) { |
1212 | - callback ({error: "Invalid sender"}); |
1213 | - return true; |
1214 | - } |
1215 | - if ( typeof (request.method) != 'string' || request.method.length == 0) { |
1216 | - callback ({error: "Invalid request method"}); |
1217 | - return true; |
1218 | - } |
1219 | - |
1220 | - log.info ('Got request: ' + request.method); |
1221 | - |
1222 | - var handler = handlers [request.method]; |
1223 | - |
1224 | - if (handler !== undefined && typeof(handler) == 'function') { |
1225 | - |
1226 | - log.info ('Calling handler for: ' + request.method); |
1227 | - |
1228 | - handler (request, sender, callback); |
1229 | - |
1230 | - return true; |
1231 | - } |
1232 | - return false; |
1233 | - } // var contentScriptsRequestHandler = |
1234 | - |
1235 | - // Main event handler and communication link |
1236 | - // w/ content scripts |
1237 | - chrome.runtime.onMessage.addListener (contentScriptsRequestHandler); |
1238 | - |
1239 | - |
1240 | - /////////////////////////////////////////////////////////////////////// |
1241 | - // |
1242 | - // Window management related functions. In chromeless mode, we have specific |
1243 | - // rules for tab management to make webapps feel more "native" than plain |
1244 | - // web applications. |
1245 | - // |
1246 | - /////////////////////////////////////////////////////////////////////// |
1247 | - |
1248 | - var onTabChanged = function (tabId, windowId, url) { |
1249 | - var onInstalled = function (installed, packageName, appName, appDomain) { }; |
1250 | - matchesIntegrationScripts (plugin, |
1251 | - url, |
1252 | - repo_, |
1253 | - { |
1254 | - windowId: windowId, |
1255 | - tabId: tabId |
1256 | - }, |
1257 | - onInstalled |
1258 | - ); |
1259 | - }; |
1260 | - chrome.tabs.onCreated.addListener( |
1261 | - function(tab) { |
1262 | - if (tab && tab.url) { |
1263 | - onTabChanged(tab.id, tab.windowId, tab.url); |
1264 | - } // if (tab && tab.url) { |
1265 | - } |
1266 | - ); |
1267 | - chrome.tabs.onUpdated.addListener ( |
1268 | - function(tabId, changeInfo, tab) { |
1269 | - if (changeInfo && changeInfo.url) { |
1270 | - onTabChanged(tabId, tab.windowId, changeInfo.url); |
1271 | - } |
1272 | - } |
1273 | - ); |
1274 | - |
1275 | - return { |
1276 | - /* |
1277 | - * Returns a potential message associated with a tab id (infobar) |
1278 | - */ |
1279 | - getMessageForTabId: function (tabId) { |
1280 | - return getDataIfAnyFor (tabId).message; |
1281 | - } |
1282 | - }; |
1283 | - }) (); |
1284 | + var init_requested_stamps = {}; |
1285 | + var contentScriptsRequestHandler = function (request, sender, callback) { |
1286 | + var handlers = { |
1287 | + get_extension_settings: function (request, sender, callback) { |
1288 | + var settings = { |
1289 | + logging: false, |
1290 | + incognito: sender.tab.incognito |
1291 | + }; |
1292 | + |
1293 | + try { |
1294 | + if (window.localStorage) { |
1295 | + settings.logging = localStorage['logging']; |
1296 | + } |
1297 | + } |
1298 | + catch (e) { |
1299 | + console.log("Error while trying to retrieve logging information: " + str(e)); |
1300 | + } |
1301 | + |
1302 | + callback (settings); |
1303 | + }, |
1304 | + on_user_infobar_request_result: function (request, sender, callback) { |
1305 | + invokeAndRemoveCallbackIfAnyFor (request.tabId, request); |
1306 | + }, |
1307 | + init_requested: function (request, sender, callback) { |
1308 | + sendNativeMessage({ |
1309 | + "method" : "url_loaded", |
1310 | + "url" : request.options.url |
1311 | + }, |
1312 | + function (response) { |
1313 | + if (response.available) { |
1314 | + addInfobarRequestCallbackFor( |
1315 | + sender.tab.id, |
1316 | + function (result) { |
1317 | + if (result && result.integrate) { |
1318 | + sendNativeMessage({ |
1319 | + "method" : "install", |
1320 | + "url" : request.options.url |
1321 | + }) |
1322 | + } else { |
1323 | + sendNativeMessage({ |
1324 | + "method" : "dont_ask", |
1325 | + "url" : request.options.url |
1326 | + }) |
1327 | + } |
1328 | + }, |
1329 | + chrome.i18n.getMessage("integration_copy", [ response.appName, response.appDomain ]), |
1330 | + null); |
1331 | + |
1332 | + chrome.infobars.show({ tabId: windowInfos.tabId, path: "infobar.html" }); |
1333 | + } |
1334 | + }); |
1335 | + } |
1336 | + }; |
1337 | + |
1338 | + // validate request |
1339 | + if (!request || !request.method) { |
1340 | + callback({ error: "Invalid request structure" }); |
1341 | + return true; |
1342 | + } |
1343 | + if (!sender) { |
1344 | + callback({ error: "Invalid sender" }); |
1345 | + return true; |
1346 | + } |
1347 | + |
1348 | + if (typeof(request.method) != 'string' || request.method.length == 0) { |
1349 | + callback({ error: "Invalid request method" }); |
1350 | + return true; |
1351 | + } |
1352 | + |
1353 | + console.log('Got request: ' + request.method); |
1354 | + |
1355 | + var handler = handlers [request.method]; |
1356 | + if (handler !== undefined && typeof(handler) == 'function') { |
1357 | + handler(request, sender, callback); |
1358 | + return true; |
1359 | + } |
1360 | + return false; |
1361 | + } |
1362 | + |
1363 | + // Main event handler and communication link |
1364 | + // w/ content scripts |
1365 | + chrome.runtime.onMessage.addListener (contentScriptsRequestHandler); |
1366 | + // }}} |
1367 | + |
1368 | + /////////////////////////////////////////////////////////////////////// |
1369 | + // |
1370 | + // Window management related functions. In chromeless mode, we have specific |
1371 | + // rules for tab management to make webapps feel more "native" than plain |
1372 | + // web applications. |
1373 | + // |
1374 | + /////////////////////////////////////////////////////////////////////// |
1375 | + |
1376 | + var onTabChanged = function (tabId, windowId, url) { |
1377 | + var onInstalled = function (installed, packageName, appName, appDomain) { }; |
1378 | + |
1379 | + console.log("onTabChanged: " + url); |
1380 | + |
1381 | + matchesIntegrationScripts( |
1382 | + null, //plugin, |
1383 | + url, |
1384 | + null, // repo_, |
1385 | + { |
1386 | + windowId: windowId, |
1387 | + tabId: tabId |
1388 | + }, |
1389 | + onInstalled |
1390 | + ); |
1391 | + }; |
1392 | + |
1393 | + chrome.tabs.onCreated.addListener( |
1394 | + function(tab) { |
1395 | + if (tab && tab.url) { |
1396 | + onTabChanged(tab.id, tab.windowId, tab.url); |
1397 | + } |
1398 | + } |
1399 | + ); |
1400 | + |
1401 | + chrome.tabs.onUpdated.addListener( |
1402 | + function(tabId, changeInfo, tab) { |
1403 | + console.log("onUpdated " + changeInfo.url); |
1404 | + if (changeInfo && changeInfo.url) { |
1405 | + onTabChanged(tabId, tab.windowId, changeInfo.url); |
1406 | + } |
1407 | + } |
1408 | + ); |
1409 | + |
1410 | + /* |
1411 | + * Returns a potential message associated with a tab id (infobar) |
1412 | + */ |
1413 | + return { |
1414 | + getMessageForTabId: function (tabId) { |
1415 | + return getDataIfAnyFor(tabId).message; |
1416 | + } |
1417 | + }; |
1418 | +})(); |
1419 | |
1420 | |
1421 | === modified file 'chromium-extension/base-content-script.js' |
1422 | --- chromium-extension/base-content-script.js 2013-12-16 07:15:32 +0000 |
1423 | +++ chromium-extension/base-content-script.js 2014-11-18 07:07:55 +0000 |
1424 | @@ -6,7 +6,7 @@ |
1425 | * under the terms of the GNU General Public License version 3, as published |
1426 | * by the Free Software Foundation. |
1427 | * |
1428 | - * This program is distributed in the hope that it will be useful, but |
1429 | + * This program is distributed in the hope that it will be useful, but |
1430 | * WITHOUT ANY WARRANTY; without even the implied warranties of |
1431 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1432 | * PURPOSE. See the GNU General Public License for more details. |
1433 | |
1434 | === added file 'chromium-extension/browser.js' |
1435 | --- chromium-extension/browser.js 1970-01-01 00:00:00 +0000 |
1436 | +++ chromium-extension/browser.js 2014-11-18 07:07:55 +0000 |
1437 | @@ -0,0 +1,154 @@ |
1438 | +/** |
1439 | + * Handles all the related work to injecting the 'external' extension into the |
1440 | + * content script (well, more precisely the current environment), and the proxy |
1441 | + * responsbile for handling the API requests in a webapplication. |
1442 | + * |
1443 | + */ |
1444 | +(function (currentWindow) { |
1445 | + var aWindow = currentWindow; |
1446 | + var plugin = null; |
1447 | + var service = null; |
1448 | + var api = { |
1449 | + init: function (options) { |
1450 | + options.url = window.location.href; |
1451 | + options.hostname = window.location.hostname; |
1452 | + options.host = window.location.host; |
1453 | + options.protocol = window.location.protocol; |
1454 | + chrome.runtime.sendMessage ( |
1455 | + {method: "init_requested", options: options} |
1456 | + , function (response) {}); |
1457 | + } |
1458 | + }; |
1459 | + |
1460 | + /** |
1461 | + * Inserts a given script in the webpage. |
1462 | + * Needs chrome.extension functionality. |
1463 | + * |
1464 | + * @param path of file to be injected (part of the extension) |
1465 | + */ |
1466 | + var insertScriptIntoWebpage = function (path) { |
1467 | + var script = document.createElement ('script'); |
1468 | + script.type = 'text/javascript'; |
1469 | + script.src = chrome.runtime.getURL (path); |
1470 | + document.getElementsByTagName("head")[0].appendChild (script); |
1471 | + }; |
1472 | + |
1473 | + var injectApiProxy = function () { |
1474 | + |
1475 | + // 1. inject a piece of javascript proxying all the requests |
1476 | + // to the unity webapps api |
1477 | + insertScriptIntoWebpage('unity-api-page-proxy-builder-gen.js'); |
1478 | + insertScriptIntoWebpage('unity-api-page-proxy.js'); |
1479 | + |
1480 | + function makeWebpageCallback (id) { |
1481 | + // TODO/FIXME: add support for callback params (needed for DnD) |
1482 | + return function () { |
1483 | + var d = document.createElement ("textarea"); |
1484 | + var e = document.createEvent ("Events"); |
1485 | + d.style.cssText = "display:none;"; |
1486 | + d.value = id; |
1487 | + d.addEventListener ("unity-webapps-chromium-api-com-link-callback-called-ack" |
1488 | + , function() { d.parentNode.removeChild (d); } |
1489 | + , true); |
1490 | + document.body.appendChild (d); |
1491 | + e.initEvent ("unity-webapps-chromium-api-com-link-callback-called", false, true); |
1492 | + d.dispatchEvent (e); |
1493 | + }; |
1494 | + }; |
1495 | + |
1496 | + // TODO: should be shared / generated w/ web page code |
1497 | + var isIterableObject = function(obj) { |
1498 | + if (obj === undefined || obj === null) { |
1499 | + return false; |
1500 | + } |
1501 | + var t = typeof(obj); |
1502 | + var types = {'string': 0, 'function': 0, 'number': 0, 'undefined': 0, 'boolean': 0}; |
1503 | + return types[t] === undefined; |
1504 | + }; |
1505 | + |
1506 | + /** |
1507 | + * Wraps callback ids in proper callback that dispatch to the |
1508 | + * webpage thru a proper event |
1509 | + * |
1510 | + */ |
1511 | + function wrapCallbackIds (obj) { |
1512 | + if ( ! isIterableObject(obj)) { |
1513 | + return obj; |
1514 | + } |
1515 | + if (obj |
1516 | + && obj.hasOwnProperty('callbackid') |
1517 | + && obj.callbackid != null) { |
1518 | + return makeWebpageCallback (obj.callbackid); |
1519 | + } |
1520 | + |
1521 | + var ret = (obj instanceof Array) ? [] : {}; |
1522 | + for (var key in obj) { |
1523 | + if (obj.hasOwnProperty(key)) { |
1524 | + |
1525 | + if (isIterableObject (obj[key])) { |
1526 | + |
1527 | + if (obj[key].callbackid != null) { |
1528 | + ret[key] = makeWebpageCallback (obj[key].callbackid); |
1529 | + } |
1530 | + else { |
1531 | + ret[key] = wrapCallbackIds (obj[key]); |
1532 | + } |
1533 | + } |
1534 | + else { |
1535 | + ret[key] = obj[key]; |
1536 | + } |
1537 | + } |
1538 | + } |
1539 | + return ret; |
1540 | + }; |
1541 | + |
1542 | + // 2. open the communication mean between the two |
1543 | + |
1544 | + // TODO has the implicit knowledge of who's behind ... |
1545 | + var dispatchActualFunctionCall = function (funcname, args) { |
1546 | + var funcnames = funcname.split('.'); |
1547 | + var reducetarget = api; |
1548 | + |
1549 | + // a bit hacky |
1550 | + try { |
1551 | + // Assumes that we are calling a 'callable' from a succession of objects |
1552 | + funcnames.reduce ( |
1553 | + function (prev, cur) { |
1554 | + return typeof prev[cur] == "function" ? prev[cur].bind(prev) : prev[cur]; |
1555 | + }, reducetarget).apply (null, args); |
1556 | + } catch (err) { |
1557 | + console.log ('Error while dispatching call to ' + funcnames.join('.') + ': ' + err); |
1558 | + } |
1559 | + }; |
1560 | + |
1561 | + document.addEventListener("unity-webapps-chromium-api-com-link" |
1562 | + , function(event) { |
1563 | + var from = event.target; |
1564 | + if (from) { |
1565 | + var type = from.getAttribute("data-eventType"); |
1566 | + |
1567 | + var args = JSON.parse(from.value); |
1568 | + args = args.map (function (arg) { return wrapCallbackIds (arg); }); |
1569 | + |
1570 | + // Actuall call, e.g. 'Notification.showNotification("a","b") |
1571 | + // being reduces to successive calls to associated objects: |
1572 | + // Notification, showNotification |
1573 | + // |
1574 | + // TODO add proper error handling |
1575 | + dispatchActualFunctionCall(type, args); |
1576 | + } |
1577 | + |
1578 | + // send ack event to allow cleanup |
1579 | + var ret = document.createEvent('Events'); |
1580 | + ret.initEvent('unity-webapps-chromium-api-com-link-ack', true, false); |
1581 | + from.dispatchEvent(ret); |
1582 | + } |
1583 | + , true); |
1584 | + }; |
1585 | + |
1586 | + // handle the proxy side of the api which is being injected on the |
1587 | + // webpage |
1588 | + injectApiProxy(); |
1589 | + } |
1590 | +)(window); |
1591 | + |
1592 | |
1593 | === removed file 'chromium-extension/browser.js' |
1594 | --- chromium-extension/browser.js 2013-12-16 07:15:32 +0000 |
1595 | +++ chromium-extension/browser.js 1970-01-01 00:00:00 +0000 |
1596 | @@ -1,154 +0,0 @@ |
1597 | -/** |
1598 | - * Handles all the related work to injecting the 'external' extension into the |
1599 | - * content script (well, more precisely the current environment), and the proxy |
1600 | - * responsbile for handling the API requests in a webapplication. |
1601 | - * |
1602 | - */ |
1603 | -(function (currentWindow) { |
1604 | - var aWindow = currentWindow; |
1605 | - var plugin = null; |
1606 | - var service = null; |
1607 | - var api = { |
1608 | - init: function (options) { |
1609 | - options.url = window.location.href; |
1610 | - options.hostname = window.location.hostname; |
1611 | - options.host = window.location.host; |
1612 | - options.protocol = window.location.protocol; |
1613 | - chrome.runtime.sendMessage ( |
1614 | - {method: "init_requested", options: options} |
1615 | - , function (response) {}); |
1616 | - } |
1617 | - }; |
1618 | - |
1619 | - /** |
1620 | - * Inserts a given script in the webpage. |
1621 | - * Needs chrome.extension functionality. |
1622 | - * |
1623 | - * @param path of file to be injected (part of the extension) |
1624 | - */ |
1625 | - var insertScriptIntoWebpage = function (path) { |
1626 | - var script = document.createElement ('script'); |
1627 | - script.type = 'text/javascript'; |
1628 | - script.src = chrome.runtime.getURL (path); |
1629 | - document.getElementsByTagName("head")[0].appendChild (script); |
1630 | - }; |
1631 | - |
1632 | - var injectApiProxy = function () { |
1633 | - |
1634 | - // 1. inject a piece of javascript proxying all the requests |
1635 | - // to the unity webapps api |
1636 | - insertScriptIntoWebpage('unity-api-page-proxy-builder-gen.js'); |
1637 | - insertScriptIntoWebpage('unity-api-page-proxy.js'); |
1638 | - |
1639 | - function makeWebpageCallback (id) { |
1640 | - // TODO/FIXME: add support for callback params (needed for DnD) |
1641 | - return function () { |
1642 | - var d = document.createElement ("textarea"); |
1643 | - var e = document.createEvent ("Events"); |
1644 | - d.style.cssText = "display:none;"; |
1645 | - d.value = id; |
1646 | - d.addEventListener ("unity-webapps-chromium-api-com-link-callback-called-ack" |
1647 | - , function() { d.parentNode.removeChild (d); } |
1648 | - , true); |
1649 | - document.body.appendChild (d); |
1650 | - e.initEvent ("unity-webapps-chromium-api-com-link-callback-called", false, true); |
1651 | - d.dispatchEvent (e); |
1652 | - }; |
1653 | - }; |
1654 | - |
1655 | - // TODO: should be shared / generated w/ web page code |
1656 | - var isIterableObject = function(obj) { |
1657 | - if (obj === undefined || obj === null) { |
1658 | - return false; |
1659 | - } |
1660 | - var t = typeof(obj); |
1661 | - var types = {'string': 0, 'function': 0, 'number': 0, 'undefined': 0, 'boolean': 0}; |
1662 | - return types[t] === undefined; |
1663 | - }; |
1664 | - |
1665 | - /** |
1666 | - * Wraps callback ids in proper callback that dispatch to the |
1667 | - * webpage thru a proper event |
1668 | - * |
1669 | - */ |
1670 | - function wrapCallbackIds (obj) { |
1671 | - if ( ! isIterableObject(obj)) { |
1672 | - return obj; |
1673 | - } |
1674 | - if (obj |
1675 | - && obj.hasOwnProperty('callbackid') |
1676 | - && obj.callbackid != null) { |
1677 | - return makeWebpageCallback (obj.callbackid); |
1678 | - } |
1679 | - |
1680 | - var ret = (obj instanceof Array) ? [] : {}; |
1681 | - for (var key in obj) { |
1682 | - if (obj.hasOwnProperty(key)) { |
1683 | - |
1684 | - if (isIterableObject (obj[key])) { |
1685 | - |
1686 | - if (obj[key].callbackid != null) { |
1687 | - ret[key] = makeWebpageCallback (obj[key].callbackid); |
1688 | - } |
1689 | - else { |
1690 | - ret[key] = wrapCallbackIds (obj[key]); |
1691 | - } |
1692 | - } |
1693 | - else { |
1694 | - ret[key] = obj[key]; |
1695 | - } |
1696 | - } |
1697 | - } |
1698 | - return ret; |
1699 | - }; |
1700 | - |
1701 | - // 2. open the communication mean between the two |
1702 | - |
1703 | - // TODO has the implicit knowledge of who's behind ... |
1704 | - var dispatchActualFunctionCall = function (funcname, args) { |
1705 | - var funcnames = funcname.split('.'); |
1706 | - var reducetarget = api; |
1707 | - |
1708 | - // a bit hacky |
1709 | - try { |
1710 | - // Assumes that we are calling a 'callable' from a succession of objects |
1711 | - funcnames.reduce ( |
1712 | - function (prev, cur) { |
1713 | - return typeof prev[cur] == "function" ? prev[cur].bind(prev) : prev[cur]; |
1714 | - }, reducetarget).apply (null, args); |
1715 | - } catch (err) { |
1716 | - console.log ('Error while dispatching call to ' + funcnames.join('.') + ': ' + err); |
1717 | - } |
1718 | - }; |
1719 | - |
1720 | - document.addEventListener("unity-webapps-chromium-api-com-link" |
1721 | - , function(event) { |
1722 | - var from = event.target; |
1723 | - if (from) { |
1724 | - var type = from.getAttribute("data-eventType"); |
1725 | - |
1726 | - var args = JSON.parse(from.value); |
1727 | - args = args.map (function (arg) { return wrapCallbackIds (arg); }); |
1728 | - |
1729 | - // Actuall call, e.g. 'Notification.showNotification("a","b") |
1730 | - // being reduces to successive calls to associated objects: |
1731 | - // Notification, showNotification |
1732 | - // |
1733 | - // TODO add proper error handling |
1734 | - dispatchActualFunctionCall(type, args); |
1735 | - } |
1736 | - |
1737 | - // send ack event to allow cleanup |
1738 | - var ret = document.createEvent('Events'); |
1739 | - ret.initEvent('unity-webapps-chromium-api-com-link-ack', true, false); |
1740 | - from.dispatchEvent(ret); |
1741 | - } |
1742 | - , true); |
1743 | - }; |
1744 | - |
1745 | - // handle the proxy side of the api which is being injected on the |
1746 | - // webpage |
1747 | - injectApiProxy(); |
1748 | - } |
1749 | -)(window); |
1750 | - |
1751 | |
1752 | === added file 'chromium-extension/chromium-extension.pro' |
1753 | --- chromium-extension/chromium-extension.pro 1970-01-01 00:00:00 +0000 |
1754 | +++ chromium-extension/chromium-extension.pro 2014-11-18 07:07:55 +0000 |
1755 | @@ -0,0 +1,66 @@ |
1756 | +include(../common-project-config.pri) |
1757 | +include($${TOP_SRC_DIR}/common-vars.pri) |
1758 | + |
1759 | +TEMPLATE = aux |
1760 | + |
1761 | +EXTENSION_DIR = $${INSTALL_LIBDIR}/libunity-chromium |
1762 | +EXTENSION_NAME = unity-webapps |
1763 | +EXTENSION_FILE = $${EXTENSION_NAME}.crx |
1764 | + |
1765 | +STATIC_EXTENSION_FILES = \ |
1766 | + background-page.html \ |
1767 | + background-page.js \ |
1768 | + base-content-script.js \ |
1769 | + browser.js \ |
1770 | + infobar.css \ |
1771 | + infobar.html \ |
1772 | + infobar.js \ |
1773 | + _locales \ |
1774 | + options.html \ |
1775 | + options.js \ |
1776 | + skin \ |
1777 | + unity-api-page-proxy-builder-gen.js \ |
1778 | + unity-api-page-proxy.js \ |
1779 | + |
1780 | +SCRIPT_FILES = \ |
1781 | + $${STATIC_EXTENSION_FILES} \ |
1782 | + manifest.json \ |
1783 | + unity-webapps.json |
1784 | + |
1785 | +QMAKE_SUBSTITUTES += \ |
1786 | + manifest.json.in \ |
1787 | + unity-webapps.json.in |
1788 | + |
1789 | +pemfile.target = unity-webapps.pem |
1790 | +pemfile.commands = "openssl genrsa 1024 > $${pemfile.target}" |
1791 | + |
1792 | +static_files.depends = \ |
1793 | + $${SCRIPT_FILES} |
1794 | +static_files.commands = mkdir -p $${OUT_PWD}/$${EXTENSION_NAME} && ${COPY_DIR} $${SCRIPT_FILES} $${OUT_PWD}/$${EXTENSION_NAME} |
1795 | + |
1796 | +static_files_stamp.target = buildstamp |
1797 | +static_files_stamp.depends = static_files |
1798 | +static_files_stamp.commands = touch $${static_files_stamp.target} |
1799 | + |
1800 | +extension.target = res/$${EXTENSION_NAME}.crx |
1801 | +extension.commands = $${TOP_SRC_DIR}/chromium-extension/crxmake.sh $${OUT_PWD}/$${EXTENSION_NAME} $${pemfile.target} |
1802 | +extension.depends = pemfile static_files_stamp |
1803 | + |
1804 | +QMAKE_EXTRA_TARGETS += \ |
1805 | + extension \ |
1806 | + pemfile \ |
1807 | + static_files \ |
1808 | + static_files_stamp |
1809 | + |
1810 | +PRE_TARGETDEPS = $${extension.target} |
1811 | + |
1812 | +manifest.files = \ |
1813 | + $${OUT_PWD}/res/*.json |
1814 | +manifest.path = $${INSTALL_PREFIX}/share/chromium/extensions/ |
1815 | +manifest.CONFIG = no_check_exist |
1816 | +INSTALLS += manifest |
1817 | + |
1818 | +crx.files = res/$${EXTENSION_NAME}.crx |
1819 | +crx.path = $${EXTENSION_DIR} |
1820 | +crx.CONFIG = no_check_exist |
1821 | +INSTALLS += crx |
1822 | |
1823 | === modified file 'chromium-extension/infobar.js' |
1824 | --- chromium-extension/infobar.js 2013-07-10 18:12:23 +0000 |
1825 | +++ chromium-extension/infobar.js 2014-11-18 07:07:55 +0000 |
1826 | @@ -1,29 +1,33 @@ |
1827 | var doIntegrate = function (integrate) { |
1828 | - chrome.tabs.getCurrent (function (tab) { |
1829 | - chrome.runtime.sendMessage ({tabId: tab.id, method: "on_user_infobar_request_result", integrate: integrate} |
1830 | - , function (response) {}); |
1831 | + chrome.tabs.query({currentWindow: true, active: true}, function (tabs) { |
1832 | + chrome.runtime.sendMessage({tabId: tabs[0].id, method: "on_user_infobar_request_result", integrate: integrate} |
1833 | + , function (response) {}); |
1834 | window.close(); |
1835 | }); |
1836 | }; |
1837 | |
1838 | window.onload = function () { |
1839 | chrome.runtime.getBackgroundPage(function (bg) { |
1840 | - document.getElementById('notintegrate').onclick = function () { doIntegrate(false); }; |
1841 | - document.getElementById('integrate').onclick = function () { doIntegrate(true); }; |
1842 | + document.getElementById('notintegrate').onclick = function () { doIntegrate(false); }; |
1843 | + document.getElementById('integrate').onclick = function () { doIntegrate(true); }; |
1844 | |
1845 | - chrome.tabs.getCurrent (function (tab) { |
1846 | - if (!bg|| !bg.background_page) { |
1847 | - window.close(); |
1848 | - return; |
1849 | - } |
1850 | - var msg = bg.background_page.getMessageForTabId(tab.id); |
1851 | - if (msg == null) { |
1852 | - window.close(); |
1853 | - return; |
1854 | - } |
1855 | - document.getElementById ('content').style.display = "block"; |
1856 | - document.getElementById ('message').innerHTML = msg || ""; |
1857 | - }); |
1858 | + chrome.tabs.query({currentWindow: true, active: true}, function (tabs) { |
1859 | + if (tabs.length === 0) { |
1860 | + window.close(); |
1861 | + return; |
1862 | + } |
1863 | + if (!bg || !bg.background_page) { |
1864 | + window.close(); |
1865 | + return; |
1866 | + } |
1867 | + var msg = bg.background_page.getMessageForTabId(tabs[0].id); |
1868 | + if (msg == null) { |
1869 | + window.close(); |
1870 | + return; |
1871 | + } |
1872 | + document.getElementById ('content').style.display = "block"; |
1873 | + document.getElementById ('message').innerHTML = msg || ""; |
1874 | + }); |
1875 | }); |
1876 | }; |
1877 | |
1878 | |
1879 | === modified file 'chromium-extension/manifest.json.in' |
1880 | --- chromium-extension/manifest.json.in 2013-12-16 07:15:32 +0000 |
1881 | +++ chromium-extension/manifest.json.in 2014-11-18 07:07:55 +0000 |
1882 | @@ -1,51 +1,41 @@ |
1883 | { |
1884 | - "name": "Unity WebApps Chromium extension", |
1885 | - "manifest_version": 2, |
1886 | - "minimum_chrome_version": "20.0", |
1887 | - "content_security_policy": "script-src 'self' chrome-extension://infobar.js 'unsafe-eval'; object-src 'self'", |
1888 | - |
1889 | - "version": "@VERSION@", |
1890 | - |
1891 | - "description": "Unity Webapps Chromium integration", |
1892 | - |
1893 | - "web_accessible_resources": [ |
1894 | - "browser.js", |
1895 | - "unity-api-page-proxy-builder-gen.js", |
1896 | - "unity-api-page-proxy.js", |
1897 | - "infobar.js", |
1898 | - "options.js" |
1899 | + '"name": "Unity WebApps Chromium extension"', |
1900 | + '"manifest_version"': 2, |
1901 | + '"minimum_chrome_version": "34.0"', |
1902 | + '"content_security_policy"': '"script-src \'self\' chrome-extension://infobar.js \'unsafe-eval\'; object-src \'self\'"', |
1903 | + |
1904 | + '"version": "$${PROJECT_VERSION}"', |
1905 | + |
1906 | + '"description": "Unity Webapps Chromium integration"', |
1907 | + |
1908 | + '"web_accessible_resources"': [ |
1909 | + '"browser.js"', |
1910 | + '"unity-api-page-proxy-builder-gen.js"', |
1911 | + '"unity-api-page-proxy.js"', |
1912 | + '"infobar.js"', |
1913 | + '"options.js"' |
1914 | ], |
1915 | |
1916 | - "icons": { |
1917 | - "16": "skin/cof-16.png", |
1918 | - "48": "skin/cof-48.png" |
1919 | - }, |
1920 | - |
1921 | - "default_locale": "en", |
1922 | - |
1923 | - "background": { |
1924 | - "page": "background-page.html" |
1925 | + '"icons"': { |
1926 | + '"16": "skin/cof-16.png"', |
1927 | + '"48": "skin/cof-48.png"' |
1928 | + }, |
1929 | + |
1930 | + '"default_locale": "en"', |
1931 | + |
1932 | + '"background"': { |
1933 | + '"page"': '"background-page.html"' |
1934 | }, |
1935 | |
1936 | - "permissions": ["tabs", "http://*/*", "infobars"], |
1937 | - "options_page": "options.html", |
1938 | + '"permissions": ["tabs", "http://*/*", "infobars", "nativeMessaging"]', |
1939 | + '"options_page": "options.html"', |
1940 | |
1941 | - "plugins": [ |
1942 | - |
1943 | - /** The "path" property specifies the path to your plugin, relative to the manifest file. |
1944 | - * The "public" property specifies whether your plugin can be accessed by regular web pages; |
1945 | - * the default is false, meaning only your extension can load the plugin. |
1946 | - */ |
1947 | - { "path": "libunity_npapi_plugin.so", "public": false } |
1948 | - |
1949 | - ], |
1950 | - |
1951 | - "content_scripts": [ |
1952 | + '"content_scripts"': [ |
1953 | { |
1954 | - "all_frames": true, |
1955 | - "matches": [ "<all_urls>" ], |
1956 | - "js": ["base-content-script.js"], |
1957 | - "run_at": "document_end" |
1958 | + '"all_frames"': true, |
1959 | + '"matches": [ "<all_urls>" ]', |
1960 | + '"js": ["base-content-script.js"]', |
1961 | + '"run_at": "document_end"' |
1962 | } |
1963 | ] |
1964 | } |
1965 | |
1966 | === added file 'chromium-extension/unity-api-page-proxy-builder-gen.js' |
1967 | --- chromium-extension/unity-api-page-proxy-builder-gen.js 1970-01-01 00:00:00 +0000 |
1968 | +++ chromium-extension/unity-api-page-proxy-builder-gen.js 2014-11-18 07:07:55 +0000 |
1969 | @@ -0,0 +1,384 @@ |
1970 | +var UnityWebappsApiPageProxyBuilder = function(backend) { |
1971 | + |
1972 | + var dummy = true; |
1973 | + var unity = { context: dummy, contextReady: dummy }; |
1974 | + var uwa = { ContextActionCallbackType: null }; |
1975 | + |
1976 | + var CallbackManager = { |
1977 | + makeCallback: function (dumd, func) { |
1978 | + return func; |
1979 | + } |
1980 | + }; |
1981 | + |
1982 | + function checkString(str, allowUndef) { |
1983 | + if (allowUndef && str == undefined) { |
1984 | + return; |
1985 | + } |
1986 | + if (!str || typeof(str) !== 'string') { |
1987 | + throw new TypeError("incorrect argument"); |
1988 | + } |
1989 | + } |
1990 | + |
1991 | + var findName = function (func, prefix, obj) { |
1992 | + |
1993 | + if (!prefix) { |
1994 | + return findName(func, 'Unity.', api); |
1995 | + } |
1996 | + var keys = Object.keys(obj); |
1997 | + for (var i = 0; i < keys.length; i++) { |
1998 | + if (typeof(keys[i]) !== 'string') { |
1999 | + continue; |
2000 | + } |
2001 | + var descr = Object.getOwnPropertyDescriptor(obj, keys[i]); |
2002 | + if (descr.value === func) { |
2003 | + return prefix + keys[i]; |
2004 | + } |
2005 | + if (descr.value instanceof Object) { |
2006 | + var res = findName(func, prefix + keys[i] + '.', obj[keys[i]]); |
2007 | + if (res) |
2008 | + return res; |
2009 | + } |
2010 | + if (obj.__lookupGetter__(keys[i]) === func) { |
2011 | + return prefix + keys[i]; |
2012 | + } |
2013 | + if (obj.__lookupSetter__(keys[i]) === func) { |
2014 | + return prefix + keys[i]; |
2015 | + } |
2016 | + } |
2017 | + return null; |
2018 | + |
2019 | + }; |
2020 | + |
2021 | + |
2022 | + var stringify = function (obj) { |
2023 | + |
2024 | + if (obj === undefined) |
2025 | + return obj; |
2026 | + if (obj === null) |
2027 | + return obj; |
2028 | + if (typeof(obj) == 'string') |
2029 | + return obj; |
2030 | + if (typeof(obj) == 'number') |
2031 | + return obj; |
2032 | + if (typeof(obj) == 'function') |
2033 | + return String(obj); |
2034 | + var dump = {}; |
2035 | + for (var i in obj) { |
2036 | + if (obj.hasOwnProperty(i)) |
2037 | + dump[i] = stringify(obj[i]); |
2038 | + } |
2039 | + return dump; |
2040 | + |
2041 | + }; |
2042 | + |
2043 | + |
2044 | + var stringifyArgs = function (obj) { |
2045 | + |
2046 | + var args = []; |
2047 | + for (var i = 0; i < obj.length; i++) { |
2048 | + args.push(stringify(obj[i])); |
2049 | + } |
2050 | + var res = JSON.stringify(args); |
2051 | + return res.substr(1, res.length - 2); |
2052 | + }; |
2053 | + |
2054 | + var createArgumentsSanitaizer = function (func, argsDesc, callback) { |
2055 | + |
2056 | + return function () { |
2057 | + var realArgs = arguments; |
2058 | + var name = findName(arguments.callee); |
2059 | + |
2060 | + var k = 0; |
2061 | + function argumentSanitaizer(desc, arg) { |
2062 | + if (!desc) { |
2063 | + throw new InternalError("argument description is null"); |
2064 | + } |
2065 | + if (desc.dummy) { |
2066 | + k--; |
2067 | + return null; |
2068 | + } |
2069 | + if (desc.array) { |
2070 | + if (!(desc.array instanceof Object) || !(desc.array.element instanceof Object)) { |
2071 | + throw new InternalError("invalid argument description"); |
2072 | + } |
2073 | + |
2074 | + try { |
2075 | + for (var j = 0; j < arg.length; j++) { |
2076 | + argumentSanitaizer(desc.array.element, arg[j]); |
2077 | + } |
2078 | + } catch (x) { |
2079 | + throw new TypeError("incorrect argument"); |
2080 | + } |
2081 | + |
2082 | + return arg; |
2083 | + } |
2084 | + if (desc.obj) { |
2085 | + if (!(desc.obj instanceof Object)) { |
2086 | + throw new InternalError("invalid argument description"); |
2087 | + } |
2088 | + var res = {}, i; |
2089 | + for (i in desc.obj) { |
2090 | + if (desc.obj.hasOwnProperty(i)) { |
2091 | + res[i] = argumentSanitaizer(desc.obj[i], arg[i]); |
2092 | + } |
2093 | + } |
2094 | + return res; |
2095 | + } |
2096 | + if (desc.str) { |
2097 | + if (desc.allowNull && !arg) { |
2098 | + return null; |
2099 | + } |
2100 | + checkString(arg, false); |
2101 | + return arg; |
2102 | + } |
2103 | + if (desc.number) { |
2104 | + if (typeof(arg) !== 'number' && typeof(arg) !== 'boolean') |
2105 | + throw new TypeError("incorrect argument"); |
2106 | + return arg; |
2107 | + } |
2108 | + if (!desc.type) { |
2109 | + throw new InternalError("argument description miss required parameter"); |
2110 | + } |
2111 | + if ((arg instanceof desc.type) || (desc.type === Function && ((typeof arg) === 'function')) |
2112 | + || (arg === null && desc.allowNull)) { |
2113 | + if (desc.type === Function) { |
2114 | + if (!arg) { |
2115 | + return null; |
2116 | + } |
2117 | + |
2118 | + var id; |
2119 | + if (desc.argAsCallbackId !== undefined) { |
2120 | + id = realArgs[desc.argAsCallbackId]; |
2121 | + } |
2122 | + return CallbackManager.makeCallback(uwa.ContextActionCallbackType, |
2123 | + function (context, user_data) { |
2124 | + arg(); |
2125 | + }, name, id); |
2126 | + } |
2127 | + return arg; |
2128 | + } else { |
2129 | + throw new TypeError("incorrect argument"); |
2130 | + } |
2131 | + throw new InternalError("unreacheable"); |
2132 | + } |
2133 | + var args = [unity.context], i; |
2134 | + for (i = 0; i < argsDesc.length; i++) { |
2135 | + if (k >= realArgs.length && k > 0 && !argsDesc[i].dummy) { |
2136 | + throw new Error("not enough arguments"); |
2137 | + } |
2138 | + var value = argumentSanitaizer(argsDesc[i], realArgs[k]); |
2139 | + k++; |
2140 | + |
2141 | + if (argsDesc[i].obj) { |
2142 | + args = args.concat(value); |
2143 | + } else { |
2144 | + args.push(value); |
2145 | + } |
2146 | + } |
2147 | + |
2148 | + if (k < realArgs.length) { |
2149 | + throw new Error("too much arguments"); |
2150 | + } |
2151 | + |
2152 | + if (callback) |
2153 | + callback.apply(uwa, args); |
2154 | + if (func) |
2155 | + return Function.apply.apply(func, [uwa, args]); |
2156 | + |
2157 | + return null; |
2158 | + }; |
2159 | + |
2160 | + }; |
2161 | + var api = { |
2162 | + init: function(props) { |
2163 | + checkString(props.name, false); |
2164 | + checkString(props.iconUrl, true); |
2165 | + checkString(props.domain, true); |
2166 | + checkString(props.login, true); |
2167 | + checkString(props.mimeTypes, true); |
2168 | + checkString(props.homepage, true); |
2169 | + if (props.homepage && !/^(http|https|file):\/\//.test(props.homepage)) { |
2170 | + throw new TypeError("incorrect argument"); |
2171 | + } |
2172 | + backend("init", [props]); |
2173 | + } |
2174 | + , |
2175 | + acceptData: createArgumentsSanitaizer(null, |
2176 | + [{ array: { element: { str: true } } }, { type: Function, js: true }], |
2177 | + function (context, mimeTypes, callback) { |
2178 | + backend('acceptData', [mimeTypes, callback]); |
2179 | + }) |
2180 | + , |
2181 | + addAction: createArgumentsSanitaizer(null, |
2182 | + [{ str: true }, { type: Function, argAsCallbackId: 0 }], |
2183 | + function (context, name, callback) { |
2184 | + backend('addAction', [name, callback]); |
2185 | + }) |
2186 | + , |
2187 | + clearAction: createArgumentsSanitaizer(null, |
2188 | + [{ str: true }] |
2189 | + , function (context, name) { |
2190 | + backend('clearAction', [name]); |
2191 | + }) |
2192 | + , |
2193 | + clearActions: createArgumentsSanitaizer(null, |
2194 | + [], |
2195 | + function (context) { |
2196 | + backend('clearActions', []); |
2197 | + }) |
2198 | + , |
2199 | + MediaPlayer: { |
2200 | + init: createArgumentsSanitaizer(null, |
2201 | + [{ str: true }], |
2202 | + function (context, name) { |
2203 | + backend('MediaPlayer.init', [name]); |
2204 | + }) |
2205 | + , |
2206 | + onPlayPause: createArgumentsSanitaizer(null, |
2207 | + [{ type: Function, allowNull: true }, { dummy: true }], |
2208 | + function (context, callback) { |
2209 | + backend('MediaPlayer.onPlayPause', [callback]); |
2210 | + } |
2211 | + ) |
2212 | + , |
2213 | + onPrevious: createArgumentsSanitaizer(null, |
2214 | + [{ type: Function, allowNull: true }, { dummy: true }], |
2215 | + function (context, callback) { |
2216 | + backend('MediaPlayer.onPrevious', [callback]); |
2217 | + }) |
2218 | + , |
2219 | + onNext: createArgumentsSanitaizer(null, |
2220 | + [{ type: Function, allowNull: true }, { dummy: true }], |
2221 | + function (context, callback) { |
2222 | + backend('MediaPlayer.onNext', [callback]); |
2223 | + } |
2224 | + ) |
2225 | + , |
2226 | + setTrack: createArgumentsSanitaizer(null, |
2227 | + [{ obj: { artist: { str: true, place: 0, allowNull: true }, |
2228 | + album: { str: true, place: 1, allowNull: true }, |
2229 | + title: { str: true, place: 2 }, |
2230 | + artLocation: { str: true, place: 3, allowNull: true } } }], |
2231 | + function (context, trackinfos) { |
2232 | + backend('MediaPlayer.setTrack', [trackinfos]); |
2233 | + }) |
2234 | + , |
2235 | + setCanGoNext: createArgumentsSanitaizer(null, |
2236 | + [{ number: true }], |
2237 | + function (context, v) { |
2238 | + backend('MediaPlayer.setCanGoNext', [v]); |
2239 | + } |
2240 | + ) |
2241 | + , |
2242 | + setCanGoPrevious: createArgumentsSanitaizer(null, |
2243 | + [{ number: true }], |
2244 | + function (context, v) { |
2245 | + backend('MediaPlayer.setCanGoPrevious', [v]); |
2246 | + } |
2247 | + ) |
2248 | + , |
2249 | + setCanPlay: createArgumentsSanitaizer(null, |
2250 | + [{ number: true }], |
2251 | + function (context, v) { backend('MediaPlayer.setCanPlay', [v]); } |
2252 | + ) |
2253 | + , |
2254 | + setCanPause: createArgumentsSanitaizer(null, |
2255 | + [{ number: true }], |
2256 | + function (context, v) { backend('MediaPlayer.setCanPause', [v]); } |
2257 | + ) |
2258 | + , |
2259 | + setPlaybackState: createArgumentsSanitaizer(null, |
2260 | + [{ number: true }], |
2261 | + function (context, v) { backend('MediaPlayer.setPlaybackState', [v]); } |
2262 | + ) |
2263 | + , |
2264 | + getPlaybackState: createArgumentsSanitaizer(null |
2265 | + , [{ type: Function }] |
2266 | + , function (context, callback) { |
2267 | + backend('MediaPlayer.getPlaybackState', [callback]); |
2268 | + } |
2269 | + ) |
2270 | + , |
2271 | + PlaybackState: {PLAYING: 0, PAUSED:1} |
2272 | + }, |
2273 | + |
2274 | + Notification: { |
2275 | + showNotification: createArgumentsSanitaizer(null, |
2276 | + [{ str: true }, { str: true }, { str: true, allowNull: true }], |
2277 | + function (context, title, name, dummy) { |
2278 | + backend('Notification.showNotification', [title, name, dummy]); |
2279 | + } |
2280 | + ) |
2281 | + }, |
2282 | + |
2283 | + Launcher: { |
2284 | + setCount: createArgumentsSanitaizer(null, |
2285 | + [{ number: true }], |
2286 | + function (context, count) { |
2287 | + backend('Launcher.setCount', [count]); |
2288 | + } |
2289 | + ) |
2290 | + , |
2291 | + clearCount: createArgumentsSanitaizer(null, |
2292 | + [], |
2293 | + function (context) { |
2294 | + backend('Launcher.clearCount', []); |
2295 | + }), |
2296 | + setProgress: createArgumentsSanitaizer(null, |
2297 | + [{ number: true }], |
2298 | + function (context, progress) { |
2299 | + backend('Launcher.setProgress', [progress]); |
2300 | + } |
2301 | + ) |
2302 | + , |
2303 | + clearProgress: createArgumentsSanitaizer(null, |
2304 | + [], |
2305 | + function (context) { |
2306 | + backend('Launcher.clearProgress', []); |
2307 | + } |
2308 | + ) |
2309 | + , |
2310 | + setUrgent: createArgumentsSanitaizer(null, |
2311 | + [], |
2312 | + function (context) { |
2313 | + backend('Launcher.setUrgent', []); |
2314 | + } |
2315 | + ) |
2316 | + , |
2317 | + addAction: function(arg1, arg2) { |
2318 | + backend('Launcher.addAction', [arg1, arg2]); |
2319 | + } |
2320 | + , |
2321 | + removeAction: createArgumentsSanitaizer(null, |
2322 | + [{ str: true }], |
2323 | + function (context, name) { |
2324 | + backend('Launcher.removeAction', [name]); |
2325 | + } |
2326 | + ) |
2327 | + , |
2328 | + removeActions: createArgumentsSanitaizer(null, |
2329 | + [], |
2330 | + function (context) { |
2331 | + backend('Launcher.removeActions', []); |
2332 | + } |
2333 | + ) |
2334 | + }, |
2335 | + MessagingIndicator: { |
2336 | + addAction: createArgumentsSanitaizer(null, |
2337 | + [{ str: true }, { type: Function, argAsCallbackId: 0 }, { dummy: true }], |
2338 | + function (context, name, callback, dummy) { |
2339 | + backend('MessagingIndicator.addAction', [name, callback, dummy]); |
2340 | + } |
2341 | + ) |
2342 | + , |
2343 | + showIndicator: function(name, properties) { |
2344 | + backend('MessagingIndicator.showIndicator', [name, properties]); |
2345 | + } |
2346 | + , |
2347 | + clearIndicator: createArgumentsSanitaizer(null, [{ str: true }], function(context, name) { backend('MessagingIndicator.clearIndicator', [name]); }), |
2348 | + clearIndicators: createArgumentsSanitaizer(null, [], function (context) { backend('MessagingIndicator.clearIndicators', []); }) |
2349 | + } |
2350 | + }; |
2351 | + return api; |
2352 | +}; |
2353 | + |
2354 | |
2355 | === removed file 'chromium-extension/unity-api-page-proxy-builder-gen.js' |
2356 | --- chromium-extension/unity-api-page-proxy-builder-gen.js 2013-11-01 06:37:07 +0000 |
2357 | +++ chromium-extension/unity-api-page-proxy-builder-gen.js 1970-01-01 00:00:00 +0000 |
2358 | @@ -1,384 +0,0 @@ |
2359 | -var UnityWebappsApiPageProxyBuilder = function(backend) { |
2360 | - |
2361 | - var dummy = true; |
2362 | - var unity = { context: dummy, contextReady: dummy }; |
2363 | - var uwa = { ContextActionCallbackType: null }; |
2364 | - |
2365 | - var CallbackManager = { |
2366 | - makeCallback: function (dumd, func) { |
2367 | - return func; |
2368 | - } |
2369 | - }; |
2370 | - |
2371 | - function checkString(str, allowUndef) { |
2372 | - if (allowUndef && str == undefined) { |
2373 | - return; |
2374 | - } |
2375 | - if (!str || typeof(str) !== 'string') { |
2376 | - throw new TypeError("incorrect argument"); |
2377 | - } |
2378 | - } |
2379 | - |
2380 | - var findName = function (func, prefix, obj) { |
2381 | - |
2382 | - if (!prefix) { |
2383 | - return findName(func, 'Unity.', api); |
2384 | - } |
2385 | - var keys = Object.keys(obj); |
2386 | - for (var i = 0; i < keys.length; i++) { |
2387 | - if (typeof(keys[i]) !== 'string') { |
2388 | - continue; |
2389 | - } |
2390 | - var descr = Object.getOwnPropertyDescriptor(obj, keys[i]); |
2391 | - if (descr.value === func) { |
2392 | - return prefix + keys[i]; |
2393 | - } |
2394 | - if (descr.value instanceof Object) { |
2395 | - var res = findName(func, prefix + keys[i] + '.', obj[keys[i]]); |
2396 | - if (res) |
2397 | - return res; |
2398 | - } |
2399 | - if (obj.__lookupGetter__(keys[i]) === func) { |
2400 | - return prefix + keys[i]; |
2401 | - } |
2402 | - if (obj.__lookupSetter__(keys[i]) === func) { |
2403 | - return prefix + keys[i]; |
2404 | - } |
2405 | - } |
2406 | - return null; |
2407 | - |
2408 | - }; |
2409 | - |
2410 | - |
2411 | - var stringify = function (obj) { |
2412 | - |
2413 | - if (obj === undefined) |
2414 | - return obj; |
2415 | - if (obj === null) |
2416 | - return obj; |
2417 | - if (typeof(obj) == 'string') |
2418 | - return obj; |
2419 | - if (typeof(obj) == 'number') |
2420 | - return obj; |
2421 | - if (typeof(obj) == 'function') |
2422 | - return String(obj); |
2423 | - var dump = {}; |
2424 | - for (var i in obj) { |
2425 | - if (obj.hasOwnProperty(i)) |
2426 | - dump[i] = stringify(obj[i]); |
2427 | - } |
2428 | - return dump; |
2429 | - |
2430 | - }; |
2431 | - |
2432 | - |
2433 | - var stringifyArgs = function (obj) { |
2434 | - |
2435 | - var args = []; |
2436 | - for (var i = 0; i < obj.length; i++) { |
2437 | - args.push(stringify(obj[i])); |
2438 | - } |
2439 | - var res = JSON.stringify(args); |
2440 | - return res.substr(1, res.length - 2); |
2441 | - }; |
2442 | - |
2443 | - var createArgumentsSanitaizer = function (func, argsDesc, callback) { |
2444 | - |
2445 | - return function () { |
2446 | - var realArgs = arguments; |
2447 | - var name = findName(arguments.callee); |
2448 | - |
2449 | - var k = 0; |
2450 | - function argumentSanitaizer(desc, arg) { |
2451 | - if (!desc) { |
2452 | - throw new InternalError("argument description is null"); |
2453 | - } |
2454 | - if (desc.dummy) { |
2455 | - k--; |
2456 | - return null; |
2457 | - } |
2458 | - if (desc.array) { |
2459 | - if (!(desc.array instanceof Object) || !(desc.array.element instanceof Object)) { |
2460 | - throw new InternalError("invalid argument description"); |
2461 | - } |
2462 | - |
2463 | - try { |
2464 | - for (var j = 0; j < arg.length; j++) { |
2465 | - argumentSanitaizer(desc.array.element, arg[j]); |
2466 | - } |
2467 | - } catch (x) { |
2468 | - throw new TypeError("incorrect argument"); |
2469 | - } |
2470 | - |
2471 | - return arg; |
2472 | - } |
2473 | - if (desc.obj) { |
2474 | - if (!(desc.obj instanceof Object)) { |
2475 | - throw new InternalError("invalid argument description"); |
2476 | - } |
2477 | - var res = {}, i; |
2478 | - for (i in desc.obj) { |
2479 | - if (desc.obj.hasOwnProperty(i)) { |
2480 | - res[i] = argumentSanitaizer(desc.obj[i], arg[i]); |
2481 | - } |
2482 | - } |
2483 | - return res; |
2484 | - } |
2485 | - if (desc.str) { |
2486 | - if (desc.allowNull && !arg) { |
2487 | - return null; |
2488 | - } |
2489 | - checkString(arg, false); |
2490 | - return arg; |
2491 | - } |
2492 | - if (desc.number) { |
2493 | - if (typeof(arg) !== 'number' && typeof(arg) !== 'boolean') |
2494 | - throw new TypeError("incorrect argument"); |
2495 | - return arg; |
2496 | - } |
2497 | - if (!desc.type) { |
2498 | - throw new InternalError("argument description miss required parameter"); |
2499 | - } |
2500 | - if ((arg instanceof desc.type) || (desc.type === Function && ((typeof arg) === 'function')) |
2501 | - || (arg === null && desc.allowNull)) { |
2502 | - if (desc.type === Function) { |
2503 | - if (!arg) { |
2504 | - return null; |
2505 | - } |
2506 | - |
2507 | - var id; |
2508 | - if (desc.argAsCallbackId !== undefined) { |
2509 | - id = realArgs[desc.argAsCallbackId]; |
2510 | - } |
2511 | - return CallbackManager.makeCallback(uwa.ContextActionCallbackType, |
2512 | - function (context, user_data) { |
2513 | - arg(); |
2514 | - }, name, id); |
2515 | - } |
2516 | - return arg; |
2517 | - } else { |
2518 | - throw new TypeError("incorrect argument"); |
2519 | - } |
2520 | - throw new InternalError("unreacheable"); |
2521 | - } |
2522 | - var args = [unity.context], i; |
2523 | - for (i = 0; i < argsDesc.length; i++) { |
2524 | - if (k >= realArgs.length && k > 0 && !argsDesc[i].dummy) { |
2525 | - throw new Error("not enough arguments"); |
2526 | - } |
2527 | - var value = argumentSanitaizer(argsDesc[i], realArgs[k]); |
2528 | - k++; |
2529 | - |
2530 | - if (argsDesc[i].obj) { |
2531 | - args = args.concat(value); |
2532 | - } else { |
2533 | - args.push(value); |
2534 | - } |
2535 | - } |
2536 | - |
2537 | - if (k < realArgs.length) { |
2538 | - throw new Error("too much arguments"); |
2539 | - } |
2540 | - |
2541 | - if (callback) |
2542 | - callback.apply(uwa, args); |
2543 | - if (func) |
2544 | - return Function.apply.apply(func, [uwa, args]); |
2545 | - |
2546 | - return null; |
2547 | - }; |
2548 | - |
2549 | - }; |
2550 | - var api = { |
2551 | - init: function(props) { |
2552 | - checkString(props.name, false); |
2553 | - checkString(props.iconUrl, true); |
2554 | - checkString(props.domain, true); |
2555 | - checkString(props.login, true); |
2556 | - checkString(props.mimeTypes, true); |
2557 | - checkString(props.homepage, true); |
2558 | - if (props.homepage && !/^(http|https|file):\/\//.test(props.homepage)) { |
2559 | - throw new TypeError("incorrect argument"); |
2560 | - } |
2561 | - backend("init", [props]); |
2562 | - } |
2563 | - , |
2564 | - acceptData: createArgumentsSanitaizer(null, |
2565 | - [{ array: { element: { str: true } } }, { type: Function, js: true }], |
2566 | - function (context, mimeTypes, callback) { |
2567 | - backend('acceptData', [mimeTypes, callback]); |
2568 | - }) |
2569 | - , |
2570 | - addAction: createArgumentsSanitaizer(null, |
2571 | - [{ str: true }, { type: Function, argAsCallbackId: 0 }], |
2572 | - function (context, name, callback) { |
2573 | - backend('addAction', [name, callback]); |
2574 | - }) |
2575 | - , |
2576 | - clearAction: createArgumentsSanitaizer(null, |
2577 | - [{ str: true }] |
2578 | - , function (context, name) { |
2579 | - backend('clearAction', [name]); |
2580 | - }) |
2581 | - , |
2582 | - clearActions: createArgumentsSanitaizer(null, |
2583 | - [], |
2584 | - function (context) { |
2585 | - backend('clearActions', []); |
2586 | - }) |
2587 | - , |
2588 | - MediaPlayer: { |
2589 | - init: createArgumentsSanitaizer(null, |
2590 | - [{ str: true }], |
2591 | - function (context, name) { |
2592 | - backend('MediaPlayer.init', [name]); |
2593 | - }) |
2594 | - , |
2595 | - onPlayPause: createArgumentsSanitaizer(null, |
2596 | - [{ type: Function, allowNull: true }, { dummy: true }], |
2597 | - function (context, callback) { |
2598 | - backend('MediaPlayer.onPlayPause', [callback]); |
2599 | - } |
2600 | - ) |
2601 | - , |
2602 | - onPrevious: createArgumentsSanitaizer(null, |
2603 | - [{ type: Function, allowNull: true }, { dummy: true }], |
2604 | - function (context, callback) { |
2605 | - backend('MediaPlayer.onPrevious', [callback]); |
2606 | - }) |
2607 | - , |
2608 | - onNext: createArgumentsSanitaizer(null, |
2609 | - [{ type: Function, allowNull: true }, { dummy: true }], |
2610 | - function (context, callback) { |
2611 | - backend('MediaPlayer.onNext', [callback]); |
2612 | - } |
2613 | - ) |
2614 | - , |
2615 | - setTrack: createArgumentsSanitaizer(null, |
2616 | - [{ obj: { artist: { str: true, place: 0, allowNull: true }, |
2617 | - album: { str: true, place: 1, allowNull: true }, |
2618 | - title: { str: true, place: 2 }, |
2619 | - artLocation: { str: true, place: 3, allowNull: true } } }], |
2620 | - function (context, trackinfos) { |
2621 | - backend('MediaPlayer.setTrack', [trackinfos]); |
2622 | - }) |
2623 | - , |
2624 | - setCanGoNext: createArgumentsSanitaizer(null, |
2625 | - [{ number: true }], |
2626 | - function (context, v) { |
2627 | - backend('MediaPlayer.setCanGoNext', [v]); |
2628 | - } |
2629 | - ) |
2630 | - , |
2631 | - setCanGoPrevious: createArgumentsSanitaizer(null, |
2632 | - [{ number: true }], |
2633 | - function (context, v) { |
2634 | - backend('MediaPlayer.setCanGoPrevious', [v]); |
2635 | - } |
2636 | - ) |
2637 | - , |
2638 | - setCanPlay: createArgumentsSanitaizer(null, |
2639 | - [{ number: true }], |
2640 | - function (context, v) { backend('MediaPlayer.setCanPlay', [v]); } |
2641 | - ) |
2642 | - , |
2643 | - setCanPause: createArgumentsSanitaizer(null, |
2644 | - [{ number: true }], |
2645 | - function (context, v) { backend('MediaPlayer.setCanPause', [v]); } |
2646 | - ) |
2647 | - , |
2648 | - setPlaybackState: createArgumentsSanitaizer(null, |
2649 | - [{ number: true }], |
2650 | - function (context, v) { backend('MediaPlayer.setPlaybackState', [v]); } |
2651 | - ) |
2652 | - , |
2653 | - getPlaybackState: createArgumentsSanitaizer(null |
2654 | - , [{ type: Function }] |
2655 | - , function (context, callback) { |
2656 | - backend('MediaPlayer.getPlaybackState', [callback]); |
2657 | - } |
2658 | - ) |
2659 | - , |
2660 | - PlaybackState: {PLAYING: 0, PAUSED:1} |
2661 | - }, |
2662 | - |
2663 | - Notification: { |
2664 | - showNotification: createArgumentsSanitaizer(null, |
2665 | - [{ str: true }, { str: true }, { str: true, allowNull: true }], |
2666 | - function (context, title, name, dummy) { |
2667 | - backend('Notification.showNotification', [title, name, dummy]); |
2668 | - } |
2669 | - ) |
2670 | - }, |
2671 | - |
2672 | - Launcher: { |
2673 | - setCount: createArgumentsSanitaizer(null, |
2674 | - [{ number: true }], |
2675 | - function (context, count) { |
2676 | - backend('Launcher.setCount', [count]); |
2677 | - } |
2678 | - ) |
2679 | - , |
2680 | - clearCount: createArgumentsSanitaizer(null, |
2681 | - [], |
2682 | - function (context) { |
2683 | - backend('Launcher.clearCount', []); |
2684 | - }), |
2685 | - setProgress: createArgumentsSanitaizer(null, |
2686 | - [{ number: true }], |
2687 | - function (context, progress) { |
2688 | - backend('Launcher.setProgress', [progress]); |
2689 | - } |
2690 | - ) |
2691 | - , |
2692 | - clearProgress: createArgumentsSanitaizer(null, |
2693 | - [], |
2694 | - function (context) { |
2695 | - backend('Launcher.clearProgress', []); |
2696 | - } |
2697 | - ) |
2698 | - , |
2699 | - setUrgent: createArgumentsSanitaizer(null, |
2700 | - [], |
2701 | - function (context) { |
2702 | - backend('Launcher.setUrgent', []); |
2703 | - } |
2704 | - ) |
2705 | - , |
2706 | - addAction: function(arg1, arg2) { |
2707 | - backend('Launcher.addAction', [arg1, arg2]); |
2708 | - } |
2709 | - , |
2710 | - removeAction: createArgumentsSanitaizer(null, |
2711 | - [{ str: true }], |
2712 | - function (context, name) { |
2713 | - backend('Launcher.removeAction', [name]); |
2714 | - } |
2715 | - ) |
2716 | - , |
2717 | - removeActions: createArgumentsSanitaizer(null, |
2718 | - [], |
2719 | - function (context) { |
2720 | - backend('Launcher.removeActions', []); |
2721 | - } |
2722 | - ) |
2723 | - }, |
2724 | - MessagingIndicator: { |
2725 | - addAction: createArgumentsSanitaizer(null, |
2726 | - [{ str: true }, { type: Function, argAsCallbackId: 0 }, { dummy: true }], |
2727 | - function (context, name, callback, dummy) { |
2728 | - backend('MessagingIndicator.addAction', [name, callback, dummy]); |
2729 | - } |
2730 | - ) |
2731 | - , |
2732 | - showIndicator: function(name, properties) { |
2733 | - backend('MessagingIndicator.showIndicator', [name, properties]); |
2734 | - } |
2735 | - , |
2736 | - clearIndicator: createArgumentsSanitaizer(null, [{ str: true }], function(context, name) { backend('MessagingIndicator.clearIndicator', [name]); }), |
2737 | - clearIndicators: createArgumentsSanitaizer(null, [], function (context) { backend('MessagingIndicator.clearIndicators', []); }) |
2738 | - } |
2739 | - }; |
2740 | - return api; |
2741 | -}; |
2742 | - |
2743 | |
2744 | === added file 'chromium-extension/unity-api-page-proxy.js' |
2745 | --- chromium-extension/unity-api-page-proxy.js 1970-01-01 00:00:00 +0000 |
2746 | +++ chromium-extension/unity-api-page-proxy.js 2014-11-18 07:07:55 +0000 |
2747 | @@ -0,0 +1,146 @@ |
2748 | +/** |
2749 | + * |
2750 | + * |
2751 | + */ |
2752 | +setTimeout ( |
2753 | + function () { |
2754 | + var CallbackManagerBuilder = function () { |
2755 | + var prepend = 'unity-webapps-chromium-api'; |
2756 | + var callbacks = {}; |
2757 | + return { |
2758 | + store: function (callback) { |
2759 | + var gensym = function() { return prepend + Math.random(); }; |
2760 | + var id = gensym(); |
2761 | + while (undefined != callbacks[id]) { |
2762 | + id = gensym(); |
2763 | + } |
2764 | + callbacks[id] = callback; |
2765 | + return id; |
2766 | + } |
2767 | + , |
2768 | + get: function (id) { |
2769 | + return callbacks[id]; |
2770 | + } |
2771 | + }; |
2772 | + }; |
2773 | + var callbackmanager = CallbackManagerBuilder(); |
2774 | + |
2775 | + /** |
2776 | + * Acknowledge that the API has been fully injected |
2777 | + */ |
2778 | + var sendApiCreatedAcknowledge = function () { |
2779 | + var e = document.createEvent ("Events"); |
2780 | + e.initEvent ("unity-webapps-api-ready", false, false); |
2781 | + document.dispatchEvent (e); |
2782 | + }; |
2783 | + |
2784 | + /** |
2785 | + * |
2786 | + * |
2787 | + */ |
2788 | + function sendToApi (type, data) { |
2789 | + var callback = null; |
2790 | + var d = document.createElement ("textarea"); |
2791 | + var e = document.createEvent ("Events"); |
2792 | + d.style.cssText = "display:none;"; |
2793 | + |
2794 | + var isIterableObject = function(obj) { |
2795 | + if (obj === undefined || obj === null) { |
2796 | + return false; |
2797 | + } |
2798 | + var t = typeof(obj); |
2799 | + var types = {'string': 0, 'function': 0, 'boolean': 0, 'number': 0, 'undefined': 0}; |
2800 | + return types[t] === undefined; |
2801 | + }; |
2802 | + |
2803 | + function transformToIdIfNecessary(obj) { |
2804 | + var ret = obj; |
2805 | + if (obj instanceof Function) { |
2806 | + var id = callbackmanager.store(obj); |
2807 | + ret = {callbackid: id}; |
2808 | + } |
2809 | + return ret; |
2810 | + } |
2811 | + // map function callback (not serializable to a different world) |
2812 | + // to ids |
2813 | + function transformCallbacksToIds (obj) { |
2814 | + if ( ! isIterableObject(obj)) { |
2815 | + return transformToIdIfNecessary (obj); |
2816 | + } |
2817 | + var ret = (obj instanceof Array) ? [] : {}; |
2818 | + for (var key in obj) { |
2819 | + if (obj.hasOwnProperty(key)) { |
2820 | + if (obj[key] instanceof Function) { |
2821 | + var id = callbackmanager.store(obj[key]); |
2822 | + ret[key] = {callbackid: id}; |
2823 | + } |
2824 | + else if (isIterableObject (obj[key])) { |
2825 | + ret[key] = transformCallbacksToIds (obj[key]); |
2826 | + } |
2827 | + else { |
2828 | + ret[key] = obj[key]; |
2829 | + } |
2830 | + } |
2831 | + } |
2832 | + return ret; |
2833 | + }; |
2834 | + |
2835 | + // TODO: assumes some structure, does not play well w/ arrays |
2836 | + // actually converts: [1,2,3] -> {'0': 1, '1': 2, '2': 3} |
2837 | + d.value = JSON.stringify ( |
2838 | + data.map ( |
2839 | + function (datum) { |
2840 | + return transformCallbacksToIds (datum); |
2841 | + } |
2842 | + ) |
2843 | + ); |
2844 | + d.addEventListener ("unity-webapps-chromium-api-com-link-ack" |
2845 | + , |
2846 | + function() { |
2847 | + if (callback) callback (d.value); |
2848 | + d.parentNode.removeChild (d); |
2849 | + } |
2850 | + , true); |
2851 | + |
2852 | + d.setAttribute ("data-eventType", type); |
2853 | + document.body.appendChild (d); |
2854 | + e.initEvent ("unity-webapps-chromium-api-com-link", false, true); |
2855 | + d.dispatchEvent (e); |
2856 | + }; |
2857 | + |
2858 | + document.addEventListener ("unity-webapps-chromium-api-com-link-callback-called" |
2859 | + , |
2860 | + function(event) { |
2861 | + var from = event.target; |
2862 | + if (from) { |
2863 | + if (from.value) { |
2864 | + var callback = callbackmanager.get(from.value); |
2865 | + if (callback) { |
2866 | + callback (); |
2867 | + } |
2868 | + } |
2869 | + var ret = document.createEvent('Events'); |
2870 | + ret.initEvent('unity-webapps-chromium-api-com-link-callback-called-ack', true, false); |
2871 | + from.dispatchEvent(ret); |
2872 | + } |
2873 | + } |
2874 | + , true); |
2875 | + |
2876 | + var api = UnityWebappsApiPageProxyBuilder(sendToApi); |
2877 | + |
2878 | + function unity() { |
2879 | + } |
2880 | + unity.prototype = { |
2881 | + __proto__: window.external, |
2882 | + getUnityObject: function (version) { |
2883 | + console.log ('Proxy: getUnityObject called with version ' + version); |
2884 | + if (version === 1) |
2885 | + return api; |
2886 | + throw new Error("incorrect version"); |
2887 | + } |
2888 | + }; |
2889 | + window.external = new unity(); |
2890 | + |
2891 | + sendApiCreatedAcknowledge(); |
2892 | + } |
2893 | +, 0); |
2894 | |
2895 | === removed file 'chromium-extension/unity-api-page-proxy.js' |
2896 | --- chromium-extension/unity-api-page-proxy.js 2013-12-16 07:15:32 +0000 |
2897 | +++ chromium-extension/unity-api-page-proxy.js 1970-01-01 00:00:00 +0000 |
2898 | @@ -1,146 +0,0 @@ |
2899 | -/** |
2900 | - * |
2901 | - * |
2902 | - */ |
2903 | -setTimeout ( |
2904 | - function () { |
2905 | - var CallbackManagerBuilder = function () { |
2906 | - var prepend = 'unity-webapps-chromium-api'; |
2907 | - var callbacks = {}; |
2908 | - return { |
2909 | - store: function (callback) { |
2910 | - var gensym = function() { return prepend + Math.random(); }; |
2911 | - var id = gensym(); |
2912 | - while (undefined != callbacks[id]) { |
2913 | - id = gensym(); |
2914 | - } |
2915 | - callbacks[id] = callback; |
2916 | - return id; |
2917 | - } |
2918 | - , |
2919 | - get: function (id) { |
2920 | - return callbacks[id]; |
2921 | - } |
2922 | - }; |
2923 | - }; |
2924 | - var callbackmanager = CallbackManagerBuilder(); |
2925 | - |
2926 | - /** |
2927 | - * Acknowledge that the API has been fully injected |
2928 | - */ |
2929 | - var sendApiCreatedAcknowledge = function () { |
2930 | - var e = document.createEvent ("Events"); |
2931 | - e.initEvent ("unity-webapps-api-ready", false, false); |
2932 | - document.dispatchEvent (e); |
2933 | - }; |
2934 | - |
2935 | - /** |
2936 | - * |
2937 | - * |
2938 | - */ |
2939 | - function sendToApi (type, data) { |
2940 | - var callback = null; |
2941 | - var d = document.createElement ("textarea"); |
2942 | - var e = document.createEvent ("Events"); |
2943 | - d.style.cssText = "display:none;"; |
2944 | - |
2945 | - var isIterableObject = function(obj) { |
2946 | - if (obj === undefined || obj === null) { |
2947 | - return false; |
2948 | - } |
2949 | - var t = typeof(obj); |
2950 | - var types = {'string': 0, 'function': 0, 'boolean': 0, 'number': 0, 'undefined': 0}; |
2951 | - return types[t] === undefined; |
2952 | - }; |
2953 | - |
2954 | - function transformToIdIfNecessary(obj) { |
2955 | - var ret = obj; |
2956 | - if (obj instanceof Function) { |
2957 | - var id = callbackmanager.store(obj); |
2958 | - ret = {callbackid: id}; |
2959 | - } |
2960 | - return ret; |
2961 | - } |
2962 | - // map function callback (not serializable to a different world) |
2963 | - // to ids |
2964 | - function transformCallbacksToIds (obj) { |
2965 | - if ( ! isIterableObject(obj)) { |
2966 | - return transformToIdIfNecessary (obj); |
2967 | - } |
2968 | - var ret = (obj instanceof Array) ? [] : {}; |
2969 | - for (var key in obj) { |
2970 | - if (obj.hasOwnProperty(key)) { |
2971 | - if (obj[key] instanceof Function) { |
2972 | - var id = callbackmanager.store(obj[key]); |
2973 | - ret[key] = {callbackid: id}; |
2974 | - } |
2975 | - else if (isIterableObject (obj[key])) { |
2976 | - ret[key] = transformCallbacksToIds (obj[key]); |
2977 | - } |
2978 | - else { |
2979 | - ret[key] = obj[key]; |
2980 | - } |
2981 | - } |
2982 | - } |
2983 | - return ret; |
2984 | - }; |
2985 | - |
2986 | - // TODO: assumes some structure, does not play well w/ arrays |
2987 | - // actually converts: [1,2,3] -> {'0': 1, '1': 2, '2': 3} |
2988 | - d.value = JSON.stringify ( |
2989 | - data.map ( |
2990 | - function (datum) { |
2991 | - return transformCallbacksToIds (datum); |
2992 | - } |
2993 | - ) |
2994 | - ); |
2995 | - d.addEventListener ("unity-webapps-chromium-api-com-link-ack" |
2996 | - , |
2997 | - function() { |
2998 | - if (callback) callback (d.value); |
2999 | - d.parentNode.removeChild (d); |
3000 | - } |
3001 | - , true); |
3002 | - |
3003 | - d.setAttribute ("data-eventType", type); |
3004 | - document.body.appendChild (d); |
3005 | - e.initEvent ("unity-webapps-chromium-api-com-link", false, true); |
3006 | - d.dispatchEvent (e); |
3007 | - }; |
3008 | - |
3009 | - document.addEventListener ("unity-webapps-chromium-api-com-link-callback-called" |
3010 | - , |
3011 | - function(event) { |
3012 | - var from = event.target; |
3013 | - if (from) { |
3014 | - if (from.value) { |
3015 | - var callback = callbackmanager.get(from.value); |
3016 | - if (callback) { |
3017 | - callback (); |
3018 | - } |
3019 | - } |
3020 | - var ret = document.createEvent('Events'); |
3021 | - ret.initEvent('unity-webapps-chromium-api-com-link-callback-called-ack', true, false); |
3022 | - from.dispatchEvent(ret); |
3023 | - } |
3024 | - } |
3025 | - , true); |
3026 | - |
3027 | - var api = UnityWebappsApiPageProxyBuilder(sendToApi); |
3028 | - |
3029 | - function unity() { |
3030 | - } |
3031 | - unity.prototype = { |
3032 | - __proto__: window.external, |
3033 | - getUnityObject: function (version) { |
3034 | - console.log ('Proxy: getUnityObject called with version ' + version); |
3035 | - if (version === 1) |
3036 | - return api; |
3037 | - throw new Error("incorrect version"); |
3038 | - } |
3039 | - }; |
3040 | - window.external = new unity(); |
3041 | - |
3042 | - sendApiCreatedAcknowledge(); |
3043 | - } |
3044 | -, 0); |
3045 | |
3046 | === modified file 'chromium-extension/unity-webapps.json.in' |
3047 | --- chromium-extension/unity-webapps.json.in 2012-04-30 15:39:21 +0000 |
3048 | +++ chromium-extension/unity-webapps.json.in 2014-11-18 07:07:55 +0000 |
3049 | @@ -1,4 +1,4 @@ |
3050 | { |
3051 | - "external_crx": "@EXTDIR@", |
3052 | - "external_version": "@VERSION@" |
3053 | + '"external_crx": "$${EXTENSION_DIR}/$${EXTENSION_FILE}"', |
3054 | + '"external_version": "$${PROJECT_VERSION}"' |
3055 | } |
3056 | |
3057 | === removed file 'chromium-extension/unity_api_page_proxy_generator.py' |
3058 | --- chromium-extension/unity_api_page_proxy_generator.py 2012-06-17 14:33:16 +0000 |
3059 | +++ chromium-extension/unity_api_page_proxy_generator.py 1970-01-01 00:00:00 +0000 |
3060 | @@ -1,96 +0,0 @@ |
3061 | -#!/usr/bin/python |
3062 | - |
3063 | -""" |
3064 | -Generates a *.js file (defaults to unity-api-page-proxy-builder.js) by parsing & extracting expected |
3065 | -information out of an input .js filename (defaults to unity-api.js). Extracts only the meaningful bits |
3066 | -(mostly the argument sanitizer bits) and generates a proper web page side unity api w/ a proper validation |
3067 | -layer (as exposed by unity-api.js) |
3068 | - |
3069 | -Takes an input filename as an argument. |
3070 | -""" |
3071 | - |
3072 | -import sys |
3073 | - |
3074 | -class DEFAULTS: |
3075 | - input_api_filename = "unity-api.js" |
3076 | - output_api_filename = "unity-api-page-proxy-builder-gen-py.js" |
3077 | - |
3078 | -input_api_filename = DEFAULTS.input_api_filename |
3079 | -output_api_filename = DEFAULTS.output_api_filename |
3080 | - |
3081 | -def extractFunctionDefinition (name, content): |
3082 | - import re |
3083 | - funcre = re.compile (r'([^\w_]|\s*)(' + name + r')\s*\((?P<params>.*?)\)\s*{', re.MULTILINE) |
3084 | - m = re.search (funcre, content) |
3085 | - if m: |
3086 | - s = ['{'] |
3087 | - start = m.end(0) |
3088 | - end = start + 1 |
3089 | - for idx in xrange (start, len(content)-1): |
3090 | - if content[idx] == '{': |
3091 | - s.append('{') |
3092 | - elif content[idx] == '}': |
3093 | - s.pop() |
3094 | - if s.count('{') == 0: |
3095 | - end = idx |
3096 | - break |
3097 | - return m.group('params'), content[start:end] |
3098 | - return None, None |
3099 | - |
3100 | -def untabify (body): |
3101 | - mintabs = min([len([c for c in line if c == ' ' or c == '\t']) for line in body.split('\n') if len(line.strip()) != 0]) |
3102 | - return '\n'.join ([line[mintabs:] for line in body.split('\n')]) |
3103 | - |
3104 | -def generateFunction (name, params, body): |
3105 | - return """ |
3106 | -var %s = function (%s) { |
3107 | - %s |
3108 | -}; |
3109 | -""" % (name, params, untabify(body)) |
3110 | - |
3111 | -def extractObjectDefinition(content, oname): |
3112 | - import re |
3113 | - apire = re.compile(oname + '\s*[=|:]\s*', re.MULTILINE) |
3114 | - m = re.search(apire, content) |
3115 | - s = [] |
3116 | - start = m.end(0) |
3117 | - end = start |
3118 | - for idx in xrange (start, len(content)-1): |
3119 | - if content[idx] == '{': |
3120 | - s.append('{') |
3121 | - elif content[idx] == '}': |
3122 | - s.pop() |
3123 | - if s.count('{') == 0: |
3124 | - end = idx |
3125 | - break |
3126 | - return content[start:end] |
3127 | - |
3128 | -def extractApiDefinition(content): |
3129 | - return extractObjectDefinition(content, 'api') |
3130 | - |
3131 | -def generateUnityApiTargetFile (inputfilename, outputfilename): |
3132 | - content = open(inputfilename).read() |
3133 | - function_names = ['findName', 'stringify', 'stringifyArgs', 'createArgumentsSanitaizer'] |
3134 | - extracted_data = [(function_name, extractFunctionDefinition(function_name, content)) for function_name in function_names] |
3135 | - extracted_functions = [{'name': extracted_datum[0], 'params': extracted_datum[1][0], 'body': extracted_datum[1][1]} for extracted_datum in extracted_data] |
3136 | - |
3137 | - buildercontent = 'var UnityWebappsApiPageProxyBuilder = function(backend) {\n' |
3138 | - buildercontent += """ |
3139 | - var dummy = true; |
3140 | - var unity = { context: dummy, contextReady: dummy }; |
3141 | - var uwa = { ContextActionCallbackType: null }; |
3142 | - |
3143 | - var CallbackManager = { |
3144 | - makeCallback: function (dumd, func) { |
3145 | - return func; |
3146 | - } |
3147 | - }; |
3148 | -""" |
3149 | - buildercontent += '\n'.join([generateFunction(func['name'], func['params'], func['body']) for func in extracted_functions]) |
3150 | - buildercontent += 'var api = {\n};\n' |
3151 | - buildercontent += '};\n\n' |
3152 | - open(outputfilename, "w+").write(buildercontent) |
3153 | - |
3154 | -generateUnityApiTargetFile (input_api_filename, output_api_filename) |
3155 | - |
3156 | - |
3157 | |
3158 | === added file 'common-project-config.pri' |
3159 | --- common-project-config.pri 1970-01-01 00:00:00 +0000 |
3160 | +++ common-project-config.pri 2014-11-18 07:07:55 +0000 |
3161 | @@ -0,0 +1,41 @@ |
3162 | +#----------------------------------------------------------------------------- |
3163 | +# Common configuration for all projects. |
3164 | +#----------------------------------------------------------------------------- |
3165 | + |
3166 | +# we don't like warnings... |
3167 | +QMAKE_CXXFLAGS += -Werror |
3168 | +# Disable RTTI |
3169 | +QMAKE_CXXFLAGS += -fno-exceptions -fno-rtti |
3170 | + |
3171 | +TOP_SRC_DIR = $$PWD |
3172 | +TOP_BUILD_DIR = $${TOP_SRC_DIR}/$(BUILD_DIR) |
3173 | + |
3174 | +include(coverage.pri) |
3175 | + |
3176 | +#----------------------------------------------------------------------------- |
3177 | +# setup the installation prefix |
3178 | +#----------------------------------------------------------------------------- |
3179 | +INSTALL_PREFIX = /usr # default installation prefix |
3180 | + |
3181 | +# default prefix can be overriden by defining PREFIX when running qmake |
3182 | +isEmpty(PREFIX) { |
3183 | + message("====") |
3184 | + message("==== NOTE: To override the installation path run: `qmake PREFIX=/custom/path'") |
3185 | + message("==== (current installation path is `$${INSTALL_PREFIX}')") |
3186 | +} else { |
3187 | + INSTALL_PREFIX = $${PREFIX} |
3188 | + message("====") |
3189 | + message("==== install prefix set to `$${INSTALL_PREFIX}'") |
3190 | +} |
3191 | + |
3192 | +INSTALL_LIBDIR = $${INSTALL_PREFIX}/lib |
3193 | + |
3194 | +isEmpty(LIBDIR) { |
3195 | + message("====") |
3196 | + message("==== NOTE: To override the library installation path run: `qmake LIBDIR=/custom/path'") |
3197 | + message("==== (current installation path is `$${INSTALL_LIBDIR}')") |
3198 | +} else { |
3199 | + INSTALL_LIBDIR = $${LIBDIR} |
3200 | + message("====") |
3201 | + message("==== install prefix set to `$${INSTALL_LIBDIR}'") |
3202 | +} |
3203 | |
3204 | === added file 'common-vars.pri' |
3205 | --- common-vars.pri 1970-01-01 00:00:00 +0000 |
3206 | +++ common-vars.pri 2014-11-18 07:07:55 +0000 |
3207 | @@ -0,0 +1,6 @@ |
3208 | +#----------------------------------------------------------------------------- |
3209 | +# Common variables for all projects. |
3210 | +#----------------------------------------------------------------------------- |
3211 | + |
3212 | +PROJECT_NAME = unity_webapps_chromium |
3213 | +PROJECT_VERSION = 3.2 |
3214 | |
3215 | === removed file 'configure.ac' |
3216 | --- configure.ac 2014-03-07 15:22:55 +0000 |
3217 | +++ configure.ac 1970-01-01 00:00:00 +0000 |
3218 | @@ -1,62 +0,0 @@ |
3219 | -dnl Process this file with autoconf to produce a configure script. |
3220 | -dnl Created by Anjuta application wizard. |
3221 | - |
3222 | -AC_INIT(unity_webapps_chromium, 3.1) |
3223 | -AC_CONFIG_HEADERS([config.h]) |
3224 | -AM_INIT_AUTOMAKE([1.11]) |
3225 | -AM_SILENT_RULES([yes]) |
3226 | -AC_PROG_CC |
3227 | -AC_PROG_CC_C99 |
3228 | -AM_PROG_CC_C_O |
3229 | - |
3230 | -AC_CONFIG_MACRO_DIR([m4]) |
3231 | - |
3232 | -AC_DISABLE_STATIC |
3233 | -LT_INIT |
3234 | - |
3235 | -PKG_CHECK_MODULES(UNITY_NPAPI_PLUGIN, [libunity_webapps-0.2 glib-2.0 libnotify libunity-webapps-repository libwnck-1.0]) |
3236 | - |
3237 | - |
3238 | -dnl *************************************************************************** |
3239 | -dnl debug |
3240 | -dnl *************************************************************************** |
3241 | - |
3242 | -AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging. [default=no]]), [enable_debug="yes"],[enable_debug="no"]) |
3243 | - |
3244 | -if test "x$enable_debug" = "xyes"; then |
3245 | - NPAPI_DEBUG_CFLAGS="-DNPAPI_DEBUG_ENABLED" |
3246 | -else |
3247 | - NPAPI_DEBUG_CFLAGS="" |
3248 | -fi |
3249 | - |
3250 | -AC_SUBST(NPAPI_DEBUG_CFLAGS) |
3251 | - |
3252 | -dnl ========== Tests ========== |
3253 | - |
3254 | -AC_ARG_ENABLE(tests, AC_HELP_STRING([--enable-tests], |
3255 | - [Enable tests. [default=no]]), |
3256 | - [enable_tests="yes"], [enable_tests="no"]) |
3257 | -if test "x$enable_tests" = "xyes"; then |
3258 | - AC_DEFINE([ENABLE_TESTS], 1, [Enable tests.]) |
3259 | - # Tests need debug to be enabled |
3260 | - enable_debug="yes" |
3261 | -fi |
3262 | -AM_CONDITIONAL([ENABLE_TESTS], [test "x$enable_tests" = "xyes"]) |
3263 | - |
3264 | -dnl ===== gcov coverage reporting ===== |
3265 | -m4_include([m4/gcov.m4]) |
3266 | -AC_TDD_GCOV |
3267 | -AC_SUBST(UNITY_NPAPI_PLUGIN_COVERAGE_CFLAGS) |
3268 | -AC_SUBST(UNITY_NPAPI_PLUGIN_COVERAGE_CXXFLAGS) |
3269 | -AC_SUBST(UNITY_NPAPI_PLUGIN_COVERAGE_LDFLAGS) |
3270 | - |
3271 | -AC_OUTPUT([ |
3272 | -Makefile |
3273 | -chromium-extension/Makefile |
3274 | -npapi-plugin/src/libunity_npapi_plugin-0.1.pc |
3275 | -npapi-plugin/Makefile |
3276 | -npapi-plugin/src/Makefile |
3277 | -tests/Makefile |
3278 | -tests/unit/Makefile |
3279 | -tests/unit/npapi/Makefile |
3280 | -po/Makefile]) |
3281 | |
3282 | === added file 'coverage.pri' |
3283 | --- coverage.pri 1970-01-01 00:00:00 +0000 |
3284 | +++ coverage.pri 2014-11-18 07:07:55 +0000 |
3285 | @@ -0,0 +1,49 @@ |
3286 | +# Coverage |
3287 | +CONFIG(coverage) { |
3288 | + OBJECTS_DIR = |
3289 | + MOC_DIR = |
3290 | + TOP_SRC_DIR = $$PWD |
3291 | + |
3292 | + LIBS += -lgcov |
3293 | + QMAKE_CXXFLAGS += --coverage |
3294 | + QMAKE_LDFLAGS += --coverage |
3295 | + |
3296 | + QMAKE_EXTRA_TARGETS += coverage cov |
3297 | + QMAKE_EXTRA_TARGETS += clean-gcno clean-gcda coverage-html \ |
3298 | + generate-coverage-html clean-coverage-html coverage-gcovr \ |
3299 | + generate-gcovr generate-coverage-gcovr clean-coverage-gcovr |
3300 | + |
3301 | + clean-gcno.commands = \ |
3302 | + "@echo Removing old coverage instrumentation"; \ |
3303 | + "find -name '*.gcno' -print | xargs -r rm" |
3304 | + |
3305 | + clean-gcda.commands = \ |
3306 | + "@echo Removing old coverage results"; \ |
3307 | + "find -name '*.gcda' -print | xargs -r rm" |
3308 | + |
3309 | + coverage-html.depends = clean-gcda check generate-coverage-html |
3310 | + |
3311 | + generate-coverage-html.commands = \ |
3312 | + "@echo Collecting coverage data"; \ |
3313 | + "lcov --directory $${TOP_SRC_DIR} --capture --output-file coverage.info --no-checksum --compat-libtool"; \ |
3314 | + "lcov --extract coverage.info \"*/messaging-host/*.cpp\" -o coverage.info"; \ |
3315 | + "lcov --remove coverage.info \"moc_*.cpp\" --remove coverage.info \"tests/*.cpp\" -o coverage.info"; \ |
3316 | + "LANG=C genhtml --prefix $${TOP_SRC_DIR} --output-directory coverage-html --title \"Code Coverage\" --legend --show-details coverage.info" |
3317 | + |
3318 | + clean-coverage-html.depends = clean-gcda |
3319 | + clean-coverage-html.commands = \ |
3320 | + "lcov --directory $${TOP_SRC_DIR} -z"; \ |
3321 | + "rm -rf coverage.info coverage-html" |
3322 | + |
3323 | + coverage-gcovr.depends = clean-gcda check generate-coverage-gcovr |
3324 | + |
3325 | + generate-coverage-gcovr.commands = \ |
3326 | + "@echo Generating coverage GCOVR report"; \ |
3327 | + "gcovr -x -r $${TOP_SRC_DIR} -o $${TOP_SRC_DIR}/coverage.xml -e \".*/moc_.*\" -e \"tests/.*\" -e \".*\\.h\"" |
3328 | + |
3329 | + clean-coverage-gcovr.depends = clean-gcda |
3330 | + clean-coverage-gcovr.commands = \ |
3331 | + "rm -rf $${TOP_SRC_DIR}/coverage.xml" |
3332 | + |
3333 | + QMAKE_CLEAN += *.gcda *.gcno coverage.info coverage.xml |
3334 | +} |
3335 | |
3336 | === modified file 'debian/changelog' |
3337 | --- debian/changelog 2014-03-18 20:59:35 +0000 |
3338 | +++ debian/changelog 2014-11-18 07:07:55 +0000 |
3339 | @@ -1,3 +1,9 @@ |
3340 | +unity-chromium-extension (3.2.0+14.04.20140318-0ubuntu3) UNRELEASED; urgency=medium |
3341 | + |
3342 | + * Support native messaging. (with Alberto Mardegan) |
3343 | + |
3344 | + -- Justin McPherson <justin.mcpherson@canonical.com> Fri, 23 May 2014 20:31:14 +1000 |
3345 | + |
3346 | unity-chromium-extension (3.0.0+14.04.20140318-0ubuntu1) trusty; urgency=low |
3347 | |
3348 | [ Ubuntu daily release ] |
3349 | |
3350 | === modified file 'debian/compat' |
3351 | --- debian/compat 2012-11-19 22:39:34 +0000 |
3352 | +++ debian/compat 2014-11-18 07:07:55 +0000 |
3353 | @@ -1,1 +1,1 @@ |
3354 | -8 |
3355 | +9 |
3356 | |
3357 | === modified file 'debian/control' |
3358 | --- debian/control 2014-03-18 20:50:57 +0000 |
3359 | +++ debian/control 2014-11-18 07:07:55 +0000 |
3360 | @@ -1,22 +1,18 @@ |
3361 | Source: unity-chromium-extension |
3362 | Priority: optional |
3363 | Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com> |
3364 | -# FIXME: We should be using debhelper 9, but that breaks the build |
3365 | -# for some currently unknown reason. |
3366 | -Build-Depends: autotools-dev, |
3367 | - chromium-browser (>= 20.0.1132.47~r144678-0ubuntu4), |
3368 | - debhelper (>= 8), |
3369 | +Build-Depends: chromium-browser (>= 34.0.1847.116-0ubuntu2), |
3370 | + debhelper (>= 9), |
3371 | dh-autoreconf, |
3372 | - gnome-common, |
3373 | libglib2.0-dev, |
3374 | - libgtest-dev, |
3375 | - libnotify-dev, |
3376 | libunity-webapps-dev (>= 1.8.0), |
3377 | - libwnck-dev, |
3378 | openssl, |
3379 | pkg-config, |
3380 | vim-common, |
3381 | zip, |
3382 | + qt5-default, |
3383 | + qt5-qmake, |
3384 | + xvfb, |
3385 | Standards-Version: 3.9.5 |
3386 | Section: gnome |
3387 | Homepage: https://launchpad.net/unity-chromium-extension |
3388 | @@ -27,7 +23,7 @@ |
3389 | |
3390 | Package: unity-chromium-extension |
3391 | Architecture: any |
3392 | -Depends: chromium-browser (>= 20.0.1132.47~r144678-0ubuntu4), |
3393 | +Depends: chromium-browser (>= 34.0.1847.116-0ubuntu2), |
3394 | unity-webapps-service, |
3395 | webbrowser-app, |
3396 | ${misc:Depends}, |
3397 | |
3398 | === modified file 'debian/copyright' |
3399 | --- debian/copyright 2012-11-19 19:26:58 +0000 |
3400 | +++ debian/copyright 2014-11-18 07:07:55 +0000 |
3401 | @@ -8,48 +8,3 @@ |
3402 | On Debian systems, the complete text of the GNU General |
3403 | Public License version 3 can be found in `/usr/share/common-licenses/GPL-3'. |
3404 | |
3405 | -Files: npapi-plugin/* |
3406 | -Copyright: 2012 Canonical Ltd |
3407 | -License: GPL-2+ |
3408 | - |
3409 | -Files: npapi-plugin/src/npapi-headers/headers/nptypes.h |
3410 | -Copyright: 2004 mozilla.org |
3411 | -License: GPL-2+ |
3412 | - |
3413 | -Files: npapi-plugin/src/npapi-headers/headers/npapi.h |
3414 | - npapi-plugin/src/npapi-headers/headers/npfunctions.h |
3415 | -Copyright: 1998 Netscape Communications Corporation |
3416 | -License: GPL-2+ |
3417 | - |
3418 | -Files: npapi-plugin/src/npapi-headers/headers/npruntime.h |
3419 | -Copyright: 2004 Apple Computer, Inc. |
3420 | -License: |
3421 | - Redistribution and use in source and binary forms, with or without |
3422 | - modification, are permitted provided that the following conditions are |
3423 | - met: |
3424 | - . |
3425 | - 1. Redistributions of source code must retain the above copyright |
3426 | - notice, this list of conditions and the following disclaimer. |
3427 | - 2. Redistributions in binary form must reproduce the above copyright |
3428 | - notice, this list of conditions and the following disclaimer in the |
3429 | - documentation and/or other materials provided with the distribution. |
3430 | - 3. Neither the names of Apple Computer, Inc. ("Apple") or The Mozilla |
3431 | - Foundation ("Mozilla") nor the names of their contributors may be used |
3432 | - to endorse or promote products derived from this software without |
3433 | - specific prior written permission. |
3434 | - . |
3435 | - THIS SOFTWARE IS PROVIDED BY APPLE, MOZILLA AND THEIR CONTRIBUTORS "AS |
3436 | - IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
3437 | - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
3438 | - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, MOZILLA OR |
3439 | - THEIR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
3440 | - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
3441 | - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
3442 | - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
3443 | - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
3444 | - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
3445 | - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
3446 | - |
3447 | -License: GPL-2+ |
3448 | - On Debian systems, the complete text of the GNU General |
3449 | - Public License version 2 can be found in `/usr/share/common-licenses/GPL-2'. |
3450 | |
3451 | === modified file 'debian/rules' |
3452 | --- debian/rules 2013-09-20 19:12:01 +0000 |
3453 | +++ debian/rules 2014-11-18 07:07:55 +0000 |
3454 | @@ -4,17 +4,15 @@ |
3455 | #export DH_VERBOSE=1 |
3456 | export DPKG_GENSYMBOLS_CHECK_LEVEL=4 |
3457 | |
3458 | -override_dh_autoreconf: |
3459 | - NOCONFIGURE=1 dh_autoreconf ./autogen.sh |
3460 | - |
3461 | override_dh_auto_configure: |
3462 | - cp debian/unity-webapps.pem . |
3463 | - dh_auto_configure -- --enable-tests=yes |
3464 | + cp debian/unity-webapps.pem chromium-extension/ |
3465 | + dh_auto_configure |
3466 | + |
3467 | +override_dh_auto_install: |
3468 | + dh_auto_install --destdir=debian/tmp |
3469 | |
3470 | override_dh_install: |
3471 | - rm -rf debian/*/usr/lib/*npapi* debian/*/usr/lib/pkgconfig \ |
3472 | - debian/*/usr/include |
3473 | dh_install --fail-missing |
3474 | |
3475 | %: |
3476 | - dh $@ --with autoreconf --fail-missing |
3477 | + dh $@ |
3478 | |
3479 | === added file 'debian/unity-chromium-extension.install' |
3480 | --- debian/unity-chromium-extension.install 1970-01-01 00:00:00 +0000 |
3481 | +++ debian/unity-chromium-extension.install 2014-11-18 07:07:55 +0000 |
3482 | @@ -0,0 +1,4 @@ |
3483 | +etc/chromium/native-messaging-hosts/com.canonical.webapp.installer.json |
3484 | +usr/lib/libunity-chromium/unity-webapps.crx |
3485 | +usr/share/chromium/extensions/*.json |
3486 | +usr/share/unity-webapps/bin/unity-webapps-messaging-host |
3487 | |
3488 | === removed directory 'm4' |
3489 | === removed file 'm4/gcov.m4' |
3490 | --- m4/gcov.m4 2013-12-23 01:17:40 +0000 |
3491 | +++ m4/gcov.m4 1970-01-01 00:00:00 +0000 |
3492 | @@ -1,79 +0,0 @@ |
3493 | -# Checks for existence of coverage tools: |
3494 | -# * gcov |
3495 | -# * lcov |
3496 | -# * genhtml |
3497 | -# * gcovr |
3498 | -# |
3499 | -# Sets ac_cv_check_gcov to yes if tooling is present |
3500 | -# and reports the executables to the variables LCOV, GCOVR and GENHTML. |
3501 | -AC_DEFUN([AC_TDD_GCOV], |
3502 | -[ |
3503 | - AC_ARG_ENABLE(gcov, |
3504 | - AS_HELP_STRING([--enable-gcov], |
3505 | - [enable coverage testing with gcov]), |
3506 | - [use_gcov=yes], [use_gcov=no]) |
3507 | - |
3508 | - AM_CONDITIONAL(HAVE_GCOV, test "x$use_gcov" = "xyes") |
3509 | - |
3510 | - if test "x$use_gcov" = "xyes"; then |
3511 | - # we need gcc: |
3512 | - if test "$GCC" != "yes"; then |
3513 | - AC_MSG_ERROR([GCC is required for --enable-gcov]) |
3514 | - fi |
3515 | - |
3516 | - # Check if ccache is being used |
3517 | - AC_CHECK_PROG(SHTOOL, shtool, shtool) |
3518 | - if test "$SHTOOL"; then |
3519 | - AS_CASE([`$SHTOOL path $CC`], |
3520 | - [*ccache*], [gcc_ccache=yes], |
3521 | - [gcc_ccache=no]) |
3522 | - fi |
3523 | - |
3524 | - if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then |
3525 | - AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) |
3526 | - fi |
3527 | - |
3528 | - lcov_version_list="1.6 1.7 1.8 1.9 1.10" |
3529 | - AC_CHECK_PROG(LCOV, lcov, lcov) |
3530 | - AC_CHECK_PROG(GENHTML, genhtml, genhtml) |
3531 | - |
3532 | - if test "$LCOV"; then |
3533 | - AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ |
3534 | - glib_cv_lcov_version=invalid |
3535 | - lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` |
3536 | - for lcov_check_version in $lcov_version_list; do |
3537 | - if test "$lcov_version" = "$lcov_check_version"; then |
3538 | - glib_cv_lcov_version="$lcov_check_version (ok)" |
3539 | - fi |
3540 | - done |
3541 | - ]) |
3542 | - else |
3543 | - lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list" |
3544 | - AC_MSG_ERROR([$lcov_msg]) |
3545 | - fi |
3546 | - |
3547 | - case $glib_cv_lcov_version in |
3548 | - ""|invalid[)] |
3549 | - lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)." |
3550 | - AC_MSG_ERROR([$lcov_msg]) |
3551 | - LCOV="exit 0;" |
3552 | - ;; |
3553 | - esac |
3554 | - |
3555 | - if test -z "$GENHTML"; then |
3556 | - AC_MSG_ERROR([Could not find genhtml from the lcov package]) |
3557 | - fi |
3558 | - |
3559 | - # Remove all optimization flags from CFLAGS |
3560 | - changequote({,}) |
3561 | - CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'` |
3562 | - changequote([,]) |
3563 | - |
3564 | - # Add the special gcc flags |
3565 | - UNITY_NPAPI_PLUGIN_COVERAGE_CFLAGS="--coverage" |
3566 | - UNITY_NPAPI_PLUGIN_COVERAGE_CXXFLAGS="--coverage" |
3567 | - UNITY_NPAPI_PLUGIN_COVERAGE_LDFLAGS="-lgcov" |
3568 | - |
3569 | -fi |
3570 | -]) # AC_TDD_GCOV |
3571 | - |
3572 | |
3573 | === added directory 'messaging-host' |
3574 | === added file 'messaging-host/Makefile.am' |
3575 | --- messaging-host/Makefile.am 1970-01-01 00:00:00 +0000 |
3576 | +++ messaging-host/Makefile.am 2014-11-18 07:07:55 +0000 |
3577 | @@ -0,0 +1,2 @@ |
3578 | +EXTRA_DIST += \ |
3579 | + installation-host |
3580 | |
3581 | === added file 'messaging-host/com.canonical.webapp.installer.json.in' |
3582 | --- messaging-host/com.canonical.webapp.installer.json.in 1970-01-01 00:00:00 +0000 |
3583 | +++ messaging-host/com.canonical.webapp.installer.json.in 2014-11-18 07:07:55 +0000 |
3584 | @@ -0,0 +1,9 @@ |
3585 | +{ |
3586 | + '"name": "com.canonical.webapp.installer"', |
3587 | + '"description": "Canonical WebApp Installation Host"', |
3588 | + '"path": "$${target.path}/$${TARGET}"', |
3589 | + '"type": "stdio"', |
3590 | + '"allowed_origins"': [ |
3591 | + '"chrome-extension://pmoflmbbcfgacopiikdcpmbiellfihdg/"' |
3592 | + ] |
3593 | +} |
3594 | |
3595 | === added file 'messaging-host/connection.cpp' |
3596 | --- messaging-host/connection.cpp 1970-01-01 00:00:00 +0000 |
3597 | +++ messaging-host/connection.cpp 2014-11-18 07:07:55 +0000 |
3598 | @@ -0,0 +1,152 @@ |
3599 | +/* |
3600 | + * Copyright (C) 2014 Canonical Ltd. |
3601 | + * |
3602 | + * This file is part of unity-chromium-extension |
3603 | + * |
3604 | + * This program is free software: you can redistribute it and/or modify it |
3605 | + * under the terms of the GNU General Public License version 3, as published |
3606 | + * by the Free Software Foundation. |
3607 | + * |
3608 | + * This program is distributed in the hope that it will be useful, but |
3609 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
3610 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
3611 | + * PURPOSE. See the GNU General Public License for more details. |
3612 | + * |
3613 | + * You should have received a copy of the GNU General Public License along |
3614 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
3615 | + */ |
3616 | + |
3617 | +#include "connection.h" |
3618 | + |
3619 | +#include <QByteArray> |
3620 | +#include <QDebug> |
3621 | +#include <QFile> |
3622 | +#include <QJsonDocument> |
3623 | +#include <QSocketNotifier> |
3624 | +#include <fcntl.h> |
3625 | +#include <stdio.h> |
3626 | +#include <unistd.h> |
3627 | + |
3628 | +using namespace UnityWebapps; |
3629 | + |
3630 | +namespace UnityWebapps { |
3631 | + |
3632 | +class ConnectionPrivate: public QObject |
3633 | +{ |
3634 | + Q_OBJECT |
3635 | + Q_DECLARE_PUBLIC(Connection) |
3636 | + |
3637 | +public: |
3638 | + inline ConnectionPrivate(Connection *connection); |
3639 | + inline ~ConnectionPrivate(); |
3640 | + |
3641 | + bool open(); |
3642 | + |
3643 | +private Q_SLOTS: |
3644 | + void onReadyRead(); |
3645 | + |
3646 | +private: |
3647 | + QFile m_readChannel; |
3648 | + QFile m_writeChannel; |
3649 | + QByteArray m_readBuffer; |
3650 | + int m_expectedLength; |
3651 | + mutable Connection *q_ptr; |
3652 | +}; |
3653 | + |
3654 | +} // namespace |
3655 | + |
3656 | +ConnectionPrivate::ConnectionPrivate(Connection *connection): |
3657 | + QObject(connection), |
3658 | + m_expectedLength(0), |
3659 | + q_ptr(connection) |
3660 | +{ |
3661 | +} |
3662 | + |
3663 | +ConnectionPrivate::~ConnectionPrivate() |
3664 | +{ |
3665 | +} |
3666 | + |
3667 | +bool ConnectionPrivate::open() |
3668 | +{ |
3669 | + bool ok; |
3670 | + |
3671 | + int flag = fcntl(STDIN_FILENO, F_GETFL); |
3672 | + if (Q_UNLIKELY(flag == -1)) return false; |
3673 | + |
3674 | + fcntl(STDIN_FILENO, F_SETFL, flag | O_NONBLOCK); |
3675 | + |
3676 | + ok = m_readChannel.open(stdin, QIODevice::ReadOnly); |
3677 | + if (Q_UNLIKELY(!ok)) return false; |
3678 | + |
3679 | + ok = m_writeChannel.open(stdout, QIODevice::WriteOnly); |
3680 | + if (Q_UNLIKELY(!ok)) return false; |
3681 | + |
3682 | + QSocketNotifier *notifier = new QSocketNotifier(m_readChannel.handle(), |
3683 | + QSocketNotifier::Read, |
3684 | + this); |
3685 | + QObject::connect(notifier, SIGNAL(activated(int)), |
3686 | + this, SLOT(onReadyRead())); |
3687 | + |
3688 | + // There might be already something to read |
3689 | + onReadyRead(); |
3690 | + |
3691 | + return true; |
3692 | +} |
3693 | + |
3694 | +void ConnectionPrivate::onReadyRead() |
3695 | +{ |
3696 | + Q_Q(Connection); |
3697 | + |
3698 | + while (true) { |
3699 | + if (m_expectedLength == 0) { |
3700 | + /* We are beginning a new read */ |
3701 | + |
3702 | + quint32 length; |
3703 | + int bytesRead = m_readChannel.read((char *)&length, |
3704 | + sizeof(length)); |
3705 | + if (bytesRead < int(sizeof(length))) break; |
3706 | + m_expectedLength = length; |
3707 | + m_readBuffer.clear(); |
3708 | + } |
3709 | + |
3710 | + int neededBytes = m_expectedLength - m_readBuffer.length(); |
3711 | + QByteArray buffer = m_readChannel.read(neededBytes); |
3712 | + m_readBuffer += buffer; |
3713 | + if (buffer.length() < neededBytes) break; |
3714 | + if (m_readBuffer.length() == m_expectedLength) { |
3715 | + QJsonDocument doc = QJsonDocument::fromJson(m_readBuffer); |
3716 | + Q_EMIT q->messageReceived(doc.toVariant().toMap()); |
3717 | + m_expectedLength = 0; |
3718 | + } |
3719 | + } |
3720 | +} |
3721 | + |
3722 | +Connection::Connection(QObject *parent): |
3723 | + QObject(parent), |
3724 | + d_ptr(new ConnectionPrivate(this)) |
3725 | +{ |
3726 | +} |
3727 | + |
3728 | +Connection::~Connection() |
3729 | +{ |
3730 | +} |
3731 | + |
3732 | +bool Connection::open() |
3733 | +{ |
3734 | + Q_D(Connection); |
3735 | + return d->open(); |
3736 | +} |
3737 | + |
3738 | +void Connection::postMessage(const QVariantMap &message) |
3739 | +{ |
3740 | + Q_D(Connection); |
3741 | + |
3742 | + QJsonDocument doc = QJsonDocument::fromVariant(message); |
3743 | + QByteArray json = doc.toJson(); |
3744 | + quint32 length = json.length(); |
3745 | + d->m_writeChannel.write((char *)&length, sizeof(length)); |
3746 | + d->m_writeChannel.write(json); |
3747 | + d->m_writeChannel.flush(); |
3748 | +} |
3749 | + |
3750 | +#include "connection.moc" |
3751 | |
3752 | === added file 'messaging-host/connection.h' |
3753 | --- messaging-host/connection.h 1970-01-01 00:00:00 +0000 |
3754 | +++ messaging-host/connection.h 2014-11-18 07:07:55 +0000 |
3755 | @@ -0,0 +1,52 @@ |
3756 | +/* |
3757 | + * Copyright (C) 2014 Canonical Ltd. |
3758 | + * |
3759 | + * This file is part of unity-chromium-extension |
3760 | + * |
3761 | + * This program is free software: you can redistribute it and/or modify it |
3762 | + * under the terms of the GNU General Public License version 3, as published |
3763 | + * by the Free Software Foundation. |
3764 | + * |
3765 | + * This program is distributed in the hope that it will be useful, but |
3766 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
3767 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
3768 | + * PURPOSE. See the GNU General Public License for more details. |
3769 | + * |
3770 | + * You should have received a copy of the GNU General Public License along |
3771 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
3772 | + */ |
3773 | + |
3774 | +#ifndef UNITY_WEBAPPS_CONNECTION |
3775 | +#define UNITY_WEBAPPS_CONNECTION |
3776 | + |
3777 | +#include <QObject> |
3778 | +#include <QVariantMap> |
3779 | + |
3780 | +namespace UnityWebapps { |
3781 | + |
3782 | +class ConnectionPrivate; |
3783 | + |
3784 | +class Connection: public QObject |
3785 | +{ |
3786 | + Q_OBJECT |
3787 | + |
3788 | +public: |
3789 | + explicit Connection(QObject *parent = 0); |
3790 | + ~Connection(); |
3791 | + |
3792 | + bool open(); |
3793 | + |
3794 | +public Q_SLOTS: |
3795 | + void postMessage(const QVariantMap &message); |
3796 | + |
3797 | +Q_SIGNALS: |
3798 | + void messageReceived(const QVariantMap &message); |
3799 | + |
3800 | +private: |
3801 | + ConnectionPrivate *d_ptr; |
3802 | + Q_DECLARE_PRIVATE(Connection) |
3803 | +}; |
3804 | + |
3805 | +} // namespace |
3806 | + |
3807 | +#endif // UNITY_WEBAPPS_CONNECTION |
3808 | |
3809 | === added file 'messaging-host/inactivity-timer.cpp' |
3810 | --- messaging-host/inactivity-timer.cpp 1970-01-01 00:00:00 +0000 |
3811 | +++ messaging-host/inactivity-timer.cpp 2014-11-18 07:07:55 +0000 |
3812 | @@ -0,0 +1,65 @@ |
3813 | +/* |
3814 | + * Copyright (C) 2014 Canonical Ltd. |
3815 | + * |
3816 | + * This file is part of unity-chromium-extension |
3817 | + * |
3818 | + * This program is free software: you can redistribute it and/or modify it |
3819 | + * under the terms of the GNU General Public License version 3, as published |
3820 | + * by the Free Software Foundation. |
3821 | + * |
3822 | + * This program is distributed in the hope that it will be useful, but |
3823 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
3824 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
3825 | + * PURPOSE. See the GNU General Public License for more details. |
3826 | + * |
3827 | + * You should have received a copy of the GNU General Public License along |
3828 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
3829 | + */ |
3830 | + |
3831 | +#include "inactivity-timer.h" |
3832 | + |
3833 | +#include <QVariant> |
3834 | + |
3835 | +using namespace UnityWebapps; |
3836 | + |
3837 | +InactivityTimer::InactivityTimer(int interval, QObject *parent): |
3838 | + QObject(parent), |
3839 | + m_interval(interval) |
3840 | +{ |
3841 | + m_timer.setSingleShot(true); |
3842 | + QObject::connect(&m_timer, SIGNAL(timeout()), |
3843 | + this, SLOT(onTimeout())); |
3844 | +} |
3845 | + |
3846 | +void InactivityTimer::watchObject(QObject *object) |
3847 | +{ |
3848 | + connect(object, SIGNAL(isIdleChanged()), SLOT(onIdleChanged())); |
3849 | + m_watchedObjects.append(object); |
3850 | + |
3851 | + /* Force an initial check */ |
3852 | + onIdleChanged(); |
3853 | +} |
3854 | + |
3855 | +void InactivityTimer::onIdleChanged() |
3856 | +{ |
3857 | + if (allObjectsAreIdle()) { |
3858 | + m_timer.start(m_interval); |
3859 | + } |
3860 | +} |
3861 | + |
3862 | +void InactivityTimer::onTimeout() |
3863 | +{ |
3864 | + if (allObjectsAreIdle()) { |
3865 | + Q_EMIT timeout(); |
3866 | + } |
3867 | +} |
3868 | + |
3869 | +bool InactivityTimer::allObjectsAreIdle() const |
3870 | +{ |
3871 | + foreach (const QObject *object, m_watchedObjects) { |
3872 | + if (!object->property("isIdle").toBool()) { |
3873 | + return false; |
3874 | + } |
3875 | + } |
3876 | + return true; |
3877 | +} |
3878 | |
3879 | === added file 'messaging-host/inactivity-timer.h' |
3880 | --- messaging-host/inactivity-timer.h 1970-01-01 00:00:00 +0000 |
3881 | +++ messaging-host/inactivity-timer.h 2014-11-18 07:07:55 +0000 |
3882 | @@ -0,0 +1,56 @@ |
3883 | +/* |
3884 | + * Copyright (C) 2014 Canonical Ltd. |
3885 | + * |
3886 | + * This file is part of unity-chromium-extension |
3887 | + * |
3888 | + * This program is free software: you can redistribute it and/or modify it |
3889 | + * under the terms of the GNU General Public License version 3, as published |
3890 | + * by the Free Software Foundation. |
3891 | + * |
3892 | + * This program is distributed in the hope that it will be useful, but |
3893 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
3894 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
3895 | + * PURPOSE. See the GNU General Public License for more details. |
3896 | + * |
3897 | + * You should have received a copy of the GNU General Public License along |
3898 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
3899 | + */ |
3900 | + |
3901 | +#ifndef UNITY_WEBAPPS_INACTIVITY_TIMER_H |
3902 | +#define UNITY_WEBAPPS_INACTIVITY_TIMER_H |
3903 | + |
3904 | +#include <QList> |
3905 | +#include <QObject> |
3906 | +#include <QTimer> |
3907 | + |
3908 | +namespace UnityWebapps { |
3909 | + |
3910 | +class InactivityTimer: public QObject |
3911 | +{ |
3912 | + Q_OBJECT |
3913 | + |
3914 | +public: |
3915 | + InactivityTimer(int interval, QObject *parent = 0); |
3916 | + ~InactivityTimer() {} |
3917 | + |
3918 | + void watchObject(QObject *object); |
3919 | + |
3920 | +Q_SIGNALS: |
3921 | + void timeout(); |
3922 | + |
3923 | +private Q_SLOTS: |
3924 | + void onIdleChanged(); |
3925 | + void onTimeout(); |
3926 | + |
3927 | +private: |
3928 | + bool allObjectsAreIdle() const; |
3929 | + |
3930 | +private: |
3931 | + QList<QObject*> m_watchedObjects; |
3932 | + QTimer m_timer; |
3933 | + int m_interval; |
3934 | +}; |
3935 | + |
3936 | +} // namespace |
3937 | + |
3938 | +#endif // UNITY_WEBAPPS_INACTIVITY_TIMER_H |
3939 | |
3940 | === added file 'messaging-host/main.cpp' |
3941 | --- messaging-host/main.cpp 1970-01-01 00:00:00 +0000 |
3942 | +++ messaging-host/main.cpp 2014-11-18 07:07:55 +0000 |
3943 | @@ -0,0 +1,91 @@ |
3944 | +/* |
3945 | + * Copyright (C) 2014 Canonical Ltd. |
3946 | + * |
3947 | + * This file is part of unity-chromium-extension |
3948 | + * |
3949 | + * This program is free software: you can redistribute it and/or modify it |
3950 | + * under the terms of the GNU General Public License version 3, as published |
3951 | + * by the Free Software Foundation. |
3952 | + * |
3953 | + * This program is distributed in the hope that it will be useful, but |
3954 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
3955 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
3956 | + * PURPOSE. See the GNU General Public License for more details. |
3957 | + * |
3958 | + * You should have received a copy of the GNU General Public License along |
3959 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
3960 | + */ |
3961 | + |
3962 | +#include <syslog.h> |
3963 | + |
3964 | +#include "connection.h" |
3965 | +#include "inactivity-timer.h" |
3966 | +#include "service.h" |
3967 | +#include "webapps-handler.h" |
3968 | +#include "webapps-process.h" |
3969 | + |
3970 | +#include <QCoreApplication> |
3971 | +#include <QDebug> |
3972 | + |
3973 | + |
3974 | +void syslogOutputHandler(QtMsgType type, const QMessageLogContext &, const QString &msg) |
3975 | +{ |
3976 | + QByteArray localMsg = msg.toLocal8Bit(); |
3977 | + int syslog_type = LOG_USER; |
3978 | + switch (type) { |
3979 | + case QtDebugMsg: |
3980 | + syslog_type |= LOG_DEBUG; |
3981 | + break; |
3982 | + case QtWarningMsg: |
3983 | + syslog_type |= LOG_WARNING; |
3984 | + break; |
3985 | + case QtCriticalMsg: |
3986 | + syslog_type |= LOG_CRIT; |
3987 | + break; |
3988 | + case QtFatalMsg: |
3989 | + syslog_type |= LOG_ERR; |
3990 | + break; |
3991 | + } |
3992 | + |
3993 | + syslog(syslog_type, "%s", localMsg.constData()); |
3994 | +} |
3995 | + |
3996 | + |
3997 | +int main(int argc, char **argv) |
3998 | +{ |
3999 | + if (qgetenv("UNITY_WEBAPPS_LOGGING") == QByteArrayLiteral("1")) { |
4000 | + qInstallMessageHandler(syslogOutputHandler); |
4001 | + } |
4002 | + |
4003 | + qDebug() << "Starting"; |
4004 | + |
4005 | + QCoreApplication app(argc, argv); |
4006 | + |
4007 | + UnityWebapps::Process process; |
4008 | + |
4009 | + UnityWebapps::Service service; |
4010 | + UnityWebapps::WebappsHandler handler; |
4011 | + service.addHandler(&handler); |
4012 | + |
4013 | + UnityWebapps::InactivityTimer inactivityTimer(2 * 60 * 1000); |
4014 | + QObject::connect(&inactivityTimer, SIGNAL(timeout()), &app, SLOT(quit())); |
4015 | + inactivityTimer.watchObject(&service); |
4016 | + |
4017 | + UnityWebapps::Connection connection; |
4018 | + QObject::connect(&connection, SIGNAL(messageReceived(const QVariantMap &)), |
4019 | + &service, SLOT(handleMessage(const QVariantMap &))); |
4020 | + QObject::connect(&service, SIGNAL(messageHandled(const QVariantMap &)), |
4021 | + &connection, SLOT(postMessage(const QVariantMap &))); |
4022 | + bool ok = connection.open(); |
4023 | + if (Q_UNLIKELY(!ok)) { |
4024 | + qCritical() << "Couldn't open connection"; |
4025 | + return EXIT_FAILURE; |
4026 | + } |
4027 | + |
4028 | + int r = app.exec(); |
4029 | + |
4030 | + qDebug() << "Finishing"; |
4031 | + |
4032 | + return r; |
4033 | +} |
4034 | + |
4035 | |
4036 | === added file 'messaging-host/messaging-host.pro' |
4037 | --- messaging-host/messaging-host.pro 1970-01-01 00:00:00 +0000 |
4038 | +++ messaging-host/messaging-host.pro 2014-11-18 07:07:55 +0000 |
4039 | @@ -0,0 +1,42 @@ |
4040 | +include(../common-project-config.pri) |
4041 | + |
4042 | +TEMPLATE = app |
4043 | +TARGET = unity-webapps-messaging-host |
4044 | + |
4045 | +CONFIG += \ |
4046 | + link_pkgconfig \ |
4047 | + qt |
4048 | + |
4049 | +QT += \ |
4050 | + core |
4051 | + |
4052 | +PKGCONFIG += \ |
4053 | + glib-2.0 \ |
4054 | + gobject-2.0 \ |
4055 | + libunity_webapps-0.2 \ |
4056 | + libunity-webapps-repository \ |
4057 | + |
4058 | +SOURCES = \ |
4059 | + connection.cpp \ |
4060 | + inactivity-timer.cpp \ |
4061 | + main.cpp \ |
4062 | + service.cpp \ |
4063 | + webapps-handler.cpp \ |
4064 | + webapps-process.cpp \ |
4065 | + |
4066 | +HEADERS = \ |
4067 | + connection.h \ |
4068 | + inactivity-timer.h \ |
4069 | + service.h \ |
4070 | + webapps-handler.h \ |
4071 | + webapps-process.h \ |
4072 | + |
4073 | +target.path = $${INSTALL_PREFIX}/share/unity-webapps/bin |
4074 | +INSTALLS += target |
4075 | + |
4076 | +QMAKE_SUBSTITUTES += \ |
4077 | + com.canonical.webapp.installer.json.in |
4078 | + |
4079 | +manifest.path = "/etc/chromium/native-messaging-hosts" |
4080 | +manifest.files = com.canonical.webapp.installer.json |
4081 | +INSTALLS += manifest |
4082 | |
4083 | === added file 'messaging-host/service.cpp' |
4084 | --- messaging-host/service.cpp 1970-01-01 00:00:00 +0000 |
4085 | +++ messaging-host/service.cpp 2014-11-18 07:07:55 +0000 |
4086 | @@ -0,0 +1,120 @@ |
4087 | +/* |
4088 | + * Copyright (C) 2014 Canonical Ltd. |
4089 | + * |
4090 | + * This file is part of unity-chromium-extension |
4091 | + * |
4092 | + * This program is free software: you can redistribute it and/or modify it |
4093 | + * under the terms of the GNU General Public License version 3, as published |
4094 | + * by the Free Software Foundation. |
4095 | + * |
4096 | + * This program is distributed in the hope that it will be useful, but |
4097 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
4098 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
4099 | + * PURPOSE. See the GNU General Public License for more details. |
4100 | + * |
4101 | + * You should have received a copy of the GNU General Public License along |
4102 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
4103 | + */ |
4104 | + |
4105 | +#include "service.h" |
4106 | + |
4107 | +#include <QDebug> |
4108 | +#include <QList> |
4109 | +#include <QMetaMethod> |
4110 | +#include <QMetaObject> |
4111 | + |
4112 | +using namespace UnityWebapps; |
4113 | + |
4114 | +namespace UnityWebapps { |
4115 | + |
4116 | +class ServicePrivate |
4117 | +{ |
4118 | + Q_DECLARE_PUBLIC(Service) |
4119 | + |
4120 | +public: |
4121 | + inline ServicePrivate(Service *service); |
4122 | + inline ~ServicePrivate(); |
4123 | + |
4124 | + void setIdle(bool isIdle); |
4125 | + |
4126 | +private: |
4127 | + QList<QObject *> m_handlers; |
4128 | + bool m_isIdle; |
4129 | + mutable Service *q_ptr; |
4130 | +}; |
4131 | + |
4132 | +} // namespace |
4133 | + |
4134 | +ServicePrivate::ServicePrivate(Service *service): |
4135 | + m_isIdle(true), |
4136 | + q_ptr(service) |
4137 | +{ |
4138 | +} |
4139 | + |
4140 | +ServicePrivate::~ServicePrivate() |
4141 | +{ |
4142 | +} |
4143 | + |
4144 | +void ServicePrivate::setIdle(bool isIdle) |
4145 | +{ |
4146 | + Q_Q(Service); |
4147 | + |
4148 | + if (m_isIdle == isIdle) return; |
4149 | + m_isIdle = isIdle; |
4150 | + Q_EMIT q->isIdleChanged(); |
4151 | +} |
4152 | + |
4153 | +Service::Service(QObject *parent): |
4154 | + QObject(parent), |
4155 | + d_ptr(new ServicePrivate(this)) |
4156 | +{ |
4157 | +} |
4158 | + |
4159 | +Service::~Service() |
4160 | +{ |
4161 | + delete d_ptr; |
4162 | +} |
4163 | + |
4164 | +bool Service::isIdle() const { |
4165 | + Q_D(const Service); |
4166 | + return d->m_isIdle; |
4167 | +} |
4168 | + |
4169 | +void Service::addHandler(QObject *handler) |
4170 | +{ |
4171 | + Q_D(Service); |
4172 | + |
4173 | + d->m_handlers.append(handler); |
4174 | +} |
4175 | + |
4176 | +void Service::handleMessage(const QVariantMap &message) |
4177 | +{ |
4178 | + Q_D(Service); |
4179 | + |
4180 | + QByteArray method = message.value(QStringLiteral("method")).toString().toLatin1(); |
4181 | + if (Q_UNLIKELY(method.isEmpty())) return; |
4182 | + |
4183 | + QByteArray methodSignature = method + "(QVariantMap)"; |
4184 | + |
4185 | + d->setIdle(false); |
4186 | + |
4187 | + QVariantMap reply; |
4188 | + bool ok = false; |
4189 | + Q_FOREACH(QObject *handler, d->m_handlers) { |
4190 | + const QMetaObject *metaObject = handler->metaObject(); |
4191 | + int index = metaObject->indexOfMethod(methodSignature); |
4192 | + if (index == -1) continue; |
4193 | + |
4194 | + QMetaMethod metaMethod = metaObject->method(index); |
4195 | + ok = metaMethod.invoke(handler, |
4196 | + Q_RETURN_ARG(QVariantMap, reply), |
4197 | + Q_ARG(QVariantMap, message)); |
4198 | + if (ok) break; |
4199 | + } |
4200 | + |
4201 | + if (ok) { |
4202 | + Q_EMIT messageHandled(reply); |
4203 | + } |
4204 | + |
4205 | + d->setIdle(true); |
4206 | +} |
4207 | |
4208 | === added file 'messaging-host/service.h' |
4209 | --- messaging-host/service.h 1970-01-01 00:00:00 +0000 |
4210 | +++ messaging-host/service.h 2014-11-18 07:07:55 +0000 |
4211 | @@ -0,0 +1,56 @@ |
4212 | +/* |
4213 | + * Copyright (C) 2014 Canonical Ltd. |
4214 | + * |
4215 | + * This file is part of unity-chromium-extension |
4216 | + * |
4217 | + * This program is free software: you can redistribute it and/or modify it |
4218 | + * under the terms of the GNU General Public License version 3, as published |
4219 | + * by the Free Software Foundation. |
4220 | + * |
4221 | + * This program is distributed in the hope that it will be useful, but |
4222 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
4223 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
4224 | + * PURPOSE. See the GNU General Public License for more details. |
4225 | + * |
4226 | + * You should have received a copy of the GNU General Public License along |
4227 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
4228 | + */ |
4229 | + |
4230 | +#ifndef UNITY_WEBAPPS_SERVICE |
4231 | +#define UNITY_WEBAPPS_SERVICE |
4232 | + |
4233 | +#include <QObject> |
4234 | +#include <QVariantMap> |
4235 | + |
4236 | +namespace UnityWebapps { |
4237 | + |
4238 | +class ServicePrivate; |
4239 | + |
4240 | +class Service: public QObject |
4241 | +{ |
4242 | + Q_OBJECT |
4243 | + Q_PROPERTY(bool isIdle READ isIdle NOTIFY isIdleChanged) |
4244 | + |
4245 | +public: |
4246 | + explicit Service(QObject *parent = 0); |
4247 | + ~Service(); |
4248 | + |
4249 | + bool isIdle() const; |
4250 | + |
4251 | + void addHandler(QObject *handler); |
4252 | + |
4253 | +public Q_SLOTS: |
4254 | + void handleMessage(const QVariantMap &message); |
4255 | + |
4256 | +Q_SIGNALS: |
4257 | + void messageHandled(const QVariantMap &reply); |
4258 | + void isIdleChanged(); |
4259 | + |
4260 | +private: |
4261 | + ServicePrivate *d_ptr; |
4262 | + Q_DECLARE_PRIVATE(Service) |
4263 | +}; |
4264 | + |
4265 | +} // namespace |
4266 | + |
4267 | +#endif // UNITY_WEBAPPS_SERVICE |
4268 | |
4269 | === added file 'messaging-host/webapps-handler.cpp' |
4270 | --- messaging-host/webapps-handler.cpp 1970-01-01 00:00:00 +0000 |
4271 | +++ messaging-host/webapps-handler.cpp 2014-11-18 07:07:55 +0000 |
4272 | @@ -0,0 +1,324 @@ |
4273 | +/* |
4274 | + * Copyright (C) 2014 Canonical Ltd. |
4275 | + * |
4276 | + * This file is part of unity-chromium-extension |
4277 | + * |
4278 | + * This program is free software: you can redistribute it and/or modify it |
4279 | + * under the terms of the GNU General Public License version 3, as published |
4280 | + * by the Free Software Foundation. |
4281 | + * |
4282 | + * This program is distributed in the hope that it will be useful, but |
4283 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
4284 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
4285 | + * PURPOSE. See the GNU General Public License for more details. |
4286 | + * |
4287 | + * You should have received a copy of the GNU General Public License along |
4288 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
4289 | + */ |
4290 | + |
4291 | +extern "C" { |
4292 | +#include <unity-webapps-permissions.h> |
4293 | +#include <unity-webapps-application-repository.h> |
4294 | +} |
4295 | + |
4296 | +#include "webapps-handler.h" |
4297 | + |
4298 | +#include <QDebug> |
4299 | +#include <QRegularExpression> |
4300 | + |
4301 | + |
4302 | +using namespace UnityWebapps; |
4303 | + |
4304 | +namespace UnityWebapps { |
4305 | + |
4306 | +class WebappsHandlerPrivate |
4307 | +{ |
4308 | + Q_DECLARE_PUBLIC(WebappsHandler) |
4309 | + |
4310 | +public: |
4311 | + inline WebappsHandlerPrivate(WebappsHandler *service); |
4312 | + inline ~WebappsHandlerPrivate(); |
4313 | + |
4314 | + UnityWebappsApplicationRepository *getRepository(); |
4315 | + |
4316 | +private: |
4317 | + static |
4318 | + void installationCallback(UnityWebappsApplicationRepository *repository, |
4319 | + const gchar *name, |
4320 | + UnityWebappsApplicationStatus status, |
4321 | + gpointer user_data); |
4322 | + |
4323 | + mutable WebappsHandler *q_ptr; |
4324 | + UnityWebappsApplicationRepository *applicationRepository; |
4325 | +}; |
4326 | + |
4327 | +} // namespace |
4328 | + |
4329 | + |
4330 | +WebappsHandlerPrivate::WebappsHandlerPrivate(WebappsHandler *service): |
4331 | + q_ptr(service), |
4332 | + applicationRepository(0) |
4333 | +{ |
4334 | +} |
4335 | + |
4336 | +WebappsHandlerPrivate::~WebappsHandlerPrivate() |
4337 | +{ |
4338 | + if (applicationRepository != 0) { |
4339 | + g_object_unref(G_OBJECT(applicationRepository)); |
4340 | + } |
4341 | +} |
4342 | + |
4343 | +UnityWebappsApplicationRepository *WebappsHandlerPrivate::getRepository() |
4344 | +{ |
4345 | + if (applicationRepository == 0) { |
4346 | + applicationRepository = unity_webapps_application_repository_new_default(); |
4347 | + unity_webapps_application_repository_prepare(applicationRepository); |
4348 | + } |
4349 | + return applicationRepository; |
4350 | +} |
4351 | + |
4352 | +void WebappsHandlerPrivate::installationCallback( |
4353 | + UnityWebappsApplicationRepository *repository, |
4354 | + const gchar *name, |
4355 | + UnityWebappsApplicationStatus status, |
4356 | + gpointer user_data |
4357 | +) |
4358 | +{ |
4359 | + Q_UNUSED(repository); |
4360 | + Q_UNUSED(name); |
4361 | + Q_UNUSED(status); |
4362 | + Q_UNUSED(user_data); |
4363 | +} |
4364 | + |
4365 | + |
4366 | +WebappsHandler::WebappsHandler(QObject *parent): |
4367 | + QObject(parent), |
4368 | + d_ptr(new WebappsHandlerPrivate(this)) |
4369 | +{ |
4370 | +} |
4371 | + |
4372 | +WebappsHandler::~WebappsHandler() |
4373 | +{ |
4374 | + delete d_ptr; |
4375 | +} |
4376 | + |
4377 | +QVariantMap WebappsHandler::url_loaded(const QVariantMap &message) |
4378 | +{ |
4379 | + Q_D(WebappsHandler); |
4380 | + |
4381 | + QVariantMap reply; |
4382 | + |
4383 | + if (!message.contains("url")) { |
4384 | + reply.insert("error", QStringLiteral("malformed request")); |
4385 | + return reply; |
4386 | + } |
4387 | + |
4388 | + QString url = message.value("url").toString(); |
4389 | + |
4390 | + GList *apps = unity_webapps_application_repository_resolve_url( |
4391 | + d->getRepository(), |
4392 | + url.toLocal8Bit().constData() |
4393 | + ); |
4394 | + |
4395 | + if (apps == 0) { |
4396 | + reply.insert("available", false); |
4397 | + return reply; |
4398 | + } |
4399 | + |
4400 | + // As per original extension only look at the first entry |
4401 | + const gchar *packageName = (const gchar*)apps->data; |
4402 | + UnityWebappsApplicationStatus status = unity_webapps_application_repository_get_resolved_application_status( |
4403 | + d->getRepository(), |
4404 | + packageName); |
4405 | + |
4406 | + if (status == UNITY_WEBAPPS_APPLICATION_STATUS_UNRESOLVED) { |
4407 | + reply.insert("available", false); |
4408 | + g_list_free_full(apps, g_free); |
4409 | + return reply; |
4410 | + } |
4411 | + |
4412 | + const gchar *appName = unity_webapps_application_repository_get_resolved_application_name( |
4413 | + d->getRepository(), |
4414 | + packageName); |
4415 | + |
4416 | + const gchar *appDomain = unity_webapps_application_repository_get_resolved_application_domain( |
4417 | + d->getRepository(), |
4418 | + packageName); |
4419 | + |
4420 | + if (unity_webapps_permissions_get_domain_dontask(appDomain) || |
4421 | + unity_webapps_permissions_get_domain_allowed(appDomain)) { |
4422 | + reply.insert("available", false); |
4423 | + g_list_free_full(apps, g_free); |
4424 | + return reply; |
4425 | + } |
4426 | + |
4427 | + reply.insert("available", true); |
4428 | + reply.insert("appName", QString::fromUtf8(appName)); |
4429 | + reply.insert("appDomain", QString::fromUtf8(appDomain)); |
4430 | + |
4431 | + g_list_free_full(apps, g_free); |
4432 | + |
4433 | + return reply; |
4434 | +} |
4435 | + |
4436 | +QVariantMap WebappsHandler::dont_ask(const QVariantMap &message) |
4437 | +{ |
4438 | + Q_D(WebappsHandler); |
4439 | + |
4440 | + QVariantMap reply; |
4441 | + |
4442 | + if (!message.contains("url")) { |
4443 | + reply.insert("error", QLatin1String("malformed request")); |
4444 | + return reply; |
4445 | + } |
4446 | + |
4447 | + QString url = message.value("url").toString(); |
4448 | + |
4449 | + GList *apps = unity_webapps_application_repository_resolve_url( |
4450 | + d->getRepository(), |
4451 | + url.toLocal8Bit().constData() |
4452 | + ); |
4453 | + |
4454 | + if (apps == 0) { |
4455 | + reply.insert("available", false); |
4456 | + reply.insert("dont_ask", false); |
4457 | + return reply; |
4458 | + } |
4459 | + |
4460 | + const gchar *packageName = (const gchar*)apps->data; |
4461 | + |
4462 | + const gchar *appDomain = unity_webapps_application_repository_get_resolved_application_domain( |
4463 | + d->getRepository(), |
4464 | + packageName); |
4465 | + |
4466 | + unity_webapps_permissions_dontask_domain(appDomain); |
4467 | + |
4468 | + reply.insert("dont_ask", true); |
4469 | + |
4470 | + g_list_free_full(apps, g_free); |
4471 | + |
4472 | + return reply; |
4473 | +} |
4474 | + |
4475 | +QVariantMap WebappsHandler::install(const QVariantMap &message) |
4476 | +{ |
4477 | + Q_D(WebappsHandler); |
4478 | + |
4479 | + QVariantMap reply; |
4480 | + |
4481 | + if (!message.contains("url")) { |
4482 | + reply.insert("error", QLatin1String("malformed request")); |
4483 | + return reply; |
4484 | + } |
4485 | + |
4486 | + QString url = message.value("url").toString(); |
4487 | + |
4488 | + GList *apps = unity_webapps_application_repository_resolve_url( |
4489 | + d->getRepository(), |
4490 | + url.toLocal8Bit().constData() |
4491 | + ); |
4492 | + |
4493 | + if (apps == 0) { |
4494 | + reply.insert("available", false); |
4495 | + reply.insert("installed", false); |
4496 | + return reply; |
4497 | + } |
4498 | + |
4499 | + const gchar *packageName = (const gchar*)apps->data; |
4500 | + |
4501 | + UnityWebappsApplicationStatus status = unity_webapps_application_repository_get_resolved_application_status( |
4502 | + d->getRepository(), |
4503 | + packageName); |
4504 | + |
4505 | + if (status == UNITY_WEBAPPS_APPLICATION_STATUS_UNRESOLVED) { |
4506 | + reply.insert("available", false); |
4507 | + reply.insert("installed", false); |
4508 | + g_list_free_full(apps, g_free); |
4509 | + return reply; |
4510 | + } |
4511 | + |
4512 | + const gchar *appDomain = unity_webapps_application_repository_get_resolved_application_domain( |
4513 | + d->getRepository(), |
4514 | + packageName); |
4515 | + const gchar *appName = unity_webapps_application_repository_get_resolved_application_name( |
4516 | + d->getRepository(), |
4517 | + packageName); |
4518 | + |
4519 | + switch (status) { |
4520 | + case UNITY_WEBAPPS_APPLICATION_STATUS_AVAILABLE: |
4521 | + if (unity_webapps_permissions_get_domain_dontask(appDomain)) { |
4522 | + reply.insert("available", true); |
4523 | + reply.insert("installed", false); |
4524 | + g_list_free_full(apps, g_free); |
4525 | + return reply; |
4526 | + } |
4527 | + unity_webapps_permissions_allow_domain(appDomain); |
4528 | + unity_webapps_application_repository_install_application( |
4529 | + d->getRepository(), |
4530 | + packageName, |
4531 | + WebappsHandlerPrivate::installationCallback, |
4532 | + 0); |
4533 | + break; |
4534 | + |
4535 | + case UNITY_WEBAPPS_APPLICATION_STATUS_INSTALLED: |
4536 | + if (unity_webapps_permissions_get_domain_dontask(appDomain) || |
4537 | + unity_webapps_permissions_get_domain_allowed(appDomain)) { |
4538 | + reply.insert("available", true); |
4539 | + reply.insert("installed", true); |
4540 | + g_list_free_full(apps, g_free); |
4541 | + return reply; |
4542 | + } |
4543 | + unity_webapps_application_repository_add_desktop_to_launcher( |
4544 | + createApplicationDesktopName(appName, appDomain).toLocal8Bit() |
4545 | + ); |
4546 | + unity_webapps_permissions_allow_domain(appDomain); |
4547 | + break; |
4548 | + case UNITY_WEBAPPS_APPLICATION_STATUS_UNRESOLVED: |
4549 | + // handled above |
4550 | + break; |
4551 | + } |
4552 | + |
4553 | + reply.insert("installed", true); |
4554 | + |
4555 | + g_list_free_full(apps, g_free); |
4556 | + |
4557 | + return reply; |
4558 | +} |
4559 | + |
4560 | +QVariantMap WebappsHandler::ping(const QVariantMap &message) |
4561 | +{ |
4562 | + Q_UNUSED(message); |
4563 | + |
4564 | + QVariantMap reply; |
4565 | + |
4566 | + reply.insert("pong", QLatin1String("alive")); |
4567 | + |
4568 | + return reply; |
4569 | +} |
4570 | + |
4571 | +/* |
4572 | + \fn createApplicationDesktopName(QString, QString) |
4573 | + |
4574 | + This function creates a application:// URI suitable for passing to |
4575 | + unity_webapps_application_repository_add_desktop_to_launcher(). |
4576 | + |
4577 | + To add the webapp's icon to the launcher, a dbus message is sent to the |
4578 | + launcher, referencing the webapps canonical .desktop file name. This |
4579 | + function creates the canonical name and returns it in the URI form. |
4580 | +*/ |
4581 | + |
4582 | +QString WebappsHandler::createApplicationDesktopName( |
4583 | + const QString &appName, |
4584 | + const QString &appDomain |
4585 | +) const |
4586 | +{ |
4587 | + QString basename; |
4588 | + QRegularExpression re(QStringLiteral("[^[:alnum:]]"), |
4589 | + QRegularExpression::UseUnicodePropertiesOption); |
4590 | + |
4591 | + basename.append(appName.trimmed().replace(re, QStringLiteral(""))); |
4592 | + basename.append(appDomain.trimmed().replace(re, QStringLiteral(""))); |
4593 | + |
4594 | + return QStringLiteral("application://%1.desktop").arg(basename); |
4595 | +} |
4596 | + |
4597 | |
4598 | === added file 'messaging-host/webapps-handler.h' |
4599 | --- messaging-host/webapps-handler.h 1970-01-01 00:00:00 +0000 |
4600 | +++ messaging-host/webapps-handler.h 2014-11-18 07:07:55 +0000 |
4601 | @@ -0,0 +1,59 @@ |
4602 | +/* |
4603 | + * Copyright (C) 2014 Canonical Ltd. |
4604 | + * |
4605 | + * This file is part of unity-chromium-extension |
4606 | + * |
4607 | + * This program is free software: you can redistribute it and/or modify it |
4608 | + * under the terms of the GNU General Public License version 3, as published |
4609 | + * by the Free Software Foundation. |
4610 | + * |
4611 | + * This program is distributed in the hope that it will be useful, but |
4612 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
4613 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
4614 | + * PURPOSE. See the GNU General Public License for more details. |
4615 | + * |
4616 | + * You should have received a copy of the GNU General Public License along |
4617 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
4618 | + */ |
4619 | + |
4620 | +#ifndef UNITY_WEBAPPS_WEBAPPS_HANDLER |
4621 | +#define UNITY_WEBAPPS_WEBAPPS_HANDLER |
4622 | + |
4623 | +#include <QObject> |
4624 | +#include <QVariantMap> |
4625 | + |
4626 | +namespace UnityWebapps { |
4627 | + |
4628 | +class WebappsHandlerPrivate; |
4629 | + |
4630 | +class WebappsHandler: public QObject |
4631 | +{ |
4632 | + Q_OBJECT |
4633 | + |
4634 | +public: |
4635 | + explicit WebappsHandler(QObject *parent = 0); |
4636 | + ~WebappsHandler(); |
4637 | + |
4638 | +public Q_SLOTS: |
4639 | + QVariantMap url_loaded(const QVariantMap &message); |
4640 | + QVariantMap dont_ask(const QVariantMap &message); |
4641 | + QVariantMap install(const QVariantMap &message); |
4642 | + QVariantMap ping(const QVariantMap &message); |
4643 | + |
4644 | +#if defined(UCX_UNDER_TEST) |
4645 | +public: |
4646 | +#else |
4647 | +private: |
4648 | +#endif |
4649 | + QString createApplicationDesktopName( |
4650 | + const QString &appName, |
4651 | + const QString &appDomain |
4652 | + ) const; |
4653 | + |
4654 | + WebappsHandlerPrivate *d_ptr; |
4655 | + Q_DECLARE_PRIVATE(WebappsHandler) |
4656 | +}; |
4657 | + |
4658 | +} // namespace |
4659 | + |
4660 | +#endif // UNITY_WEBAPPS_WEBAPPS_HANDLER |
4661 | |
4662 | === added file 'messaging-host/webapps-process.cpp' |
4663 | --- messaging-host/webapps-process.cpp 1970-01-01 00:00:00 +0000 |
4664 | +++ messaging-host/webapps-process.cpp 2014-11-18 07:07:55 +0000 |
4665 | @@ -0,0 +1,28 @@ |
4666 | + |
4667 | +extern "C" { |
4668 | +#include <unity-webapps-service.h> |
4669 | +} |
4670 | + |
4671 | +#include "webapps-process.h" |
4672 | + |
4673 | +namespace UnityWebapps { |
4674 | + |
4675 | +class ProcessPrivate |
4676 | +{ |
4677 | +public: |
4678 | + UnityWebappsService *service; |
4679 | +}; |
4680 | + |
4681 | +Process::Process(): |
4682 | + d_ptr(new ProcessPrivate) |
4683 | +{ |
4684 | + d_ptr->service = unity_webapps_service_new(); |
4685 | +} |
4686 | + |
4687 | +Process::~Process() |
4688 | +{ |
4689 | + g_object_unref(d_ptr->service); |
4690 | + delete d_ptr; |
4691 | +} |
4692 | + |
4693 | +} |
4694 | |
4695 | === added file 'messaging-host/webapps-process.h' |
4696 | --- messaging-host/webapps-process.h 1970-01-01 00:00:00 +0000 |
4697 | +++ messaging-host/webapps-process.h 2014-11-18 07:07:55 +0000 |
4698 | @@ -0,0 +1,37 @@ |
4699 | +/* |
4700 | + * Copyright (C) 2014 Canonical Ltd. |
4701 | + * |
4702 | + * This file is part of unity-chromium-extension |
4703 | + * |
4704 | + * This program is free software: you can redistribute it and/or modify it |
4705 | + * under the terms of the GNU General Public License version 3, as published |
4706 | + * by the Free Software Foundation. |
4707 | + * |
4708 | + * This program is distributed in the hope that it will be useful, but |
4709 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
4710 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
4711 | + * PURPOSE. See the GNU General Public License for more details. |
4712 | + * |
4713 | + * You should have received a copy of the GNU General Public License along |
4714 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
4715 | + */ |
4716 | + |
4717 | +#ifndef UNITY_WEBAPPS_PROCESS |
4718 | +#define UNITY_WEBAPPS_PROCESS |
4719 | + |
4720 | +namespace UnityWebapps { |
4721 | + |
4722 | +class ProcessPrivate; |
4723 | +class Process |
4724 | +{ |
4725 | +public: |
4726 | + Process(); |
4727 | + ~Process(); |
4728 | + |
4729 | +private: |
4730 | + ProcessPrivate *d_ptr; |
4731 | +}; |
4732 | + |
4733 | +} // namespace |
4734 | + |
4735 | +#endif // UNITY_WEBAPPS_SERVICE |
4736 | |
4737 | === removed directory 'npapi-binding-gen' |
4738 | === removed file 'npapi-binding-gen/bindinggen.py' |
4739 | --- npapi-binding-gen/bindinggen.py 2012-07-17 19:22:35 +0000 |
4740 | +++ npapi-binding-gen/bindinggen.py 1970-01-01 00:00:00 +0000 |
4741 | @@ -1,203 +0,0 @@ |
4742 | -import sys |
4743 | -import os |
4744 | -try: |
4745 | - import headers |
4746 | - import parser |
4747 | -except Exception, e: |
4748 | - print e |
4749 | - sys.exit(1) |
4750 | - |
4751 | -def _get_candidates_for_header_file_gen (files): |
4752 | - """ |
4753 | - Takes a list of files (header files) and returns a list of files |
4754 | - that should be considered for "webapps binding" generation |
4755 | - """ |
4756 | - candidates = [file for file in files if file.endswith('-context.h') |
4757 | - and -1 == file.find('-gen-') |
4758 | - or file.endswith('webapps-service.h') |
4759 | - or file.endswith('script-repo.h')] |
4760 | - return candidates |
4761 | - |
4762 | -def _get_source_file_body_template (): |
4763 | - return """ |
4764 | -/* |
4765 | - * unity-webapps-binding.c |
4766 | - * Copyright (C) Canonical LTD 2012 |
4767 | - * |
4768 | - * Author: Alexandre Abreu <alexandre.abreu@canonical.com> |
4769 | - * |
4770 | - * This program is free software; you can redistribute it and/or modify |
4771 | - * it under the terms of the GNU General Public License as published by |
4772 | - * the Free Software Foundation; either version 2 of the License, or |
4773 | - * (at your option) any later version. |
4774 | - * |
4775 | - * This program is distributed in the hope that it will be useful, |
4776 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4777 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4778 | - * GNU General Public License for more details. |
4779 | - * |
4780 | - * You should have received a copy of the GNU General Public License |
4781 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4782 | - */ |
4783 | -#include <glib.h> |
4784 | - |
4785 | -#include <unity-webapps-service.h> |
4786 | -#include <unity-webapps-context.h> |
4787 | -#include <unity-webapps-music-player-context.h> |
4788 | -#include <unity-webapps-permissions.h> |
4789 | -#include <unity-webapps-launcher-context.h> |
4790 | -#include <unity-webapps-notification-context.h> |
4791 | - |
4792 | -#include "npapi-headers/headers/npapi.h" |
4793 | -#include "npapi-headers/headers/npfunctions.h" |
4794 | -#include "npapi-headers/headers/npruntime.h" |
4795 | - |
4796 | -#include "wrapped-ptr-type.h" |
4797 | -#include "wrapped-callback-type.h" |
4798 | -#include "unity-webapps-binding-test.h" |
4799 | -#include "unity-npapi-binding-utils.h" |
4800 | -#include "unity-webapps-scriptable-object.h" |
4801 | -#include "unity-webapps-repo-userscript-wrapper.h" |
4802 | -#include "unity-npapi-plugin.h" |
4803 | - |
4804 | -#define REACHED_UNITY_WEBAPPS_FUNC_CALL() \ |
4805 | - if (unity_webapps_binding_test_is_test_mode_on()) \ |
4806 | - { \ |
4807 | - g_message("reached func call"); \ |
4808 | - unity_webapps_binding_test_reached_func_call (); \ |
4809 | - return result; \ |
4810 | - } \ |
4811 | - do {} while (false) |
4812 | - |
4813 | -#define ADD_NPOBJECT_RETAIN_FOR_CONTEXT(npp,context,object) \ |
4814 | - if (! unity_webapps_binding_test_is_test_mode_on()) \ |
4815 | - { \ |
4816 | - unity_npapi_plugin_t * pPlugin = (unity_npapi_plugin_t *) npp->pdata; \ |
4817 | - if (NULL != pPlugin) \ |
4818 | - { \ |
4819 | - unity_npapi_add_retained_objects_for_context (pPlugin,context,object); \ |
4820 | - } \ |
4821 | - } |
4822 | - |
4823 | -""" |
4824 | - |
4825 | -def _get_header_body_template (): |
4826 | - return """ |
4827 | -/* |
4828 | - * Copyright (C) Canonical LTD 2012 |
4829 | - * |
4830 | - * Author: Alexandre Abreu <alexandre.abreu@canonical.com> |
4831 | - * |
4832 | - * This program is free software; you can redistribute it and/or modify |
4833 | - * it under the terms of the GNU General Public License as published by |
4834 | - * the Free Software Foundation; either version 2 of the License, or |
4835 | - * (at your option) any later version. |
4836 | - * |
4837 | - * This program is distributed in the hope that it will be useful, |
4838 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4839 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4840 | - * GNU General Public License for more details. |
4841 | - * |
4842 | - * You should have received a copy of the GNU General Public License |
4843 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4844 | - */ |
4845 | - |
4846 | -#if ! defined (UNITY_WEBAPPS_BINDING_H) |
4847 | -#define UNITY_WEBAPPS_BINDING_H |
4848 | - |
4849 | -#include "npapi-headers/headers/npapi.h" |
4850 | -#include "npapi-headers/headers/nptypes.h" |
4851 | - |
4852 | -%s |
4853 | - |
4854 | -#endif // UNITY_WEBAPPS_BINDING_H |
4855 | - |
4856 | -""" |
4857 | - |
4858 | -def _get_unittest_func_header_template(): |
4859 | - return """ #ifndef %s_TEST_H |
4860 | -#define %s_TEST_H |
4861 | - |
4862 | -int %s_test(void); |
4863 | - |
4864 | -#endif |
4865 | -""" |
4866 | - |
4867 | -def _get_function_defs (parsed_data): |
4868 | - return [parsed_datum for parsed_datum in parsed_data if parsed_datum['type'] == 'func_decl'] |
4869 | - |
4870 | -def _get_callback_typedefs (parsed_data): |
4871 | - return [parsed_datum for parsed_datum in parsed_data if parsed_datum['type'] == 'func_typedef' and parsed_datum['name'][1].endswith('Callback')] |
4872 | - |
4873 | -if __name__ == "__main__": |
4874 | - import sys |
4875 | - |
4876 | - import argparse |
4877 | - parser = argparse.ArgumentParser(description='Generate NPAPI binding from header files.') |
4878 | - parser.add_argument ('--outf', default='unity-webapps-npapi-binding') |
4879 | - parser.add_argument ('--inf') |
4880 | - args = parser.parse_args() |
4881 | - |
4882 | - outfilename = args.outf |
4883 | - infilename = args.inf |
4884 | - |
4885 | - header_content = "// this file has been generated\n\n" |
4886 | - source_content = "// this file has been generated\n\n" + _get_source_file_body_template() |
4887 | - |
4888 | - binding_headers = [] |
4889 | - if infilename is not None: |
4890 | - import os |
4891 | - if not os.path.exists(infilename): |
4892 | - print "Invalid filename (does not exist):", infilename |
4893 | - sys.exit(1) |
4894 | - infilename = os.path.normpath (infilename) |
4895 | - binding_headers = [infilename] |
4896 | - else: |
4897 | - header_file_path = headers.getLibHeaderFilesPath() |
4898 | - if not os.path.exists(header_file_path): |
4899 | - print "libunity-webapps not installed or found" |
4900 | - sys.exit(1) |
4901 | - |
4902 | - binding_headers = _get_candidates_for_header_file_gen (headers.getHeaderFilesFrom (header_file_path)) |
4903 | - if len(binding_headers) == 0: |
4904 | - print "nothing to do, no header found" |
4905 | - sys.exit(1) |
4906 | - |
4907 | - # 'fix' the paths |
4908 | - binding_headers = [os.path.join (header_file_path, binding_header) for binding_header in binding_headers] |
4909 | - |
4910 | - import common_gen |
4911 | - import subprocess |
4912 | - functions_to_generate = [common_gen.get_unity_webapps_function_prefix() + function_to_generate for function_to_generate in subprocess.check_output('./get_functions_to_generate.sh', shell=True).split()] |
4913 | - |
4914 | - import header_generator |
4915 | - import source_generator |
4916 | - import unittest_gen |
4917 | - |
4918 | - import prepasses |
4919 | - import parser |
4920 | - for binding_header in binding_headers: |
4921 | - print "--- processing", binding_header |
4922 | - parsed_data = parser.parse (prepasses.run_prepasses(open(binding_header).read())) |
4923 | - |
4924 | - callback_decls = _get_callback_typedefs (parsed_data) |
4925 | - func_decls = _get_function_defs (parsed_data) |
4926 | - |
4927 | - # filter func defs |
4928 | - func_decls = [func_decl for func_decl in func_decls if func_decl['name'][1] in functions_to_generate] |
4929 | - |
4930 | - # generate |
4931 | - header_content += header_generator.generate_headers_for(func_decls) |
4932 | - source_content += source_generator.generate_sources_for(func_decls, callback_decls) |
4933 | - |
4934 | - for func_decl in func_decls: |
4935 | - unittest_content = unittest_gen.generate_unittest_for(func_decl) |
4936 | - func_name = func_decl['name'][1] |
4937 | - func_name_filename = func_name.replace('_', '-') |
4938 | - open(func_name_filename + "-test.c", "w+").write(unittest_content) |
4939 | - open(func_name_filename + "-test.h", "w+").write(_get_unittest_func_header_template() % (func_name.upper(), func_name.upper(), func_name)) |
4940 | - |
4941 | - open(outfilename + '.h', 'w+').write (_get_header_body_template() % header_content) |
4942 | - open(outfilename + '.c', 'w+').write (source_content) |
4943 | - |
4944 | - |
4945 | |
4946 | === removed file 'npapi-binding-gen/common_gen.py' |
4947 | --- npapi-binding-gen/common_gen.py 2012-06-04 14:04:32 +0000 |
4948 | +++ npapi-binding-gen/common_gen.py 1970-01-01 00:00:00 +0000 |
4949 | @@ -1,9 +0,0 @@ |
4950 | -""" |
4951 | -""" |
4952 | - |
4953 | -def get_binding_function_prefix (): |
4954 | - return "unity_webapps_binding_" |
4955 | - |
4956 | -def get_unity_webapps_function_prefix (): |
4957 | - return "unity_webapps_" |
4958 | - |
4959 | |
4960 | === removed file 'npapi-binding-gen/get_functions_to_generate.sh' |
4961 | --- npapi-binding-gen/get_functions_to_generate.sh 2012-06-04 14:04:32 +0000 |
4962 | +++ npapi-binding-gen/get_functions_to_generate.sh 1970-01-01 00:00:00 +0000 |
4963 | @@ -1,5 +0,0 @@ |
4964 | -#!/bin/bash |
4965 | - |
4966 | -set -e |
4967 | -find ../chromium-extension -name *.js | xargs grep -Po "(uwa\.[\w_]*)" | awk -F":" '{ print $2 }' | awk -F"." '{print $2}' | tee functions_to_generate | cat |
4968 | - |
4969 | |
4970 | === removed file 'npapi-binding-gen/header_generator.py' |
4971 | --- npapi-binding-gen/header_generator.py 2012-06-04 14:04:32 +0000 |
4972 | +++ npapi-binding-gen/header_generator.py 1970-01-01 00:00:00 +0000 |
4973 | @@ -1,23 +0,0 @@ |
4974 | -""" |
4975 | -""" |
4976 | - |
4977 | -import common_gen |
4978 | - |
4979 | -def generate_headers_for(func_descriptions): |
4980 | - func_decls = [] |
4981 | - for func_description in [func_description for func_description in func_descriptions if func_description['type'] == 'func_decl']: |
4982 | - func_decls.append(_generate_header_for(func_description)) |
4983 | - return '\n'.join (func_decls) |
4984 | - |
4985 | - |
4986 | -def _generate_header_for(func_description): |
4987 | - return """ |
4988 | -NPVariant |
4989 | -%s%s (NPP instance |
4990 | - , NPObject * npobject |
4991 | - , const NPVariant *args |
4992 | - , uint32_t argCount); |
4993 | -""" % (common_gen.get_binding_function_prefix (), func_description['name'][1].replace(common_gen.get_unity_webapps_function_prefix(), '')) |
4994 | - |
4995 | - |
4996 | - |
4997 | |
4998 | === removed file 'npapi-binding-gen/header_generator_test.py' |
4999 | --- npapi-binding-gen/header_generator_test.py 2012-06-04 14:04:32 +0000 |
5000 | +++ npapi-binding-gen/header_generator_test.py 1970-01-01 00:00:00 +0000 |
FAILED: Continuous integration, rev:256 jenkins. qa.ubuntu. com/job/ unity-chromium- extension- ci/26/ jenkins. qa.ubuntu. com/job/ unity-chromium- extension- utopic- amd64-ci/ 1/console jenkins. qa.ubuntu. com/job/ unity-chromium- extension- utopic- armhf-ci/ 1/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- chromium- extension- ci/26/rebuild
http://