I know this question has been asked several times but there is not clear cut Answer i have got yet. Please enlighten me with your thoughts.
Requirement :- Application is a browser in which only "whitelisted" URLs are allowed to be viewed and visited. One example is, say, Yahoo.com is in whitelist but Youtube is not. Yahoo might have an embedded Youtube Video on its web page. In this case i want that my browser not to show the Embedded Video at all, ie blocking part of a Webview.
Findings :-
1) There are 2 methods , one is shouldOverrideUrlLoading()
which we can override andd decide whether to Open a Link or not . Second is shouldInterceptRequest()
[3.0 above] which we can override and change the content of a page , like given here. But it is not useful for modifying individual contents of the webpage.
onLoadResource()
is the method called for each resource that is loaded, but we cannot override it to display custom content. Something similar to onLoadResource would have been a perfect solution if we could change the contents of whats being loaded. (Possible security issue)
2) Alter the HTML content :- There are few ways given like here where we download the page content using HTTPClient and then load it in a Webview. Here the way would be possibly altering the HTML to replace the blocked content with some 'Site Blocked' message. Here the question is whether the method is full proof. Will javascript have any issues here.
3) Use Javascript to modify page contents. (Any examples ?) I have seen this. Are there any more such examples which i can refer to for say replacing/removing the tags which contain a blacklisted URL
4) It is not possible to do what i am asking.