Skip to content

Commit

Permalink
Added API for checking if BASE_URI
Browse files Browse the repository at this point in the history
The contribution provides an API to check if the location is the
location where custom texts are loaded in a browser. By construct,
"about:blank" is used for that purpose. This API can be adapted by the
clients instead of explicitly defining the string and checking.

Contributes to #213
  • Loading branch information
amartya4256 committed Aug 16, 2024
1 parent 248ab17 commit 3ef45a9
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.swt.browser;

import java.net.*;

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

Expand Down Expand Up @@ -52,6 +54,7 @@ public class Browser extends Composite {
static final String NO_INPUT_METHOD = "org.eclipse.swt.internal.gtk.noInputMethod"; //$NON-NLS-1$
static final String PACKAGE_PREFIX = "org.eclipse.swt.browser."; //$NON-NLS-1$
static final String PROPERTY_DEFAULTTYPE = "org.eclipse.swt.browser.DefaultType"; //$NON-NLS-1$
private static final URI BASE_URI = URI.create("about:blank");

/**
* Constructs a new instance of this class given its parent
Expand Down Expand Up @@ -1201,4 +1204,16 @@ public void stop () {
checkWidget();
webBrowser.stop ();
}

/**
* Checks if the location supplied is the location for setting custom text in the browser
*
* @param location the URL to be checked
*
* @since 3.127
*/
public static boolean isLocationForCustomText(String location) {
return URI.create(location).equals(Browser.BASE_URI)
|| location.startsWith("data:");
}
}

0 comments on commit 3ef45a9

Please sign in to comment.