-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend Browser API to check for custom text location #1409
Extend Browser API to check for custom text location #1409
Conversation
3ef45a9
to
68427b0
Compare
3428a6f
to
4652035
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing the implementation, I am wondering whether it would also be sufficient to just add a showsCustomText()
method instead of the isLocationForCustomText(String)
one. Then the functionality would be completely independent from the location and the browser handle the state of whether it shows custom text or some URI-based page completely internally and even better hide it from consumers.
@amartya4256 Can you check whether that's possible?
Edit: Please also validate against the WebKit implementation. It seems to already have the about:blank page encoded as kind of a base URI internally. It also has some comments about using about:blank to be consistent with IE, so maybe there is also some further chance to align. I.e., a comment states:
Lines 634 to 637 in 97cf720
/* | |
* 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. | |
*/ |
using showsCustomText() won't be possible everywhere since there are Url comparison before the location of the browser has changed. For example in location listener in the changing method which executes before the location is actually changed. Another option was to cache the state type on setText but we don't know where we land with back and forward calls so it cannot be fully implemented. Moreover, I find the current method fine to accept a location as an argument. If you want to check something explictly, that can be passed, otherwise browser.getUrl() can be passed. The Webkit implementation does make the behaviour consistent by exchanging the places in the API result with about:blank but I think that our implementattion takes thwe technicality away from the client and they dont have to hardcode about:blank anymore and they can leave his decision completely on the browser to tell if it is their custom text page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API extension in general looks good to me. I have some comments on naming, documentation and testing.
Please also adapt the commit message header (and PR name) to be more self-explaining. I.e., instead of "Added API for checking if BASE_URI" use something like "Extend Browser API to check for custom text location"
bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java
Outdated
Show resolved
Hide resolved
@@ -724,6 +726,10 @@ public void setBrowser (Browser browser) { | |||
this.browser = browser; | |||
} | |||
|
|||
public URI getBaseUri() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be package protected, since the only intended consumer (`Browser´) is in the same package? Please also improve the name according to field name (see comment on the field name for that).
In addition, please check whether this method can be used by the IE and WebKit implementations, which currently have their own ABOUT_BLANK
field, which might (at least at some places) be reasonably replaced by this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made it package protected but I think refactoring of the browser specific usage can be done in a follow up PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's also fine. But then it should be done directly after merging this change.
bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java
Outdated
Show resolved
Hide resolved
....swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
Outdated
Show resolved
Hide resolved
....swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
Show resolved
Hide resolved
5671ddd
to
66ae8a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding the tests! In general, they look fine. My comments are mostly nitpicky style proposals, but some are also on potential race conditions. Anyway, all of them should be easy to resolve.
....swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
Show resolved
Hide resolved
....swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
Outdated
Show resolved
Hide resolved
....swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java
Outdated
Show resolved
Hide resolved
....swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
Outdated
Show resolved
Hide resolved
....swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
Outdated
Show resolved
Hide resolved
....swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
Outdated
Show resolved
Hide resolved
....swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
Outdated
Show resolved
Hide resolved
....swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
Show resolved
Hide resolved
....swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
Outdated
Show resolved
Hide resolved
343bb38
to
03601c4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for the recent update! I have some minor questions/comments left.
....swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
Outdated
Show resolved
Hide resolved
....swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
Outdated
Show resolved
Hide resolved
....swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
Outdated
Show resolved
Hide resolved
8253b50
to
66c8ae2
Compare
b7ab89b
to
642aa32
Compare
51b8d8f
to
50c18c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my side, this is ready to be merged once master branch is open again. Thank you!
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 eclipse-platform#213
50c18c5
to
aa4988a
Compare
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