Merge lp:~webapps/unity-chromium-extension/staging2 into lp:unity-chromium-extension
- staging2
- Merge into 14.04
Proposed by
David Barth
on 2014-12-17
| Status: | Merged |
|---|---|
| Approved by: | David Barth on 2014-12-17 |
| Approved revision: | 265 |
| Merged at revision: | 248 |
| Proposed branch: | lp:~webapps/unity-chromium-extension/staging2 |
| Merge into: | lp:unity-chromium-extension |
| Diff against target: |
25664 lines (+2599/-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 (+10/-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/staging2 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| WebApps | 2014-12-17 | Pending | |
|
Review via email:
|
|||
Commit Message
Support native messaging (Justin McPherson, Alberto Mardegan)
Description of the Change
Support native messaging (Justin McPherson, Alberto Mardegan)
To post a comment you must log in.
lp:~webapps/unity-chromium-extension/staging2
updated
on 2015-01-19
- 266. By David Barth on 2014-12-17
-
sync with latest upstream (vivid) debian changelog
- 267. By David Barth on 2014-12-17
-
add libtool dependency
- 268. By David Barth on 2014-12-17
-
revert
- 269. By David Barth on 2015-01-19
-
reset to UNRELEASED for the ci bot
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
| 1 | === modified file '.bzrignore' |
| 2 | --- .bzrignore 2012-03-16 12:42:18 +0000 |
| 3 | +++ .bzrignore 2015-01-19 16:40:00 +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 2015-01-19 16:40:00 +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 2015-01-19 16:40:00 +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 2015-01-19 16:40:00 +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 2015-01-19 16:40:00 +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 2015-01-19 16:40:00 +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 2015-01-19 16:40:00 +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 2015-01-19 16:40:00 +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 2015-01-19 16:40:00 +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 2015-01-19 16:40:00 +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 2015-01-19 16:40:00 +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 2015-01-19 16:40:00 +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 2015-01-19 16:40:00 +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 2015-01-19 16:40:00 +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 2015-01-19 16:40:00 +0000 |
| 3339 | @@ -1,3 +1,13 @@ |
| 3340 | +unity-chromium-extension (3.2.0+14.10.20140626-0ubuntu1) UNRELEASED; urgency=medium |
| 3341 | + |
| 3342 | + [ Justin McPherson ] |
| 3343 | + * Support native messaging. (with Alberto Mardegan) |
| 3344 | + |
| 3345 | + [ Ubuntu daily release ] |
| 3346 | + * New rebuild forced |
| 3347 | + |
| 3348 | + -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Thu, 26 Jun 2014 09:40:22 +0000 |
| 3349 | + |
| 3350 | unity-chromium-extension (3.0.0+14.04.20140318-0ubuntu1) trusty; urgency=low |
| 3351 | |
| 3352 | [ Ubuntu daily release ] |
| 3353 | |
| 3354 | === modified file 'debian/compat' |
| 3355 | --- debian/compat 2012-11-19 22:39:34 +0000 |
| 3356 | +++ debian/compat 2015-01-19 16:40:00 +0000 |
| 3357 | @@ -1,1 +1,1 @@ |
| 3358 | -8 |
| 3359 | +9 |
| 3360 | |
| 3361 | === modified file 'debian/control' |
| 3362 | --- debian/control 2014-03-18 20:50:57 +0000 |
| 3363 | +++ debian/control 2015-01-19 16:40:00 +0000 |
| 3364 | @@ -1,22 +1,18 @@ |
| 3365 | Source: unity-chromium-extension |
| 3366 | Priority: optional |
| 3367 | Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com> |
| 3368 | -# FIXME: We should be using debhelper 9, but that breaks the build |
| 3369 | -# for some currently unknown reason. |
| 3370 | -Build-Depends: autotools-dev, |
| 3371 | - chromium-browser (>= 20.0.1132.47~r144678-0ubuntu4), |
| 3372 | - debhelper (>= 8), |
| 3373 | +Build-Depends: chromium-browser (>= 34.0.1847.116-0ubuntu2), |
| 3374 | + debhelper (>= 9), |
| 3375 | dh-autoreconf, |
| 3376 | - gnome-common, |
| 3377 | libglib2.0-dev, |
| 3378 | - libgtest-dev, |
| 3379 | - libnotify-dev, |
| 3380 | libunity-webapps-dev (>= 1.8.0), |
| 3381 | - libwnck-dev, |
| 3382 | openssl, |
| 3383 | pkg-config, |
| 3384 | vim-common, |
| 3385 | zip, |
| 3386 | + qt5-default, |
| 3387 | + qt5-qmake, |
| 3388 | + xvfb, |
| 3389 | Standards-Version: 3.9.5 |
| 3390 | Section: gnome |
| 3391 | Homepage: https://launchpad.net/unity-chromium-extension |
| 3392 | @@ -27,7 +23,7 @@ |
| 3393 | |
| 3394 | Package: unity-chromium-extension |
| 3395 | Architecture: any |
| 3396 | -Depends: chromium-browser (>= 20.0.1132.47~r144678-0ubuntu4), |
| 3397 | +Depends: chromium-browser (>= 34.0.1847.116-0ubuntu2), |
| 3398 | unity-webapps-service, |
| 3399 | webbrowser-app, |
| 3400 | ${misc:Depends}, |
| 3401 | |
| 3402 | === modified file 'debian/copyright' |
| 3403 | --- debian/copyright 2012-11-19 19:26:58 +0000 |
| 3404 | +++ debian/copyright 2015-01-19 16:40:00 +0000 |
| 3405 | @@ -8,48 +8,3 @@ |
| 3406 | On Debian systems, the complete text of the GNU General |
| 3407 | Public License version 3 can be found in `/usr/share/common-licenses/GPL-3'. |
| 3408 | |
| 3409 | -Files: npapi-plugin/* |
| 3410 | -Copyright: 2012 Canonical Ltd |
| 3411 | -License: GPL-2+ |
| 3412 | - |
| 3413 | -Files: npapi-plugin/src/npapi-headers/headers/nptypes.h |
| 3414 | -Copyright: 2004 mozilla.org |
| 3415 | -License: GPL-2+ |
| 3416 | - |
| 3417 | -Files: npapi-plugin/src/npapi-headers/headers/npapi.h |
| 3418 | - npapi-plugin/src/npapi-headers/headers/npfunctions.h |
| 3419 | -Copyright: 1998 Netscape Communications Corporation |
| 3420 | -License: GPL-2+ |
| 3421 | - |
| 3422 | -Files: npapi-plugin/src/npapi-headers/headers/npruntime.h |
| 3423 | -Copyright: 2004 Apple Computer, Inc. |
| 3424 | -License: |
| 3425 | - Redistribution and use in source and binary forms, with or without |
| 3426 | - modification, are permitted provided that the following conditions are |
| 3427 | - met: |
| 3428 | - . |
| 3429 | - 1. Redistributions of source code must retain the above copyright |
| 3430 | - notice, this list of conditions and the following disclaimer. |
| 3431 | - 2. Redistributions in binary form must reproduce the above copyright |
| 3432 | - notice, this list of conditions and the following disclaimer in the |
| 3433 | - documentation and/or other materials provided with the distribution. |
| 3434 | - 3. Neither the names of Apple Computer, Inc. ("Apple") or The Mozilla |
| 3435 | - Foundation ("Mozilla") nor the names of their contributors may be used |
| 3436 | - to endorse or promote products derived from this software without |
| 3437 | - specific prior written permission. |
| 3438 | - . |
| 3439 | - THIS SOFTWARE IS PROVIDED BY APPLE, MOZILLA AND THEIR CONTRIBUTORS "AS |
| 3440 | - IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 3441 | - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
| 3442 | - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, MOZILLA OR |
| 3443 | - THEIR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 3444 | - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
| 3445 | - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 3446 | - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 3447 | - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 3448 | - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 3449 | - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 3450 | - |
| 3451 | -License: GPL-2+ |
| 3452 | - On Debian systems, the complete text of the GNU General |
| 3453 | - Public License version 2 can be found in `/usr/share/common-licenses/GPL-2'. |
| 3454 | |
| 3455 | === modified file 'debian/rules' |
| 3456 | --- debian/rules 2013-09-20 19:12:01 +0000 |
| 3457 | +++ debian/rules 2015-01-19 16:40:00 +0000 |
| 3458 | @@ -4,17 +4,15 @@ |
| 3459 | #export DH_VERBOSE=1 |
| 3460 | export DPKG_GENSYMBOLS_CHECK_LEVEL=4 |
| 3461 | |
| 3462 | -override_dh_autoreconf: |
| 3463 | - NOCONFIGURE=1 dh_autoreconf ./autogen.sh |
| 3464 | - |
| 3465 | override_dh_auto_configure: |
| 3466 | - cp debian/unity-webapps.pem . |
| 3467 | - dh_auto_configure -- --enable-tests=yes |
| 3468 | + cp debian/unity-webapps.pem chromium-extension/ |
| 3469 | + dh_auto_configure |
| 3470 | + |
| 3471 | +override_dh_auto_install: |
| 3472 | + dh_auto_install --destdir=debian/tmp |
| 3473 | |
| 3474 | override_dh_install: |
| 3475 | - rm -rf debian/*/usr/lib/*npapi* debian/*/usr/lib/pkgconfig \ |
| 3476 | - debian/*/usr/include |
| 3477 | dh_install --fail-missing |
| 3478 | |
| 3479 | %: |
| 3480 | - dh $@ --with autoreconf --fail-missing |
| 3481 | + dh $@ |
| 3482 | |
| 3483 | === added file 'debian/unity-chromium-extension.install' |
| 3484 | --- debian/unity-chromium-extension.install 1970-01-01 00:00:00 +0000 |
| 3485 | +++ debian/unity-chromium-extension.install 2015-01-19 16:40:00 +0000 |
| 3486 | @@ -0,0 +1,4 @@ |
| 3487 | +etc/chromium/native-messaging-hosts/com.canonical.webapp.installer.json |
| 3488 | +usr/lib/libunity-chromium/unity-webapps.crx |
| 3489 | +usr/share/chromium/extensions/*.json |
| 3490 | +usr/share/unity-webapps/bin/unity-webapps-messaging-host |
| 3491 | |
| 3492 | === removed directory 'm4' |
| 3493 | === removed file 'm4/gcov.m4' |
| 3494 | --- m4/gcov.m4 2013-12-23 01:17:40 +0000 |
| 3495 | +++ m4/gcov.m4 1970-01-01 00:00:00 +0000 |
| 3496 | @@ -1,79 +0,0 @@ |
| 3497 | -# Checks for existence of coverage tools: |
| 3498 | -# * gcov |
| 3499 | -# * lcov |
| 3500 | -# * genhtml |
| 3501 | -# * gcovr |
| 3502 | -# |
| 3503 | -# Sets ac_cv_check_gcov to yes if tooling is present |
| 3504 | -# and reports the executables to the variables LCOV, GCOVR and GENHTML. |
| 3505 | -AC_DEFUN([AC_TDD_GCOV], |
| 3506 | -[ |
| 3507 | - AC_ARG_ENABLE(gcov, |
| 3508 | - AS_HELP_STRING([--enable-gcov], |
| 3509 | - [enable coverage testing with gcov]), |
| 3510 | - [use_gcov=yes], [use_gcov=no]) |
| 3511 | - |
| 3512 | - AM_CONDITIONAL(HAVE_GCOV, test "x$use_gcov" = "xyes") |
| 3513 | - |
| 3514 | - if test "x$use_gcov" = "xyes"; then |
| 3515 | - # we need gcc: |
| 3516 | - if test "$GCC" != "yes"; then |
| 3517 | - AC_MSG_ERROR([GCC is required for --enable-gcov]) |
| 3518 | - fi |
| 3519 | - |
| 3520 | - # Check if ccache is being used |
| 3521 | - AC_CHECK_PROG(SHTOOL, shtool, shtool) |
| 3522 | - if test "$SHTOOL"; then |
| 3523 | - AS_CASE([`$SHTOOL path $CC`], |
| 3524 | - [*ccache*], [gcc_ccache=yes], |
| 3525 | - [gcc_ccache=no]) |
| 3526 | - fi |
| 3527 | - |
| 3528 | - if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then |
| 3529 | - AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) |
| 3530 | - fi |
| 3531 | - |
| 3532 | - lcov_version_list="1.6 1.7 1.8 1.9 1.10" |
| 3533 | - AC_CHECK_PROG(LCOV, lcov, lcov) |
| 3534 | - AC_CHECK_PROG(GENHTML, genhtml, genhtml) |
| 3535 | - |
| 3536 | - if test "$LCOV"; then |
| 3537 | - AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ |
| 3538 | - glib_cv_lcov_version=invalid |
| 3539 | - lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` |
| 3540 | - for lcov_check_version in $lcov_version_list; do |
| 3541 | - if test "$lcov_version" = "$lcov_check_version"; then |
| 3542 | - glib_cv_lcov_version="$lcov_check_version (ok)" |
| 3543 | - fi |
| 3544 | - done |
| 3545 | - ]) |
| 3546 | - else |
| 3547 | - lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list" |
| 3548 | - AC_MSG_ERROR([$lcov_msg]) |
| 3549 | - fi |
| 3550 | - |
| 3551 | - case $glib_cv_lcov_version in |
| 3552 | - ""|invalid[)] |
| 3553 | - lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)." |
| 3554 | - AC_MSG_ERROR([$lcov_msg]) |
| 3555 | - LCOV="exit 0;" |
| 3556 | - ;; |
| 3557 | - esac |
| 3558 | - |
| 3559 | - if test -z "$GENHTML"; then |
| 3560 | - AC_MSG_ERROR([Could not find genhtml from the lcov package]) |
| 3561 | - fi |
| 3562 | - |
| 3563 | - # Remove all optimization flags from CFLAGS |
| 3564 | - changequote({,}) |
| 3565 | - CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'` |
| 3566 | - changequote([,]) |
| 3567 | - |
| 3568 | - # Add the special gcc flags |
| 3569 | - UNITY_NPAPI_PLUGIN_COVERAGE_CFLAGS="--coverage" |
| 3570 | - UNITY_NPAPI_PLUGIN_COVERAGE_CXXFLAGS="--coverage" |
| 3571 | - UNITY_NPAPI_PLUGIN_COVERAGE_LDFLAGS="-lgcov" |
| 3572 | - |
| 3573 | -fi |
| 3574 | -]) # AC_TDD_GCOV |
| 3575 | - |
| 3576 | |
| 3577 | === added directory 'messaging-host' |
| 3578 | === added file 'messaging-host/Makefile.am' |
| 3579 | --- messaging-host/Makefile.am 1970-01-01 00:00:00 +0000 |
| 3580 | +++ messaging-host/Makefile.am 2015-01-19 16:40:00 +0000 |
| 3581 | @@ -0,0 +1,2 @@ |
| 3582 | +EXTRA_DIST += \ |
| 3583 | + installation-host |
| 3584 | |
| 3585 | === added file 'messaging-host/com.canonical.webapp.installer.json.in' |
| 3586 | --- messaging-host/com.canonical.webapp.installer.json.in 1970-01-01 00:00:00 +0000 |
| 3587 | +++ messaging-host/com.canonical.webapp.installer.json.in 2015-01-19 16:40:00 +0000 |
| 3588 | @@ -0,0 +1,9 @@ |
| 3589 | +{ |
| 3590 | + '"name": "com.canonical.webapp.installer"', |
| 3591 | + '"description": "Canonical WebApp Installation Host"', |
| 3592 | + '"path": "$${target.path}/$${TARGET}"', |
| 3593 | + '"type": "stdio"', |
| 3594 | + '"allowed_origins"': [ |
| 3595 | + '"chrome-extension://pmoflmbbcfgacopiikdcpmbiellfihdg/"' |
| 3596 | + ] |
| 3597 | +} |
| 3598 | |
| 3599 | === added file 'messaging-host/connection.cpp' |
| 3600 | --- messaging-host/connection.cpp 1970-01-01 00:00:00 +0000 |
| 3601 | +++ messaging-host/connection.cpp 2015-01-19 16:40:00 +0000 |
| 3602 | @@ -0,0 +1,152 @@ |
| 3603 | +/* |
| 3604 | + * Copyright (C) 2014 Canonical Ltd. |
| 3605 | + * |
| 3606 | + * This file is part of unity-chromium-extension |
| 3607 | + * |
| 3608 | + * This program is free software: you can redistribute it and/or modify it |
| 3609 | + * under the terms of the GNU General Public License version 3, as published |
| 3610 | + * by the Free Software Foundation. |
| 3611 | + * |
| 3612 | + * This program is distributed in the hope that it will be useful, but |
| 3613 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
| 3614 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 3615 | + * PURPOSE. See the GNU General Public License for more details. |
| 3616 | + * |
| 3617 | + * You should have received a copy of the GNU General Public License along |
| 3618 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 3619 | + */ |
| 3620 | + |
| 3621 | +#include "connection.h" |
| 3622 | + |
| 3623 | +#include <QByteArray> |
| 3624 | +#include <QDebug> |
| 3625 | +#include <QFile> |
| 3626 | +#include <QJsonDocument> |
| 3627 | +#include <QSocketNotifier> |
| 3628 | +#include <fcntl.h> |
| 3629 | +#include <stdio.h> |
| 3630 | +#include <unistd.h> |
| 3631 | + |
| 3632 | +using namespace UnityWebapps; |
| 3633 | + |
| 3634 | +namespace UnityWebapps { |
| 3635 | + |
| 3636 | +class ConnectionPrivate: public QObject |
| 3637 | +{ |
| 3638 | + Q_OBJECT |
| 3639 | + Q_DECLARE_PUBLIC(Connection) |
| 3640 | + |
| 3641 | +public: |
| 3642 | + inline ConnectionPrivate(Connection *connection); |
| 3643 | + inline ~ConnectionPrivate(); |
| 3644 | + |
| 3645 | + bool open(); |
| 3646 | + |
| 3647 | +private Q_SLOTS: |
| 3648 | + void onReadyRead(); |
| 3649 | + |
| 3650 | +private: |
| 3651 | + QFile m_readChannel; |
| 3652 | + QFile m_writeChannel; |
| 3653 | + QByteArray m_readBuffer; |
| 3654 | + int m_expectedLength; |
| 3655 | + mutable Connection *q_ptr; |
| 3656 | +}; |
| 3657 | + |
| 3658 | +} // namespace |
| 3659 | + |
| 3660 | +ConnectionPrivate::ConnectionPrivate(Connection *connection): |
| 3661 | + QObject(connection), |
| 3662 | + m_expectedLength(0), |
| 3663 | + q_ptr(connection) |
| 3664 | +{ |
| 3665 | +} |
| 3666 | + |
| 3667 | +ConnectionPrivate::~ConnectionPrivate() |
| 3668 | +{ |
| 3669 | +} |
| 3670 | + |
| 3671 | +bool ConnectionPrivate::open() |
| 3672 | +{ |
| 3673 | + bool ok; |
| 3674 | + |
| 3675 | + int flag = fcntl(STDIN_FILENO, F_GETFL); |
| 3676 | + if (Q_UNLIKELY(flag == -1)) return false; |
| 3677 | + |
| 3678 | + fcntl(STDIN_FILENO, F_SETFL, flag | O_NONBLOCK); |
| 3679 | + |
| 3680 | + ok = m_readChannel.open(stdin, QIODevice::ReadOnly); |
| 3681 | + if (Q_UNLIKELY(!ok)) return false; |
| 3682 | + |
| 3683 | + ok = m_writeChannel.open(stdout, QIODevice::WriteOnly); |
| 3684 | + if (Q_UNLIKELY(!ok)) return false; |
| 3685 | + |
| 3686 | + QSocketNotifier *notifier = new QSocketNotifier(m_readChannel.handle(), |
| 3687 | + QSocketNotifier::Read, |
| 3688 | + this); |
| 3689 | + QObject::connect(notifier, SIGNAL(activated(int)), |
| 3690 | + this, SLOT(onReadyRead())); |
| 3691 | + |
| 3692 | + // There might be already something to read |
| 3693 | + onReadyRead(); |
| 3694 | + |
| 3695 | + return true; |
| 3696 | +} |
| 3697 | + |
| 3698 | +void ConnectionPrivate::onReadyRead() |
| 3699 | +{ |
| 3700 | + Q_Q(Connection); |
| 3701 | + |
| 3702 | + while (true) { |
| 3703 | + if (m_expectedLength == 0) { |
| 3704 | + /* We are beginning a new read */ |
| 3705 | + |
| 3706 | + quint32 length; |
| 3707 | + int bytesRead = m_readChannel.read((char *)&length, |
| 3708 | + sizeof(length)); |
| 3709 | + if (bytesRead < int(sizeof(length))) break; |
| 3710 | + m_expectedLength = length; |
| 3711 | + m_readBuffer.clear(); |
| 3712 | + } |
| 3713 | + |
| 3714 | + int neededBytes = m_expectedLength - m_readBuffer.length(); |
| 3715 | + QByteArray buffer = m_readChannel.read(neededBytes); |
| 3716 | + m_readBuffer += buffer; |
| 3717 | + if (buffer.length() < neededBytes) break; |
| 3718 | + if (m_readBuffer.length() == m_expectedLength) { |
| 3719 | + QJsonDocument doc = QJsonDocument::fromJson(m_readBuffer); |
| 3720 | + Q_EMIT q->messageReceived(doc.toVariant().toMap()); |
| 3721 | + m_expectedLength = 0; |
| 3722 | + } |
| 3723 | + } |
| 3724 | +} |
| 3725 | + |
| 3726 | +Connection::Connection(QObject *parent): |
| 3727 | + QObject(parent), |
| 3728 | + d_ptr(new ConnectionPrivate(this)) |
| 3729 | +{ |
| 3730 | +} |
| 3731 | + |
| 3732 | +Connection::~Connection() |
| 3733 | +{ |
| 3734 | +} |
| 3735 | + |
| 3736 | +bool Connection::open() |
| 3737 | +{ |
| 3738 | + Q_D(Connection); |
| 3739 | + return d->open(); |
| 3740 | +} |
| 3741 | + |
| 3742 | +void Connection::postMessage(const QVariantMap &message) |
| 3743 | +{ |
| 3744 | + Q_D(Connection); |
| 3745 | + |
| 3746 | + QJsonDocument doc = QJsonDocument::fromVariant(message); |
| 3747 | + QByteArray json = doc.toJson(); |
| 3748 | + quint32 length = json.length(); |
| 3749 | + d->m_writeChannel.write((char *)&length, sizeof(length)); |
| 3750 | + d->m_writeChannel.write(json); |
| 3751 | + d->m_writeChannel.flush(); |
| 3752 | +} |
| 3753 | + |
| 3754 | +#include "connection.moc" |
| 3755 | |
| 3756 | === added file 'messaging-host/connection.h' |
| 3757 | --- messaging-host/connection.h 1970-01-01 00:00:00 +0000 |
| 3758 | +++ messaging-host/connection.h 2015-01-19 16:40:00 +0000 |
| 3759 | @@ -0,0 +1,52 @@ |
| 3760 | +/* |
| 3761 | + * Copyright (C) 2014 Canonical Ltd. |
| 3762 | + * |
| 3763 | + * This file is part of unity-chromium-extension |
| 3764 | + * |
| 3765 | + * This program is free software: you can redistribute it and/or modify it |
| 3766 | + * under the terms of the GNU General Public License version 3, as published |
| 3767 | + * by the Free Software Foundation. |
| 3768 | + * |
| 3769 | + * This program is distributed in the hope that it will be useful, but |
| 3770 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
| 3771 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 3772 | + * PURPOSE. See the GNU General Public License for more details. |
| 3773 | + * |
| 3774 | + * You should have received a copy of the GNU General Public License along |
| 3775 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 3776 | + */ |
| 3777 | + |
| 3778 | +#ifndef UNITY_WEBAPPS_CONNECTION |
| 3779 | +#define UNITY_WEBAPPS_CONNECTION |
| 3780 | + |
| 3781 | +#include <QObject> |
| 3782 | +#include <QVariantMap> |
| 3783 | + |
| 3784 | +namespace UnityWebapps { |
| 3785 | + |
| 3786 | +class ConnectionPrivate; |
| 3787 | + |
| 3788 | +class Connection: public QObject |
| 3789 | +{ |
| 3790 | + Q_OBJECT |
| 3791 | + |
| 3792 | +public: |
| 3793 | + explicit Connection(QObject *parent = 0); |
| 3794 | + ~Connection(); |
| 3795 | + |
| 3796 | + bool open(); |
| 3797 | + |
| 3798 | +public Q_SLOTS: |
| 3799 | + void postMessage(const QVariantMap &message); |
| 3800 | + |
| 3801 | +Q_SIGNALS: |
| 3802 | + void messageReceived(const QVariantMap &message); |
| 3803 | + |
| 3804 | +private: |
| 3805 | + ConnectionPrivate *d_ptr; |
| 3806 | + Q_DECLARE_PRIVATE(Connection) |
| 3807 | +}; |
| 3808 | + |
| 3809 | +} // namespace |
| 3810 | + |
| 3811 | +#endif // UNITY_WEBAPPS_CONNECTION |
| 3812 | |
| 3813 | === added file 'messaging-host/inactivity-timer.cpp' |
| 3814 | --- messaging-host/inactivity-timer.cpp 1970-01-01 00:00:00 +0000 |
| 3815 | +++ messaging-host/inactivity-timer.cpp 2015-01-19 16:40:00 +0000 |
| 3816 | @@ -0,0 +1,65 @@ |
| 3817 | +/* |
| 3818 | + * Copyright (C) 2014 Canonical Ltd. |
| 3819 | + * |
| 3820 | + * This file is part of unity-chromium-extension |
| 3821 | + * |
| 3822 | + * This program is free software: you can redistribute it and/or modify it |
| 3823 | + * under the terms of the GNU General Public License version 3, as published |
| 3824 | + * by the Free Software Foundation. |
| 3825 | + * |
| 3826 | + * This program is distributed in the hope that it will be useful, but |
| 3827 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
| 3828 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 3829 | + * PURPOSE. See the GNU General Public License for more details. |
| 3830 | + * |
| 3831 | + * You should have received a copy of the GNU General Public License along |
| 3832 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 3833 | + */ |
| 3834 | + |
| 3835 | +#include "inactivity-timer.h" |
| 3836 | + |
| 3837 | +#include <QVariant> |
| 3838 | + |
| 3839 | +using namespace UnityWebapps; |
| 3840 | + |
| 3841 | +InactivityTimer::InactivityTimer(int interval, QObject *parent): |
| 3842 | + QObject(parent), |
| 3843 | + m_interval(interval) |
| 3844 | +{ |
| 3845 | + m_timer.setSingleShot(true); |
| 3846 | + QObject::connect(&m_timer, SIGNAL(timeout()), |
| 3847 | + this, SLOT(onTimeout())); |
| 3848 | +} |
| 3849 | + |
| 3850 | +void InactivityTimer::watchObject(QObject *object) |
| 3851 | +{ |
| 3852 | + connect(object, SIGNAL(isIdleChanged()), SLOT(onIdleChanged())); |
| 3853 | + m_watchedObjects.append(object); |
| 3854 | + |
| 3855 | + /* Force an initial check */ |
| 3856 | + onIdleChanged(); |
| 3857 | +} |
| 3858 | + |
| 3859 | +void InactivityTimer::onIdleChanged() |
| 3860 | +{ |
| 3861 | + if (allObjectsAreIdle()) { |
| 3862 | + m_timer.start(m_interval); |
| 3863 | + } |
| 3864 | +} |
| 3865 | + |
| 3866 | +void InactivityTimer::onTimeout() |
| 3867 | +{ |
| 3868 | + if (allObjectsAreIdle()) { |
| 3869 | + Q_EMIT timeout(); |
| 3870 | + } |
| 3871 | +} |
| 3872 | + |
| 3873 | +bool InactivityTimer::allObjectsAreIdle() const |
| 3874 | +{ |
| 3875 | + foreach (const QObject *object, m_watchedObjects) { |
| 3876 | + if (!object->property("isIdle").toBool()) { |
| 3877 | + return false; |
| 3878 | + } |
| 3879 | + } |
| 3880 | + return true; |
| 3881 | +} |
| 3882 | |
| 3883 | === added file 'messaging-host/inactivity-timer.h' |
| 3884 | --- messaging-host/inactivity-timer.h 1970-01-01 00:00:00 +0000 |
| 3885 | +++ messaging-host/inactivity-timer.h 2015-01-19 16:40:00 +0000 |
| 3886 | @@ -0,0 +1,56 @@ |
| 3887 | +/* |
| 3888 | + * Copyright (C) 2014 Canonical Ltd. |
| 3889 | + * |
| 3890 | + * This file is part of unity-chromium-extension |
| 3891 | + * |
| 3892 | + * This program is free software: you can redistribute it and/or modify it |
| 3893 | + * under the terms of the GNU General Public License version 3, as published |
| 3894 | + * by the Free Software Foundation. |
| 3895 | + * |
| 3896 | + * This program is distributed in the hope that it will be useful, but |
| 3897 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
| 3898 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 3899 | + * PURPOSE. See the GNU General Public License for more details. |
| 3900 | + * |
| 3901 | + * You should have received a copy of the GNU General Public License along |
| 3902 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 3903 | + */ |
| 3904 | + |
| 3905 | +#ifndef UNITY_WEBAPPS_INACTIVITY_TIMER_H |
| 3906 | +#define UNITY_WEBAPPS_INACTIVITY_TIMER_H |
| 3907 | + |
| 3908 | +#include <QList> |
| 3909 | +#include <QObject> |
| 3910 | +#include <QTimer> |
| 3911 | + |
| 3912 | +namespace UnityWebapps { |
| 3913 | + |
| 3914 | +class InactivityTimer: public QObject |
| 3915 | +{ |
| 3916 | + Q_OBJECT |
| 3917 | + |
| 3918 | +public: |
| 3919 | + InactivityTimer(int interval, QObject *parent = 0); |
| 3920 | + ~InactivityTimer() {} |
| 3921 | + |
| 3922 | + void watchObject(QObject *object); |
| 3923 | + |
| 3924 | +Q_SIGNALS: |
| 3925 | + void timeout(); |
| 3926 | + |
| 3927 | +private Q_SLOTS: |
| 3928 | + void onIdleChanged(); |
| 3929 | + void onTimeout(); |
| 3930 | + |
| 3931 | +private: |
| 3932 | + bool allObjectsAreIdle() const; |
| 3933 | + |
| 3934 | +private: |
| 3935 | + QList<QObject*> m_watchedObjects; |
| 3936 | + QTimer m_timer; |
| 3937 | + int m_interval; |
| 3938 | +}; |
| 3939 | + |
| 3940 | +} // namespace |
| 3941 | + |
| 3942 | +#endif // UNITY_WEBAPPS_INACTIVITY_TIMER_H |
| 3943 | |
| 3944 | === added file 'messaging-host/main.cpp' |
| 3945 | --- messaging-host/main.cpp 1970-01-01 00:00:00 +0000 |
| 3946 | +++ messaging-host/main.cpp 2015-01-19 16:40:00 +0000 |
| 3947 | @@ -0,0 +1,91 @@ |
| 3948 | +/* |
| 3949 | + * Copyright (C) 2014 Canonical Ltd. |
| 3950 | + * |
| 3951 | + * This file is part of unity-chromium-extension |
| 3952 | + * |
| 3953 | + * This program is free software: you can redistribute it and/or modify it |
| 3954 | + * under the terms of the GNU General Public License version 3, as published |
| 3955 | + * by the Free Software Foundation. |
| 3956 | + * |
| 3957 | + * This program is distributed in the hope that it will be useful, but |
| 3958 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
| 3959 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 3960 | + * PURPOSE. See the GNU General Public License for more details. |
| 3961 | + * |
| 3962 | + * You should have received a copy of the GNU General Public License along |
| 3963 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 3964 | + */ |
| 3965 | + |
| 3966 | +#include <syslog.h> |
| 3967 | + |
| 3968 | +#include "connection.h" |
| 3969 | +#include "inactivity-timer.h" |
| 3970 | +#include "service.h" |
| 3971 | +#include "webapps-handler.h" |
| 3972 | +#include "webapps-process.h" |
| 3973 | + |
| 3974 | +#include <QCoreApplication> |
| 3975 | +#include <QDebug> |
| 3976 | + |
| 3977 | + |
| 3978 | +void syslogOutputHandler(QtMsgType type, const QMessageLogContext &, const QString &msg) |
| 3979 | +{ |
| 3980 | + QByteArray localMsg = msg.toLocal8Bit(); |
| 3981 | + int syslog_type = LOG_USER; |
| 3982 | + switch (type) { |
| 3983 | + case QtDebugMsg: |
| 3984 | + syslog_type |= LOG_DEBUG; |
| 3985 | + break; |
| 3986 | + case QtWarningMsg: |
| 3987 | + syslog_type |= LOG_WARNING; |
| 3988 | + break; |
| 3989 | + case QtCriticalMsg: |
| 3990 | + syslog_type |= LOG_CRIT; |
| 3991 | + break; |
| 3992 | + case QtFatalMsg: |
| 3993 | + syslog_type |= LOG_ERR; |
| 3994 | + break; |
| 3995 | + } |
| 3996 | + |
| 3997 | + syslog(syslog_type, "%s", localMsg.constData()); |
| 3998 | +} |
| 3999 | + |
| 4000 | + |
| 4001 | +int main(int argc, char **argv) |
| 4002 | +{ |
| 4003 | + if (qgetenv("UNITY_WEBAPPS_LOGGING") == QByteArrayLiteral("1")) { |
| 4004 | + qInstallMessageHandler(syslogOutputHandler); |
| 4005 | + } |
| 4006 | + |
| 4007 | + qDebug() << "Starting"; |
| 4008 | + |
| 4009 | + QCoreApplication app(argc, argv); |
| 4010 | + |
| 4011 | + UnityWebapps::Process process; |
| 4012 | + |
| 4013 | + UnityWebapps::Service service; |
| 4014 | + UnityWebapps::WebappsHandler handler; |
| 4015 | + service.addHandler(&handler); |
| 4016 | + |
| 4017 | + UnityWebapps::InactivityTimer inactivityTimer(2 * 60 * 1000); |
| 4018 | + QObject::connect(&inactivityTimer, SIGNAL(timeout()), &app, SLOT(quit())); |
| 4019 | + inactivityTimer.watchObject(&service); |
| 4020 | + |
| 4021 | + UnityWebapps::Connection connection; |
| 4022 | + QObject::connect(&connection, SIGNAL(messageReceived(const QVariantMap &)), |
| 4023 | + &service, SLOT(handleMessage(const QVariantMap &))); |
| 4024 | + QObject::connect(&service, SIGNAL(messageHandled(const QVariantMap &)), |
| 4025 | + &connection, SLOT(postMessage(const QVariantMap &))); |
| 4026 | + bool ok = connection.open(); |
| 4027 | + if (Q_UNLIKELY(!ok)) { |
| 4028 | + qCritical() << "Couldn't open connection"; |
| 4029 | + return EXIT_FAILURE; |
| 4030 | + } |
| 4031 | + |
| 4032 | + int r = app.exec(); |
| 4033 | + |
| 4034 | + qDebug() << "Finishing"; |
| 4035 | + |
| 4036 | + return r; |
| 4037 | +} |
| 4038 | + |
| 4039 | |
| 4040 | === added file 'messaging-host/messaging-host.pro' |
| 4041 | --- messaging-host/messaging-host.pro 1970-01-01 00:00:00 +0000 |
| 4042 | +++ messaging-host/messaging-host.pro 2015-01-19 16:40:00 +0000 |
| 4043 | @@ -0,0 +1,42 @@ |
| 4044 | +include(../common-project-config.pri) |
| 4045 | + |
| 4046 | +TEMPLATE = app |
| 4047 | +TARGET = unity-webapps-messaging-host |
| 4048 | + |
| 4049 | +CONFIG += \ |
| 4050 | + link_pkgconfig \ |
| 4051 | + qt |
| 4052 | + |
| 4053 | +QT += \ |
| 4054 | + core |
| 4055 | + |
| 4056 | +PKGCONFIG += \ |
| 4057 | + glib-2.0 \ |
| 4058 | + gobject-2.0 \ |
| 4059 | + libunity_webapps-0.2 \ |
| 4060 | + libunity-webapps-repository \ |
| 4061 | + |
| 4062 | +SOURCES = \ |
| 4063 | + connection.cpp \ |
| 4064 | + inactivity-timer.cpp \ |
| 4065 | + main.cpp \ |
| 4066 | + service.cpp \ |
| 4067 | + webapps-handler.cpp \ |
| 4068 | + webapps-process.cpp \ |
| 4069 | + |
| 4070 | +HEADERS = \ |
| 4071 | + connection.h \ |
| 4072 | + inactivity-timer.h \ |
| 4073 | + service.h \ |
| 4074 | + webapps-handler.h \ |
| 4075 | + webapps-process.h \ |
| 4076 | + |
| 4077 | +target.path = $${INSTALL_PREFIX}/share/unity-webapps/bin |
| 4078 | +INSTALLS += target |
| 4079 | + |
| 4080 | +QMAKE_SUBSTITUTES += \ |
| 4081 | + com.canonical.webapp.installer.json.in |
| 4082 | + |
| 4083 | +manifest.path = "/etc/chromium/native-messaging-hosts" |
| 4084 | +manifest.files = com.canonical.webapp.installer.json |
| 4085 | +INSTALLS += manifest |
| 4086 | |
| 4087 | === added file 'messaging-host/service.cpp' |
| 4088 | --- messaging-host/service.cpp 1970-01-01 00:00:00 +0000 |
| 4089 | +++ messaging-host/service.cpp 2015-01-19 16:40:00 +0000 |
| 4090 | @@ -0,0 +1,120 @@ |
| 4091 | +/* |
| 4092 | + * Copyright (C) 2014 Canonical Ltd. |
| 4093 | + * |
| 4094 | + * This file is part of unity-chromium-extension |
| 4095 | + * |
| 4096 | + * This program is free software: you can redistribute it and/or modify it |
| 4097 | + * under the terms of the GNU General Public License version 3, as published |
| 4098 | + * by the Free Software Foundation. |
| 4099 | + * |
| 4100 | + * This program is distributed in the hope that it will be useful, but |
| 4101 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
| 4102 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 4103 | + * PURPOSE. See the GNU General Public License for more details. |
| 4104 | + * |
| 4105 | + * You should have received a copy of the GNU General Public License along |
| 4106 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 4107 | + */ |
| 4108 | + |
| 4109 | +#include "service.h" |
| 4110 | + |
| 4111 | +#include <QDebug> |
| 4112 | +#include <QList> |
| 4113 | +#include <QMetaMethod> |
| 4114 | +#include <QMetaObject> |
| 4115 | + |
| 4116 | +using namespace UnityWebapps; |
| 4117 | + |
| 4118 | +namespace UnityWebapps { |
| 4119 | + |
| 4120 | +class ServicePrivate |
| 4121 | +{ |
| 4122 | + Q_DECLARE_PUBLIC(Service) |
| 4123 | + |
| 4124 | +public: |
| 4125 | + inline ServicePrivate(Service *service); |
| 4126 | + inline ~ServicePrivate(); |
| 4127 | + |
| 4128 | + void setIdle(bool isIdle); |
| 4129 | + |
| 4130 | +private: |
| 4131 | + QList<QObject *> m_handlers; |
| 4132 | + bool m_isIdle; |
| 4133 | + mutable Service *q_ptr; |
| 4134 | +}; |
| 4135 | + |
| 4136 | +} // namespace |
| 4137 | + |
| 4138 | +ServicePrivate::ServicePrivate(Service *service): |
| 4139 | + m_isIdle(true), |
| 4140 | + q_ptr(service) |
| 4141 | +{ |
| 4142 | +} |
| 4143 | + |
| 4144 | +ServicePrivate::~ServicePrivate() |
| 4145 | +{ |
| 4146 | +} |
| 4147 | + |
| 4148 | +void ServicePrivate::setIdle(bool isIdle) |
| 4149 | +{ |
| 4150 | + Q_Q(Service); |
| 4151 | + |
| 4152 | + if (m_isIdle == isIdle) return; |
| 4153 | + m_isIdle = isIdle; |
| 4154 | + Q_EMIT q->isIdleChanged(); |
| 4155 | +} |
| 4156 | + |
| 4157 | +Service::Service(QObject *parent): |
| 4158 | + QObject(parent), |
| 4159 | + d_ptr(new ServicePrivate(this)) |
| 4160 | +{ |
| 4161 | +} |
| 4162 | + |
| 4163 | +Service::~Service() |
| 4164 | +{ |
| 4165 | + delete d_ptr; |
| 4166 | +} |
| 4167 | + |
| 4168 | +bool Service::isIdle() const { |
| 4169 | + Q_D(const Service); |
| 4170 | + return d->m_isIdle; |
| 4171 | +} |
| 4172 | + |
| 4173 | +void Service::addHandler(QObject *handler) |
| 4174 | +{ |
| 4175 | + Q_D(Service); |
| 4176 | + |
| 4177 | + d->m_handlers.append(handler); |
| 4178 | +} |
| 4179 | + |
| 4180 | +void Service::handleMessage(const QVariantMap &message) |
| 4181 | +{ |
| 4182 | + Q_D(Service); |
| 4183 | + |
| 4184 | + QByteArray method = message.value(QStringLiteral("method")).toString().toLatin1(); |
| 4185 | + if (Q_UNLIKELY(method.isEmpty())) return; |
| 4186 | + |
| 4187 | + QByteArray methodSignature = method + "(QVariantMap)"; |
| 4188 | + |
| 4189 | + d->setIdle(false); |
| 4190 | + |
| 4191 | + QVariantMap reply; |
| 4192 | + bool ok = false; |
| 4193 | + Q_FOREACH(QObject *handler, d->m_handlers) { |
| 4194 | + const QMetaObject *metaObject = handler->metaObject(); |
| 4195 | + int index = metaObject->indexOfMethod(methodSignature); |
| 4196 | + if (index == -1) continue; |
| 4197 | + |
| 4198 | + QMetaMethod metaMethod = metaObject->method(index); |
| 4199 | + ok = metaMethod.invoke(handler, |
| 4200 | + Q_RETURN_ARG(QVariantMap, reply), |
| 4201 | + Q_ARG(QVariantMap, message)); |
| 4202 | + if (ok) break; |
| 4203 | + } |
| 4204 | + |
| 4205 | + if (ok) { |
| 4206 | + Q_EMIT messageHandled(reply); |
| 4207 | + } |
| 4208 | + |
| 4209 | + d->setIdle(true); |
| 4210 | +} |
| 4211 | |
| 4212 | === added file 'messaging-host/service.h' |
| 4213 | --- messaging-host/service.h 1970-01-01 00:00:00 +0000 |
| 4214 | +++ messaging-host/service.h 2015-01-19 16:40:00 +0000 |
| 4215 | @@ -0,0 +1,56 @@ |
| 4216 | +/* |
| 4217 | + * Copyright (C) 2014 Canonical Ltd. |
| 4218 | + * |
| 4219 | + * This file is part of unity-chromium-extension |
| 4220 | + * |
| 4221 | + * This program is free software: you can redistribute it and/or modify it |
| 4222 | + * under the terms of the GNU General Public License version 3, as published |
| 4223 | + * by the Free Software Foundation. |
| 4224 | + * |
| 4225 | + * This program is distributed in the hope that it will be useful, but |
| 4226 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
| 4227 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 4228 | + * PURPOSE. See the GNU General Public License for more details. |
| 4229 | + * |
| 4230 | + * You should have received a copy of the GNU General Public License along |
| 4231 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 4232 | + */ |
| 4233 | + |
| 4234 | +#ifndef UNITY_WEBAPPS_SERVICE |
| 4235 | +#define UNITY_WEBAPPS_SERVICE |
| 4236 | + |
| 4237 | +#include <QObject> |
| 4238 | +#include <QVariantMap> |
| 4239 | + |
| 4240 | +namespace UnityWebapps { |
| 4241 | + |
| 4242 | +class ServicePrivate; |
| 4243 | + |
| 4244 | +class Service: public QObject |
| 4245 | +{ |
| 4246 | + Q_OBJECT |
| 4247 | + Q_PROPERTY(bool isIdle READ isIdle NOTIFY isIdleChanged) |
| 4248 | + |
| 4249 | +public: |
| 4250 | + explicit Service(QObject *parent = 0); |
| 4251 | + ~Service(); |
| 4252 | + |
| 4253 | + bool isIdle() const; |
| 4254 | + |
| 4255 | + void addHandler(QObject *handler); |
| 4256 | + |
| 4257 | +public Q_SLOTS: |
| 4258 | + void handleMessage(const QVariantMap &message); |
| 4259 | + |
| 4260 | +Q_SIGNALS: |
| 4261 | + void messageHandled(const QVariantMap &reply); |
| 4262 | + void isIdleChanged(); |
| 4263 | + |
| 4264 | +private: |
| 4265 | + ServicePrivate *d_ptr; |
| 4266 | + Q_DECLARE_PRIVATE(Service) |
| 4267 | +}; |
| 4268 | + |
| 4269 | +} // namespace |
| 4270 | + |
| 4271 | +#endif // UNITY_WEBAPPS_SERVICE |
| 4272 | |
| 4273 | === added file 'messaging-host/webapps-handler.cpp' |
| 4274 | --- messaging-host/webapps-handler.cpp 1970-01-01 00:00:00 +0000 |
| 4275 | +++ messaging-host/webapps-handler.cpp 2015-01-19 16:40:00 +0000 |
| 4276 | @@ -0,0 +1,324 @@ |
| 4277 | +/* |
| 4278 | + * Copyright (C) 2014 Canonical Ltd. |
| 4279 | + * |
| 4280 | + * This file is part of unity-chromium-extension |
| 4281 | + * |
| 4282 | + * This program is free software: you can redistribute it and/or modify it |
| 4283 | + * under the terms of the GNU General Public License version 3, as published |
| 4284 | + * by the Free Software Foundation. |
| 4285 | + * |
| 4286 | + * This program is distributed in the hope that it will be useful, but |
| 4287 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
| 4288 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 4289 | + * PURPOSE. See the GNU General Public License for more details. |
| 4290 | + * |
| 4291 | + * You should have received a copy of the GNU General Public License along |
| 4292 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 4293 | + */ |
| 4294 | + |
| 4295 | +extern "C" { |
| 4296 | +#include <unity-webapps-permissions.h> |
| 4297 | +#include <unity-webapps-application-repository.h> |
| 4298 | +} |
| 4299 | + |
| 4300 | +#include "webapps-handler.h" |
| 4301 | + |
| 4302 | +#include <QDebug> |
| 4303 | +#include <QRegularExpression> |
| 4304 | + |
| 4305 | + |
| 4306 | +using namespace UnityWebapps; |
| 4307 | + |
| 4308 | +namespace UnityWebapps { |
| 4309 | + |
| 4310 | +class WebappsHandlerPrivate |
| 4311 | +{ |
| 4312 | + Q_DECLARE_PUBLIC(WebappsHandler) |
| 4313 | + |
| 4314 | +public: |
| 4315 | + inline WebappsHandlerPrivate(WebappsHandler *service); |
| 4316 | + inline ~WebappsHandlerPrivate(); |
| 4317 | + |
| 4318 | + UnityWebappsApplicationRepository *getRepository(); |
| 4319 | + |
| 4320 | +private: |
| 4321 | + static |
| 4322 | + void installationCallback(UnityWebappsApplicationRepository *repository, |
| 4323 | + const gchar *name, |
| 4324 | + UnityWebappsApplicationStatus status, |
| 4325 | + gpointer user_data); |
| 4326 | + |
| 4327 | + mutable WebappsHandler *q_ptr; |
| 4328 | + UnityWebappsApplicationRepository *applicationRepository; |
| 4329 | +}; |
| 4330 | + |
| 4331 | +} // namespace |
| 4332 | + |
| 4333 | + |
| 4334 | +WebappsHandlerPrivate::WebappsHandlerPrivate(WebappsHandler *service): |
| 4335 | + q_ptr(service), |
| 4336 | + applicationRepository(0) |
| 4337 | +{ |
| 4338 | +} |
| 4339 | + |
| 4340 | +WebappsHandlerPrivate::~WebappsHandlerPrivate() |
| 4341 | +{ |
| 4342 | + if (applicationRepository != 0) { |
| 4343 | + g_object_unref(G_OBJECT(applicationRepository)); |
| 4344 | + } |
| 4345 | +} |
| 4346 | + |
| 4347 | +UnityWebappsApplicationRepository *WebappsHandlerPrivate::getRepository() |
| 4348 | +{ |
| 4349 | + if (applicationRepository == 0) { |
| 4350 | + applicationRepository = unity_webapps_application_repository_new_default(); |
| 4351 | + unity_webapps_application_repository_prepare(applicationRepository); |
| 4352 | + } |
| 4353 | + return applicationRepository; |
| 4354 | +} |
| 4355 | + |
| 4356 | +void WebappsHandlerPrivate::installationCallback( |
| 4357 | + UnityWebappsApplicationRepository *repository, |
| 4358 | + const gchar *name, |
| 4359 | + UnityWebappsApplicationStatus status, |
| 4360 | + gpointer user_data |
| 4361 | +) |
| 4362 | +{ |
| 4363 | + Q_UNUSED(repository); |
| 4364 | + Q_UNUSED(name); |
| 4365 | + Q_UNUSED(status); |
| 4366 | + Q_UNUSED(user_data); |
| 4367 | +} |
| 4368 | + |
| 4369 | + |
| 4370 | +WebappsHandler::WebappsHandler(QObject *parent): |
| 4371 | + QObject(parent), |
| 4372 | + d_ptr(new WebappsHandlerPrivate(this)) |
| 4373 | +{ |
| 4374 | +} |
| 4375 | + |
| 4376 | +WebappsHandler::~WebappsHandler() |
| 4377 | +{ |
| 4378 | + delete d_ptr; |
| 4379 | +} |
| 4380 | + |
| 4381 | +QVariantMap WebappsHandler::url_loaded(const QVariantMap &message) |
| 4382 | +{ |
| 4383 | + Q_D(WebappsHandler); |
| 4384 | + |
| 4385 | + QVariantMap reply; |
| 4386 | + |
| 4387 | + if (!message.contains("url")) { |
| 4388 | + reply.insert("error", QStringLiteral("malformed request")); |
| 4389 | + return reply; |
| 4390 | + } |
| 4391 | + |
| 4392 | + QString url = message.value("url").toString(); |
| 4393 | + |
| 4394 | + GList *apps = unity_webapps_application_repository_resolve_url( |
| 4395 | + d->getRepository(), |
| 4396 | + url.toLocal8Bit().constData() |
| 4397 | + ); |
| 4398 | + |
| 4399 | + if (apps == 0) { |
| 4400 | + reply.insert("available", false); |
| 4401 | + return reply; |
| 4402 | + } |
| 4403 | + |
| 4404 | + // As per original extension only look at the first entry |
| 4405 | + const gchar *packageName = (const gchar*)apps->data; |
| 4406 | + UnityWebappsApplicationStatus status = unity_webapps_application_repository_get_resolved_application_status( |
| 4407 | + d->getRepository(), |
| 4408 | + packageName); |
| 4409 | + |
| 4410 | + if (status == UNITY_WEBAPPS_APPLICATION_STATUS_UNRESOLVED) { |
| 4411 | + reply.insert("available", false); |
| 4412 | + g_list_free_full(apps, g_free); |
| 4413 | + return reply; |
| 4414 | + } |
| 4415 | + |
| 4416 | + const gchar *appName = unity_webapps_application_repository_get_resolved_application_name( |
| 4417 | + d->getRepository(), |
| 4418 | + packageName); |
| 4419 | + |
| 4420 | + const gchar *appDomain = unity_webapps_application_repository_get_resolved_application_domain( |
| 4421 | + d->getRepository(), |
| 4422 | + packageName); |
| 4423 | + |
| 4424 | + if (unity_webapps_permissions_get_domain_dontask(appDomain) || |
| 4425 | + unity_webapps_permissions_get_domain_allowed(appDomain)) { |
| 4426 | + reply.insert("available", false); |
| 4427 | + g_list_free_full(apps, g_free); |
| 4428 | + return reply; |
| 4429 | + } |
| 4430 | + |
| 4431 | + reply.insert("available", true); |
| 4432 | + reply.insert("appName", QString::fromUtf8(appName)); |
| 4433 | + reply.insert("appDomain", QString::fromUtf8(appDomain)); |
| 4434 | + |
| 4435 | + g_list_free_full(apps, g_free); |
| 4436 | + |
| 4437 | + return reply; |
| 4438 | +} |
| 4439 | + |
| 4440 | +QVariantMap WebappsHandler::dont_ask(const QVariantMap &message) |
| 4441 | +{ |
| 4442 | + Q_D(WebappsHandler); |
| 4443 | + |
| 4444 | + QVariantMap reply; |
| 4445 | + |
| 4446 | + if (!message.contains("url")) { |
| 4447 | + reply.insert("error", QLatin1String("malformed request")); |
| 4448 | + return reply; |
| 4449 | + } |
| 4450 | + |
| 4451 | + QString url = message.value("url").toString(); |
| 4452 | + |
| 4453 | + GList *apps = unity_webapps_application_repository_resolve_url( |
| 4454 | + d->getRepository(), |
| 4455 | + url.toLocal8Bit().constData() |
| 4456 | + ); |
| 4457 | + |
| 4458 | + if (apps == 0) { |
| 4459 | + reply.insert("available", false); |
| 4460 | + reply.insert("dont_ask", false); |
| 4461 | + return reply; |
| 4462 | + } |
| 4463 | + |
| 4464 | + const gchar *packageName = (const gchar*)apps->data; |
| 4465 | + |
| 4466 | + const gchar *appDomain = unity_webapps_application_repository_get_resolved_application_domain( |
| 4467 | + d->getRepository(), |
| 4468 | + packageName); |
| 4469 | + |
| 4470 | + unity_webapps_permissions_dontask_domain(appDomain); |
| 4471 | + |
| 4472 | + reply.insert("dont_ask", true); |
| 4473 | + |
| 4474 | + g_list_free_full(apps, g_free); |
| 4475 | + |
| 4476 | + return reply; |
| 4477 | +} |
| 4478 | + |
| 4479 | +QVariantMap WebappsHandler::install(const QVariantMap &message) |
| 4480 | +{ |
| 4481 | + Q_D(WebappsHandler); |
| 4482 | + |
| 4483 | + QVariantMap reply; |
| 4484 | + |
| 4485 | + if (!message.contains("url")) { |
| 4486 | + reply.insert("error", QLatin1String("malformed request")); |
| 4487 | + return reply; |
| 4488 | + } |
| 4489 | + |
| 4490 | + QString url = message.value("url").toString(); |
| 4491 | + |
| 4492 | + GList *apps = unity_webapps_application_repository_resolve_url( |
| 4493 | + d->getRepository(), |
| 4494 | + url.toLocal8Bit().constData() |
| 4495 | + ); |
| 4496 | + |
| 4497 | + if (apps == 0) { |
| 4498 | + reply.insert("available", false); |
| 4499 | + reply.insert("installed", false); |
| 4500 | + return reply; |
| 4501 | + } |
| 4502 | + |
| 4503 | + const gchar *packageName = (const gchar*)apps->data; |
| 4504 | + |
| 4505 | + UnityWebappsApplicationStatus status = unity_webapps_application_repository_get_resolved_application_status( |
| 4506 | + d->getRepository(), |
| 4507 | + packageName); |
| 4508 | + |
| 4509 | + if (status == UNITY_WEBAPPS_APPLICATION_STATUS_UNRESOLVED) { |
| 4510 | + reply.insert("available", false); |
| 4511 | + reply.insert("installed", false); |
| 4512 | + g_list_free_full(apps, g_free); |
| 4513 | + return reply; |
| 4514 | + } |
| 4515 | + |
| 4516 | + const gchar *appDomain = unity_webapps_application_repository_get_resolved_application_domain( |
| 4517 | + d->getRepository(), |
| 4518 | + packageName); |
| 4519 | + const gchar *appName = unity_webapps_application_repository_get_resolved_application_name( |
| 4520 | + d->getRepository(), |
| 4521 | + packageName); |
| 4522 | + |
| 4523 | + switch (status) { |
| 4524 | + case UNITY_WEBAPPS_APPLICATION_STATUS_AVAILABLE: |
| 4525 | + if (unity_webapps_permissions_get_domain_dontask(appDomain)) { |
| 4526 | + reply.insert("available", true); |
| 4527 | + reply.insert("installed", false); |
| 4528 | + g_list_free_full(apps, g_free); |
| 4529 | + return reply; |
| 4530 | + } |
| 4531 | + unity_webapps_permissions_allow_domain(appDomain); |
| 4532 | + unity_webapps_application_repository_install_application( |
| 4533 | + d->getRepository(), |
| 4534 | + packageName, |
| 4535 | + WebappsHandlerPrivate::installationCallback, |
| 4536 | + 0); |
| 4537 | + break; |
| 4538 | + |
| 4539 | + case UNITY_WEBAPPS_APPLICATION_STATUS_INSTALLED: |
| 4540 | + if (unity_webapps_permissions_get_domain_dontask(appDomain) || |
| 4541 | + unity_webapps_permissions_get_domain_allowed(appDomain)) { |
| 4542 | + reply.insert("available", true); |
| 4543 | + reply.insert("installed", true); |
| 4544 | + g_list_free_full(apps, g_free); |
| 4545 | + return reply; |
| 4546 | + } |
| 4547 | + unity_webapps_application_repository_add_desktop_to_launcher( |
| 4548 | + createApplicationDesktopName(appName, appDomain).toLocal8Bit() |
| 4549 | + ); |
| 4550 | + unity_webapps_permissions_allow_domain(appDomain); |
| 4551 | + break; |
| 4552 | + case UNITY_WEBAPPS_APPLICATION_STATUS_UNRESOLVED: |
| 4553 | + // handled above |
| 4554 | + break; |
| 4555 | + } |
| 4556 | + |
| 4557 | + reply.insert("installed", true); |
| 4558 | + |
| 4559 | + g_list_free_full(apps, g_free); |
| 4560 | + |
| 4561 | + return reply; |
| 4562 | +} |
| 4563 | + |
| 4564 | +QVariantMap WebappsHandler::ping(const QVariantMap &message) |
| 4565 | +{ |
| 4566 | + Q_UNUSED(message); |
| 4567 | + |
| 4568 | + QVariantMap reply; |
| 4569 | + |
| 4570 | + reply.insert("pong", QLatin1String("alive")); |
| 4571 | + |
| 4572 | + return reply; |
| 4573 | +} |
| 4574 | + |
| 4575 | +/* |
| 4576 | + \fn createApplicationDesktopName(QString, QString) |
| 4577 | + |
| 4578 | + This function creates a application:// URI suitable for passing to |
| 4579 | + unity_webapps_application_repository_add_desktop_to_launcher(). |
| 4580 | + |
| 4581 | + To add the webapp's icon to the launcher, a dbus message is sent to the |
| 4582 | + launcher, referencing the webapps canonical .desktop file name. This |
| 4583 | + function creates the canonical name and returns it in the URI form. |
| 4584 | +*/ |
| 4585 | + |
| 4586 | +QString WebappsHandler::createApplicationDesktopName( |
| 4587 | + const QString &appName, |
| 4588 | + const QString &appDomain |
| 4589 | +) const |
| 4590 | +{ |
| 4591 | + QString basename; |
| 4592 | + QRegularExpression re(QStringLiteral("[^[:alnum:]]"), |
| 4593 | + QRegularExpression::UseUnicodePropertiesOption); |
| 4594 | + |
| 4595 | + basename.append(appName.trimmed().replace(re, QStringLiteral(""))); |
| 4596 | + basename.append(appDomain.trimmed().replace(re, QStringLiteral(""))); |
| 4597 | + |
| 4598 | + return QStringLiteral("application://%1.desktop").arg(basename); |
| 4599 | +} |
| 4600 | + |
| 4601 | |
| 4602 | === added file 'messaging-host/webapps-handler.h' |
| 4603 | --- messaging-host/webapps-handler.h 1970-01-01 00:00:00 +0000 |
| 4604 | +++ messaging-host/webapps-handler.h 2015-01-19 16:40:00 +0000 |
| 4605 | @@ -0,0 +1,59 @@ |
| 4606 | +/* |
| 4607 | + * Copyright (C) 2014 Canonical Ltd. |
| 4608 | + * |
| 4609 | + * This file is part of unity-chromium-extension |
| 4610 | + * |
| 4611 | + * This program is free software: you can redistribute it and/or modify it |
| 4612 | + * under the terms of the GNU General Public License version 3, as published |
| 4613 | + * by the Free Software Foundation. |
| 4614 | + * |
| 4615 | + * This program is distributed in the hope that it will be useful, but |
| 4616 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
| 4617 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 4618 | + * PURPOSE. See the GNU General Public License for more details. |
| 4619 | + * |
| 4620 | + * You should have received a copy of the GNU General Public License along |
| 4621 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 4622 | + */ |
| 4623 | + |
| 4624 | +#ifndef UNITY_WEBAPPS_WEBAPPS_HANDLER |
| 4625 | +#define UNITY_WEBAPPS_WEBAPPS_HANDLER |
| 4626 | + |
| 4627 | +#include <QObject> |
| 4628 | +#include <QVariantMap> |
| 4629 | + |
| 4630 | +namespace UnityWebapps { |
| 4631 | + |
| 4632 | +class WebappsHandlerPrivate; |
| 4633 | + |
| 4634 | +class WebappsHandler: public QObject |
| 4635 | +{ |
| 4636 | + Q_OBJECT |
| 4637 | + |
| 4638 | +public: |
| 4639 | + explicit WebappsHandler(QObject *parent = 0); |
| 4640 | + ~WebappsHandler(); |
| 4641 | + |
| 4642 | +public Q_SLOTS: |
| 4643 | + QVariantMap url_loaded(const QVariantMap &message); |
| 4644 | + QVariantMap dont_ask(const QVariantMap &message); |
| 4645 | + QVariantMap install(const QVariantMap &message); |
| 4646 | + QVariantMap ping(const QVariantMap &message); |
| 4647 | + |
| 4648 | +#if defined(UCX_UNDER_TEST) |
| 4649 | +public: |
| 4650 | +#else |
| 4651 | +private: |
| 4652 | +#endif |
| 4653 | + QString createApplicationDesktopName( |
| 4654 | + const QString &appName, |
| 4655 | + const QString &appDomain |
| 4656 | + ) const; |
| 4657 | + |
| 4658 | + WebappsHandlerPrivate *d_ptr; |
| 4659 | + Q_DECLARE_PRIVATE(WebappsHandler) |
| 4660 | +}; |
| 4661 | + |
| 4662 | +} // namespace |
| 4663 | + |
| 4664 | +#endif // UNITY_WEBAPPS_WEBAPPS_HANDLER |
| 4665 | |
| 4666 | === added file 'messaging-host/webapps-process.cpp' |
| 4667 | --- messaging-host/webapps-process.cpp 1970-01-01 00:00:00 +0000 |
| 4668 | +++ messaging-host/webapps-process.cpp 2015-01-19 16:40:00 +0000 |
| 4669 | @@ -0,0 +1,28 @@ |
| 4670 | + |
| 4671 | +extern "C" { |
| 4672 | +#include <unity-webapps-service.h> |
| 4673 | +} |
| 4674 | + |
| 4675 | +#include "webapps-process.h" |
| 4676 | + |
| 4677 | +namespace UnityWebapps { |
| 4678 | + |
| 4679 | +class ProcessPrivate |
| 4680 | +{ |
| 4681 | +public: |
| 4682 | + UnityWebappsService *service; |
| 4683 | +}; |
| 4684 | + |
| 4685 | +Process::Process(): |
| 4686 | + d_ptr(new ProcessPrivate) |
| 4687 | +{ |
| 4688 | + d_ptr->service = unity_webapps_service_new(); |
| 4689 | +} |
| 4690 | + |
| 4691 | +Process::~Process() |
| 4692 | +{ |
| 4693 | + g_object_unref(d_ptr->service); |
| 4694 | + delete d_ptr; |
| 4695 | +} |
| 4696 | + |
| 4697 | +} |
| 4698 | |
| 4699 | === added file 'messaging-host/webapps-process.h' |
| 4700 | --- messaging-host/webapps-process.h 1970-01-01 00:00:00 +0000 |
| 4701 | +++ messaging-host/webapps-process.h 2015-01-19 16:40:00 +0000 |
| 4702 | @@ -0,0 +1,37 @@ |
| 4703 | +/* |
| 4704 | + * Copyright (C) 2014 Canonical Ltd. |
| 4705 | + * |
| 4706 | + * This file is part of unity-chromium-extension |
| 4707 | + * |
| 4708 | + * This program is free software: you can redistribute it and/or modify it |
| 4709 | + * under the terms of the GNU General Public License version 3, as published |
| 4710 | + * by the Free Software Foundation. |
| 4711 | + * |
| 4712 | + * This program is distributed in the hope that it will be useful, but |
| 4713 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
| 4714 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 4715 | + * PURPOSE. See the GNU General Public License for more details. |
| 4716 | + * |
| 4717 | + * You should have received a copy of the GNU General Public License along |
| 4718 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 4719 | + */ |
| 4720 | + |
| 4721 | +#ifndef UNITY_WEBAPPS_PROCESS |
| 4722 | +#define UNITY_WEBAPPS_PROCESS |
| 4723 | + |
| 4724 | +namespace UnityWebapps { |
| 4725 | + |
| 4726 | +class ProcessPrivate; |
| 4727 | +class Process |
| 4728 | +{ |
| 4729 | +public: |
| 4730 | + Process(); |
| 4731 | + ~Process(); |
| 4732 | + |
| 4733 | +private: |
| 4734 | + ProcessPrivate *d_ptr; |
| 4735 | +}; |
| 4736 | + |
| 4737 | +} // namespace |
| 4738 | + |
| 4739 | +#endif // UNITY_WEBAPPS_SERVICE |
| 4740 | |
| 4741 | === removed directory 'npapi-binding-gen' |
| 4742 | === removed file 'npapi-binding-gen/bindinggen.py' |
| 4743 | --- npapi-binding-gen/bindinggen.py 2012-07-17 19:22:35 +0000 |
| 4744 | +++ npapi-binding-gen/bindinggen.py 1970-01-01 00:00:00 +0000 |
| 4745 | @@ -1,203 +0,0 @@ |
| 4746 | -import sys |
| 4747 | -import os |
| 4748 | -try: |
| 4749 | - import headers |
| 4750 | - import parser |
| 4751 | -except Exception, e: |
| 4752 | - print e |
| 4753 | - sys.exit(1) |
| 4754 | - |
| 4755 | -def _get_candidates_for_header_file_gen (files): |
| 4756 | - """ |
| 4757 | - Takes a list of files (header files) and returns a list of files |
| 4758 | - that should be considered for "webapps binding" generation |
| 4759 | - """ |
| 4760 | - candidates = [file for file in files if file.endswith('-context.h') |
| 4761 | - and -1 == file.find('-gen-') |
| 4762 | - or file.endswith('webapps-service.h') |
| 4763 | - or file.endswith('script-repo.h')] |
| 4764 | - return candidates |
| 4765 | - |
| 4766 | -def _get_source_file_body_template (): |
| 4767 | - return """ |
| 4768 | -/* |
| 4769 | - * unity-webapps-binding.c |
| 4770 | - * Copyright (C) Canonical LTD 2012 |
| 4771 | - * |
| 4772 | - * Author: Alexandre Abreu <alexandre.abreu@canonical.com> |
| 4773 | - * |
| 4774 | - * This program is free software; you can redistribute it and/or modify |
| 4775 | - * it under the terms of the GNU General Public License as published by |
| 4776 | - * the Free Software Foundation; either version 2 of the License, or |
| 4777 | - * (at your option) any later version. |
| 4778 | - * |
| 4779 | - * This program is distributed in the hope that it will be useful, |
| 4780 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 4781 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 4782 | - * GNU General Public License for more details. |
| 4783 | - * |
| 4784 | - * You should have received a copy of the GNU General Public License |
| 4785 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 4786 | - */ |
| 4787 | -#include <glib.h> |
| 4788 | - |
| 4789 | -#include <unity-webapps-service.h> |
| 4790 | -#include <unity-webapps-context.h> |
| 4791 | -#include <unity-webapps-music-player-context.h> |
| 4792 | -#include <unity-webapps-permissions.h> |
| 4793 | -#include <unity-webapps-launcher-context.h> |
| 4794 | -#include <unity-webapps-notification-context.h> |
| 4795 | - |
| 4796 | -#include "npapi-headers/headers/npapi.h" |
| 4797 | -#include "npapi-headers/headers/npfunctions.h" |
| 4798 | -#include "npapi-headers/headers/npruntime.h" |
| 4799 | - |
| 4800 | -#include "wrapped-ptr-type.h" |
| 4801 | -#include "wrapped-callback-type.h" |
| 4802 | -#include "unity-webapps-binding-test.h" |
| 4803 | -#include "unity-npapi-binding-utils.h" |
| 4804 | -#include "unity-webapps-scriptable-object.h" |
| 4805 | -#include "unity-webapps-repo-userscript-wrapper.h" |
| 4806 | -#include "unity-npapi-plugin.h" |
| 4807 | - |
| 4808 | -#define REACHED_UNITY_WEBAPPS_FUNC_CALL() \ |
| 4809 | - if (unity_webapps_binding_test_is_test_mode_on()) \ |
| 4810 | - { \ |
| 4811 | - g_message("reached func call"); \ |
| 4812 | - unity_webapps_binding_test_reached_func_call (); \ |
| 4813 | - return result; \ |
| 4814 | - } \ |
| 4815 | - do {} while (false) |
| 4816 | - |
| 4817 | -#define ADD_NPOBJECT_RETAIN_FOR_CONTEXT(npp,context,object) \ |
| 4818 | - if (! unity_webapps_binding_test_is_test_mode_on()) \ |
| 4819 | - { \ |
| 4820 | - unity_npapi_plugin_t * pPlugin = (unity_npapi_plugin_t *) npp->pdata; \ |
| 4821 | - if (NULL != pPlugin) \ |
| 4822 | - { \ |
| 4823 | - unity_npapi_add_retained_objects_for_context (pPlugin,context,object); \ |
| 4824 | - } \ |
| 4825 | - } |
| 4826 | - |
| 4827 | -""" |
| 4828 | - |
| 4829 | -def _get_header_body_template (): |
| 4830 | - return """ |
| 4831 | -/* |
| 4832 | - * Copyright (C) Canonical LTD 2012 |
| 4833 | - * |
| 4834 | - * Author: Alexandre Abreu <alexandre.abreu@canonical.com> |
| 4835 | - * |
| 4836 | - * This program is free software; you can redistribute it and/or modify |
| 4837 | - * it under the terms of the GNU General Public License as published by |
| 4838 | - * the Free Software Foundation; either version 2 of the License, or |
| 4839 | - * (at your option) any later version. |
| 4840 | - * |
| 4841 | - * This program is distributed in the hope that it will be useful, |
| 4842 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 4843 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 4844 | - * GNU General Public License for more details. |
| 4845 | - * |
| 4846 | - * You should have received a copy of the GNU General Public License |
| 4847 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 4848 | - */ |
| 4849 | - |
| 4850 | -#if ! defined (UNITY_WEBAPPS_BINDING_H) |
| 4851 | -#define UNITY_WEBAPPS_BINDING_H |
| 4852 | - |
| 4853 | -#include "npapi-headers/headers/npapi.h" |
| 4854 | -#include "npapi-headers/headers/nptypes.h" |
| 4855 | - |
| 4856 | -%s |
| 4857 | - |
| 4858 | -#endif // UNITY_WEBAPPS_BINDING_H |
| 4859 | - |
| 4860 | -""" |
| 4861 | - |
| 4862 | -def _get_unittest_func_header_template(): |
| 4863 | - return """ #ifndef %s_TEST_H |
| 4864 | -#define %s_TEST_H |
| 4865 | - |
| 4866 | -int %s_test(void); |
| 4867 | - |
| 4868 | -#endif |
| 4869 | -""" |
| 4870 | - |
| 4871 | -def _get_function_defs (parsed_data): |
| 4872 | - return [parsed_datum for parsed_datum in parsed_data if parsed_datum['type'] == 'func_decl'] |
| 4873 | - |
| 4874 | -def _get_callback_typedefs (parsed_data): |
| 4875 | - return [parsed_datum for parsed_datum in parsed_data if parsed_datum['type'] == 'func_typedef' and parsed_datum['name'][1].endswith('Callback')] |
| 4876 | - |
| 4877 | -if __name__ == "__main__": |
| 4878 | - import sys |
| 4879 | - |
| 4880 | - import argparse |
| 4881 | - parser = argparse.ArgumentParser(description='Generate NPAPI binding from header files.') |
| 4882 | - parser.add_argument ('--outf', default='unity-webapps-npapi-binding') |
| 4883 | - parser.add_argument ('--inf') |
| 4884 | - args = parser.parse_args() |
| 4885 | - |
| 4886 | - outfilename = args.outf |
| 4887 | - infilename = args.inf |
| 4888 | - |
| 4889 | - header_content = "// this file has been generated\n\n" |
| 4890 | - source_content = "// this file has been generated\n\n" + _get_source_file_body_template() |
| 4891 | - |
| 4892 | - binding_headers = [] |
| 4893 | - if infilename is not None: |
| 4894 | - import os |
| 4895 | - if not os.path.exists(infilename): |
| 4896 | - print "Invalid filename (does not exist):", infilename |
| 4897 | - sys.exit(1) |
| 4898 | - infilename = os.path.normpath (infilename) |
| 4899 | - binding_headers = [infilename] |
| 4900 | - else: |
| 4901 | - header_file_path = headers.getLibHeaderFilesPath() |
| 4902 | - if not os.path.exists(header_file_path): |
| 4903 | - print "libunity-webapps not installed or found" |
| 4904 | - sys.exit(1) |
| 4905 | - |
| 4906 | - binding_headers = _get_candidates_for_header_file_gen (headers.getHeaderFilesFrom (header_file_path)) |
| 4907 | - if len(binding_headers) == 0: |
| 4908 | - print "nothing to do, no header found" |
| 4909 | - sys.exit(1) |
| 4910 | - |
| 4911 | - # 'fix' the paths |
| 4912 | - binding_headers = [os.path.join (header_file_path, binding_header) for binding_header in binding_headers] |
| 4913 | - |
| 4914 | - import common_gen |
| 4915 | - import subprocess |
| 4916 | - 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()] |
| 4917 | - |
| 4918 | - import header_generator |
| 4919 | - import source_generator |
| 4920 | - import unittest_gen |
| 4921 | - |
| 4922 | - import prepasses |
| 4923 | - import parser |
| 4924 | - for binding_header in binding_headers: |
| 4925 | - print "--- processing", binding_header |
| 4926 | - parsed_data = parser.parse (prepasses.run_prepasses(open(binding_header).read())) |
| 4927 | - |
| 4928 | - callback_decls = _get_callback_typedefs (parsed_data) |
| 4929 | - func_decls = _get_function_defs (parsed_data) |
| 4930 | - |
| 4931 | - # filter func defs |
| 4932 | - func_decls = [func_decl for func_decl in func_decls if func_decl['name'][1] in functions_to_generate] |
| 4933 | - |
| 4934 | - # generate |
| 4935 | - header_content += header_generator.generate_headers_for(func_decls) |
| 4936 | - source_content += source_generator.generate_sources_for(func_decls, callback_decls) |
| 4937 | - |
| 4938 | - for func_decl in func_decls: |
| 4939 | - unittest_content = unittest_gen.generate_unittest_for(func_decl) |
| 4940 | - func_name = func_decl['name'][1] |
| 4941 | - func_name_filename = func_name.replace('_', '-') |
| 4942 | - open(func_name_filename + "-test.c", "w+").write(unittest_content) |
| 4943 | - open(func_name_filename + "-test.h", "w+").write(_get_unittest_func_header_template() % (func_name.upper(), func_name.upper(), func_name)) |
| 4944 | - |
| 4945 | - open(outfilename + '.h', 'w+').write (_get_header_body_template() % header_content) |
| 4946 | - open(outfilename + '.c', 'w+').write (source_content) |
| 4947 | - |
| 4948 | - |
| 4949 | |
| 4950 | === removed file 'npapi-binding-gen/common_gen.py' |
| 4951 | --- npapi-binding-gen/common_gen.py 2012-06-04 14:04:32 +0000 |
| 4952 | +++ npapi-binding-gen/common_gen.py 1970-01-01 00:00:00 +0000 |
| 4953 | @@ -1,9 +0,0 @@ |
| 4954 | -""" |
| 4955 | -""" |
| 4956 | - |
| 4957 | -def get_binding_function_prefix (): |
| 4958 | - return "unity_webapps_binding_" |
| 4959 | - |
| 4960 | -def get_unity_webapps_function_prefix (): |
| 4961 | - return "unity_webapps_" |
| 4962 | - |
| 4963 | |
| 4964 | === removed file 'npapi-binding-gen/get_functions_to_generate.sh' |
| 4965 | --- npapi-binding-gen/get_functions_to_generate.sh 2012-06-04 14:04:32 +0000 |
| 4966 | +++ npapi-binding-gen/get_functions_to_generate.sh 1970-01-01 00:00:00 +0000 |
| 4967 | @@ -1,5 +0,0 @@ |
| 4968 | -#!/bin/bash |
| 4969 | - |
| 4970 | -set -e |
| 4971 | -find ../chromium-extension -name *.js | xargs grep -Po "(uwa\.[\w_]*)" | awk -F":" '{ print $2 }' | awk -F"." '{print $2}' | tee functions_to_generate | cat |
| 4972 | - |
| 4973 | |
| 4974 | === removed file 'npapi-binding-gen/header_generator.py' |
| 4975 | --- npapi-binding-gen/header_generator.py 2012-06-04 14:04:32 +0000 |
| 4976 | +++ npapi-binding-gen/header_generator.py 1970-01-01 00:00:00 +0000 |
| 4977 | @@ -1,23 +0,0 @@ |
| 4978 | -""" |
| 4979 | -""" |
| 4980 | - |
| 4981 | -import common_gen |
| 4982 | - |
| 4983 | -def generate_headers_for(func_descriptions): |
| 4984 | - func_decls = [] |
| 4985 | - for func_description in [func_description for func_description in func_descriptions if func_description['type'] == 'func_decl']: |
| 4986 | - func_decls.append(_generate_header_for(func_description)) |
| 4987 | - return '\n'.join (func_decls) |
| 4988 | - |
| 4989 | - |
| 4990 | -def _generate_header_for(func_description): |
| 4991 | - return """ |
| 4992 | -NPVariant |
| 4993 | -%s%s (NPP instance |
| 4994 | - , NPObject * npobject |
| 4995 | - , const NPVariant *args |
| 4996 | - , uint32_t argCount); |
| 4997 | -""" % (common_gen.get_binding_function_prefix (), func_description['name'][1].replace(common_gen.get_unity_webapps_function_prefix(), '')) |
| 4998 | - |
| 4999 | - |
| 5000 | - |
The diff has been truncated for viewing.
