diff options
author | Grant Gayed <ggayed> | 2009-11-13 19:08:04 +0000 |
---|---|---|
committer | Grant Gayed <ggayed> | 2009-11-13 19:08:04 +0000 |
commit | 5d553beb026a9c36ce49081735e3a236e6013699 (patch) | |
tree | 8362b9686ab38f97f576023a9d224c263d4fa3ff /bundles | |
parent | a0a9d258e4ba6447d350edb2b6535418f42f6638 (diff) | |
download | eclipse.platform.swt-5d553beb026a9c36ce49081735e3a236e6013699.tar.gz eclipse.platform.swt-5d553beb026a9c36ce49081735e3a236e6013699.tar.xz eclipse.platform.swt-5d553beb026a9c36ce49081735e3a236e6013699.zip |
278299 - SWT Browser (IE based) to support multiple zones
Diffstat (limited to 'bundles')
12 files changed, 161 insertions, 71 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java index 30782f784d..d03315616f 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java @@ -31,7 +31,7 @@ class Safari extends WebBrowser { int windowBoundsHandler; int preferences; - boolean changingLocation, hasNewFocusElement; + boolean changingLocation, hasNewFocusElement, untrustedText; String lastHoveredLinkURL, lastNavigateURL; String html; int identifier; @@ -51,7 +51,7 @@ class Safari extends WebBrowser { static final int MAX_PROGRESS = 100; static final String WebElementLinkURLKey = "WebElementLinkURL"; //$NON-NLS-1$ static final String AGENT_STRING = "Safari/412.0"; /* Safari version on OSX 10.4 initial release */ //$NON-NLS-1$ - static final String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$ + static final String URI_FILEROOT = "file:///"; //$NON-NLS-1$ static final String PROTOCOL_FILE = "file://"; //$NON-NLS-1$ static final String PROTOCOL_HTTP = "http://"; //$NON-NLS-1$ static final String URI_APPLEWEBDATA = "applewebdata://"; //$NON-NLS-1$ @@ -754,7 +754,7 @@ public void refresh() { Cocoa.objc_msgSend(webView, Cocoa.S_reload, 0); } -public boolean setText(String html) { +public boolean setText(String html, boolean trusted) { /* * Bug in Safari. The web view segment faults in some circumstances * when the text changes during the location changing callback. The @@ -762,16 +762,22 @@ public boolean setText(String html) { */ if (changingLocation) { this.html = html; + untrustedText = !trusted; } else { - _setText(html); + _setText(html, !trusted); } return true; } -void _setText(String html) { +void _setText(String html, boolean untrusted) { int string = createNSString(html); - int URLString = createNSString(URI_FROMMEMORY); - + int URLString; + if (untrusted) { + URLString = createNSString(ABOUT_BLANK); + } else { + URLString = createNSString(URI_FILEROOT); + } + /* * Note. URLWithString uses autorelease. The resulting URL * does not need to be released. @@ -871,9 +877,13 @@ void didChangeLocationWithinPageForFrame(int frame) { int dataSource = Cocoa.objc_msgSend(frame, Cocoa.S_dataSource); int request = Cocoa.objc_msgSend(dataSource, Cocoa.S_request); int url = Cocoa.objc_msgSend(request, Cocoa.S_URL); - int s = Cocoa.objc_msgSend(url, Cocoa.S_absoluteString); + int s = Cocoa.objc_msgSend(url, Cocoa.S_absoluteString); int length = OS.CFStringGetLength(s); if (length == 0) return; + int emptyString = Cocoa.objc_msgSend(Cocoa.C_NSString, Cocoa.S_string); + s = OS.CFURLCreateStringByReplacingPercentEscapes (0, s, emptyString); + OS.CFRelease(emptyString); + length = OS.CFStringGetLength(s); char[] buffer = new char[length]; CFRange range = new CFRange(); range.length = length; @@ -883,11 +893,11 @@ void didChangeLocationWithinPageForFrame(int frame) { * 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 (url2.equals (URI_FROMMEMORY)) { + if (url2.equals (URI_FILEROOT)) { url2 = ABOUT_BLANK; } else { - length = URI_FROMMEMORY.length (); - if (url2.startsWith (URI_FROMMEMORY) && url2.charAt (length) == '#') { + length = URI_FILEROOT.length (); + if (url2.startsWith (URI_FILEROOT) && url2.charAt (length) == '#') { url2 = ABOUT_BLANK + url2.substring (length); } } @@ -1102,6 +1112,10 @@ void didCommitLoadForFrame(int frame) { int s = Cocoa.objc_msgSend(url, Cocoa.S_absoluteString); int length = OS.CFStringGetLength(s); if (length == 0) return; + int emptyString = Cocoa.objc_msgSend(Cocoa.C_NSString, Cocoa.S_string); + s = OS.CFURLCreateStringByReplacingPercentEscapes (0, s, emptyString); + OS.CFRelease(emptyString); + length = OS.CFStringGetLength(s); char[] buffer = new char[length]; CFRange range = new CFRange(); range.length = length; @@ -1111,11 +1125,11 @@ void didCommitLoadForFrame(int frame) { * 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 (url2.equals (URI_FROMMEMORY)) { + if (url2.equals (URI_FILEROOT)) { url2 = ABOUT_BLANK; } else { - length = URI_FROMMEMORY.length (); - if (url2.startsWith (URI_FROMMEMORY) && url2.charAt (length) == '#') { + length = URI_FILEROOT.length (); + if (url2.startsWith (URI_FILEROOT) && url2.charAt (length) == '#') { url2 = ABOUT_BLANK + url2.substring (length); } } @@ -1646,6 +1660,10 @@ void mouseDidMoveOverElement (int elementInformation, int modifierFlags) { if (length == 0) { urlString = ""; //$NON-NLS-1$ } else { + int emptyString = Cocoa.objc_msgSend(Cocoa.C_NSString, Cocoa.S_string); + stringPtr = OS.CFURLCreateStringByReplacingPercentEscapes (0, stringPtr, emptyString); + OS.CFRelease(emptyString); + length = OS.CFStringGetLength(stringPtr); char[] chars = new char[length]; CFRange range = new CFRange(); range.length = length; @@ -1679,6 +1697,9 @@ void decidePolicyForNavigationAction(int actionInformation, int request, int fra return; } int s = Cocoa.objc_msgSend(url, Cocoa.S_absoluteString); + int emptyString = Cocoa.objc_msgSend(Cocoa.C_NSString, Cocoa.S_string); + s = OS.CFURLCreateStringByReplacingPercentEscapes (0, s, emptyString); + OS.CFRelease(emptyString); int length = OS.CFStringGetLength(s); char[] buffer = new char[length]; CFRange range = new CFRange(); @@ -1689,11 +1710,11 @@ void decidePolicyForNavigationAction(int actionInformation, int request, int fra * 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 (url2.equals (URI_FROMMEMORY)) { + if (url2.equals (URI_FILEROOT)) { url2 = ABOUT_BLANK; } else { - length = URI_FROMMEMORY.length (); - if (url2.startsWith (URI_FROMMEMORY) && url2.charAt (length) == '#') { + length = URI_FILEROOT.length (); + if (url2.startsWith (URI_FILEROOT) && url2.charAt (length) == '#') { url2 = ABOUT_BLANK + url2.substring (length); } } @@ -1732,7 +1753,7 @@ void decidePolicyForNavigationAction(int actionInformation, int request, int fra if (html != null && !browser.isDisposed()) { String html = this.html; this.html = null; - _setText(html); + _setText(html, untrustedText); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java index 58e3138e87..07b68180d0 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java @@ -23,7 +23,7 @@ class Safari extends WebBrowser { WebView webView; WebPreferences preferences; SWTWebViewDelegate delegate; - boolean changingLocation; + boolean changingLocation, untrustedText; String lastHoveredLinkURL, lastNavigateURL; String html; int /*long*/ identifier; @@ -45,7 +45,7 @@ class Safari extends WebBrowser { static final int MAX_PROGRESS = 100; static final String WebElementLinkURLKey = "WebElementLinkURL"; //$NON-NLS-1$ static final String AGENT_STRING = "Safari/522.0"; /* Safari version on OSX 10.5 initial release */ //$NON-NLS-1$ - static final String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$ + static final String URI_FILEROOT = "file:///"; //$NON-NLS-1$ static final String PROTOCOL_FILE = "file://"; //$NON-NLS-1$ static final String PROTOCOL_HTTP = "http://"; //$NON-NLS-1$ static final String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$ @@ -486,23 +486,29 @@ public void refresh() { webView.reload(null); } -public boolean setText(String html) { +public boolean setText(String html, boolean trusted) { /* * Bug in Safari. The web view segment faults in some circumstances * when the text changes during the location changing callback. The * fix is to defer the work until the callback is done. */ if (changingLocation) { + untrustedText = !trusted; this.html = html; } else { - _setText(html); + _setText(html, !trusted); } return true; } -void _setText(String html) { +void _setText(String html, boolean untrusted) { NSString string = NSString.stringWith(html); - NSString URLString = NSString.stringWith(URI_FROMMEMORY); + NSString URLString; + if (untrusted) { + URLString = NSString.stringWith(ABOUT_BLANK); + } else { + URLString = NSString.stringWith(URI_FILEROOT); + } NSURL URL = NSURL.URLWithString(URLString); WebFrame mainFrame = webView.mainFrame(); mainFrame.loadHTMLString(string, URL); @@ -575,16 +581,18 @@ void webView_didChangeLocationWithinPageForFrame(int /*long*/ sender, int /*long NSString s = url.absoluteString(); int length = (int)/*64*/s.length(); if (length == 0) return; - String url2 = s.getString(); + int /*long*/ ptr = OS.CFURLCreateStringByReplacingPercentEscapesUsingEncoding (0, s.id, NSString.string().id, OS.kCFStringEncodingUTF8); + String url2 = new NSString(ptr).getString(); + OS.CFRelease(ptr); /* * 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 (url2.equals (URI_FROMMEMORY)) { + if (url2.equals (URI_FILEROOT)) { url2 = ABOUT_BLANK; } else { - length = URI_FROMMEMORY.length (); - if (url2.startsWith (URI_FROMMEMORY) && url2.charAt (length) == '#') { + length = URI_FILEROOT.length (); + if (url2.startsWith (URI_FILEROOT) && url2.charAt (length) == '#') { url2 = ABOUT_BLANK + url2.substring (length); } } @@ -774,16 +782,18 @@ void webView_didCommitLoadForFrame(int /*long*/ sender, int /*long*/ frameID) { NSString s = url.absoluteString(); int length = (int)/*64*/s.length(); if (length == 0) return; - String url2 = s.getString(); + int /*long*/ ptr = OS.CFURLCreateStringByReplacingPercentEscapesUsingEncoding (0, s.id, NSString.string().id, OS.kCFStringEncodingUTF8); + String url2 = new NSString(ptr).getString(); + OS.CFRelease(ptr); /* * 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 (url2.equals (URI_FROMMEMORY)) { + if (url2.equals (URI_FILEROOT)) { url2 = ABOUT_BLANK; } else { - length = URI_FROMMEMORY.length (); - if (url2.startsWith (URI_FROMMEMORY) && url2.charAt (length) == '#') { + length = URI_FILEROOT.length (); + if (url2.startsWith (URI_FILEROOT) && url2.charAt (length) == '#') { url2 = ABOUT_BLANK + url2.substring (length); } } @@ -1274,7 +1284,9 @@ void webView_mouseDidMoveOverElement_modifierFlags (int /*long*/ sender, int /*l if (length == 0) { urlString = ""; //$NON-NLS-1$ } else { - urlString = url.getString(); + int /*long*/ ptr = OS.CFURLCreateStringByReplacingPercentEscapesUsingEncoding (0, url.id, NSString.string().id, OS.kCFStringEncodingUTF8); + urlString = new NSString(ptr).getString(); + OS.CFRelease(ptr); } if (urlString.equals(lastHoveredLinkURL)) return; @@ -1321,16 +1333,18 @@ void webView_decidePolicyForNavigationAction_request_frame_decisionListener(int return; } NSString s = url.absoluteString(); - String url2 = s.getString(); + int /*long*/ ptr = OS.CFURLCreateStringByReplacingPercentEscapesUsingEncoding (0, s.id, NSString.string().id, OS.kCFStringEncodingUTF8); + String url2 = new NSString(ptr).getString(); + OS.CFRelease(ptr); /* * 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 (url2.equals (URI_FROMMEMORY)) { + if (url2.equals (URI_FILEROOT)) { url2 = ABOUT_BLANK; } else { - int length = URI_FROMMEMORY.length (); - if (url2.startsWith (URI_FROMMEMORY) && url2.charAt (length) == '#') { + int length = URI_FILEROOT.length (); + if (url2.startsWith (URI_FILEROOT) && url2.charAt (length) == '#') { url2 = ABOUT_BLANK + url2.substring (length); } } @@ -1364,7 +1378,7 @@ void webView_decidePolicyForNavigationAction_request_frame_decisionListener(int if (html != null && !browser.isDisposed()) { String html = this.html; this.html = null; - _setText(html); + _setText(html, untrustedText); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java index 9227805dc9..808d255d72 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java @@ -948,8 +948,10 @@ public void setJavascriptEnabled (boolean enabled) { /** * Renders a string containing HTML. The rendering of the content occurs asynchronously. + * The rendered page will be given trusted permissions; to render the page with untrusted + * permissions use <code>setText(String html, boolean trusted)</code> instead. * <p> - * The html parameter is Unicode encoded since it is a java <code>String</code>. + * The html parameter is Unicode-encoded since it is a java <code>String</code>. * As a result, the HTML meta tag charset should not be set. The charset is implied * by the <code>String</code> itself. * @@ -966,14 +968,56 @@ public void setJavascriptEnabled (boolean enabled) { * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> * + * @see #setText(String,boolean) * @see #setUrl * * @since 3.0 */ public boolean setText (String html) { checkWidget(); + return setText (html, true); +} + +/** + * Renders a string containing HTML. The rendering of the content occurs asynchronously. + * The rendered page can be given either trusted or untrusted permissions. + * <p> + * The html parameter is Unicode-encoded since it is a java <code>String</code>. + * As a result, the HTML meta tag charset should not be set. The charset is implied + * by the <code>String</code> itself. + * <p> + * The trusted parameter affects the permissions that will be granted to the rendered + * page. Specifying <code>true</code> for trusted gives the page permissions equivalent + * to a page on the local file system, while specifying <code>false</code> for trusted + * gives the page permissions equivalent to a page from the internet. Page content should + * be specified as trusted if the invoker created it or trusts its source, since this would + * allow (for instance) style sheets on the local file system to be referenced. Page + * content should be specified as untrusted if its source is not trusted or is not known. + * + * @param html the HTML content to be rendered + * @param trusted <code>false</code> if the rendered page should be granted restricted + * permissions and <code>true</code> otherwise + * + * @return true if the operation was successful and false otherwise. + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the html is null</li> + * </ul> + * + * @exception SWTException <ul> + * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> + * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> + * </ul> + * + * @see #setText(String) + * @see #setUrl + * + * @since 3.6 + */ +public boolean setText (String html, boolean trusted) { + checkWidget(); if (html == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - return webBrowser.setText (html); + return webBrowser.setText (html, trusted); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java index 2dbeba10b3..39ea2ed416 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java @@ -610,7 +610,7 @@ public void setBrowser (Browser browser) { this.browser = browser; } -public abstract boolean setText (String html); +public abstract boolean setText (String html, boolean trusted); public abstract boolean setUrl (String url, String postData, String[] headers); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/forms/org/eclipse/swt/browser/IE.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/forms/org/eclipse/swt/browser/IE.java index 03c61fd09e..040b404a39 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/forms/org/eclipse/swt/browser/IE.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/forms/org/eclipse/swt/browser/IE.java @@ -245,7 +245,7 @@ public void refresh() { OS.WebBrowser_Refresh(webBrowser); } -public boolean setText(String html) { +public boolean setText(String html, boolean trusted) { int state = OS.WebBrowser_ReadyState(webBrowser); if (!(state == OS.WebBrowserReadyState_Uninitialized || state == OS.WebBrowserReadyState_Complete)) { OS.WebBrowser_Stop(webBrowser); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/photon/org/eclipse/swt/browser/Voyager.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/photon/org/eclipse/swt/browser/Voyager.java index 2354716706..2798796d5e 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/photon/org/eclipse/swt/browser/Voyager.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/photon/org/eclipse/swt/browser/Voyager.java @@ -443,7 +443,7 @@ public void refresh() { OS.PtSetResource(webHandle, OS.Pt_ARG_WEB_RELOAD, 1, 0); } -public boolean setText(String html) { +public boolean setText(String html, boolean trusted) { text = html; textOffset = 0; byte[] buffer = Converter.wcsToMbcs(null, "client:", true); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java index 45210963db..711626396c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java @@ -28,7 +28,8 @@ class IE extends WebBrowser { OleListener domListener; OleAutomation[] documents = new OleAutomation[0]; - boolean back, forward, navigate, delaySetText, ignoreDispose, installFunctionsOnDocumentComplete; + boolean back, forward, navigate, delaySetText, ignoreDispose; + boolean installFunctionsOnDocumentComplete, untrustedText; Point location; Point size; boolean addressBar = true, menuBar = true, statusBar = true, toolBar = true; @@ -1162,7 +1163,7 @@ void setHTML (String string) { } } -public boolean setText(final String html) { +public boolean setText(final String html, boolean trusted) { /* * If the html field is non-null then the about:blank page is already being * loaded, so no Stop or Navigate is required. Just set the html that is to @@ -1170,6 +1171,7 @@ public boolean setText(final String html) { */ boolean blankLoading = this.html != null; this.html = html; + untrustedText = !trusted; if (blankLoading) return true; /* diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/WebSite.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/WebSite.java index f2a92a4639..ba41584778 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/WebSite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/WebSite.java @@ -496,7 +496,7 @@ int MapUrlToZone(int /*long*/ pwszUrl, int /*long*/ pdwZone, int dwFlags) { * For some reason IE8 invokes this function after the Browser has * been disposed. To detect this case check for ie.auto != null. */ - if (ie.auto != null && ie.getUrl().startsWith(IE.ABOUT_BLANK)) { + if (ie.auto != null && ie.getUrl().startsWith(IE.ABOUT_BLANK) && !ie.untrustedText) { COM.MoveMemory(pdwZone, new int[] {IE.URLZONE_INTRANET}, 4); return COM.S_OK; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/wpf/org/eclipse/swt/browser/IE.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/wpf/org/eclipse/swt/browser/IE.java index 7d4708b294..9ca6733ad0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/wpf/org/eclipse/swt/browser/IE.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/wpf/org/eclipse/swt/browser/IE.java @@ -142,7 +142,7 @@ public void refresh() { OS.Frame_Refresh(frame); } -public boolean setText(String html) { +public boolean setText(String html, boolean trusted) { return true; // /* // * If the html field is non-null then the about:blank page is already being diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java index 4134b43f57..352fa69566 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java @@ -47,7 +47,7 @@ class Mozilla extends WebBrowser { int refCount, lastKeyCode, lastCharCode, authCount; int /*long*/ request; Point location, size; - boolean visible, isChild, ignoreDispose, isRetrievingBadCert, isViewingErrorPage, ignoreAllMessages; + boolean visible, isChild, ignoreDispose, isRetrievingBadCert, isViewingErrorPage, ignoreAllMessages, untrustedText; Shell tip = null; Listener listener; Vector unhookedDOMWindows = new Vector (); @@ -98,7 +98,7 @@ class Mozilla extends WebBrowser { static final String SHUTDOWN_PERSIST = "shutdown-persist"; //$NON-NLS-1$ static final String STARTUP = "startup"; //$NON-NLS-1$ static final String TOKENIZER_LOCALE = ","; //$NON-NLS-1$ - static final String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$ + static final String URI_FILEROOT = "file:///"; //$NON-NLS-1$ static final String XULRUNNER_PATH = "org.eclipse.swt.browser.XULRunnerPath"; //$NON-NLS-1$ // TEMPORARY CODE @@ -1999,11 +1999,11 @@ public String getUrl () { * 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 (location.equals (URI_FROMMEMORY)) { + if (location.equals (URI_FILEROOT)) { location = ABOUT_BLANK; } else { - int length = URI_FROMMEMORY.length (); - if (location.startsWith (URI_FROMMEMORY) && location.charAt (length) == '#') { + int length = URI_FILEROOT.length (); + if (location.startsWith (URI_FILEROOT) && location.charAt (length) == '#') { location = ABOUT_BLANK + location.substring (length); } } @@ -2202,7 +2202,7 @@ void registerFunction (BrowserFunction function) { AllFunctions.put (new Integer (function.index), function); } -public boolean setText (String html) { +public boolean setText (String html, boolean trusted) { /* * Feature in Mozilla. The focus memory of Mozilla must be * properly managed through the nsIWebBrowserFocus interface. @@ -2255,6 +2255,7 @@ public boolean setText (String html) { */ boolean blankLoading = htmlBytes != null; htmlBytes = data; + untrustedText = !trusted; if (blankLoading) return true; /* navigate to about:blank */ @@ -2287,12 +2288,12 @@ public boolean setText (String html) { nsIIOService ioService = new nsIIOService (result[0]); result[0] = 0; - /* - * Note. Mozilla ignores LINK tags used to load CSS stylesheets - * when the URI protocol for the nsInputStreamChannel - * is about:blank. The fix is to specify the file protocol. - */ - byte[] aString = MozillaDelegate.wcsToMbcs (null, URI_FROMMEMORY, false); + byte[] aString; + if (trusted) { + aString = MozillaDelegate.wcsToMbcs (null, URI_FILEROOT, false); + } else { + aString = MozillaDelegate.wcsToMbcs (null, ABOUT_BLANK, false); + } int /*long*/ aSpec = XPCOM.nsEmbedCString_new (aString, aString.length); rc = ioService.NewURI (aSpec, null, 0, result); if (rc != XPCOM.NS_OK) error (rc); @@ -2815,12 +2816,12 @@ int OnStateChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStateF nsIIOService ioService = new nsIIOService (result[0]); result[0] = 0; - /* - * Note. Mozilla ignores LINK tags used to load CSS stylesheets - * when the URI protocol for the nsInputStreamChannel - * is about:blank. The fix is to specify the file protocol. - */ - byte[] aString = MozillaDelegate.wcsToMbcs (null, URI_FROMMEMORY, false); + byte[] aString; + if (untrustedText) { + aString = MozillaDelegate.wcsToMbcs (null, ABOUT_BLANK, false); + } else { + aString = MozillaDelegate.wcsToMbcs (null, URI_FILEROOT, false); + } int /*long*/ aSpec = XPCOM.nsEmbedCString_new (aString, aString.length); rc = ioService.NewURI (aSpec, null, 0, result); if (rc != XPCOM.NS_OK) error (rc); @@ -3053,11 +3054,11 @@ int OnLocationChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int /*lo * 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 (event.location.equals (URI_FROMMEMORY)) { + if (event.location.equals (URI_FILEROOT)) { event.location = ABOUT_BLANK; } else { - length = URI_FROMMEMORY.length (); - if (event.location.startsWith (URI_FROMMEMORY) && event.location.charAt (length) == '#') { + length = URI_FILEROOT.length (); + if (event.location.startsWith (URI_FILEROOT) && event.location.charAt (length) == '#') { event.location = ABOUT_BLANK + event.location.substring (length); } } @@ -3453,11 +3454,11 @@ int OnStartURIOpen (int /*long*/ aURI, int /*long*/ retval) { * 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 (event.location.equals (URI_FROMMEMORY)) { + if (event.location.equals (URI_FILEROOT)) { event.location = ABOUT_BLANK; } else { - length = URI_FROMMEMORY.length (); - if (event.location.startsWith (URI_FROMMEMORY) && event.location.charAt (length) == '#') { + length = URI_FILEROOT.length (); + if (event.location.startsWith (URI_FILEROOT) && event.location.charAt (length) == '#') { event.location = ABOUT_BLANK + event.location.substring (length); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/cocoa/Cocoa.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/cocoa/Cocoa.java index 9e3fa3eaac..f43a615e05 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/cocoa/Cocoa.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/cocoa/Cocoa.java @@ -144,6 +144,7 @@ public static final int S_sharedHandler = Cocoa.sel_registerName("sharedHandler" public static final int S_standardPreferences = Cocoa.sel_registerName("standardPreferences"); //$NON-NLS-1$ public static final int S_startAuthentication = sel_registerName("startAuthentication:window:"); //$NON-NLS-1$ public static final int S_stopLoading = Cocoa.sel_registerName("stopLoading:"); //$NON-NLS-1$ +public static final int S_string = Cocoa.sel_registerName("string"); //$NON-NLS-1$ public static final int S_stringByEvaluatingJavaScriptFromString = Cocoa.sel_registerName("stringByEvaluatingJavaScriptFromString:"); //$NON-NLS-1$ public static final int S_takeStringURLFrom = Cocoa.sel_registerName("takeStringURLFrom:"); //$NON-NLS-1$ public static final int S_undefined = Cocoa.sel_registerName("undefined"); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java index 8f0c52df52..30041a323f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java @@ -2666,6 +2666,13 @@ public static final native int /*long*/ CFURLCreateFromFSRef(int /*long*/ alloca */ public static final native int /*long*/ CFURLCreateStringByAddingPercentEscapes(int /*long*/ allocator, int /*long*/ originalString, int /*long*/ charactersToLeaveUnescaped, int /*long*/ legalURLCharactersToBeEscaped, int encoding); /** + * @param allocator cast=(CFAllocatorRef) + * @param origString cast=(CFStringRef) + * @param charsToLeaveEscaped cast=(CFStringRef) + * @param encoding cast=(CFStringEncoding) + */ +public static final native int /*long*/ CFURLCreateStringByReplacingPercentEscapesUsingEncoding(int /*long*/ allocator, int /*long*/ origString, int /*long*/ charsToLeaveEscaped, int encoding); +/** * @param data cast=(void*) * @param width cast=(size_t) * @param height cast=(size_t) |