How does Lastpass know the current URL in Chrome

烂漫一生 提交于 2019-12-01 02:52:39

问题


When browsing around in Chrome for Android, Lastpass pops up with suggestions if it recognizes the URL as one you have associated login details with.

How does it know which URL Chrome is looking at? I know that Lastpass makes use of Accessibility Services, but I wonder how it queries the current URL from Chrome.

PS. Apparently it only works for Chrome (it doesn't pop up in Opera for example) so it might be something Chrome specific.


回答1:


LastPass on Android asks for Accessibility permission with canRetrieveWindowContent true. This lets it traverse the current view hierarchy, and access the views as AccessibilityNodeInfo objects.

Accessibility API lets you search nodes by the text displayed on the view, and also gives you java class name of each such view. AccessibilityNodeInfo#findAccessibilityNodeInfosByText

The feature doesn't work on Opera probably because the devs never handled the view hierarchy traversing logic for it.

Check out https://developer.android.com/guide/topics/ui/accessibility/services.html




回答2:


I general using javascript, apart from Andoid functionality, and with some hacking, it is possible to get references to all open windows (and for instance get their URL). See this answer from 2009.



来源:https://stackoverflow.com/questions/41364628/how-does-lastpass-know-the-current-url-in-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!