Since you are passing webview here to constructor, you don't need to branch for OS version below. Webview object should handle the calls. You can define one init function in this webview to refactor below code.