Android WebViewClient 属性 中的 "isForMainFrame" 请求是什么意思?

What is "isForMainFrame" request in Android WebViewClient property meaning?

isForMainFrame 是什么意思 (android-21)?

whether the request was made for the main frame. Will be false for iframes, for example.

不清楚,因为它下面的日志 returns false 用于主机请求。

和android-19中的isMainFrame一样吗?

对于 "google.com"(根据我的语言环境立即重定向到 "google.ru")我得到以下 android-19 的日志:

3068-3088 D/IoThreadClientInvocationHandler: isMainFrame=true for http://www.google.com/
3068-3088 D/IoThreadClientInvocationHandler: isMainFrame=false for https://ssl.gstatic.com/gb/images/qi2_00ed8ca1.png
3068-3088 D/IoThreadClientInvocationHandler: isMainFrame=false for https://www.google.ru/images/branding/googlelogo/2x/googlelogo_color_160x56dp.png
3068-3088 D/IoThreadClientInvocationHandler: isMainFrame=false for https://www.google.ru/images/nav_logo242_hr.png
3068-3088 D/IoThreadClientInvocationHandler: isMainFrame=false for https://www.gstatic.com/og/_/js/k=og.mob.en_US.p8Smm-clGwA.O/rt=j/m=md/exm=mih,mab,meb/d=1/ed=1/rs=AA2YrTsvrSisM1LDBap6j28t9xwsb4oJBg
3068-3088 D/IoThreadClientInvocationHandler: isMainFrame=false for https://www.google.ru/xjs/_/js/k=xjs.qs.ru.WqzjCT34eOw.O/m=sx,c,sb_mob,bct,cdos,elog,hsm,jsa,mbsf,r,qsm,d,csi/am=AIG2TGBhALBBYgn5FBACKAE/rt=j/d=1/t=zcms/rs=ACT90oHeC71MlDyUp6g3gXk23kbF4ygyvw
3068-3088 D/IoThreadClientInvocationHandler: isMainFrame=false for https://www.google.ru/xjs/_/js/k=xjs.qs.ru.WqzjCT34eOw.O/m=sy7,sy13,em2,sy12,aa,abd,sy55,sy54,sy53,sy57,em10,async,sy280,sy320,sy319,dvl,sy425,foot,ipv6,shm/am=AIG2TGBhALBBYgn5FBACKAE/rt=j/d=0/t=zcms/rs=ACT90oHeC71MlDyUp6g3gXk23kbF4ygyvw
3068-3088 D/IoThreadClientInvocationHandler: isMainFrame=false for https://www.google.ru/images/branding/product/ico/googleg_lodp.ico
3068-3088 D/IoThreadClientInvocationHandler: isMainFrame=false for https://www.google.ru/images/nav_logo242.png
3068-3088 D/IoThreadClientInvocationHandler: isMainFrame=false for https://www.google.ru/gen_204?v=3&s=mobilewebhp&atyp=csi&ei=7kT-V-OSNcOfsgHEgL2gAw&imc=1&imn=1&imp=1&adh=&xjs=init.251.13.sb_mob.199.dvl.23.c.8.async.6.jsa.5&ima=1&rt=xjsls.161,prt.164,iml.716,dcl.574,xjses.1086,xjsee.1535,xjs.1536,ol.1873,aft.716,wsrt.1937,cst.728,dnst.1,rqst.219,rspt.36,sslt.721,rqstt.1645,unt.862,cstt.916,dit.2155
3068-3088 D/IoThreadClientInvocationHandler: isMainFrame=false for https://www.gstatic.com/og/_/ss/k=og.mob.-1m1er1bg50qhy.L.W.O/m=md/excm=mih,mab,meb/d=1/ed=1/rs=AA2YrTuS2ZHRm9kj5jyes52ZN2R47G8RQQ

对于 android-21 我可以看到:

1725-1851 D/IoThreadClientInvocationHandler: 21: true for http://www.google.com/
1725-1851 D/IoThreadClientInvocationHandler: 21: false for https://www.google.ru/images/branding/googlelogo/2x/googlelogo_color_160x56dp.png
1725-1851 D/IoThreadClientInvocationHandler: 21: false for https://ssl.gstatic.com/gb/images/qi2_00ed8ca1.png
1725-1851 D/IoThreadClientInvocationHandler: 21: false for https://www.google.ru/images/nav_logo242_hr.png
1725-1851 D/IoThreadClientInvocationHandler: 21: false for https://www.gstatic.com/og/_/js/k=og.mob.en_US.p8Smm-clGwA.O/rt=j/m=md/exm=mih,mab,meb/d=1/ed=1/rs=AA2YrTsvrSisM1LDBap6j28t9xwsb4oJBg
1725-1851 D/IoThreadClientInvocationHandler: 21: false for https://www.google.ru/xjs/_/js/k=xjs.qs.ru.WqzjCT34eOw.O/m=sx,c,sb_mob,bct,cdos,elog,hsm,jsa,mbsf,r,qsm,d,csi/am=AIG2ZGBhALBBYgn5FBACKAE/rt=j/d=1/t=zcms/rs=ACT90oGqh459Mg-Bg7N2WXgWV78Tvd2J1A
1725-1851 D/IoThreadClientInvocationHandler: 21: false for https://www.google.ru/xjs/_/js/k=xjs.qs.ru.WqzjCT34eOw.O/m=sy7,sy13,em2,sy12,aa,abd,sy55,sy54,sy53,sy57,em10,async,sy280,sy320,sy319,dvl,sy425,foot,ipv6,shm,udlg/am=AIG2ZGBhALBBYgn5FBACKAE/rt=j/d=0/t=zcms/rs=ACT90oGqh459Mg-Bg7N2WXgWV78Tvd2J1A
1725-1851 D/IoThreadClientInvocationHandler: 21: false for https://www.google.ru/images/nav_logo242.png
1725-1851 D/IoThreadClientInvocationHandler: 21: false for https://www.google.ru/gen_204?v=3&s=mobilewebhp&atyp=csi&ei=Qkb-V4-7AoOisAGdzq24Bg&imc=1&imn=1&imp=1&adh=&xjs=init.181.13.sb_mob.151.c.12.mbsf.4.jsa.4.async.4&conn=unknown&ima=1&rt=xjsls.146,prt.155,iml.4995,dcl.4791,xjses.5597,xjsee.6069,xjs.6070,ol.6264,aft.4995,wsrt.1045,cst.155,dnst.0,rqst.127,rspt.9,sslt.147,rqstt.837,unt.671,cstt.681,dit.1305
1725-1851 D/IoThreadClientInvocationHandler: 21: false for https://www.gstatic.com/og/_/ss/k=og.mob.-1m1er1bg50qhy.L.W.O/m=md/excm=mih,mab,meb/d=1/ed=1/rs=AA2YrTuS2ZHRm9kj5jyes52ZN2R47G8RQQ
1725-1851 D/IoThreadClientInvocationHandler: 21: false for https://www.google.ru/images/branding/product/1x/gsa_shadowed_144dp.png

我希望看到所有资源的 true,因为它是来自位于 "google.ru" 的主(和单个)框架的资源。我错了吗?

isForMainFrame方法其实是继承自WebKit。例如,这里是 Apple docs

因此,这里的MainFrame指的是WebKit的概念,也就是根WebFrame。

Behind the scenes, WebFrame objects encapsulate the content contained in a single frame element. A hierarchy of WebFrame objects is used to model an entire webpage where the root is called the main frame

您可以在 the docs

中找到更多相关信息

根据这个定义,只有初始请求是针对 "main frame" 的,其余都是针对子 WebFrames 的请求。