对于很多链接打开以后会启动一个下载任务,本来以为这个功能也是通过shouldoverrideurlloding回调接口来判断的。实际发现并不是,下载链接最初被当作正常的url打开,在webkit解析response过程中判断出这是一个下载任务,并且启动下载。先给出一个webkit的调用堆栈:
#0 WebKit::FrameLoaderClientImpl::download FrameLoaderClientImpl.cpp:1488
#1 WebCore::MainResourceLoader::continueAfterContentPolicy MainResourceLoader.cpp:305
#2 WebCore::MainResourceLoader::continueAfterContentPolicy MainResourceLoader.cpp:362
#3 WebCore::PolicyCallback::call PolicyCallback.cpp:114
#4 WebCore::PolicyChecker::continueAfterContentPolicy PolicyChecker.cpp:200
#5 WebKit::FrameLoaderClientImpl::dispatchDecidePolicyForResponse FrameLoaderClientImpl.cpp:964
#6 WebCore::PolicyChecker::checkContentPolicy PolicyChecker.cpp:11