diff options
| author | Joakim Verona | 2011-07-18 22:45:22 +0200 |
|---|---|---|
| committer | Joakim Verona | 2011-07-18 22:45:22 +0200 |
| commit | d202b5a0bae129aff4af5db194603e055d29440c (patch) | |
| tree | 0e147433430bf9882b5a29262cb6aa13303a8e68 | |
| parent | cd1f21dd9e794a14aa6907296c6ee95cc5f693a1 (diff) | |
| download | emacs-d202b5a0bae129aff4af5db194603e055d29440c.tar.gz emacs-d202b5a0bae129aff4af5db194603e055d29440c.zip | |
support for disabling plugins(flash is undesirable) in webkit
| -rw-r--r-- | README.xwidget | 2 | ||||
| -rw-r--r-- | lisp/xwidget.el | 51 | ||||
| -rw-r--r-- | src/xwidget.c | 17 |
3 files changed, 52 insertions, 18 deletions
diff --git a/README.xwidget b/README.xwidget index 783e9605ad5..1ff79d958d6 100644 --- a/README.xwidget +++ b/README.xwidget | |||
| @@ -24,7 +24,7 @@ The xwidget code attempts to keep the visual appearance of the views | |||
| 24 | in sync with through an Observer pattern implementation. | 24 | in sync with through an Observer pattern implementation. |
| 25 | 25 | ||
| 26 | ** building | 26 | ** building |
| 27 | bzr co bzr+ssh://jave@bzr.savannah.gnu.org/emacs/xwidget/ | 27 | bzr co bzr+ssh://bzr.savannah.gnu.org/emacs/xwidget/ |
| 28 | export CFLAGS=" -g -DGLYPH_DEBUG=1" | 28 | export CFLAGS=" -g -DGLYPH_DEBUG=1" |
| 29 | #export CFLAGS="-g" | 29 | #export CFLAGS="-g" |
| 30 | ./configure --with-x-toolkit=gtk3 --with-xwidgets | 30 | ./configure --with-x-toolkit=gtk3 --with-xwidgets |
diff --git a/lisp/xwidget.el b/lisp/xwidget.el index b389265692e..93dafea7df9 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el | |||
| @@ -12,12 +12,17 @@ see xwidget.c for types suitable for TYPE. | |||
| 12 | " | 12 | " |
| 13 | (goto-char pos) | 13 | (goto-char pos) |
| 14 | (let ((id (make-xwidget (point) (point) type title width height nil))) | 14 | (let ((id (make-xwidget (point) (point) type title width height nil))) |
| 15 | (put-text-property (point) (+ 1 (point)) 'display (list 'xwidget ':xwidget id)) | 15 | (put-text-property (point) |
| 16 | (+ 1 (point)) 'display (list 'xwidget ':xwidget id)) | ||
| 17 | |||
| 16 | id)) | 18 | id)) |
| 17 | 19 | ||
| 20 | |||
| 18 | (defun xwidget-at (pos) | 21 | (defun xwidget-at (pos) |
| 19 | (car (cdr (cdr (get-text-property pos 'display))) | 22 | (car (cdr (cdr (get-text-property pos 'display))))) |
| 20 | )) | 23 | |
| 24 | |||
| 25 | |||
| 21 | 26 | ||
| 22 | (defun xwidget-socket-handler () | 27 | (defun xwidget-socket-handler () |
| 23 | "creates plug for socket. TODO" | 28 | "creates plug for socket. TODO" |
| @@ -37,9 +42,9 @@ see xwidget.c for types suitable for TYPE. | |||
| 37 | ;; (start-process "xembed" "*xembed*" (format "%ssrc/emacs" default-directory) "-q" "--parent-id" (number-to-string xembed-id) ) ) | 42 | ;; (start-process "xembed" "*xembed*" (format "%ssrc/emacs" default-directory) "-q" "--parent-id" (number-to-string xembed-id) ) ) |
| 38 | ;; ((eq 5 xwidget-id) | 43 | ;; ((eq 5 xwidget-id) |
| 39 | ;; (start-process "xembed2" "*xembed2*" "uzbl-core" "-s" (number-to-string xembed-id) "http://www.fsf.org" ) ) | 44 | ;; (start-process "xembed2" "*xembed2*" "uzbl-core" "-s" (number-to-string xembed-id) "http://www.fsf.org" ) ) |
| 40 | 45 | ))))) | |
| 41 | ) | 46 | |
| 42 | )))) | 47 | |
| 43 | 48 | ||
| 44 | 49 | ||
| 45 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 50 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| @@ -59,20 +64,25 @@ defaults to the string looking like a url around the cursor position." | |||
| 59 | (xwidget-webkit-goto-url url)))) | 64 | (xwidget-webkit-goto-url url)))) |
| 60 | 65 | ||
| 61 | 66 | ||
| 67 | |||
| 62 | ;;todo. | 68 | ;;todo. |
| 63 | ;; - support browse-url with xwidget-webkit | 69 | ;; - support browse-url with xwidget-webkit |
| 64 | ;; - check that the webkit support is compiled in | 70 | ;; - check that the webkit support is compiled in |
| 65 | (define-derived-mode xwidget-webkit-mode | ||
| 66 | special-mode "xwidget-webkit" "xwidget webkit view mode" | ||
| 67 | (setq buffer-read-only t)) | ||
| 68 | (defvar xwidget-webkit-mode-map | 71 | (defvar xwidget-webkit-mode-map |
| 69 | (let ((map (make-sparse-keymap))) | 72 | (let ((map (make-sparse-keymap))) |
| 70 | (define-key map "g" 'xwidget-webkit-browse-url) | 73 | (define-key map "g" 'xwidget-webkit-browse-url) |
| 71 | (define-key map "a" 'xwidget-webkit-adjust-size-to-content) | 74 | (define-key map "a" 'xwidget-webkit-adjust-size-to-content) |
| 72 | (define-key map "\C-m" 'xwidget-webkit-insert-string) | 75 | (define-key map "\C-m" 'xwidget-webkit-insert-string) |
| 73 | map) | 76 | map) |
| 77 | |||
| 74 | "Keymap for `xwidget-webkit-mode'.") | 78 | "Keymap for `xwidget-webkit-mode'.") |
| 75 | 79 | ||
| 80 | |||
| 81 | |||
| 82 | (define-derived-mode xwidget-webkit-mode | ||
| 83 | special-mode "xwidget-webkit" "xwidget webkit view mode" | ||
| 84 | (setq buffer-read-only t)) | ||
| 85 | |||
| 76 | (defvar xwidget-webkit-last-session-buffer nil) | 86 | (defvar xwidget-webkit-last-session-buffer nil) |
| 77 | 87 | ||
| 78 | (defun xwidget-webkit-last-session () | 88 | (defun xwidget-webkit-last-session () |
| @@ -86,8 +96,8 @@ defaults to the string looking like a url around the cursor position." | |||
| 86 | ;;xwidgets doesnt support widgets that have thoir own opinions about size well yet | 96 | ;;xwidgets doesnt support widgets that have thoir own opinions about size well yet |
| 87 | ;;this reads the size and sets it back | 97 | ;;this reads the size and sets it back |
| 88 | (let ((size (xwidget-size-request xw))) | 98 | (let ((size (xwidget-size-request xw))) |
| 89 | (xwidget-resize xw (car size) (cadr size))) | 99 | (xwidget-resize xw (car size) (cadr size)))) |
| 90 | ) | 100 | |
| 91 | 101 | ||
| 92 | (defun xwidget-webkit-insert-string (xw str) | 102 | (defun xwidget-webkit-insert-string (xw str) |
| 93 | (interactive (list (xwidget-webkit-last-session) | 103 | (interactive (list (xwidget-webkit-last-session) |
| @@ -96,8 +106,8 @@ defaults to the string looking like a url around the cursor position." | |||
| 96 | 106 | ||
| 97 | (defun xwidget-webkit-adjust-size-to-content () | 107 | (defun xwidget-webkit-adjust-size-to-content () |
| 98 | (interactive) | 108 | (interactive) |
| 99 | ( xwidget-adjust-size-to-content ( xwidget-webkit-last-session)) | 109 | ( xwidget-adjust-size-to-content ( xwidget-webkit-last-session))) |
| 100 | ) | 110 | |
| 101 | 111 | ||
| 102 | (defun xwidget-webkit-new-session (url) | 112 | (defun xwidget-webkit-new-session (url) |
| 103 | 113 | ||
| @@ -108,10 +118,8 @@ defaults to the string looking like a url around the cursor position." | |||
| 108 | (insert " ") | 118 | (insert " ") |
| 109 | (xwidget-insert 1 'webkit-osr bufname 1000 1000) | 119 | (xwidget-insert 1 'webkit-osr bufname 1000 1000) |
| 110 | (xwidget-webkit-mode) | 120 | (xwidget-webkit-mode) |
| 111 | (xwidget-webkit-goto-uri ( xwidget-webkit-last-session) url )) | 121 | (xwidget-webkit-goto-uri ( xwidget-webkit-last-session) url ))) |
| 112 | |||
| 113 | 122 | ||
| 114 | ) | ||
| 115 | 123 | ||
| 116 | (defun xwidget-webkit-goto-url (url) | 124 | (defun xwidget-webkit-goto-url (url) |
| 117 | (if ( xwidget-webkit-last-session) | 125 | (if ( xwidget-webkit-last-session) |
| @@ -132,7 +140,18 @@ defaults to the string looking like a url around the cursor position." | |||
| 132 | (redraw-display);;redraw display otherwise ghost of zombies will remain to haunt the screen | 140 | (redraw-display);;redraw display otherwise ghost of zombies will remain to haunt the screen |
| 133 | ) | 141 | ) |
| 134 | 142 | ||
| 143 | |||
| 144 | |||
| 135 | ;;this is a workaround because I cant find the right place to put it in C | 145 | ;;this is a workaround because I cant find the right place to put it in C |
| 136 | (add-hook 'window-configuration-change-hook 'xwidget-cleanup) | 146 | (add-hook 'window-configuration-change-hook 'xwidget-cleanup) |
| 137 | 147 | ||
| 148 | (defvar xwidget-webkit-kill-flash-oneshot nil) | ||
| 149 | (defun xwidget-webkit-kill-flash () | ||
| 150 | ;;you can only call this once or webkit crashes and takes emacs with it. odd. | ||
| 151 | (unless xwidget-webkit-kill-flash-oneshot | ||
| 152 | (xwidget-disable-plugin-for-mime "application/x-shockwave-flash") | ||
| 153 | (setq xwidget-webkit-kill-flash-oneshot t))) | ||
| 154 | |||
| 155 | (xwidget-webkit-kill-flash) | ||
| 156 | |||
| 138 | (provide 'xwidget) | 157 | (provide 'xwidget) |
diff --git a/src/xwidget.c b/src/xwidget.c index 263e8553ca9..c75f9bbd83e 100644 --- a/src/xwidget.c +++ b/src/xwidget.c | |||
| @@ -93,6 +93,9 @@ | |||
| 93 | 93 | ||
| 94 | #ifdef HAVE_WEBKIT_OSR | 94 | #ifdef HAVE_WEBKIT_OSR |
| 95 | #include <webkit/webkitwebview.h> | 95 | #include <webkit/webkitwebview.h> |
| 96 | #include <webkit/webkitwebplugindatabase.h> | ||
| 97 | #include <webkit/webkitwebplugin.h> | ||
| 98 | #include <webkit/webkitglobals.h> | ||
| 96 | #endif | 99 | #endif |
| 97 | 100 | ||
| 98 | #include "xwidget.h" | 101 | #include "xwidget.h" |
| @@ -808,7 +811,18 @@ DEFUN("xwidget-delete-zombies", Fxwidget_delete_zombies , Sxwidget_delete_zombie | |||
| 808 | } | 811 | } |
| 809 | } | 812 | } |
| 810 | 813 | ||
| 811 | 814 | DEFUN("xwidget-disable-plugin-for-mime", Fxwidget_disable_plugin_for_mime , Sxwidget_disable_plugin_for_mime, 1,1,0, doc: /* */) | |
| 815 | (Lisp_Object mime) | ||
| 816 | { | ||
| 817 | WebKitWebPlugin *wp = webkit_web_plugin_database_get_plugin_for_mimetype | ||
| 818 | (webkit_get_web_plugin_database(), SDATA(mime)); | ||
| 819 | if(wp == NULL) return Qnil; | ||
| 820 | if(webkit_web_plugin_get_enabled (wp)){ | ||
| 821 | webkit_web_plugin_set_enabled (wp, FALSE); | ||
| 822 | return Qt; | ||
| 823 | } | ||
| 824 | return Qnil; | ||
| 825 | } | ||
| 812 | 826 | ||
| 813 | void | 827 | void |
| 814 | syms_of_xwidget (void) | 828 | syms_of_xwidget (void) |
| @@ -827,6 +841,7 @@ syms_of_xwidget (void) | |||
| 827 | defsubr (&Sxwidget_webkit_get_title); | 841 | defsubr (&Sxwidget_webkit_get_title); |
| 828 | defsubr (&Sxwidget_size_request ); | 842 | defsubr (&Sxwidget_size_request ); |
| 829 | defsubr (&Sxwidget_delete_zombies); | 843 | defsubr (&Sxwidget_delete_zombies); |
| 844 | defsubr (&Sxwidget_disable_plugin_for_mime); | ||
| 830 | DEFSYM (Qxwidget ,"xwidget"); | 845 | DEFSYM (Qxwidget ,"xwidget"); |
| 831 | 846 | ||
| 832 | DEFSYM (Qcxwidget ,":xwidget"); | 847 | DEFSYM (Qcxwidget ,":xwidget"); |