3

I'm using SWT Browser based on XULRUNNER 10.0 in Eclipse 3.8.

I want to configure the embedded browser for enable the access to system clipboard by javascript.

In my web application running on the embedded Browser I use CKeditor 3 and I want to use the copy/cut/paste functions.

I can't use JavaXPCOM interface because for the version 10.0 of XULRunner is not supported.

How can I achieve this programmatically or even by configuration file?

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126

1 Answers1

0

You have to set certain preferences to the xulrunner engine.

At first you have to access the prefs.js file for the xulrunner. This can be done with the following snippet:

Class<?> loadClass = Activator.getDefault().getClass()
        .getClassLoader()
        .loadClass("org.eclipse.swt.browser.MozillaDelegate");
Method declaredMethod = loadClass
        .getDeclaredMethod("getProfilePath");
declaredMethod.setAccessible(true);
String profilePath = (String) declaredMethod.invoke(null);
File userPrefs = new File(profilePath + File.separator + "prefs.js"))

In this file you have to set the following key-values:

capability.policy.policynames, allowclipboard
capability.policy.allowclipboard.Clipboard.cutcopy,allAccess
capability.policy.allowclipboard.Clipboard.paste,allAccess
capability.policy.allowclipboard.sites,file://

See also http://kb.mozillazine.org/Granting_JavaScript_access_to_the_clipboard

Note: This is only working if your website is local. Otherwise you have to add the domains to the capability.policy.allowclipboard.sites key.

Tom Seidel
  • 9,525
  • 1
  • 26
  • 38