Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2011-01-20 20:26:09 +0000
committerLakshmi Shanmugam2011-01-20 20:26:09 +0000
commit478edeb5845364e73b9a63bf7615144091d8042f (patch)
tree466687e47153282b2f7381cd518891b740f38cb8 /bundles/org.eclipse.swt/Eclipse SWT WebKit
parent8f69618fc3b877d652c7fe2fd695fbdc73e7c8ea (diff)
downloadeclipse.platform.swt-478edeb5845364e73b9a63bf7615144091d8042f.tar.gz
eclipse.platform.swt-478edeb5845364e73b9a63bf7615144091d8042f.tar.xz
eclipse.platform.swt-478edeb5845364e73b9a63bf7615144091d8042f.zip
use separate preferences for webviews
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT WebKit')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebKit.java45
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/internal/webkit/IWebPreferences.java4
2 files changed, 39 insertions, 10 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebKit.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebKit.java
index c97cb90fc7..5f1e3b2f5b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebKit.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebKit.java
@@ -43,6 +43,7 @@ class WebKit extends WebBrowser {
String lastNavigateURL;
BrowserFunction eventFunction;
+ static int prefsIdentifier;
static int /*long*/ ExternalClass;
static boolean LibraryLoaded = false;
static String LibraryLoadError;
@@ -601,16 +602,7 @@ public void create (Composite parent, int style) {
error (hr);
}
- result[0] = 0;
- hr = webView.preferences (result);
- if (hr == COM.S_OK && result[0] != 0) {
- IWebPreferences preferences = new IWebPreferences (result[0]);
- preferences.setJavaScriptCanOpenWindowsAutomatically (1);
- preferences.setJavaEnabled (0); /* disable applets */
- preferences.setTabsToLinks (1);
- preferences.setFontSmoothing (WebKit_win32.FontSmoothingTypeWindows);
- preferences.Release ();
- }
+ initializeWebViewPreferences ();
Listener listener = new Listener () {
public void handleEvent (Event e) {
@@ -1041,6 +1033,7 @@ void onDispose () {
eventFunction = null;
C.free (webViewData);
+ webView.setPreferences (0);
webView.setHostWindow (0);
webView.setFrameLoadDelegate (0);
webView.setResourceLoadDelegate (0);
@@ -1277,4 +1270,36 @@ public void stop () {
webIBActions.Release ();
}
+void initializeWebViewPreferences () {
+ /*
+ * Try to create separate preferences for each webview using different identifier for each webview.
+ * Otherwise all the webviews use the shared preferences.
+ */
+ int /*long*/[] result = new int /*long*/[1];
+ int hr = WebKit_win32.WebKitCreateInstance (WebKit_win32.CLSID_WebPreferences, 0, WebKit_win32.IID_IWebPreferences, result);
+ if (hr == COM.S_OK && result[0] != 0) {
+ IWebPreferences preferences = new IWebPreferences (result[0]);
+ result[0] = 0;
+ hr = preferences.initWithIdentifier (createBSTR (String.valueOf (prefsIdentifier++)), result);
+ preferences.Release ();
+ if (hr == COM.S_OK && result[0] != 0) {
+ preferences = new IWebPreferences (result[0]);
+ webView.setPreferences (preferences.getAddress());
+ preferences.Release ();
+ }
+ }
+
+ result[0] = 0;
+ hr = webView.preferences (result);
+ if (hr == COM.S_OK && result[0] != 0) {
+ IWebPreferences preferences = new IWebPreferences (result[0]);
+ preferences.setJavaScriptEnabled (1);
+ preferences.setJavaScriptCanOpenWindowsAutomatically (1);
+ preferences.setJavaEnabled (0); /* disable applets */
+ preferences.setTabsToLinks (1);
+ preferences.setFontSmoothing (WebKit_win32.FontSmoothingTypeWindows);
+ preferences.Release ();
+ }
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/internal/webkit/IWebPreferences.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/internal/webkit/IWebPreferences.java
index 1e2f044431..1e26b21fa6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/internal/webkit/IWebPreferences.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/internal/webkit/IWebPreferences.java
@@ -19,6 +19,10 @@ public IWebPreferences (int /*long*/ address) {
super (address);
}
+public int initWithIdentifier (int /*long*/ identifier, int /*long*/[] preferences) {
+ return COM.VtblCall (4, getAddress (), identifier, preferences);
+}
+
public int setJavaEnabled (int enabled) {
return COM.VtblCall (33, getAddress (), enabled);
}

Back to the top