summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorBenoit Hiller2013-03-12 20:50:59 (EDT)
committer Grant Gayed2013-03-13 10:01:44 (EDT)
commita587ccebeb14f1a19c8e7d1be250201c28af863c (patch)
tree77c5c7a57c674f1d97058bbcd5223f80b27018f7
parent9b66864a124cfaa40908a43ae368184c34689b61 (diff)
downloadeclipse.platform.swt-a587ccebeb14f1a19c8e7d1be250201c28af863c.zip
eclipse.platform.swt-a587ccebeb14f1a19c8e7d1be250201c28af863c.tar.gz
eclipse.platform.swt-a587ccebeb14f1a19c8e7d1be250201c28af863c.tar.bz2
adding location event
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java53
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFClient.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFLoadHandler.java18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFFrame.java4
4 files changed, 56 insertions, 21 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java
index bb3035f..12fffa8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java
@@ -185,6 +185,27 @@ static String ExtractCEFString(long /*int*/ stringPointer) {
return new String(chars);
}
+public static String getUrl(CEFFrame frame) {
+ long /*int*/ url = frame.get_url();
+ String javaStringUrl = ExtractCEFString(url);
+
+ /*
+ * If the URI indicates that the page is being rendered from memory
+ * (via setText()) then set it to about:blank to be consistent with IE.
+ */
+ if (javaStringUrl.equals (URI_FILEROOT)) {
+ javaStringUrl = ABOUT_BLANK;
+ } else {
+ int length = URI_FILEROOT.length ();
+ if (javaStringUrl.startsWith (URI_FILEROOT) && javaStringUrl.charAt (length) == '#') {
+ javaStringUrl = ABOUT_BLANK + javaStringUrl.substring (length);
+ }
+ }
+ return javaStringUrl;
+}
+
+
+
static boolean IsInstalled() {
if (!LibraryLoaded) return false;
// TODO if CEF3 has API to get its version then verify that it is supported, for now assume that it is
@@ -314,23 +335,7 @@ public String getUrl() {
}
CEFFrame frame = new CEFFrame(result);
- long /*int*/ url = frame.get_url();
- String javaStringUrl = ExtractCEFString(url);
-
- /*
- * If the URI indicates that the page is being rendered from memory
- * (via setText()) then set it to about:blank to be consistent with IE.
- */
- if (javaStringUrl.equals (URI_FILEROOT)) {
- javaStringUrl = ABOUT_BLANK;
- } else {
- int length = URI_FILEROOT.length ();
- if (javaStringUrl.startsWith (URI_FILEROOT) && javaStringUrl.charAt (length) == '#') {
- javaStringUrl = ABOUT_BLANK + javaStringUrl.substring (length);
- }
- }
-
- return javaStringUrl;
+ return getUrl(frame);
}
public boolean isBackEnabled() {
@@ -353,11 +358,23 @@ void onDispose(Event e) {
// TODO more clean up
}
+
void onResize() {
Rectangle bounds = browser.getClientArea();
OS.SetWindowPos(windowHandle, 0, bounds.x, bounds.y, bounds.width, bounds.height, OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE | OS.SWP_ASYNCWINDOWPOS);
}
-
+
+public void onLocationChange(String location, boolean top) {
+ LocationEvent event = new LocationEvent(browser);
+ event.display = browser.getDisplay ();
+ event.widget = browser;
+ event.location = location;
+ event.top = top;
+ for (int i=0; i < locationListeners.length; i++) {
+ locationListeners[i].changed (event);
+ }
+}
+
public void refresh() {
if (cefBrowser == null) return;
cefBrowser.reload();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFClient.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFClient.java
index 040d75b..29fe908 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFClient.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFClient.java
@@ -164,7 +164,7 @@ long /*int*/ get_life_span_handler() {
long /*int*/ get_load_handler() {
if (Device.DEBUG) System.out.println("get_load_handler (impl)");
if (loadHandler == null) {
- loadHandler = new CEFLoadHandler();
+ loadHandler = new CEFLoadHandler(host);
}
loadHandler.add_ref();
return loadHandler.getAddress();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFLoadHandler.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFLoadHandler.java
index d193064..aa01a18 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFLoadHandler.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFLoadHandler.java
@@ -12,12 +12,16 @@ package org.eclipse.swt.browser;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.internal.cef3.CEF3Object;
+import org.eclipse.swt.internal.cef3.CEFFrame;
+import org.eclipse.swt.widgets.Display;
public class CEFLoadHandler {
CEF3Object object;
+ CEF host;
int refCount = 1;
-public CEFLoadHandler() {
+public CEFLoadHandler(CEF host) {
+ this.host = host;
object = new CEF3Object (new int[] {0, 0, 0, 2, 3, 5, 2, 2}) {
public long /*int*/ method0(long /*int*/[] args) {return add_ref();}
public long /*int*/ method1(long /*int*/[] args) {return CEFLoadHandler.this.release();}
@@ -59,7 +63,17 @@ synchronized int release() {
/* cef_load_handler_t */
long /*int*/ on_load_start(long /*int*/ browser, long /*int*/ frame) {
- if (Device.DEBUG) System.out.println("on_load_start (TODO)");
+ if (Device.DEBUG) System.out.println("on_load_start (impl)");
+
+ CEFFrame cefFrame = new CEFFrame(frame);
+ final String location = CEF.getUrl(cefFrame);
+ final boolean top = cefFrame.is_main() == 1;
+
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ host.onLocationChange(location, top);
+ }
+ });
return 0;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFFrame.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFFrame.java
index b7711d8..c936dde 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFFrame.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEFFrame.java
@@ -28,4 +28,8 @@ public long /*int*/ get_url() {
return CEF3.callFuncPtr(struct.get_url, address);
}
+public long /*int*/ is_main() {
+ return CEF3.callFuncInt(struct.is_main, address);
+}
+
}