WebView2.idl 346 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395
  1. // Copyright (C) Microsoft Corporation. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. import "objidl.idl";
  5. import "oaidl.idl";
  6. import "EventToken.idl";
  7. [uuid(26d34152-879f-4065-bea2-3daa2cfadfb8), version(1.0)]
  8. library WebView2 {
  9. // Interface forward declarations
  10. interface ICoreWebView2AcceleratorKeyPressedEventArgs;
  11. interface ICoreWebView2AcceleratorKeyPressedEventHandler;
  12. interface ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler;
  13. interface ICoreWebView2CallDevToolsProtocolMethodCompletedHandler;
  14. interface ICoreWebView2CapturePreviewCompletedHandler;
  15. interface ICoreWebView2;
  16. interface ICoreWebView2_2;
  17. interface ICoreWebView2_3;
  18. interface ICoreWebView2_4;
  19. interface ICoreWebView2_5;
  20. interface ICoreWebView2_6;
  21. interface ICoreWebView2_7;
  22. interface ICoreWebView2_8;
  23. interface ICoreWebView2_9;
  24. interface ICoreWebView2_10;
  25. interface ICoreWebView2_11;
  26. interface ICoreWebView2_12;
  27. interface ICoreWebView2_13;
  28. interface ICoreWebView2BasicAuthenticationRequestedEventArgs;
  29. interface ICoreWebView2BasicAuthenticationRequestedEventHandler;
  30. interface ICoreWebView2BasicAuthenticationResponse;
  31. interface ICoreWebView2BrowserProcessExitedEventArgs;
  32. interface ICoreWebView2BrowserProcessExitedEventHandler;
  33. interface ICoreWebView2BytesReceivedChangedEventHandler;
  34. interface ICoreWebView2CompositionController;
  35. interface ICoreWebView2CompositionController2;
  36. interface ICoreWebView2Controller;
  37. interface ICoreWebView2Controller2;
  38. interface ICoreWebView2Controller3;
  39. interface ICoreWebView2Controller4;
  40. interface ICoreWebView2ControllerOptions;
  41. interface ICoreWebView2ContentLoadingEventArgs;
  42. interface ICoreWebView2ContentLoadingEventHandler;
  43. interface ICoreWebView2ContextMenuRequestedEventArgs;
  44. interface ICoreWebView2ContextMenuRequestedEventHandler;
  45. interface ICoreWebView2Cookie;
  46. interface ICoreWebView2CookieList;
  47. interface ICoreWebView2CookieManager;
  48. interface ICoreWebView2Certificate;
  49. interface ICoreWebView2ClientCertificate;
  50. interface ICoreWebView2StringCollection;
  51. interface ICoreWebView2ClearBrowsingDataCompletedHandler;
  52. interface ICoreWebView2ClientCertificateCollection;
  53. interface ICoreWebView2ClientCertificateRequestedEventArgs;
  54. interface ICoreWebView2ClientCertificateRequestedEventHandler;
  55. interface ICoreWebView2ContextMenuItem;
  56. interface ICoreWebView2ContextMenuItemCollection;
  57. interface ICoreWebView2ContextMenuRequestedEventArgs;
  58. interface ICoreWebView2ContextMenuRequestedEventHandler;
  59. interface ICoreWebView2ContextMenuTarget;
  60. interface ICoreWebView2ClearServerCertificateErrorActionsCompletedHandler;
  61. interface ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler;
  62. interface ICoreWebView2CreateCoreWebView2ControllerCompletedHandler;
  63. interface ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler;
  64. interface ICoreWebView2ContainsFullScreenElementChangedEventHandler;
  65. interface ICoreWebView2CursorChangedEventHandler;
  66. interface ICoreWebView2CustomItemSelectedEventHandler;
  67. interface ICoreWebView2DocumentTitleChangedEventHandler;
  68. interface ICoreWebView2DOMContentLoadedEventArgs;
  69. interface ICoreWebView2DOMContentLoadedEventHandler;
  70. interface ICoreWebView2Deferral;
  71. interface ICoreWebView2DevToolsProtocolEventReceivedEventArgs;
  72. interface ICoreWebView2DevToolsProtocolEventReceivedEventArgs2;
  73. interface ICoreWebView2DevToolsProtocolEventReceivedEventHandler;
  74. interface ICoreWebView2DevToolsProtocolEventReceiver;
  75. interface ICoreWebView2DownloadOperation;
  76. interface ICoreWebView2DownloadStartingEventArgs;
  77. interface ICoreWebView2DownloadStartingEventHandler;
  78. interface ICoreWebView2Environment;
  79. interface ICoreWebView2Environment2;
  80. interface ICoreWebView2Environment3;
  81. interface ICoreWebView2Environment4;
  82. interface ICoreWebView2Environment5;
  83. interface ICoreWebView2Environment6;
  84. interface ICoreWebView2Environment7;
  85. interface ICoreWebView2Environment8;
  86. interface ICoreWebView2Environment9;
  87. interface ICoreWebView2Environment10;
  88. interface ICoreWebView2EnvironmentOptions;
  89. interface ICoreWebView2EnvironmentOptions2;
  90. interface ICoreWebView2EstimatedEndTimeChangedEventHandler;
  91. interface ICoreWebView2ExecuteScriptCompletedHandler;
  92. interface ICoreWebView2Frame;
  93. interface ICoreWebView2Frame2;
  94. interface ICoreWebView2Frame3;
  95. interface ICoreWebView2FrameContentLoadingEventHandler;
  96. interface ICoreWebView2FrameCreatedEventArgs;
  97. interface ICoreWebView2FrameCreatedEventHandler;
  98. interface ICoreWebView2FrameDestroyedEventHandler;
  99. interface ICoreWebView2FrameDOMContentLoadedEventHandler;
  100. interface ICoreWebView2FrameNameChangedEventHandler;
  101. interface ICoreWebView2FrameNavigationCompletedEventHandler;
  102. interface ICoreWebView2FrameNavigationStartingEventHandler;
  103. interface ICoreWebView2FramePermissionRequestedEventHandler;
  104. interface ICoreWebView2FrameWebMessageReceivedEventHandler;
  105. interface ICoreWebView2FrameInfo;
  106. interface ICoreWebView2FrameInfoCollection;
  107. interface ICoreWebView2FrameInfoCollectionIterator;
  108. interface ICoreWebView2FocusChangedEventHandler;
  109. interface ICoreWebView2GetCookiesCompletedHandler;
  110. interface ICoreWebView2HistoryChangedEventHandler;
  111. interface ICoreWebView2HttpHeadersCollectionIterator;
  112. interface ICoreWebView2HttpRequestHeaders;
  113. interface ICoreWebView2HttpResponseHeaders;
  114. interface ICoreWebView2IsDefaultDownloadDialogOpenChangedEventHandler;
  115. interface ICoreWebView2MoveFocusRequestedEventArgs;
  116. interface ICoreWebView2MoveFocusRequestedEventHandler;
  117. interface ICoreWebView2NavigationCompletedEventArgs;
  118. interface ICoreWebView2NavigationCompletedEventArgs2;
  119. interface ICoreWebView2NavigationCompletedEventHandler;
  120. interface ICoreWebView2NavigationStartingEventArgs;
  121. interface ICoreWebView2NavigationStartingEventArgs2;
  122. interface ICoreWebView2NavigationStartingEventHandler;
  123. interface ICoreWebView2NewBrowserVersionAvailableEventHandler;
  124. interface ICoreWebView2NewWindowRequestedEventArgs;
  125. interface ICoreWebView2NewWindowRequestedEventArgs2;
  126. interface ICoreWebView2NewWindowRequestedEventHandler;
  127. interface ICoreWebView2PermissionRequestedEventArgs;
  128. interface ICoreWebView2PermissionRequestedEventArgs2;
  129. interface ICoreWebView2PermissionRequestedEventHandler;
  130. interface ICoreWebView2PointerInfo;
  131. interface ICoreWebView2PrintSettings;
  132. interface ICoreWebView2PrintToPdfCompletedHandler;
  133. interface ICoreWebView2ProcessFailedEventArgs;
  134. interface ICoreWebView2ProcessFailedEventArgs2;
  135. interface ICoreWebView2ProcessFailedEventHandler;
  136. interface ICoreWebView2Profile;
  137. interface ICoreWebView2Profile2;
  138. interface ICoreWebView2RasterizationScaleChangedEventHandler;
  139. interface ICoreWebView2ServerCertificateErrorDetectedEventArgs;
  140. interface ICoreWebView2ServerCertificateErrorDetectedEventHandler;
  141. interface ICoreWebView2ScriptDialogOpeningEventArgs;
  142. interface ICoreWebView2ScriptDialogOpeningEventHandler;
  143. interface ICoreWebView2Settings;
  144. interface ICoreWebView2Settings2;
  145. interface ICoreWebView2Settings3;
  146. interface ICoreWebView2Settings4;
  147. interface ICoreWebView2Settings5;
  148. interface ICoreWebView2Settings6;
  149. interface ICoreWebView2Settings7;
  150. interface ICoreWebView2SourceChangedEventArgs;
  151. interface ICoreWebView2SourceChangedEventHandler;
  152. interface ICoreWebView2StateChangedEventHandler;
  153. interface ICoreWebView2StatusBarTextChangedEventHandler;
  154. interface ICoreWebView2TrySuspendCompletedHandler;
  155. interface ICoreWebView2WebMessageReceivedEventArgs;
  156. interface ICoreWebView2WebMessageReceivedEventHandler;
  157. interface ICoreWebView2WebResourceRequest;
  158. interface ICoreWebView2WebResourceRequestedEventArgs;
  159. interface ICoreWebView2WebResourceRequestedEventHandler;
  160. interface ICoreWebView2WebResourceResponse;
  161. interface ICoreWebView2WebResourceResponseReceivedEventHandler;
  162. interface ICoreWebView2WebResourceResponseReceivedEventArgs;
  163. interface ICoreWebView2WebResourceResponseView;
  164. interface ICoreWebView2WebResourceResponseViewGetContentCompletedHandler;
  165. interface ICoreWebView2WindowCloseRequestedEventHandler;
  166. interface ICoreWebView2WindowFeatures;
  167. interface ICoreWebView2ZoomFactorChangedEventHandler;
  168. interface ICoreWebView2IsMutedChangedEventHandler;
  169. interface ICoreWebView2IsDocumentPlayingAudioChangedEventHandler;
  170. interface ICoreWebView2ProcessInfo;
  171. interface ICoreWebView2ProcessInfoCollection;
  172. interface ICoreWebView2ProcessInfosChangedEventHandler;
  173. // Enums and structs
  174. /// Specifies the image format for the `ICoreWebView2::CapturePreview` method.
  175. [v1_enum]
  176. typedef enum COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT {
  177. /// Indicates that the PNG image format is used.
  178. COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT_PNG,
  179. /// Indicates the JPEG image format is used.
  180. COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT_JPEG,
  181. } COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT;
  182. /// Kind of cookie SameSite status used in the ICoreWebView2Cookie interface.
  183. /// These fields match those as specified in https://developer.mozilla.org/docs/Web/HTTP/Cookies#.
  184. /// Learn more about SameSite cookies here: https://tools.ietf.org/html/draft-west-first-party-cookies-07
  185. [v1_enum]
  186. typedef enum COREWEBVIEW2_COOKIE_SAME_SITE_KIND {
  187. /// None SameSite type. No restrictions on cross-site requests.
  188. COREWEBVIEW2_COOKIE_SAME_SITE_KIND_NONE,
  189. /// Lax SameSite type. The cookie will be sent with "same-site" requests, and with "cross-site" top level navigation.
  190. COREWEBVIEW2_COOKIE_SAME_SITE_KIND_LAX,
  191. /// Strict SameSite type. The cookie will only be sent along with "same-site" requests.
  192. COREWEBVIEW2_COOKIE_SAME_SITE_KIND_STRICT,
  193. } COREWEBVIEW2_COOKIE_SAME_SITE_KIND;
  194. /// Kind of cross origin resource access allowed for host resources during download.
  195. /// Note that other normal access checks like same origin DOM access check and [Content
  196. /// Security Policy](https://developer.mozilla.org/docs/Web/HTTP/CSP) still apply.
  197. /// The following table illustrates the host resource cross origin access according to
  198. /// access context and `COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND`.
  199. ///
  200. /// Cross Origin Access Context | DENY | ALLOW | DENY_CORS
  201. /// --- | --- | --- | ---
  202. /// From DOM like src of img, script or iframe element| Deny | Allow | Allow
  203. /// From Script like Fetch or XMLHttpRequest| Deny | Allow | Deny
  204. [v1_enum]
  205. typedef enum COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND {
  206. /// All cross origin resource access is denied, including normal sub resource access
  207. /// as src of a script or image element.
  208. COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_DENY,
  209. /// All cross origin resource access is allowed, including accesses that are
  210. /// subject to Cross-Origin Resource Sharing(CORS) check. The behavior is similar to
  211. /// a web site sends back http header Access-Control-Allow-Origin: *.
  212. COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_ALLOW,
  213. /// Cross origin resource access is allowed for normal sub resource access like
  214. /// as src of a script or image element, while any access that subjects to CORS check
  215. /// will be denied.
  216. /// See [Cross-Origin Resource Sharing](https://developer.mozilla.org/docs/Web/HTTP/CORS)
  217. /// for more information.
  218. COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_DENY_CORS,
  219. } COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND;
  220. /// Specifies the JavaScript dialog type used in the
  221. /// `ICoreWebView2ScriptDialogOpeningEventHandler` interface.
  222. [v1_enum]
  223. typedef enum COREWEBVIEW2_SCRIPT_DIALOG_KIND {
  224. /// Indicates that the dialog uses the `window.alert` JavaScript function.
  225. COREWEBVIEW2_SCRIPT_DIALOG_KIND_ALERT,
  226. /// Indicates that the dialog uses the `window.confirm` JavaScript function.
  227. COREWEBVIEW2_SCRIPT_DIALOG_KIND_CONFIRM,
  228. /// Indicates that the dialog uses the `window.prompt` JavaScript function.
  229. COREWEBVIEW2_SCRIPT_DIALOG_KIND_PROMPT,
  230. /// Indicates that the dialog uses the `beforeunload` JavaScript event.
  231. COREWEBVIEW2_SCRIPT_DIALOG_KIND_BEFOREUNLOAD,
  232. } COREWEBVIEW2_SCRIPT_DIALOG_KIND;
  233. /// Specifies the process failure type used in the
  234. /// `ICoreWebView2ProcessFailedEventHandler` interface. The values in this enum
  235. /// make reference to the process kinds in the Chromium architecture. For more
  236. /// information about what these processes are and what they do, see
  237. /// [Browser Architecture - Inside look at modern web browser](https://developers.google.com/web/updates/2018/09/inside-browser-part1).
  238. [v1_enum]
  239. typedef enum COREWEBVIEW2_PROCESS_FAILED_KIND {
  240. /// Indicates that the browser process ended unexpectedly. The WebView
  241. /// automatically moves to the Closed state. The app has to recreate a new
  242. /// WebView to recover from this failure.
  243. COREWEBVIEW2_PROCESS_FAILED_KIND_BROWSER_PROCESS_EXITED,
  244. /// Indicates that the main frame's render process ended unexpectedly. A new
  245. /// render process is created automatically and navigated to an error page.
  246. /// You can use the `Reload` method to try to reload the page that failed.
  247. COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_EXITED,
  248. /// Indicates that the main frame's render process is unresponsive.
  249. // Note that this does not seem to work right now.
  250. // Does not fire for simple long running script case, the only related test
  251. // SitePerProcessBrowserTest::NoCommitTimeoutForInvisibleWebContents is
  252. // disabled.
  253. COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_UNRESPONSIVE,
  254. /// Indicates that a frame-only render process ended unexpectedly. The process
  255. /// exit does not affect the top-level document, only a subset of the
  256. /// subframes within it. The content in these frames is replaced with an error
  257. /// page in the frame.
  258. COREWEBVIEW2_PROCESS_FAILED_KIND_FRAME_RENDER_PROCESS_EXITED,
  259. /// Indicates that a utility process ended unexpectedly.
  260. COREWEBVIEW2_PROCESS_FAILED_KIND_UTILITY_PROCESS_EXITED,
  261. /// Indicates that a sandbox helper process ended unexpectedly.
  262. COREWEBVIEW2_PROCESS_FAILED_KIND_SANDBOX_HELPER_PROCESS_EXITED,
  263. /// Indicates that the GPU process ended unexpectedly.
  264. COREWEBVIEW2_PROCESS_FAILED_KIND_GPU_PROCESS_EXITED,
  265. /// Indicates that a PPAPI plugin process ended unexpectedly.
  266. COREWEBVIEW2_PROCESS_FAILED_KIND_PPAPI_PLUGIN_PROCESS_EXITED,
  267. /// Indicates that a PPAPI plugin broker process ended unexpectedly.
  268. COREWEBVIEW2_PROCESS_FAILED_KIND_PPAPI_BROKER_PROCESS_EXITED,
  269. /// Indicates that a process of unspecified kind ended unexpectedly.
  270. COREWEBVIEW2_PROCESS_FAILED_KIND_UNKNOWN_PROCESS_EXITED,
  271. } COREWEBVIEW2_PROCESS_FAILED_KIND;
  272. /// Specifies the process failure reason used in the
  273. /// `ICoreWebView2ProcessFailedEventHandler` interface.
  274. [v1_enum]
  275. typedef enum COREWEBVIEW2_PROCESS_FAILED_REASON {
  276. /// An unexpected process failure occurred.
  277. COREWEBVIEW2_PROCESS_FAILED_REASON_UNEXPECTED,
  278. /// The process became unresponsive.
  279. /// This only applies to the main frame's render process.
  280. COREWEBVIEW2_PROCESS_FAILED_REASON_UNRESPONSIVE,
  281. /// The process was terminated. For example, from Task Manager.
  282. COREWEBVIEW2_PROCESS_FAILED_REASON_TERMINATED,
  283. /// The process crashed.
  284. COREWEBVIEW2_PROCESS_FAILED_REASON_CRASHED,
  285. /// The process failed to launch.
  286. COREWEBVIEW2_PROCESS_FAILED_REASON_LAUNCH_FAILED,
  287. /// The process died due to running out of memory.
  288. COREWEBVIEW2_PROCESS_FAILED_REASON_OUT_OF_MEMORY,
  289. } COREWEBVIEW2_PROCESS_FAILED_REASON;
  290. /// Indicates the type of a permission request.
  291. [v1_enum]
  292. typedef enum COREWEBVIEW2_PERMISSION_KIND {
  293. /// Indicates an unknown permission.
  294. COREWEBVIEW2_PERMISSION_KIND_UNKNOWN_PERMISSION,
  295. /// Indicates permission to capture audio.
  296. COREWEBVIEW2_PERMISSION_KIND_MICROPHONE,
  297. /// Indicates permission to capture video.
  298. COREWEBVIEW2_PERMISSION_KIND_CAMERA,
  299. /// Indicates permission to access geolocation.
  300. COREWEBVIEW2_PERMISSION_KIND_GEOLOCATION,
  301. /// Indicates permission to send web notifications. This permission request
  302. /// is currently auto-rejected and no event is run for it.
  303. COREWEBVIEW2_PERMISSION_KIND_NOTIFICATIONS,
  304. /// Indicates permission to access generic sensor. Generic Sensor covering
  305. /// ambient-light-sensor, accelerometer, gyroscope, and magnetometer.
  306. COREWEBVIEW2_PERMISSION_KIND_OTHER_SENSORS,
  307. /// Indicates permission to read the system clipboard without a user gesture.
  308. COREWEBVIEW2_PERMISSION_KIND_CLIPBOARD_READ,
  309. } COREWEBVIEW2_PERMISSION_KIND;
  310. /// Specifies the response to a permission request.
  311. [v1_enum]
  312. typedef enum COREWEBVIEW2_PERMISSION_STATE {
  313. /// Specifies that the default browser behavior is used, which normally
  314. /// prompt users for decision.
  315. COREWEBVIEW2_PERMISSION_STATE_DEFAULT,
  316. /// Specifies that the permission request is granted.
  317. COREWEBVIEW2_PERMISSION_STATE_ALLOW,
  318. /// Specifies that the permission request is denied.
  319. COREWEBVIEW2_PERMISSION_STATE_DENY,
  320. } COREWEBVIEW2_PERMISSION_STATE;
  321. /// Indicates the error status values for web navigations.
  322. [v1_enum]
  323. typedef enum COREWEBVIEW2_WEB_ERROR_STATUS {
  324. /// Indicates that an unknown error occurred.
  325. COREWEBVIEW2_WEB_ERROR_STATUS_UNKNOWN,
  326. /// Indicates that the SSL certificate common name does not match the web
  327. /// address.
  328. COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_COMMON_NAME_IS_INCORRECT,
  329. /// Indicates that the SSL certificate has expired.
  330. COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_EXPIRED,
  331. /// Indicates that the SSL client certificate contains errors.
  332. COREWEBVIEW2_WEB_ERROR_STATUS_CLIENT_CERTIFICATE_CONTAINS_ERRORS,
  333. /// Indicates that the SSL certificate has been revoked.
  334. COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_REVOKED,
  335. /// Indicates that the SSL certificate is not valid. The certificate may not
  336. /// match the public key pins for the host name, the certificate is signed
  337. /// by an untrusted authority or using a weak sign algorithm, the certificate
  338. /// claimed DNS names violate name constraints, the certificate contains a
  339. /// weak key, the validity period of the certificate is too long, lack of
  340. /// revocation information or revocation mechanism, non-unique host name,
  341. /// lack of certificate transparency information, or the certificate is
  342. /// chained to a
  343. /// [legacy Symantec root](https://security.googleblog.com/2018/03/distrust-of-symantec-pki-immediate.html).
  344. COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_IS_INVALID,
  345. /// Indicates that the host is unreachable.
  346. COREWEBVIEW2_WEB_ERROR_STATUS_SERVER_UNREACHABLE,
  347. /// Indicates that the connection has timed out.
  348. COREWEBVIEW2_WEB_ERROR_STATUS_TIMEOUT,
  349. /// Indicates that the server returned an invalid or unrecognized response.
  350. COREWEBVIEW2_WEB_ERROR_STATUS_ERROR_HTTP_INVALID_SERVER_RESPONSE,
  351. /// Indicates that the connection was stopped.
  352. COREWEBVIEW2_WEB_ERROR_STATUS_CONNECTION_ABORTED,
  353. /// Indicates that the connection was reset.
  354. COREWEBVIEW2_WEB_ERROR_STATUS_CONNECTION_RESET,
  355. /// Indicates that the Internet connection has been lost.
  356. COREWEBVIEW2_WEB_ERROR_STATUS_DISCONNECTED,
  357. /// Indicates that a connection to the destination was not established.
  358. COREWEBVIEW2_WEB_ERROR_STATUS_CANNOT_CONNECT,
  359. /// Indicates that the provided host name was not able to be resolved.
  360. COREWEBVIEW2_WEB_ERROR_STATUS_HOST_NAME_NOT_RESOLVED,
  361. /// Indicates that the operation was canceled.
  362. COREWEBVIEW2_WEB_ERROR_STATUS_OPERATION_CANCELED,
  363. /// Indicates that the request redirect failed.
  364. COREWEBVIEW2_WEB_ERROR_STATUS_REDIRECT_FAILED,
  365. /// Indicates that an unexpected error occurred.
  366. COREWEBVIEW2_WEB_ERROR_STATUS_UNEXPECTED_ERROR,
  367. /// Indicates that user is prompted with a login, waiting on user action.
  368. /// Initial navigation to a login site will always return this even if app provides
  369. /// credential using BasicAuthenticationRequested.
  370. /// HTTP response status code in this case is 401.
  371. /// See status code reference here: https://developer.mozilla.org/docs/Web/HTTP/Status.
  372. COREWEBVIEW2_WEB_ERROR_STATUS_VALID_AUTHENTICATION_CREDENTIALS_REQUIRED,
  373. /// Indicates that user lacks proper authentication credentials for a proxy server.
  374. /// HTTP response status code in this case is 407.
  375. /// See status code reference here: https://developer.mozilla.org/docs/Web/HTTP/Status.
  376. COREWEBVIEW2_WEB_ERROR_STATUS_VALID_PROXY_AUTHENTICATION_REQUIRED,
  377. } COREWEBVIEW2_WEB_ERROR_STATUS;
  378. /// Specifies the web resource request contexts.
  379. [v1_enum]
  380. typedef enum COREWEBVIEW2_WEB_RESOURCE_CONTEXT {
  381. /// Specifies all resources.
  382. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_ALL,
  383. /// Specifies a document resource.
  384. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_DOCUMENT,
  385. /// Specifies a CSS resource.
  386. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_STYLESHEET,
  387. /// Specifies an image resource.
  388. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_IMAGE,
  389. /// Specifies another media resource such as a video.
  390. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_MEDIA,
  391. /// Specifies a font resource.
  392. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_FONT,
  393. /// Specifies a script resource.
  394. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_SCRIPT,
  395. /// Specifies an XML HTTP request.
  396. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_XML_HTTP_REQUEST,
  397. /// Specifies a Fetch API communication.
  398. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_FETCH,
  399. /// Specifies a TextTrack resource.
  400. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_TEXT_TRACK,
  401. /// Specifies an EventSource API communication.
  402. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_EVENT_SOURCE,
  403. /// Specifies a WebSocket API communication.
  404. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_WEBSOCKET,
  405. /// Specifies a Web App Manifest.
  406. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_MANIFEST,
  407. /// Specifies a Signed HTTP Exchange.
  408. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_SIGNED_EXCHANGE,
  409. /// Specifies a Ping request.
  410. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_PING,
  411. /// Specifies a CSP Violation Report.
  412. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_CSP_VIOLATION_REPORT,
  413. /// Specifies an other resource.
  414. COREWEBVIEW2_WEB_RESOURCE_CONTEXT_OTHER
  415. } COREWEBVIEW2_WEB_RESOURCE_CONTEXT;
  416. /// Specifies the reason for moving focus.
  417. [v1_enum]
  418. typedef enum COREWEBVIEW2_MOVE_FOCUS_REASON {
  419. /// Specifies that the code is setting focus into WebView.
  420. COREWEBVIEW2_MOVE_FOCUS_REASON_PROGRAMMATIC,
  421. /// Specifies that the focus is moving due to Tab traversal forward.
  422. COREWEBVIEW2_MOVE_FOCUS_REASON_NEXT,
  423. /// Specifies that the focus is moving due to Tab traversal backward.
  424. COREWEBVIEW2_MOVE_FOCUS_REASON_PREVIOUS,
  425. } COREWEBVIEW2_MOVE_FOCUS_REASON;
  426. /// Specifies the key event type that triggered an `AcceleratorKeyPressed`
  427. /// event.
  428. [v1_enum]
  429. typedef enum COREWEBVIEW2_KEY_EVENT_KIND {
  430. /// Specifies that the key event type corresponds to window message
  431. /// `WM_KEYDOWN`.
  432. COREWEBVIEW2_KEY_EVENT_KIND_KEY_DOWN,
  433. /// Specifies that the key event type corresponds to window message
  434. /// `WM_KEYUP`.
  435. COREWEBVIEW2_KEY_EVENT_KIND_KEY_UP,
  436. /// Specifies that the key event type corresponds to window message
  437. /// `WM_SYSKEYDOWN`.
  438. COREWEBVIEW2_KEY_EVENT_KIND_SYSTEM_KEY_DOWN,
  439. /// Specifies that the key event type corresponds to window message
  440. /// `WM_SYSKEYUP`.
  441. COREWEBVIEW2_KEY_EVENT_KIND_SYSTEM_KEY_UP,
  442. } COREWEBVIEW2_KEY_EVENT_KIND;
  443. /// Specifies the browser process exit type used in the
  444. /// `ICoreWebView2BrowserProcessExitedEventArgs` interface.
  445. [v1_enum]
  446. typedef enum COREWEBVIEW2_BROWSER_PROCESS_EXIT_KIND {
  447. /// Indicates that the browser process ended normally.
  448. COREWEBVIEW2_BROWSER_PROCESS_EXIT_KIND_NORMAL,
  449. /// Indicates that the browser process ended unexpectedly.
  450. /// A `ProcessFailed` event will also be sent to listening WebViews from the
  451. /// `ICoreWebView2Environment` associated to the failed process.
  452. COREWEBVIEW2_BROWSER_PROCESS_EXIT_KIND_FAILED
  453. } COREWEBVIEW2_BROWSER_PROCESS_EXIT_KIND;
  454. /// Contains the information packed into the `LPARAM` sent to a Win32 key
  455. /// event. For more information about `WM_KEYDOWN`, navigate to
  456. /// [WM_KEYDOWN message](/windows/win32/inputdev/wm-keydown).
  457. typedef struct COREWEBVIEW2_PHYSICAL_KEY_STATUS {
  458. /// Specifies the repeat count for the current message.
  459. UINT32 RepeatCount;
  460. /// Specifies the scan code.
  461. UINT32 ScanCode;
  462. /// Indicates that the key is an extended key.
  463. BOOL IsExtendedKey;
  464. /// Indicates that a menu key is held down (context code).
  465. BOOL IsMenuKeyDown;
  466. /// Indicates that the key was held down.
  467. BOOL WasKeyDown;
  468. /// Indicates that the key was released.
  469. BOOL IsKeyReleased;
  470. } COREWEBVIEW2_PHYSICAL_KEY_STATUS;
  471. /// A value representing RGBA color (Red, Green, Blue, Alpha) for WebView2.
  472. /// Each component takes a value from 0 to 255, with 0 being no intensity
  473. /// and 255 being the highest intensity.
  474. typedef struct COREWEBVIEW2_COLOR {
  475. /// Specifies the intensity of the Alpha ie. opacity value. 0 is transparent,
  476. /// 255 is opaque.
  477. BYTE A;
  478. /// Specifies the intensity of the Red color.
  479. BYTE R;
  480. /// Specifies the intensity of the Green color.
  481. BYTE G;
  482. /// Specifies the intensity of the Blue color.
  483. BYTE B;
  484. } COREWEBVIEW2_COLOR;
  485. /// Mouse event type used by SendMouseInput to convey the type of mouse event
  486. /// being sent to WebView. The values of this enum align with the matching
  487. /// WM_* window messages.
  488. [v1_enum]
  489. typedef enum COREWEBVIEW2_MOUSE_EVENT_KIND {
  490. /// Mouse horizontal wheel scroll event, WM_MOUSEHWHEEL.
  491. COREWEBVIEW2_MOUSE_EVENT_KIND_HORIZONTAL_WHEEL = 0x020E,
  492. /// Left button double click mouse event, WM_LBUTTONDBLCLK.
  493. COREWEBVIEW2_MOUSE_EVENT_KIND_LEFT_BUTTON_DOUBLE_CLICK = 0x0203,
  494. /// Left button down mouse event, WM_LBUTTONDOWN.
  495. COREWEBVIEW2_MOUSE_EVENT_KIND_LEFT_BUTTON_DOWN = 0x0201,
  496. /// Left button up mouse event, WM_LBUTTONUP.
  497. COREWEBVIEW2_MOUSE_EVENT_KIND_LEFT_BUTTON_UP = 0x0202,
  498. /// Mouse leave event, WM_MOUSELEAVE.
  499. COREWEBVIEW2_MOUSE_EVENT_KIND_LEAVE = 0x02A3,
  500. /// Middle button double click mouse event, WM_MBUTTONDBLCLK.
  501. COREWEBVIEW2_MOUSE_EVENT_KIND_MIDDLE_BUTTON_DOUBLE_CLICK = 0x0209,
  502. /// Middle button down mouse event, WM_MBUTTONDOWN.
  503. COREWEBVIEW2_MOUSE_EVENT_KIND_MIDDLE_BUTTON_DOWN = 0x0207,
  504. /// Middle button up mouse event, WM_MBUTTONUP.
  505. COREWEBVIEW2_MOUSE_EVENT_KIND_MIDDLE_BUTTON_UP = 0x0208,
  506. /// Mouse move event, WM_MOUSEMOVE.
  507. COREWEBVIEW2_MOUSE_EVENT_KIND_MOVE = 0x0200,
  508. /// Right button double click mouse event, WM_RBUTTONDBLCLK.
  509. COREWEBVIEW2_MOUSE_EVENT_KIND_RIGHT_BUTTON_DOUBLE_CLICK = 0x0206,
  510. /// Right button down mouse event, WM_RBUTTONDOWN.
  511. COREWEBVIEW2_MOUSE_EVENT_KIND_RIGHT_BUTTON_DOWN = 0x0204,
  512. /// Right button up mouse event, WM_RBUTTONUP.
  513. COREWEBVIEW2_MOUSE_EVENT_KIND_RIGHT_BUTTON_UP = 0x0205,
  514. /// Mouse wheel scroll event, WM_MOUSEWHEEL.
  515. COREWEBVIEW2_MOUSE_EVENT_KIND_WHEEL = 0x020A,
  516. /// First or second X button double click mouse event, WM_XBUTTONDBLCLK.
  517. COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_DOUBLE_CLICK = 0x020D,
  518. /// First or second X button down mouse event, WM_XBUTTONDOWN.
  519. COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_DOWN = 0x020B,
  520. /// First or second X button up mouse event, WM_XBUTTONUP.
  521. COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_UP = 0x020C,
  522. } COREWEBVIEW2_MOUSE_EVENT_KIND;
  523. /// Mouse event virtual keys associated with a COREWEBVIEW2_MOUSE_EVENT_KIND for
  524. /// SendMouseInput. These values can be combined into a bit flag if more than
  525. /// one virtual key is pressed for the event. The values of this enum align
  526. /// with the matching MK_* mouse keys.
  527. [v1_enum]
  528. typedef enum COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS {
  529. /// No additional keys pressed.
  530. COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_NONE = 0x0,
  531. /// Left mouse button is down, MK_LBUTTON.
  532. COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_LEFT_BUTTON = 0x0001,
  533. /// Right mouse button is down, MK_RBUTTON.
  534. COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_RIGHT_BUTTON = 0x0002,
  535. /// SHIFT key is down, MK_SHIFT.
  536. COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_SHIFT = 0x0004,
  537. /// CTRL key is down, MK_CONTROL.
  538. COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_CONTROL = 0x0008,
  539. /// Middle mouse button is down, MK_MBUTTON.
  540. COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_MIDDLE_BUTTON = 0x0010,
  541. /// First X button is down, MK_XBUTTON1
  542. COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_X_BUTTON1 = 0x0020,
  543. /// Second X button is down, MK_XBUTTON2
  544. COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_X_BUTTON2 = 0x0040,
  545. } COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS;
  546. cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS);")
  547. /// Pointer event type used by SendPointerInput to convey the type of pointer
  548. /// event being sent to WebView. The values of this enum align with the
  549. /// matching WM_POINTER* window messages.
  550. [v1_enum]
  551. typedef enum COREWEBVIEW2_POINTER_EVENT_KIND {
  552. /// Corresponds to WM_POINTERACTIVATE.
  553. COREWEBVIEW2_POINTER_EVENT_KIND_ACTIVATE = 0x024B,
  554. /// Corresponds to WM_POINTERDOWN.
  555. COREWEBVIEW2_POINTER_EVENT_KIND_DOWN = 0x0246,
  556. /// Corresponds to WM_POINTERENTER.
  557. COREWEBVIEW2_POINTER_EVENT_KIND_ENTER = 0x0249,
  558. /// Corresponds to WM_POINTERLEAVE.
  559. COREWEBVIEW2_POINTER_EVENT_KIND_LEAVE = 0x024A,
  560. /// Corresponds to WM_POINTERUP.
  561. COREWEBVIEW2_POINTER_EVENT_KIND_UP = 0x0247,
  562. /// Corresponds to WM_POINTERUPDATE.
  563. COREWEBVIEW2_POINTER_EVENT_KIND_UPDATE = 0x0245,
  564. } COREWEBVIEW2_POINTER_EVENT_KIND;
  565. /// Mode for how the Bounds property is interpreted in relation to the RasterizationScale property.
  566. [v1_enum]
  567. typedef enum COREWEBVIEW2_BOUNDS_MODE {
  568. /// Bounds property represents raw pixels. Physical size of Webview is not impacted by RasterizationScale.
  569. COREWEBVIEW2_BOUNDS_MODE_USE_RAW_PIXELS,
  570. /// Bounds property represents logicl pixels and the RasterizationScale property is used to get the physical size of the WebView.
  571. COREWEBVIEW2_BOUNDS_MODE_USE_RASTERIZATION_SCALE,
  572. } COREWEBVIEW2_BOUNDS_MODE;
  573. /// Specifies the client certificate kind.
  574. [v1_enum] typedef enum COREWEBVIEW2_CLIENT_CERTIFICATE_KIND {
  575. /// Specifies smart card certificate.
  576. COREWEBVIEW2_CLIENT_CERTIFICATE_KIND_SMART_CARD,
  577. /// Specifies PIN certificate.
  578. COREWEBVIEW2_CLIENT_CERTIFICATE_KIND_PIN,
  579. /// Specifies other certificate.
  580. COREWEBVIEW2_CLIENT_CERTIFICATE_KIND_OTHER,
  581. } COREWEBVIEW2_CLIENT_CERTIFICATE_KIND;
  582. /// State of the download operation.
  583. [v1_enum]
  584. typedef enum COREWEBVIEW2_DOWNLOAD_STATE {
  585. /// The download is in progress.
  586. COREWEBVIEW2_DOWNLOAD_STATE_IN_PROGRESS,
  587. /// The connection with the file host was broken. The `InterruptReason` property
  588. /// can be accessed from `ICoreWebView2DownloadOperation`. See
  589. /// `COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON` for descriptions of kinds of
  590. /// interrupt reasons. Host can check whether an interrupted download can be
  591. /// resumed with the `CanResume` property on the `ICoreWebView2DownloadOperation`.
  592. /// Once resumed, a download is in the `COREWEBVIEW2_DOWNLOAD_STATE_IN_PROGRESS` state.
  593. COREWEBVIEW2_DOWNLOAD_STATE_INTERRUPTED,
  594. /// The download completed successfully.
  595. COREWEBVIEW2_DOWNLOAD_STATE_COMPLETED,
  596. } COREWEBVIEW2_DOWNLOAD_STATE;
  597. /// Reason why a download was interrupted.
  598. [v1_enum]
  599. typedef enum COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON {
  600. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_NONE,
  601. /// Generic file error.
  602. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_FAILED,
  603. /// Access denied due to security restrictions.
  604. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED,
  605. /// Disk full. User should free some space or choose a different location to
  606. /// store the file.
  607. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE,
  608. /// Result file path with file name is too long.
  609. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG,
  610. /// File is too large for file system.
  611. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_TOO_LARGE,
  612. /// Microsoft Defender Smartscreen detected a virus in the file.
  613. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_MALICIOUS,
  614. /// File was in use, too many files opened, or out of memory.
  615. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR,
  616. /// File blocked by local policy.
  617. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_BLOCKED_BY_POLICY,
  618. /// Security check failed unexpectedly. Microsoft Defender SmartScreen could
  619. /// not scan this file.
  620. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED,
  621. /// Seeking past the end of a file in opening a file, as part of resuming an
  622. /// interrupted download. The file did not exist or was not as large as
  623. /// expected. Partially downloaded file was truncated or deleted, and download
  624. /// will be restarted automatically.
  625. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_TOO_SHORT,
  626. /// Partial file did not match the expected hash and was deleted. Download
  627. /// will be restarted automatically.
  628. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_HASH_MISMATCH,
  629. /// Generic network error. User can retry the download manually.
  630. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED,
  631. /// Network operation timed out.
  632. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT,
  633. /// Network connection lost. User can retry the download manually.
  634. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED,
  635. /// Server has gone down. User can retry the download manually.
  636. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_NETWORK_SERVER_DOWN,
  637. /// Network request invalid because original or redirected URI is invalid, has
  638. /// an unsupported scheme, or is disallowed by network policy.
  639. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST,
  640. /// Generic server error. User can retry the download manually.
  641. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED,
  642. /// Server does not support range requests.
  643. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE,
  644. /// Server does not have the requested data.
  645. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT,
  646. /// Server did not authorize access to resource.
  647. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_UNAUTHORIZED,
  648. /// Server certificate problem.
  649. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_CERTIFICATE_PROBLEM,
  650. /// Server access forbidden.
  651. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_FORBIDDEN,
  652. /// Unexpected server response. Responding server may not be intended server.
  653. /// User can retry the download manually.
  654. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_UNEXPECTED_RESPONSE,
  655. /// Server sent fewer bytes than the Content-Length header. Content-length
  656. /// header may be invalid or connection may have closed. Download is treated
  657. /// as complete unless there are
  658. /// [strong validators](https://tools.ietf.org/html/rfc7232#section-2) present
  659. /// to interrupt the download.
  660. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_CONTENT_LENGTH_MISMATCH,
  661. /// Unexpected cross-origin redirect.
  662. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_CROSS_ORIGIN_REDIRECT,
  663. /// User canceled the download.
  664. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_USER_CANCELED,
  665. /// User shut down the WebView. Resuming downloads that were interrupted
  666. /// during shutdown is not yet supported.
  667. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN,
  668. /// User paused the download.
  669. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_USER_PAUSED,
  670. /// WebView crashed.
  671. COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_DOWNLOAD_PROCESS_CRASHED,
  672. } COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON;
  673. /// The orientation for printing, used by the `Orientation` property on
  674. /// `ICoreWebView2PrintSettings`. Currently only printing to PDF is supported.
  675. [v1_enum]
  676. typedef enum COREWEBVIEW2_PRINT_ORIENTATION {
  677. /// Print the page(s) in portrait orientation.
  678. COREWEBVIEW2_PRINT_ORIENTATION_PORTRAIT,
  679. /// Print the page(s) in landscape orientation.
  680. COREWEBVIEW2_PRINT_ORIENTATION_LANDSCAPE,
  681. } COREWEBVIEW2_PRINT_ORIENTATION;
  682. /// The default download dialog can be aligned to any of the WebView corners
  683. /// by setting the `DefaultDownloadDialogCornerAlignment` property. The default
  684. /// position is top-right corner.
  685. [v1_enum]
  686. typedef enum COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT {
  687. /// Top-left corner of the WebView.
  688. COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT_TOP_LEFT,
  689. /// Top-right corner of the WebView.
  690. COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT_TOP_RIGHT,
  691. /// Bottom-left corner of the WebView.
  692. COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT_BOTTOM_LEFT,
  693. /// Bottom-right corner of the WebView.
  694. COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT_BOTTOM_RIGHT,
  695. } COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT;
  696. /// Indicates the process type used in the ICoreWebView2ProcessInfo interface.
  697. [v1_enum]
  698. typedef enum COREWEBVIEW2_PROCESS_KIND {
  699. /// Indicates the browser process kind.
  700. COREWEBVIEW2_PROCESS_KIND_BROWSER,
  701. /// Indicates the render process kind.
  702. COREWEBVIEW2_PROCESS_KIND_RENDERER,
  703. /// Indicates the utility process kind.
  704. COREWEBVIEW2_PROCESS_KIND_UTILITY,
  705. /// Indicates the sandbox helper process kind.
  706. COREWEBVIEW2_PROCESS_KIND_SANDBOX_HELPER,
  707. /// Indicates the GPU process kind.
  708. COREWEBVIEW2_PROCESS_KIND_GPU,
  709. /// Indicates the PPAPI plugin process kind.
  710. COREWEBVIEW2_PROCESS_KIND_PPAPI_PLUGIN,
  711. /// Indicates the PPAPI plugin broker process kind.
  712. COREWEBVIEW2_PROCESS_KIND_PPAPI_BROKER,
  713. } COREWEBVIEW2_PROCESS_KIND;
  714. // PDF toolbar item. This enum must be in sync with ToolBarItem in pdf-store-data-types.ts
  715. /// Specifies the PDF toolbar item types used for the `ICoreWebView2Settings::put_HiddenPdfToolbarItems` method.
  716. [v1_enum]
  717. typedef enum COREWEBVIEW2_PDF_TOOLBAR_ITEMS {
  718. /// No item
  719. COREWEBVIEW2_PDF_TOOLBAR_ITEMS_NONE = 0x0,
  720. /// The save button
  721. COREWEBVIEW2_PDF_TOOLBAR_ITEMS_SAVE = 0x0001,
  722. /// The print button
  723. COREWEBVIEW2_PDF_TOOLBAR_ITEMS_PRINT = 0x0002,
  724. /// The save as button
  725. COREWEBVIEW2_PDF_TOOLBAR_ITEMS_SAVE_AS = 0x0004,
  726. /// The zoom in button
  727. COREWEBVIEW2_PDF_TOOLBAR_ITEMS_ZOOM_IN = 0x0008,
  728. /// The zoom out button
  729. COREWEBVIEW2_PDF_TOOLBAR_ITEMS_ZOOM_OUT = 0x0010,
  730. /// The rotate button
  731. COREWEBVIEW2_PDF_TOOLBAR_ITEMS_ROTATE = 0x0020,
  732. /// The fit page button
  733. COREWEBVIEW2_PDF_TOOLBAR_ITEMS_FIT_PAGE = 0x0040,
  734. /// The page layout button
  735. COREWEBVIEW2_PDF_TOOLBAR_ITEMS_PAGE_LAYOUT = 0x0080,
  736. /// The bookmarks button
  737. COREWEBVIEW2_PDF_TOOLBAR_ITEMS_BOOKMARKS = 0x0100,
  738. /// The page select button
  739. COREWEBVIEW2_PDF_TOOLBAR_ITEMS_PAGE_SELECTOR = 0x0200,
  740. /// The search button
  741. COREWEBVIEW2_PDF_TOOLBAR_ITEMS_SEARCH = 0x0400,
  742. } COREWEBVIEW2_PDF_TOOLBAR_ITEMS;
  743. cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(COREWEBVIEW2_PDF_TOOLBAR_ITEMS);")
  744. /// Indicates the kind of context for which the context menu was created
  745. /// for the `ICoreWebView2ContextMenuTarget::get_Kind` method.
  746. /// This enum will always represent the active element that caused the context menu request.
  747. /// If there is a selection with multiple images, audio and text, for example, the element that
  748. /// the end user right clicks on within this selection will be the option represented by this enum.
  749. [v1_enum]
  750. typedef enum COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND {
  751. /// Indicates that the context menu was created for the page without any additional content.
  752. COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND_PAGE,
  753. /// Indicates that the context menu was created for an image element.
  754. COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND_IMAGE,
  755. /// Indicates that the context menu was created for selected text.
  756. COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND_SELECTED_TEXT,
  757. /// Indicates that the context menu was created for an audio element.
  758. COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND_AUDIO,
  759. /// Indicates that the context menu was created for a video element.
  760. COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND_VIDEO,
  761. } COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND;
  762. /// Specifies the menu item kind
  763. /// for the `ICoreWebView2ContextMenuItem::get_Kind` method
  764. [v1_enum]
  765. typedef enum COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND {
  766. /// Specifies a command menu item kind.
  767. COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_COMMAND,
  768. /// Specifies a check box menu item kind. `ContextMenuItem` objects of this kind
  769. /// will need the `IsChecked` property to determine current state of the check box.
  770. COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_CHECK_BOX,
  771. /// Specifies a radio button menu item kind. `ContextMenuItem` objects of this kind
  772. /// will need the `IsChecked` property to determine current state of the radio button.
  773. COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_RADIO,
  774. /// Specifies a separator menu item kind. `ContextMenuItem` objects of this kind
  775. /// are used to signal a visual separator with no functionality.
  776. COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_SEPARATOR,
  777. /// Specifies a submenu menu item kind. `ContextMenuItem` objects of this kind will contain
  778. /// a `ContextMenuItemCollection` of its children `ContextMenuItem` objects.
  779. COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_SUBMENU,
  780. } COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND;
  781. /// An enum to represent the options for WebView2 color scheme: auto, light, or dark.
  782. [v1_enum]
  783. typedef enum COREWEBVIEW2_PREFERRED_COLOR_SCHEME {
  784. /// Auto color scheme.
  785. COREWEBVIEW2_PREFERRED_COLOR_SCHEME_AUTO,
  786. /// Light color scheme.
  787. COREWEBVIEW2_PREFERRED_COLOR_SCHEME_LIGHT,
  788. /// Dark color scheme.
  789. COREWEBVIEW2_PREFERRED_COLOR_SCHEME_DARK
  790. } COREWEBVIEW2_PREFERRED_COLOR_SCHEME;
  791. /// Specifies the datatype for the
  792. /// `ICoreWebView2Profile2::ClearBrowsingData` method.
  793. [v1_enum]
  794. typedef enum COREWEBVIEW2_BROWSING_DATA_KINDS {
  795. /// Specifies file systems data.
  796. COREWEBVIEW2_BROWSING_DATA_KINDS_FILE_SYSTEMS = 1 << 0,
  797. /// Specifies data stored by the IndexedDB DOM feature.
  798. COREWEBVIEW2_BROWSING_DATA_KINDS_INDEXED_DB = 1 << 1,
  799. /// Specifies data stored by the localStorage DOM API.
  800. COREWEBVIEW2_BROWSING_DATA_KINDS_LOCAL_STORAGE = 1 << 2,
  801. /// Specifies data stored by the Web SQL database DOM API.
  802. COREWEBVIEW2_BROWSING_DATA_KINDS_WEB_SQL = 1 << 3,
  803. /// Specifies data stored by the CacheStorage DOM API.
  804. COREWEBVIEW2_BROWSING_DATA_KINDS_CACHE_STORAGE = 1 << 4,
  805. /// Specifies DOM storage data, now and future. This browsing data kind is
  806. /// inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_FILE_SYSTEMS,
  807. /// COREWEBVIEW2_BROWSING_DATA_KINDS_INDEXED_DB,
  808. /// COREWEBVIEW2_BROWSING_DATA_KINDS_LOCAL_STORAGE,
  809. /// COREWEBVIEW2_BROWSING_DATA_KINDS_WEB_SQL,
  810. /// COREWEBVIEW2_BROWSING_DATA_KINDS_CACHE_STORAGE.
  811. /// New DOM storage data types may be added to this data kind in the future.
  812. COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_DOM_STORAGE = 1 << 5,
  813. /// Specifies HTTP cookies data.
  814. COREWEBVIEW2_BROWSING_DATA_KINDS_COOKIES = 1 << 6,
  815. /// Specifies all site data, now and future. This browsing data kind
  816. /// is inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_DOM_STORAGE and
  817. /// COREWEBVIEW2_BROWSING_DATA_KINDS_COOKIES. New site data types
  818. /// may be added to this data kind in the future.
  819. COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_SITE = 1 << 7,
  820. /// Specifies disk cache.
  821. COREWEBVIEW2_BROWSING_DATA_KINDS_DISK_CACHE = 1 << 8,
  822. /// Specifies download history data.
  823. COREWEBVIEW2_BROWSING_DATA_KINDS_DOWNLOAD_HISTORY = 1 << 9,
  824. /// Specifies general autofill form data.
  825. /// This excludes password information and includes information like:
  826. /// names, street and email addresses, phone numbers, and arbitrary input.
  827. /// This also includes payment data.
  828. COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL = 1 << 10,
  829. /// Specifies password autosave data.
  830. COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE = 1 << 11,
  831. /// Specifies browsing history data.
  832. COREWEBVIEW2_BROWSING_DATA_KINDS_BROWSING_HISTORY = 1 << 12,
  833. /// Specifies settings data.
  834. COREWEBVIEW2_BROWSING_DATA_KINDS_SETTINGS = 1 << 13,
  835. /// Specifies profile data that should be wiped to make it look like a new profile.
  836. /// This does not delete account-scoped data like passwords but will remove access
  837. /// to account-scoped data by signing the user out.
  838. /// Specifies all profile data, now and future. New profile data types may be added
  839. /// to this data kind in the future.
  840. /// This browsing data kind is inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_SITE,
  841. /// COREWEBVIEW2_BROWSING_DATA_KINDS_DISK_CACHE,
  842. /// COREWEBVIEW2_BROWSING_DATA_KINDS_DOWNLOAD_HISTORY,
  843. /// COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL,
  844. /// COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE,
  845. /// COREWEBVIEW2_BROWSING_DATA_KINDS_BROWSING_HISTORY, and
  846. /// COREWEBVIEW2_BROWSING_DATA_KINDS_SETTINGS.
  847. COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_PROFILE = 1 << 14,
  848. } COREWEBVIEW2_BROWSING_DATA_KINDS;
  849. cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(COREWEBVIEW2_BROWSING_DATA_KINDS);")
  850. /// Specifies the action type when server certificate error is detected to be
  851. /// used in the `ICoreWebView2ServerCertificateErrorDetectedEventArgs`
  852. /// interface.
  853. [v1_enum] typedef enum COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION {
  854. /// Indicates to ignore the warning and continue the request with the TLS
  855. /// certificate. This decision is cached for the RequestUri's host and the
  856. /// server certificate in the session.
  857. COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION_ALWAYS_ALLOW,
  858. /// Indicates to reject the certificate and cancel the request.
  859. COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION_CANCEL,
  860. /// Indicates to display the default TLS interstitial error page to user for
  861. /// page navigations.
  862. /// For others TLS certificate is rejected and the request is cancelled.
  863. COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION_DEFAULT
  864. } COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION;
  865. // End of enums and structs
  866. /// WebView2 enables you to host web content using the latest Microsoft Edge
  867. /// browser and web technology.
  868. [uuid(76eceacb-0462-4d94-ac83-423a6793775e), object, pointer_default(unique)]
  869. interface ICoreWebView2 : IUnknown {
  870. /// The `ICoreWebView2Settings` object contains various modifiable settings
  871. /// for the running WebView.
  872. [propget] HRESULT Settings([out, retval] ICoreWebView2Settings** settings);
  873. /// The URI of the current top level document. This value potentially
  874. /// changes as a part of the `SourceChanged` event that runs for some cases
  875. /// such as navigating to a different site or fragment navigations. It
  876. /// remains the same for other types of navigations such as page refreshes
  877. /// or `history.pushState` with the same URL as the current page.
  878. ///
  879. /// The caller must free the returned string with `CoTaskMemFree`. See
  880. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  881. ///
  882. /// \snippet ControlComponent.cpp SourceChanged
  883. [propget] HRESULT Source([out, retval] LPWSTR* uri);
  884. /// Cause a navigation of the top-level document to run to the specified URI.
  885. /// For more information, navigate to [Navigation
  886. /// events](/microsoft-edge/webview2/concepts/navigation-events).
  887. ///
  888. /// \> [!NOTE]\n\> This operation starts a navigation and the corresponding
  889. /// `NavigationStarting` event triggers sometime after `Navigate` runs.
  890. ///
  891. /// \snippet ControlComponent.cpp Navigate
  892. HRESULT Navigate([in] LPCWSTR uri);
  893. /// Initiates a navigation to htmlContent as source HTML of a new document.
  894. /// The `htmlContent` parameter may not be larger than 2 MB (2 * 1024 * 1024 bytes) in total size.
  895. /// The origin of the new page is `about:blank`.
  896. ///
  897. /// ```cpp
  898. /// SetVirtualHostNameToFolderMapping(
  899. /// L"appassets.example", L"assets",
  900. /// COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_DENY);
  901. ///
  902. /// WCHAR c_navString[] = LR"
  903. /// <head><link rel='stylesheet' href ='http://appassets.example/wv2.css'/></head>
  904. /// <body>
  905. /// <img src='http://appassets.example/wv2.png' />
  906. /// <p><a href='http://appassets.example/winrt_test.txt'>Click me</a></p>
  907. /// </body>";
  908. /// m_webView->NavigateToString(c_navString);
  909. /// ```
  910. /// \snippet SettingsComponent.cpp NavigateToString
  911. HRESULT NavigateToString([in] LPCWSTR htmlContent);
  912. /// Add an event handler for the `NavigationStarting` event.
  913. /// `NavigationStarting` runs when the WebView main frame is requesting
  914. /// permission to navigate to a different URI. Redirects trigger this
  915. /// operation as well, and the navigation id is the same as the original
  916. /// one.
  917. ///
  918. /// Navigations will be blocked until all `NavigationStarting` event handlers
  919. /// return.
  920. ///
  921. /// \snippet SettingsComponent.cpp NavigationStarting
  922. HRESULT add_NavigationStarting(
  923. [in] ICoreWebView2NavigationStartingEventHandler* eventHandler,
  924. [out] EventRegistrationToken* token);
  925. /// Remove an event handler previously added with `add_NavigationStarting`.
  926. HRESULT remove_NavigationStarting(
  927. [in] EventRegistrationToken token);
  928. /// Add an event handler for the `ContentLoading` event. `ContentLoading`
  929. /// triggers before any content is loaded, including scripts added with
  930. /// `AddScriptToExecuteOnDocumentCreated`. `ContentLoading` does not trigger
  931. /// if a same page navigation occurs (such as through `fragment`
  932. /// navigations or `history.pushState` navigations). This operation
  933. /// follows the `NavigationStarting` and `SourceChanged` events and precedes
  934. /// the `HistoryChanged` and `NavigationCompleted` events.
  935. HRESULT add_ContentLoading(
  936. [in] ICoreWebView2ContentLoadingEventHandler* eventHandler,
  937. [out] EventRegistrationToken* token);
  938. /// Remove an event handler previously added with `add_ContentLoading`.
  939. HRESULT remove_ContentLoading(
  940. [in] EventRegistrationToken token);
  941. /// Add an event handler for the `SourceChanged` event. `SourceChanged`
  942. /// triggers when the `Source` property changes. `SourceChanged` runs when
  943. /// navigating to a different site or fragment navigations. It does not
  944. /// trigger for other types of navigations such as page refreshes or
  945. /// `history.pushState` with the same URL as the current page.
  946. /// `SourceChanged` runs before `ContentLoading` for navigation to a new
  947. /// document.
  948. ///
  949. /// \snippet ControlComponent.cpp SourceChanged
  950. HRESULT add_SourceChanged(
  951. [in] ICoreWebView2SourceChangedEventHandler* eventHandler,
  952. [out] EventRegistrationToken* token);
  953. /// Remove an event handler previously added with `add_SourceChanged`.
  954. HRESULT remove_SourceChanged(
  955. [in] EventRegistrationToken token);
  956. /// Add an event handler for the `HistoryChanged` event. `HistoryChanged` is
  957. /// raised for changes to joint session history, which consists of top-level
  958. /// and manual frame navigations. Use `HistoryChanged` to verify that the
  959. /// `CanGoBack` or `CanGoForward` value has changed. `HistoryChanged` also
  960. /// runs for using `GoBack` or `GoForward`. `HistoryChanged` runs after
  961. /// `SourceChanged` and `ContentLoading`. `CanGoBack` is false for
  962. /// navigations initiated through ICoreWebView2Frame APIs if there has not yet
  963. /// been a user gesture.
  964. ///
  965. /// \snippet ControlComponent.cpp HistoryChanged
  966. HRESULT add_HistoryChanged(
  967. [in] ICoreWebView2HistoryChangedEventHandler* eventHandler,
  968. [out] EventRegistrationToken* token);
  969. /// Remove an event handler previously added with `add_HistoryChanged`.
  970. HRESULT remove_HistoryChanged(
  971. [in] EventRegistrationToken token);
  972. /// Add an event handler for the `NavigationCompleted` event.
  973. /// `NavigationCompleted` runs when the WebView has completely loaded
  974. /// (concurrently when `body.onload` runs) or loading stopped with error.
  975. ///
  976. /// \snippet ControlComponent.cpp NavigationCompleted
  977. HRESULT add_NavigationCompleted(
  978. [in] ICoreWebView2NavigationCompletedEventHandler* eventHandler,
  979. [out] EventRegistrationToken* token);
  980. /// Remove an event handler previously added with `add_NavigationCompleted`.
  981. HRESULT remove_NavigationCompleted(
  982. [in] EventRegistrationToken token);
  983. /// Add an event handler for the `FrameNavigationStarting` event.
  984. /// `FrameNavigationStarting` triggers when a child frame in the WebView
  985. /// requests permission to navigate to a different URI. Redirects trigger
  986. /// this operation as well, and the navigation id is the same as the original
  987. /// one.
  988. ///
  989. /// Navigations will be blocked until all `FrameNavigationStarting` event
  990. /// handlers return.
  991. ///
  992. /// \snippet SettingsComponent.cpp FrameNavigationStarting
  993. HRESULT add_FrameNavigationStarting(
  994. [in] ICoreWebView2NavigationStartingEventHandler* eventHandler,
  995. [out] EventRegistrationToken* token);
  996. /// Remove an event handler previously added with
  997. /// `add_FrameNavigationStarting`.
  998. HRESULT remove_FrameNavigationStarting(
  999. [in] EventRegistrationToken token);
  1000. /// Add an event handler for the `FrameNavigationCompleted` event.
  1001. /// `FrameNavigationCompleted` triggers when a child frame has completely
  1002. /// loaded (concurrently when `body.onload` has triggered) or loading stopped with error.
  1003. ///
  1004. /// \snippet ControlComponent.cpp FrameNavigationCompleted
  1005. HRESULT add_FrameNavigationCompleted(
  1006. [in] ICoreWebView2NavigationCompletedEventHandler* eventHandler,
  1007. [out] EventRegistrationToken* token);
  1008. /// Remove an event handler previously added with
  1009. /// `add_FrameNavigationCompleted`.
  1010. HRESULT remove_FrameNavigationCompleted(
  1011. [in] EventRegistrationToken token);
  1012. /// Add an event handler for the `ScriptDialogOpening` event.
  1013. /// `ScriptDialogOpening` runs when a JavaScript dialog (`alert`, `confirm`,
  1014. /// `prompt`, or `beforeunload`) displays for the webview. This event only
  1015. /// triggers if the `ICoreWebView2Settings::AreDefaultScriptDialogsEnabled`
  1016. /// property is set to `FALSE`. The `ScriptDialogOpening` event suppresses
  1017. /// dialogs or replaces default dialogs with custom dialogs.
  1018. ///
  1019. /// If a deferral is not taken on the event args, the subsequent scripts are
  1020. /// blocked until the event handler returns. If a deferral is taken, the
  1021. /// scripts are blocked until the deferral is completed.
  1022. ///
  1023. /// \snippet SettingsComponent.cpp ScriptDialogOpening
  1024. HRESULT add_ScriptDialogOpening(
  1025. [in] ICoreWebView2ScriptDialogOpeningEventHandler* eventHandler,
  1026. [out] EventRegistrationToken* token);
  1027. /// Remove an event handler previously added with `add_ScriptDialogOpening`.
  1028. HRESULT remove_ScriptDialogOpening(
  1029. [in] EventRegistrationToken token);
  1030. /// Add an event handler for the `PermissionRequested` event.
  1031. /// `PermissionRequested` runs when content in a WebView requests permission
  1032. /// to access some privileged resources.
  1033. ///
  1034. /// If a deferral is not taken on the event args, the subsequent scripts are
  1035. /// blocked until the event handler returns. If a deferral is taken, the
  1036. /// scripts are blocked until the deferral is completed.
  1037. ///
  1038. /// \snippet SettingsComponent.cpp PermissionRequested0
  1039. /// \snippet SettingsComponent.cpp PermissionRequested1
  1040. HRESULT add_PermissionRequested(
  1041. [in] ICoreWebView2PermissionRequestedEventHandler* eventHandler,
  1042. [out] EventRegistrationToken* token);
  1043. /// Remove an event handler previously added with `add_PermissionRequested`.
  1044. HRESULT remove_PermissionRequested(
  1045. [in] EventRegistrationToken token);
  1046. /// Add an event handler for the `ProcessFailed` event. `ProcessFailed` runs
  1047. /// when a WebView process ends unexpectedly or becomes unresponsive.
  1048. ///
  1049. /// \snippet ProcessComponent.cpp ProcessFailed
  1050. HRESULT add_ProcessFailed(
  1051. [in] ICoreWebView2ProcessFailedEventHandler* eventHandler,
  1052. [out] EventRegistrationToken* token);
  1053. /// Remove an event handler previously added with add_ProcessFailed.
  1054. HRESULT remove_ProcessFailed(
  1055. [in] EventRegistrationToken token);
  1056. /// Add the provided JavaScript to a list of scripts that should be run after
  1057. /// the global object has been created, but before the HTML document has
  1058. /// been parsed and before any other script included by the HTML document is
  1059. /// run. This method injects a script that runs on all top-level document
  1060. /// and child frame page navigations. This method runs asynchronously, and
  1061. /// you must wait for the completion handler to finish before the injected
  1062. /// script is ready to run. When this method completes, the `Invoke` method
  1063. /// of the handler is run with the `id` of the injected script. `id` is a
  1064. /// string. To remove the injected script, use
  1065. /// `RemoveScriptToExecuteOnDocumentCreated`.
  1066. ///
  1067. /// If the method is run in add_NewWindowRequested handler it should be called
  1068. /// after the new window is set. For more details see `ICoreWebView2NewWindowRequestedEventArgs::put_NewWindow`.
  1069. ///
  1070. /// \> [!NOTE]\n\> If an HTML document is running in a sandbox of some kind using
  1071. /// [sandbox](https://developer.mozilla.org/docs/Web/HTML/Element/iframe#attr-sandbox)
  1072. /// properties or the
  1073. /// [Content-Security-Policy](https://developer.mozilla.org/docs/Web/HTTP/Headers/Content-Security-Policy)
  1074. /// HTTP header affects the script that runs. For example, if the
  1075. /// `allow-modals` keyword is not set then requests to run the `alert`
  1076. /// function are ignored.
  1077. ///
  1078. /// \snippet ScriptComponent.cpp AddScriptToExecuteOnDocumentCreated
  1079. HRESULT AddScriptToExecuteOnDocumentCreated(
  1080. [in] LPCWSTR javaScript,
  1081. [in] ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler* handler);
  1082. /// Remove the corresponding JavaScript added using
  1083. /// `AddScriptToExecuteOnDocumentCreated` with the specified script ID.
  1084. HRESULT RemoveScriptToExecuteOnDocumentCreated([in] LPCWSTR id);
  1085. /// Run JavaScript code from the javascript parameter in the current
  1086. /// top-level document rendered in the WebView. The result of evaluating
  1087. /// the provided JavaScript is used in this parameter. The result value is
  1088. /// a JSON encoded string. If the result is undefined, contains a reference
  1089. /// cycle, or otherwise is not able to be encoded into JSON, then the result
  1090. /// is considered to be null, which is encoded in JSON as the string "null".
  1091. ///
  1092. /// \> [!NOTE]\n\> A function that has no explicit return value returns undefined. If the
  1093. /// script that was run throws an unhandled exception, then the result is
  1094. /// also "null". This method is applied asynchronously. If the method is
  1095. /// run after the `NavigationStarting` event during a navigation, the script
  1096. /// runs in the new document when loading it, around the time
  1097. /// `ContentLoading` is run. This operation executes the script even if
  1098. /// `ICoreWebView2Settings::IsScriptEnabled` is set to `FALSE`.
  1099. ///
  1100. /// \snippet ScriptComponent.cpp ExecuteScript
  1101. HRESULT ExecuteScript(
  1102. [in] LPCWSTR javaScript,
  1103. [in] ICoreWebView2ExecuteScriptCompletedHandler* handler);
  1104. /// Capture an image of what WebView is displaying. Specify the format of
  1105. /// the image with the `imageFormat` parameter. The resulting image binary
  1106. /// data is written to the provided `imageStream` parameter. When
  1107. /// `CapturePreview` finishes writing to the stream, the `Invoke` method on
  1108. /// the provided `handler` parameter is run. This method fails if called
  1109. /// before the first ContentLoading event. For example if this is called in
  1110. /// the NavigationStarting event for the first navigation it will fail.
  1111. /// For subsequent navigations, the method may not fail, but will not capture
  1112. /// an image of a given webpage until the ContentLoading event has been fired
  1113. /// for it. Any call to this method prior to that will result in a capture of
  1114. /// the page being navigated away from.
  1115. ///
  1116. /// \snippet FileComponent.cpp CapturePreview
  1117. HRESULT CapturePreview(
  1118. [in] COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT imageFormat,
  1119. [in] IStream* imageStream,
  1120. [in] ICoreWebView2CapturePreviewCompletedHandler* handler);
  1121. /// Reload the current page. This is similar to navigating to the URI of
  1122. /// current top level document including all navigation events firing and
  1123. /// respecting any entries in the HTTP cache. But, the back or forward
  1124. /// history are not modified.
  1125. HRESULT Reload();
  1126. /// Post the specified webMessage to the top level document in this WebView.
  1127. /// The main page receives the message by subscribing to the `message` event of the
  1128. /// `window.chrome.webview` of the page document.
  1129. ///
  1130. /// ```cpp
  1131. /// window.chrome.webview.addEventListener('message', handler)
  1132. /// window.chrome.webview.removeEventListener('message', handler)
  1133. /// ```
  1134. ///
  1135. /// The event args is an instance of `MessageEvent`. The
  1136. /// `ICoreWebView2Settings::IsWebMessageEnabled` setting must be `TRUE` or
  1137. /// this method fails with `E_INVALIDARG`. The `data` property of the event
  1138. /// arg is the `webMessage` string parameter parsed as a JSON string into a
  1139. /// JavaScript object. The `source` property of the event arg is a reference
  1140. /// to the `window.chrome.webview` object. For information about sending
  1141. /// messages from the HTML document in the WebView to the host, navigate to
  1142. /// [add_WebMessageReceived](/microsoft-edge/webview2/reference/win32/icorewebview2#add_webmessagereceived).
  1143. /// The message is delivered asynchronously. If a navigation occurs before
  1144. /// the message is posted to the page, the message is discarded.
  1145. ///
  1146. /// \snippet ScenarioWebMessage.cpp WebMessageReceived
  1147. HRESULT PostWebMessageAsJson([in] LPCWSTR webMessageAsJson);
  1148. /// Posts a message that is a simple string rather than a JSON string
  1149. /// representation of a JavaScript object. This behaves in exactly the same
  1150. /// manner as `PostWebMessageAsJson`, but the `data` property of the event
  1151. /// arg of the `window.chrome.webview` message is a string with the same
  1152. /// value as `webMessageAsString`. Use this instead of
  1153. /// `PostWebMessageAsJson` if you want to communicate using simple strings
  1154. /// rather than JSON objects.
  1155. HRESULT PostWebMessageAsString([in] LPCWSTR webMessageAsString);
  1156. /// Add an event handler for the `WebMessageReceived` event.
  1157. /// `WebMessageReceived` runs when the
  1158. /// `ICoreWebView2Settings::IsWebMessageEnabled` setting is set and the
  1159. /// top-level document of the WebView runs
  1160. /// `window.chrome.webview.postMessage`. The `postMessage` function is
  1161. /// `void postMessage(object)` where object is any object supported by JSON
  1162. /// conversion.
  1163. ///
  1164. /// \snippet assets\ScenarioWebMessage.html chromeWebView
  1165. ///
  1166. /// When the page calls `postMessage`, the object parameter is converted to a
  1167. /// JSON string and is posted asynchronously to the host process. This will
  1168. /// result in the handler's `Invoke` method being called with the JSON string
  1169. /// as a parameter.
  1170. ///
  1171. /// \snippet ScenarioWebMessage.cpp WebMessageReceived
  1172. ///
  1173. /// If the same page calls `postMessage` multiple times, the corresponding
  1174. /// `WebMessageReceived` events are guaranteed to be fired in the same order.
  1175. /// However, if multiple frames call `postMessage`, there is no guaranteed
  1176. /// order. In addition, `WebMessageReceived` events caused by calls to
  1177. /// `postMessage` are not guaranteed to be sequenced with events caused by DOM
  1178. /// APIs. For example, if the page runs
  1179. ///
  1180. /// ```javascript
  1181. /// chrome.webview.postMessage("message");
  1182. /// window.open();
  1183. /// ```
  1184. ///
  1185. /// then the `NewWindowRequested` event might be fired before the
  1186. /// `WebMessageReceived` event. If you need the `WebMessageReceived` event
  1187. /// to happen before anything else, then in the `WebMessageReceived` handler
  1188. /// you can post a message back to the page and have the page wait until it
  1189. /// receives that message before continuing.
  1190. HRESULT add_WebMessageReceived(
  1191. [in] ICoreWebView2WebMessageReceivedEventHandler* handler,
  1192. [out] EventRegistrationToken* token);
  1193. /// Remove an event handler previously added with `add_WebMessageReceived`.
  1194. HRESULT remove_WebMessageReceived(
  1195. [in] EventRegistrationToken token);
  1196. /// Runs an asynchronous `DevToolsProtocol` method. For more information
  1197. /// about available methods, navigate to
  1198. /// [DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/tot)
  1199. /// . The `methodName` parameter is the full name of the method in the
  1200. /// `{domain}.{method}` format. The `parametersAsJson` parameter is a JSON
  1201. /// formatted string containing the parameters for the corresponding method.
  1202. /// The `Invoke` method of the `handler` is run when the method
  1203. /// asynchronously completes. `Invoke` is run with the return object of the
  1204. /// method as a JSON string.
  1205. ///
  1206. /// \snippet ScriptComponent.cpp CallDevToolsProtocolMethod
  1207. HRESULT CallDevToolsProtocolMethod(
  1208. [in] LPCWSTR methodName,
  1209. [in] LPCWSTR parametersAsJson,
  1210. [in] ICoreWebView2CallDevToolsProtocolMethodCompletedHandler* handler);
  1211. /// The process ID of the browser process that hosts the WebView.
  1212. [propget] HRESULT BrowserProcessId([out, retval] UINT32* value);
  1213. /// `TRUE` if the WebView is able to navigate to a previous page in the
  1214. /// navigation history. If `CanGoBack` changes value, the `HistoryChanged`
  1215. /// event runs.
  1216. [propget] HRESULT CanGoBack([out, retval] BOOL* canGoBack);
  1217. /// `TRUE` if the WebView is able to navigate to a next page in the
  1218. /// navigation history. If `CanGoForward` changes value, the
  1219. /// `HistoryChanged` event runs.
  1220. [propget] HRESULT CanGoForward([out, retval] BOOL* canGoForward);
  1221. /// Navigates the WebView to the previous page in the navigation history.
  1222. HRESULT GoBack();
  1223. /// Navigates the WebView to the next page in the navigation history.
  1224. HRESULT GoForward();
  1225. /// Get a DevTools Protocol event receiver that allows you to subscribe to a
  1226. /// DevTools Protocol event. The `eventName` parameter is the full name of
  1227. /// the event in the format `{domain}.{event}`. For more information about
  1228. /// DevTools Protocol events description and event args, navigate to
  1229. /// [DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/tot).
  1230. ///
  1231. /// \snippet ScriptComponent.cpp DevToolsProtocolEventReceived
  1232. HRESULT GetDevToolsProtocolEventReceiver(
  1233. [in] LPCWSTR eventName,
  1234. [out, retval] ICoreWebView2DevToolsProtocolEventReceiver** receiver);
  1235. /// Stop all navigations and pending resource fetches. Does not stop scripts.
  1236. HRESULT Stop();
  1237. /// Add an event handler for the `NewWindowRequested` event.
  1238. /// `NewWindowRequested` runs when content inside the WebView requests to
  1239. /// open a new window, such as through `window.open`. The app passes a
  1240. /// target WebView that is considered the opened window.
  1241. ///
  1242. /// If a deferral is not taken on the event args, scripts that resulted in
  1243. /// the new window that are requested are blocked until the event handler
  1244. /// returns. If a deferral is taken, then scripts are blocked until the
  1245. /// deferral is completed or new window is set.
  1246. ///
  1247. /// For more details and considerations on the target WebView to be supplied
  1248. /// at the opened window, see `ICoreWebView2NewWindowRequestedEventArgs::put_NewWindow`.
  1249. ///
  1250. /// \snippet AppWindow.cpp NewWindowRequested
  1251. HRESULT add_NewWindowRequested(
  1252. [in] ICoreWebView2NewWindowRequestedEventHandler* eventHandler,
  1253. [out] EventRegistrationToken* token);
  1254. /// Remove an event handler previously added with `add_NewWindowRequested`.
  1255. HRESULT remove_NewWindowRequested(
  1256. [in] EventRegistrationToken token);
  1257. /// Add an event handler for the `DocumentTitleChanged` event.
  1258. /// `DocumentTitleChanged` runs when the `DocumentTitle` property of the
  1259. /// WebView changes and may run before or after the `NavigationCompleted`
  1260. /// event.
  1261. ///
  1262. /// \snippet FileComponent.cpp DocumentTitleChanged
  1263. HRESULT add_DocumentTitleChanged(
  1264. [in] ICoreWebView2DocumentTitleChangedEventHandler* eventHandler,
  1265. [out] EventRegistrationToken* token);
  1266. /// Remove an event handler previously added with `add_DocumentTitleChanged`.
  1267. HRESULT remove_DocumentTitleChanged(
  1268. [in] EventRegistrationToken token);
  1269. /// The title for the current top-level document. If the document has no
  1270. /// explicit title or is otherwise empty, a default that may or may not match
  1271. /// the URI of the document is used.
  1272. ///
  1273. /// The caller must free the returned string with `CoTaskMemFree`. See
  1274. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  1275. [propget] HRESULT DocumentTitle([out, retval] LPWSTR* title);
  1276. /// Add the provided host object to script running in the WebView with the
  1277. /// specified name. Host objects are exposed as host object proxies using
  1278. /// `window.chrome.webview.hostObjects.{name}`. Host object proxies are
  1279. /// promises and resolves to an object representing the host object. The
  1280. /// promise is rejected if the app has not added an object with the name.
  1281. /// When JavaScript code access a property or method of the object, a promise
  1282. /// is return, which resolves to the value returned from the host for the
  1283. /// property or method, or rejected in case of error, for example, no
  1284. /// property or method on the object or parameters are not valid.
  1285. ///
  1286. /// \> [!NOTE]\n\> While simple types, `IDispatch` and array are supported, and
  1287. /// `IUnknown` objects that also implement `IDispatch` are treated as `IDispatch`,
  1288. /// generic `IUnknown`, `VT_DECIMAL`, or `VT_RECORD` variant is not supported.
  1289. /// Remote JavaScript objects like callback functions are represented as an
  1290. /// `VT_DISPATCH` `VARIANT` with the object implementing `IDispatch`. The
  1291. /// JavaScript callback method may be invoked using `DISPID_VALUE` for the
  1292. /// `DISPID`. Nested arrays are supported up to a depth of 3. Arrays of by
  1293. /// reference types are not supported. `VT_EMPTY` and `VT_NULL` are mapped
  1294. /// into JavaScript as `null`. In JavaScript, `null` and undefined are
  1295. /// mapped to `VT_EMPTY`.
  1296. ///
  1297. /// Additionally, all host objects are exposed as
  1298. /// `window.chrome.webview.hostObjects.sync.{name}`. Here the host objects
  1299. /// are exposed as synchronous host object proxies. These are not promises
  1300. /// and function runtimes or property access synchronously block running
  1301. /// script waiting to communicate cross process for the host code to run.
  1302. /// Accordingly the result may have reliability issues and it is recommended
  1303. /// that you use the promise-based asynchronous
  1304. /// `window.chrome.webview.hostObjects.{name}` API.
  1305. ///
  1306. /// Synchronous host object proxies and asynchronous host object proxies may
  1307. /// both use a proxy to the same host object. Remote changes made by one
  1308. /// proxy propagates to any other proxy of that same host object whether
  1309. /// the other proxies and synchronous or asynchronous.
  1310. ///
  1311. /// While JavaScript is blocked on a synchronous run to native code, that
  1312. /// native code is unable to run back to JavaScript. Attempts to do so fail
  1313. /// with `HRESULT_FROM_WIN32(ERROR_POSSIBLE_DEADLOCK)`.
  1314. ///
  1315. /// Host object proxies are JavaScript Proxy objects that intercept all
  1316. /// property get, property set, and method invocations. Properties or methods
  1317. /// that are a part of the Function or Object prototype are run locally.
  1318. /// Additionally any property or method in the
  1319. /// `chrome.webview.hostObjects.options.forceLocalProperties`
  1320. /// array are also run locally. This defaults to including optional methods
  1321. /// that have meaning in JavaScript like `toJSON` and `Symbol.toPrimitive`.
  1322. /// Add more to the array as required.
  1323. ///
  1324. /// The `chrome.webview.hostObjects.cleanupSome` method performs a best
  1325. /// effort garbage collection on host object proxies.
  1326. ///
  1327. /// The `chrome.webview.hostObjects.options` object provides the ability to
  1328. /// change some functionality of host objects.
  1329. ///
  1330. /// Options property | Details
  1331. /// ---|---
  1332. /// `forceLocalProperties` | This is an array of host object property names that will be run locally, instead of being called on the native host object. This defaults to `then`, `toJSON`, `Symbol.toString`, and `Symbol.toPrimitive`. You can add other properties to specify that they should be run locally on the javascript host object proxy.
  1333. /// `log` | This is a callback that will be called with debug information. For example, you can set this to `console.log.bind(console)` to have it print debug information to the console to help when troubleshooting host object usage. By default this is null.
  1334. /// `shouldSerializeDates` | By default this is false, and javascript Date objects will be sent to host objects as a string using `JSON.stringify`. You can set this property to true to have Date objects properly serialize as a `VT_DATE` when sending to the native host object, and have `VT_DATE` properties and return values create a javascript Date object.
  1335. /// `defaultSyncProxy` | When calling a method on a synchronous proxy, the result should also be a synchronous proxy. But in some cases, the sync/async context is lost (for example, when providing to native code a reference to a function, and then calling that function in native code). In these cases, the proxy will be asynchronous, unless this property is set.
  1336. /// `forceAsyncMethodMatches ` | This is an array of regular expressions. When calling a method on a synchronous proxy, the method call will be performed asynchronously if the method name matches a string or regular expression in this array. Setting this value to `Async` will make any method that ends with Async be an asynchronous method call. If an async method doesn't match here and isn't forced to be asynchronous, the method will be invoked synchronously, blocking execution of the calling JavaScript and then returning the resolution of the promise, rather than returning a promise.
  1337. /// `ignoreMemberNotFoundError` | By default, an exception is thrown when attempting to get the value of a proxy property that doesn't exist on the corresponding native class. Setting this property to `true` switches the behavior to match Chakra WinRT projection (and general JavaScript) behavior of returning `undefined` with no error.
  1338. ///
  1339. /// Host object proxies additionally have the following methods which run
  1340. /// locally.
  1341. ///
  1342. /// Method name | Details
  1343. /// ---|---
  1344. ///`applyHostFunction`, `getHostProperty`, `setHostProperty` | Perform a method invocation, property get, or property set on the host object. Use the methods to explicitly force a method or property to run remotely if a conflicting local method or property exists. For instance, `proxy.toString()` runs the local `toString` method on the proxy object. But proxy.applyHostFunction('toString') runs `toString` on the host proxied object instead.
  1345. ///`getLocalProperty`, `setLocalProperty` | Perform property get, or property set locally. Use the methods to force getting or setting a property on the host object proxy rather than on the host object it represents. For instance, `proxy.unknownProperty` gets the property named `unknownProperty` from the host proxied object. But proxy.getLocalProperty('unknownProperty') gets the value of the property `unknownProperty` on the proxy object.
  1346. ///`sync` | Asynchronous host object proxies expose a sync method which returns a promise for a synchronous host object proxy for the same host object. For example, `chrome.webview.hostObjects.sample.methodCall()` returns an asynchronous host object proxy. Use the `sync` method to obtain a synchronous host object proxy instead: `const syncProxy = await chrome.webview.hostObjects.sample.methodCall().sync()`.
  1347. ///`async` | Synchronous host object proxies expose an async method which blocks and returns an asynchronous host object proxy for the same host object. For example, `chrome.webview.hostObjects.sync.sample.methodCall()` returns a synchronous host object proxy. Running the `async` method on this blocks and then returns an asynchronous host object proxy for the same host object: `const asyncProxy = chrome.webview.hostObjects.sync.sample.methodCall().async()`.
  1348. ///`then` | Asynchronous host object proxies have a `then` method. Allows proxies to be awaitable. `then` returns a promise that resolves with a representation of the host object. If the proxy represents a JavaScript literal, a copy of that is returned locally. If the proxy represents a function, a non-awaitable proxy is returned. If the proxy represents a JavaScript object with a mix of literal properties and function properties, the a copy of the object is returned with some properties as host object proxies.
  1349. ///
  1350. /// All other property and method invocations (other than the above Remote
  1351. /// object proxy methods, `forceLocalProperties` list, and properties on
  1352. /// Function and Object prototypes) are run remotely. Asynchronous host
  1353. /// object proxies return a promise representing asynchronous completion of
  1354. /// remotely invoking the method, or getting the property. The promise
  1355. /// resolves after the remote operations complete and the promises resolve to
  1356. /// the resulting value of the operation. Synchronous host object proxies
  1357. /// work similarly, but block running JavaScript and wait for the remote
  1358. /// operation to complete.
  1359. ///
  1360. /// Setting a property on an asynchronous host object proxy works slightly
  1361. /// differently. The set returns immediately and the return value is the
  1362. /// value that is set. This is a requirement of the JavaScript Proxy object.
  1363. /// If you need to asynchronously wait for the property set to complete, use
  1364. /// the `setHostProperty` method which returns a promise as described above.
  1365. /// Synchronous object property set property synchronously blocks until the
  1366. /// property is set.
  1367. ///
  1368. /// For example, suppose you have a COM object with the following interface.
  1369. ///
  1370. /// \snippet HostObjectSample.idl AddHostObjectInterface
  1371. ///
  1372. /// Add an instance of this interface into your JavaScript with
  1373. /// `AddHostObjectToScript`. In this case, name it `sample`.
  1374. ///
  1375. /// \snippet ScenarioAddHostObject.cpp AddHostObjectToScript
  1376. ///
  1377. /// In the HTML document, use the COM object using
  1378. /// `chrome.webview.hostObjects.sample`.
  1379. ///
  1380. /// \snippet assets\ScenarioAddHostObject.html HostObjectUsage
  1381. ///
  1382. /// Exposing host objects to script has security risk. For more information
  1383. /// about best practices, navigate to
  1384. /// [Best practices for developing secure WebView2 applications](/microsoft-edge/webview2/concepts/security).
  1385. HRESULT AddHostObjectToScript([in] LPCWSTR name, [in] VARIANT* object);
  1386. /// Remove the host object specified by the name so that it is no longer
  1387. /// accessible from JavaScript code in the WebView. While new access
  1388. /// attempts are denied, if the object is already obtained by JavaScript code
  1389. /// in the WebView, the JavaScript code continues to have access to that
  1390. /// object. Run this method for a name that is already removed or never
  1391. /// added fails.
  1392. HRESULT RemoveHostObjectFromScript([in] LPCWSTR name);
  1393. /// Opens the DevTools window for the current document in the WebView. Does
  1394. /// nothing if run when the DevTools window is already open.
  1395. HRESULT OpenDevToolsWindow();
  1396. /// Add an event handler for the `ContainsFullScreenElementChanged` event.
  1397. /// `ContainsFullScreenElementChanged` triggers when the
  1398. /// `ContainsFullScreenElement` property changes. An HTML element inside the
  1399. /// WebView may enter fullscreen to the size of the WebView or leave
  1400. /// fullscreen. This event is useful when, for example, a video element
  1401. /// requests to go fullscreen. The listener of
  1402. /// `ContainsFullScreenElementChanged` may resize the WebView in response.
  1403. ///
  1404. /// \snippet AppWindow.cpp ContainsFullScreenElementChanged
  1405. HRESULT add_ContainsFullScreenElementChanged(
  1406. [in] ICoreWebView2ContainsFullScreenElementChangedEventHandler* eventHandler,
  1407. [out] EventRegistrationToken* token);
  1408. /// Remove an event handler previously added with
  1409. /// `add_ContainsFullScreenElementChanged`.
  1410. HRESULT remove_ContainsFullScreenElementChanged(
  1411. [in] EventRegistrationToken token);
  1412. /// Indicates if the WebView contains a fullscreen HTML element.
  1413. [propget] HRESULT ContainsFullScreenElement(
  1414. [out, retval] BOOL* containsFullScreenElement);
  1415. /// Add an event handler for the `WebResourceRequested` event.
  1416. /// `WebResourceRequested` runs when the WebView is performing a URL request
  1417. /// to a matching URL and resource context filter that was added with
  1418. /// `AddWebResourceRequestedFilter`. At least one filter must be added for
  1419. /// the event to run.
  1420. ///
  1421. /// The web resource requested may be blocked until the event handler returns
  1422. /// if a deferral is not taken on the event args. If a deferral is taken,
  1423. /// then the web resource requested is blocked until the deferral is
  1424. /// completed.
  1425. ///
  1426. /// If this event is subscribed in the add_NewWindowRequested handler it should be called
  1427. /// after the new window is set. For more details see `ICoreWebView2NewWindowRequestedEventArgs::put_NewWindow`.
  1428. ///
  1429. /// Currently this only supports file, http, and https URI schemes.
  1430. ///
  1431. /// \snippet SettingsComponent.cpp WebResourceRequested0
  1432. /// \snippet SettingsComponent.cpp WebResourceRequested1
  1433. HRESULT add_WebResourceRequested(
  1434. [in] ICoreWebView2WebResourceRequestedEventHandler* eventHandler,
  1435. [out] EventRegistrationToken* token);
  1436. /// Remove an event handler previously added with `add_WebResourceRequested`.
  1437. HRESULT remove_WebResourceRequested(
  1438. [in] EventRegistrationToken token);
  1439. /// Adds a URI and resource context filter for the `WebResourceRequested`
  1440. /// event. A web resource request with a resource context that matches this
  1441. /// filter's resource context and a URI that matches this filter's URI
  1442. /// wildcard string will be raised via the `WebResourceRequested` event.
  1443. ///
  1444. /// The `uri` parameter value is a wildcard string matched against the URI
  1445. /// of the web resource request. This is a glob style
  1446. /// wildcard string in which a `*` matches zero or more characters and a `?`
  1447. /// matches exactly one character.
  1448. /// These wildcard characters can be escaped using a backslash just before
  1449. /// the wildcard character in order to represent the literal `*` or `?`.
  1450. ///
  1451. /// The matching occurs over the URI as a whole string and not limiting
  1452. /// wildcard matches to particular parts of the URI.
  1453. /// The wildcard filter is compared to the URI after the URI has been
  1454. /// normalized, any URI fragment has been removed, and non-ASCII hostnames
  1455. /// have been converted to punycode.
  1456. ///
  1457. /// Specifying a `nullptr` for the uri is equivalent to an empty string which
  1458. /// matches no URIs.
  1459. ///
  1460. /// For more information about resource context filters, navigate to
  1461. /// [COREWEBVIEW2_WEB_RESOURCE_CONTEXT].
  1462. ///
  1463. /// | URI Filter String | Request URI | Match | Notes |
  1464. /// | ---- | ---- | ---- | ---- |
  1465. /// | `*` | `https://contoso.com/a/b/c` | Yes | A single * will match all URIs |
  1466. /// | `*://contoso.com/*` | `https://contoso.com/a/b/c` | Yes | Matches everything in contoso.com across all schemes |
  1467. /// | `*://contoso.com/*` | `https://example.com/?https://contoso.com/` | Yes | But also matches a URI with just the same text anywhere in the URI |
  1468. /// | `example` | `https://contoso.com/example` | No | The filter does not perform partial matches |
  1469. /// | `*example` | `https://contoso.com/example` | Yes | The filter matches across URI parts |
  1470. /// | `*example` | `https://contoso.com/path/?example` | Yes | The filter matches across URI parts |
  1471. /// | `*example` | `https://contoso.com/path/?query#example` | No | The filter is matched against the URI with no fragment |
  1472. /// | `*example` | `https://example` | No | The URI is normalized before filter matching so the actual URI used for comparison is `https://example.com/` |
  1473. /// | `*example/` | `https://example` | Yes | Just like above, but this time the filter ends with a / just like the normalized URI |
  1474. /// | `https://xn--qei.example/` | `https://&#x2764;.example/` | Yes | Non-ASCII hostnames are normalized to punycode before wildcard comparison |
  1475. /// | `https://&#x2764;.example/` | `https://xn--qei.example/` | No | Non-ASCII hostnames are normalized to punycode before wildcard comparison |
  1476. HRESULT AddWebResourceRequestedFilter(
  1477. [in] LPCWSTR const uri,
  1478. [in] COREWEBVIEW2_WEB_RESOURCE_CONTEXT const resourceContext);
  1479. /// Removes a matching WebResource filter that was previously added for the
  1480. /// `WebResourceRequested` event. If the same filter was added multiple
  1481. /// times, then it must be removed as many times as it was added for the
  1482. /// removal to be effective. Returns `E_INVALIDARG` for a filter that was
  1483. /// never added.
  1484. HRESULT RemoveWebResourceRequestedFilter(
  1485. [in] LPCWSTR const uri,
  1486. [in] COREWEBVIEW2_WEB_RESOURCE_CONTEXT const resourceContext);
  1487. /// Add an event handler for the `WindowCloseRequested` event.
  1488. /// `WindowCloseRequested` triggers when content inside the WebView
  1489. /// requested to close the window, such as after `window.close` is run. The
  1490. /// app should close the WebView and related app window if that makes sense
  1491. /// to the app.
  1492. ///
  1493. /// \snippet AppWindow.cpp WindowCloseRequested
  1494. HRESULT add_WindowCloseRequested(
  1495. [in] ICoreWebView2WindowCloseRequestedEventHandler* eventHandler,
  1496. [out] EventRegistrationToken* token);
  1497. /// Remove an event handler previously added with `add_WindowCloseRequested`.
  1498. HRESULT remove_WindowCloseRequested(
  1499. [in] EventRegistrationToken token);
  1500. }
  1501. /// A continuation of the ICoreWebView2 interface.
  1502. [uuid(9E8F0CF8-E670-4B5E-B2BC-73E061E3184C), object, pointer_default(unique)]
  1503. interface ICoreWebView2_2 : ICoreWebView2 {
  1504. /// Add an event handler for the WebResourceResponseReceived event.
  1505. /// WebResourceResponseReceived is raised when the WebView receives the
  1506. /// response for a request for a web resource (any URI resolution performed by
  1507. /// the WebView; such as HTTP/HTTPS, file and data requests from redirects,
  1508. /// navigations, declarations in HTML, implicit favicon lookups, and fetch API
  1509. /// usage in the document). The host app can use this event to view the actual
  1510. /// request and response for a web resource. There is no guarantee about the
  1511. /// order in which the WebView processes the response and the host app's
  1512. /// handler runs. The app's handler will not block the WebView from processing
  1513. /// the response.
  1514. /// \snippet ScenarioAuthentication.cpp WebResourceResponseReceived
  1515. HRESULT add_WebResourceResponseReceived(
  1516. [in] ICoreWebView2WebResourceResponseReceivedEventHandler* eventHandler,
  1517. [out] EventRegistrationToken* token);
  1518. /// Remove an event handler previously added with
  1519. /// add_WebResourceResponseReceived.
  1520. HRESULT remove_WebResourceResponseReceived(
  1521. [in] EventRegistrationToken token);
  1522. /// Navigates using a constructed WebResourceRequest object. This lets you
  1523. /// provide post data or additional request headers during navigation.
  1524. /// The headers in the WebResourceRequest override headers
  1525. /// added by WebView2 runtime except for Cookie headers.
  1526. /// Method can only be either "GET" or "POST". Provided post data will only
  1527. /// be sent only if the method is "POST" and the uri scheme is HTTP(S).
  1528. /// \snippet ScenarioNavigateWithWebResourceRequest.cpp NavigateWithWebResourceRequest
  1529. HRESULT NavigateWithWebResourceRequest([in] ICoreWebView2WebResourceRequest* request);
  1530. /// Add an event handler for the DOMContentLoaded event.
  1531. /// DOMContentLoaded is raised when the initial html document has been parsed.
  1532. /// This aligns with the document's DOMContentLoaded event in html.
  1533. ///
  1534. /// \snippet ScenarioDOMContentLoaded.cpp DOMContentLoaded
  1535. HRESULT add_DOMContentLoaded(
  1536. [in] ICoreWebView2DOMContentLoadedEventHandler* eventHandler,
  1537. [out] EventRegistrationToken* token);
  1538. /// Remove an event handler previously added with add_DOMContentLoaded.
  1539. HRESULT remove_DOMContentLoaded(
  1540. [in] EventRegistrationToken token);
  1541. /// Gets the cookie manager object associated with this ICoreWebView2.
  1542. /// See ICoreWebView2CookieManager.
  1543. ///
  1544. /// \snippet ScenarioCookieManagement.cpp CookieManager
  1545. [propget] HRESULT CookieManager([out, retval] ICoreWebView2CookieManager** cookieManager);
  1546. /// Exposes the CoreWebView2Environment used to create this CoreWebView2.
  1547. [propget] HRESULT Environment([out, retval] ICoreWebView2Environment** environment);
  1548. }
  1549. /// A continuation of the ICoreWebView2_2 interface.
  1550. [uuid(A0D6DF20-3B92-416D-AA0C-437A9C727857), object, pointer_default(unique)]
  1551. interface ICoreWebView2_3 : ICoreWebView2_2 {
  1552. /// An app may call the `TrySuspend` API to have the WebView2 consume less memory.
  1553. /// This is useful when a Win32 app becomes invisible, or when a Universal Windows
  1554. /// Platform app is being suspended, during the suspended event handler before completing
  1555. /// the suspended event.
  1556. /// The CoreWebView2Controller's IsVisible property must be false when the API is called.
  1557. /// Otherwise, the API fails with `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)`.
  1558. /// Suspending is similar to putting a tab to sleep in the Edge browser. Suspending pauses
  1559. /// WebView script timers and animations, minimizes CPU usage for the associated
  1560. /// browser renderer process and allows the operating system to reuse the memory that was
  1561. /// used by the renderer process for other processes.
  1562. /// Note that Suspend is best effort and considered completed successfully once the request
  1563. /// is sent to browser renderer process. If there is a running script, the script will continue
  1564. /// to run and the renderer process will be suspended after that script is done.
  1565. /// See [Sleeping Tabs FAQ](https://techcommunity.microsoft.com/t5/articles/sleeping-tabs-faq/m-p/1705434)
  1566. /// for conditions that might prevent WebView from being suspended. In those situations,
  1567. /// the completed handler will be invoked with isSuccessful as false and errorCode as S_OK.
  1568. /// The WebView will be automatically resumed when it becomes visible. Therefore, the
  1569. /// app normally does not have to call `Resume` explicitly.
  1570. /// The app can call `Resume` and then `TrySuspend` periodically for an invisible WebView so that
  1571. /// the invisible WebView can sync up with latest data and the page ready to show fresh content
  1572. /// when it becomes visible.
  1573. /// All WebView APIs can still be accessed when a WebView is suspended. Some APIs like Navigate
  1574. /// will auto resume the WebView. To avoid unexpected auto resume, check `IsSuspended` property
  1575. /// before calling APIs that might change WebView state.
  1576. ///
  1577. /// \snippet ViewComponent.cpp ToggleIsVisibleOnMinimize
  1578. ///
  1579. /// \snippet ViewComponent.cpp Suspend
  1580. ///
  1581. HRESULT TrySuspend([in] ICoreWebView2TrySuspendCompletedHandler* handler);
  1582. /// Resumes the WebView so that it resumes activities on the web page.
  1583. /// This API can be called while the WebView2 controller is invisible.
  1584. /// The app can interact with the WebView immediately after `Resume`.
  1585. /// WebView will be automatically resumed when it becomes visible.
  1586. ///
  1587. /// \snippet ViewComponent.cpp ToggleIsVisibleOnMinimize
  1588. ///
  1589. /// \snippet ViewComponent.cpp Resume
  1590. ///
  1591. HRESULT Resume();
  1592. /// Whether WebView is suspended.
  1593. /// `TRUE` when WebView is suspended, from the time when TrySuspend has completed
  1594. /// successfully until WebView is resumed.
  1595. [propget] HRESULT IsSuspended([out, retval] BOOL* isSuspended);
  1596. /// Sets a mapping between a virtual host name and a folder path to make available to web sites
  1597. /// via that host name.
  1598. ///
  1599. /// After setting the mapping, documents loaded in the WebView can use HTTP or HTTPS URLs at
  1600. /// the specified host name specified by hostName to access files in the local folder specified
  1601. /// by folderPath.
  1602. ///
  1603. /// This mapping applies to both top-level document and iframe navigations as well as subresource
  1604. /// references from a document. This also applies to web workers including dedicated/shared worker
  1605. /// and service worker, for loading either worker scripts or subresources
  1606. /// (importScripts(), fetch(), XHR, etc.) issued from within a worker.
  1607. /// For virtual host mapping to work with service worker, please keep the virtual host name
  1608. /// mappings consistent among all WebViews sharing the same browser instance. As service worker
  1609. /// works independently of WebViews, we merge mappings from all WebViews when resolving virtual
  1610. /// host name, inconsistent mappings between WebViews would lead unexpected behavior.
  1611. ///
  1612. /// Due to a current implementation limitation, media files accessed using virtual host name can be
  1613. /// very slow to load.
  1614. /// As the resource loaders for the current page might have already been created and running,
  1615. /// changes to the mapping might not be applied to the current page and a reload of the page is
  1616. /// needed to apply the new mapping.
  1617. ///
  1618. /// Both absolute and relative paths are supported for folderPath. Relative paths are interpreted
  1619. /// as relative to the folder where the exe of the app is in.
  1620. ///
  1621. /// Note that the folderPath length must not exceed the Windows MAX_PATH limit.
  1622. ///
  1623. /// accessKind specifies the level of access to resources under the virtual host from other sites.
  1624. ///
  1625. /// For example, after calling
  1626. /// ```cpp
  1627. /// SetVirtualHostNameToFolderMapping(
  1628. /// L"appassets.example", L"assets",
  1629. /// COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_DENY);
  1630. /// ```
  1631. /// navigating to `https://appassets.example/my-local-file.html` will
  1632. /// show the content from my-local-file.html in the assets subfolder located on disk under
  1633. /// the same path as the app's executable file.
  1634. ///
  1635. /// DOM elements that want to reference local files will have their host reference virtual host in the source.
  1636. /// If there are multiple folders being used, define one unique virtual host per folder.
  1637. /// For example, you can embed a local image like this
  1638. /// ```cpp
  1639. /// WCHAR c_navString[] = L"<img src=\"http://appassets.example/wv2.png\"/>";
  1640. /// m_webView->NavigateToString(c_navString);
  1641. /// ```
  1642. /// The example above shows the image wv2.png by resolving the folder mapping above.
  1643. ///
  1644. /// You should typically choose virtual host names that are never used by real sites.
  1645. /// If you own a domain such as example.com, another option is to use a subdomain reserved for
  1646. /// the app (like my-app.example.com).
  1647. ///
  1648. /// [RFC 6761](https://tools.ietf.org/html/rfc6761) has reserved several special-use domain
  1649. /// names that are guaranteed to not be used by real sites (for example, .example, .test, and
  1650. /// .invalid.)
  1651. ///
  1652. /// Note that using `.local` as the top-level domain name will work but can cause a delay
  1653. /// during navigations. You should avoid using `.local` if you can.
  1654. ///
  1655. /// Apps should use distinct domain names when mapping folder from different sources that
  1656. /// should be isolated from each other. For instance, the app might use app-file.example for
  1657. /// files that ship as part of the app, and book1.example might be used for files containing
  1658. /// books from a less trusted source that were previously downloaded and saved to the disk by
  1659. /// the app.
  1660. ///
  1661. /// The host name used in the APIs is canonicalized using Chromium's host name parsing logic
  1662. /// before being used internally. For more information see [HTML5 2.6 URLs](https://dev.w3.org/html5/spec-LC/urls.html).
  1663. ///
  1664. /// All host names that are canonicalized to the same string are considered identical.
  1665. /// For example, `EXAMPLE.COM` and `example.com` are treated as the same host name.
  1666. /// An international host name and its Punycode-encoded host name are considered the same host
  1667. /// name. There is no DNS resolution for host name and the trailing '.' is not normalized as
  1668. /// part of canonicalization.
  1669. ///
  1670. /// Therefore `example.com` and `example.com.` are treated as different host names. Similarly,
  1671. /// `virtual-host-name` and `virtual-host-name.example.com` are treated as different host names
  1672. /// even if the machine has a DNS suffix of `example.com`.
  1673. ///
  1674. /// Specify the minimal cross-origin access necessary to run the app. If there is not a need to
  1675. /// access local resources from other origins, use COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_DENY.
  1676. ///
  1677. /// \snippet AppWindow.cpp AddVirtualHostNameToFolderMapping
  1678. ///
  1679. /// \snippet AppWindow.cpp LocalUrlUsage
  1680. HRESULT SetVirtualHostNameToFolderMapping(
  1681. [in] LPCWSTR hostName,
  1682. [in] LPCWSTR folderPath,
  1683. [in] COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND accessKind);
  1684. /// Clears a host name mapping for local folder that was added by `SetVirtualHostNameToFolderMapping`.
  1685. HRESULT ClearVirtualHostNameToFolderMapping(
  1686. [in] LPCWSTR hostName);
  1687. }
  1688. /// A continuation of the ICoreWebView2_3 interface to support FrameCreated and
  1689. /// DownloadStarting events.
  1690. [uuid(20d02d59-6df2-42dc-bd06-f98a694b1302), object, pointer_default(unique)]
  1691. interface ICoreWebView2_4 : ICoreWebView2_3 {
  1692. /// Raised when a new iframe is created. Use the
  1693. /// CoreWebView2Frame.add_Destroyed to listen for when this iframe goes
  1694. /// away.
  1695. HRESULT add_FrameCreated(
  1696. [in] ICoreWebView2FrameCreatedEventHandler * eventHandler,
  1697. [out] EventRegistrationToken * token);
  1698. /// Remove an event handler previously added with add_FrameCreated.
  1699. HRESULT remove_FrameCreated([in] EventRegistrationToken token);
  1700. /// Add an event handler for the `DownloadStarting` event. This event is
  1701. /// raised when a download has begun, blocking the default download dialog,
  1702. /// but not blocking the progress of the download.
  1703. ///
  1704. /// The host can choose to cancel a download, change the result file path,
  1705. /// and hide the default download dialog.
  1706. /// If the host chooses to cancel the download, the download is not saved, no
  1707. /// dialog is shown, and the state is changed to
  1708. /// COREWEBVIEW2_DOWNLOAD_STATE_INTERRUPTED with interrupt reason
  1709. /// COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_USER_CANCELED. Otherwise, the
  1710. /// download is saved to the default path after the event completes,
  1711. /// and default download dialog is shown if the host did not choose to hide it.
  1712. /// The host can change the visibility of the download dialog using the
  1713. /// `Handled` property. If the event is not handled, downloads complete
  1714. /// normally with the default dialog shown.
  1715. ///
  1716. /// \snippet ScenarioCustomDownloadExperience.cpp DownloadStarting
  1717. HRESULT add_DownloadStarting(
  1718. [in] ICoreWebView2DownloadStartingEventHandler* eventHandler,
  1719. [out] EventRegistrationToken* token);
  1720. /// Remove an event handler previously added with `add_DownloadStarting`.
  1721. HRESULT remove_DownloadStarting(
  1722. [in] EventRegistrationToken token);
  1723. }
  1724. /// A continuation of the ICoreWebView2_4 interface to support ClientCertificateRequested
  1725. /// event.
  1726. [uuid(bedb11b8-d63c-11eb-b8bc-0242ac130003), object, pointer_default(unique)]
  1727. interface ICoreWebView2_5 : ICoreWebView2_4 {
  1728. /// Add an event handler for the ClientCertificateRequested event.
  1729. /// The ClientCertificateRequested event is raised when the WebView2
  1730. /// is making a request to an HTTP server that needs a client certificate
  1731. /// for HTTP authentication.
  1732. /// Read more about HTTP client certificates at
  1733. /// [RFC 8446 The Transport Layer Security (TLS) Protocol Version 1.3](https://tools.ietf.org/html/rfc8446).
  1734. ///
  1735. /// With this event you have several options for responding to client certificate requests:
  1736. ///
  1737. /// Scenario | Handled | Cancel | SelectedCertificate
  1738. /// ---------------------------------------------------------- | ------- | ------ | -------------------
  1739. /// Respond to server with a certificate | True | False | MutuallyTrustedCertificate value
  1740. /// Respond to server without certificate | True | False | null
  1741. /// Display default client certificate selection dialog prompt | False | False | n/a
  1742. /// Cancel the request | n/a | True | n/a
  1743. ///
  1744. /// If you don't handle the event, WebView2 will
  1745. /// show the default client certificate selection dialog prompt to user.
  1746. ///
  1747. /// \snippet SettingsComponent.cpp ClientCertificateRequested1
  1748. /// \snippet ScenarioClientCertificateRequested.cpp ClientCertificateRequested2
  1749. HRESULT add_ClientCertificateRequested(
  1750. [in] ICoreWebView2ClientCertificateRequestedEventHandler* eventHandler,
  1751. [out] EventRegistrationToken* token);
  1752. /// Remove an event handler previously added with add_ClientCertificateRequested.
  1753. HRESULT remove_ClientCertificateRequested([in] EventRegistrationToken token);
  1754. }
  1755. /// This interface is an extension of `ICoreWebView2_5` that manages opening
  1756. /// the browser task manager window.
  1757. [uuid(499aadac-d92c-4589-8a75-111bfc167795), object, pointer_default(unique)]
  1758. interface ICoreWebView2_6 : ICoreWebView2_5 {
  1759. /// Opens the Browser Task Manager view as a new window in the foreground.
  1760. /// If the Browser Task Manager is already open, this will bring it into
  1761. /// the foreground. WebView2 currently blocks the Shift+Esc shortcut for
  1762. /// opening the task manager. An end user can open the browser task manager
  1763. /// manually via the `Browser task manager` entry of the DevTools window's
  1764. /// title bar's context menu.
  1765. HRESULT OpenTaskManagerWindow();
  1766. }
  1767. /// This interface is an extension of `ICoreWebView2_6` that supports printing
  1768. /// to PDF.
  1769. [uuid(79c24d83-09a3-45ae-9418-487f32a58740), object, pointer_default(unique)]
  1770. interface ICoreWebView2_7 : ICoreWebView2_6 {
  1771. /// Print the current page to PDF asynchronously with the provided settings.
  1772. /// See `ICoreWebView2PrintSettings` for description of settings. Passing
  1773. /// nullptr for `printSettings` results in default print settings used.
  1774. ///
  1775. /// Use `resultFilePath` to specify the path to the PDF file. The host should
  1776. /// provide an absolute path, including file name. If the path
  1777. /// points to an existing file, the file will be overwritten. If the path is
  1778. /// not valid, the method fails with `E_INVALIDARG`.
  1779. ///
  1780. /// The async `PrintToPdf` operation completes when the data has been written
  1781. /// to the PDF file. At this time the
  1782. /// `ICoreWebView2PrintToPdfCompletedHandler` is invoked. If the
  1783. /// application exits before printing is complete, the file is not saved.
  1784. /// Only one `PrintToPdf` operation can be in progress at a time. If
  1785. /// `PrintToPdf` is called while a print to PDF job is in progress, the
  1786. /// completed handler is immediately invoked with `isSuccessful` set to FALSE.
  1787. ///
  1788. /// \snippet FileComponent.cpp PrintToPdf
  1789. HRESULT PrintToPdf(
  1790. [in] LPCWSTR resultFilePath,
  1791. [in] ICoreWebView2PrintSettings* printSettings,
  1792. [in] ICoreWebView2PrintToPdfCompletedHandler* handler);
  1793. }
  1794. /// This interface is an extension of `ICoreWebView2_7` that supports media features.
  1795. [uuid(E9632730-6E1E-43AB-B7B8-7B2C9E62E094), object, pointer_default(unique)]
  1796. interface ICoreWebView2_8 : ICoreWebView2_7 {
  1797. /// Adds an event handler for the `IsMutedChanged` event.
  1798. /// `IsMutedChanged` is raised when the IsMuted property changes value.
  1799. ///
  1800. /// \snippet AudioComponent.cpp IsMutedChanged
  1801. HRESULT add_IsMutedChanged(
  1802. [in] ICoreWebView2IsMutedChangedEventHandler* eventHandler,
  1803. [out] EventRegistrationToken* token);
  1804. /// Remove an event handler previously added with `add_IsMutedChanged`.
  1805. HRESULT remove_IsMutedChanged(
  1806. [in] EventRegistrationToken token);
  1807. /// Indicates whether all audio output from this CoreWebView2 is muted or not.
  1808. ///
  1809. /// \snippet AudioComponent.cpp ToggleIsMuted
  1810. [propget] HRESULT IsMuted([out, retval] BOOL* value);
  1811. /// Sets the `IsMuted` property.
  1812. ///
  1813. /// \snippet AudioComponent.cpp ToggleIsMuted
  1814. [propput] HRESULT IsMuted([in] BOOL value);
  1815. /// Adds an event handler for the `IsDocumentPlayingAudioChanged` event.
  1816. /// `IsDocumentPlayingAudioChanged` is raised when the IsDocumentPlayingAudio property changes value.
  1817. ///
  1818. /// \snippet AudioComponent.cpp IsDocumentPlayingAudioChanged
  1819. HRESULT add_IsDocumentPlayingAudioChanged(
  1820. [in] ICoreWebView2IsDocumentPlayingAudioChangedEventHandler* eventHandler,
  1821. [out] EventRegistrationToken* token);
  1822. /// Remove an event handler previously added with `add_IsDocumentPlayingAudioChanged`.
  1823. HRESULT remove_IsDocumentPlayingAudioChanged(
  1824. [in] EventRegistrationToken token);
  1825. /// Indicates whether any audio output from this CoreWebView2 is playing.
  1826. /// This property will be true if audio is playing even if IsMuted is true.
  1827. ///
  1828. /// \snippet AudioComponent.cpp IsDocumentPlayingAudio
  1829. [propget] HRESULT IsDocumentPlayingAudio([out, retval] BOOL* value);
  1830. }
  1831. /// This interface is an extension of `ICoreWebView2_8` that default download
  1832. /// dialog positioning and anchoring.
  1833. [uuid(4d7b2eab-9fdc-468d-b998-a9260b5ed651), object, pointer_default(unique)]
  1834. interface ICoreWebView2_9 : ICoreWebView2_8 {
  1835. /// Raised when the `IsDefaultDownloadDialogOpen` property changes. This event
  1836. /// comes after the `DownloadStarting` event. Setting the `Handled` property
  1837. /// on the `DownloadStartingEventArgs` disables the default download dialog
  1838. /// and ensures that this event is never raised.
  1839. HRESULT add_IsDefaultDownloadDialogOpenChanged(
  1840. [in] ICoreWebView2IsDefaultDownloadDialogOpenChangedEventHandler* handler,
  1841. [out] EventRegistrationToken* token);
  1842. /// Remove an event handler previously added with
  1843. /// `add_IsDefaultDownloadDialogOpenChanged`.
  1844. HRESULT remove_IsDefaultDownloadDialogOpenChanged(
  1845. [in] EventRegistrationToken token);
  1846. /// `TRUE` if the default download dialog is currently open. The value of this
  1847. /// property changes only when the default download dialog is explicitly
  1848. /// opened or closed. Hiding the WebView implicitly hides the dialog, but does
  1849. /// not change the value of this property.
  1850. [propget] HRESULT IsDefaultDownloadDialogOpen([out, retval] BOOL* value);
  1851. /// Open the default download dialog. If the dialog is opened before there
  1852. /// are recent downloads, the dialog shows all past downloads for the
  1853. /// current profile. Otherwise, the dialog shows only the recent downloads
  1854. /// with a "See more" button for past downloads. Calling this method raises
  1855. /// the `IsDefaultDownloadDialogOpenChanged` event if the dialog was closed.
  1856. /// No effect if the dialog is already open.
  1857. ///
  1858. /// \snippet ViewComponent.cpp ToggleDefaultDownloadDialog
  1859. HRESULT OpenDefaultDownloadDialog();
  1860. /// Close the default download dialog. Calling this method raises the
  1861. /// `IsDefaultDownloadDialogOpenChanged` event if the dialog was open. No
  1862. /// effect if the dialog is already closed.
  1863. HRESULT CloseDefaultDownloadDialog();
  1864. /// Get the default download dialog corner alignment.
  1865. [propget] HRESULT DefaultDownloadDialogCornerAlignment(
  1866. [out, retval] COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT* value);
  1867. /// Set the default download dialog corner alignment. The dialog can be
  1868. /// aligned to any of the WebView corners (see
  1869. /// COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT). When the WebView
  1870. /// or dialog changes size, the dialog keeps its position relative to the
  1871. /// corner. The dialog may become partially or completely outside of the
  1872. /// WebView bounds if the WebView is small enough. Set the margin relative to
  1873. /// the corner with the `DefaultDownloadDialogMargin` property.
  1874. ///
  1875. /// \snippet ViewComponent.cpp SetDefaultDownloadDialogPosition
  1876. [propput] HRESULT DefaultDownloadDialogCornerAlignment(
  1877. [in] COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT value);
  1878. /// Get the default download dialog margin.
  1879. [propget] HRESULT DefaultDownloadDialogMargin([out, retval] POINT* value);
  1880. /// Set the default download dialog margin relative to the WebView corner
  1881. /// specified by `DefaultDownloadDialogCornerAlignment`. The margin is a
  1882. /// point that describes the vertical and horizontal distances between the
  1883. /// chosen WebView corner and the default download dialog corner nearest to
  1884. /// it. Positive values move the dialog towards the center of the WebView from
  1885. /// the chosen WebView corner, and negative values move the dialog away from
  1886. /// it. Use (0, 0) to align the dialog to the WebView corner with no margin.
  1887. [propput] HRESULT DefaultDownloadDialogMargin([in] POINT value);
  1888. }
  1889. /// This interface is an extension of `ICoreWebView2_9` that supports
  1890. /// BasicAuthenticationRequested event.
  1891. [uuid(b1690564-6f5a-4983-8e48-31d1143fecdb), object, pointer_default(unique)]
  1892. interface ICoreWebView2_10 : ICoreWebView2_9 {
  1893. /// Add an event handler for the BasicAuthenticationRequested event.
  1894. /// BasicAuthenticationRequested event is raised when WebView encounters a Basic HTTP
  1895. /// Authentication request as described in
  1896. /// https://developer.mozilla.org/docs/Web/HTTP/Authentication or an NTLM authentication request.
  1897. ///
  1898. /// The host can provide a response with credentials for the authentication or
  1899. /// cancel the request. If the host doesn't set the Cancel property to true or
  1900. /// set either UserName or Password properties on the Response property, then WebView2 will show the default
  1901. /// authentication challenge dialog prompt to the user.
  1902. ///
  1903. /// \snippet ScenarioAuthentication.cpp BasicAuthenticationRequested
  1904. HRESULT add_BasicAuthenticationRequested(
  1905. [in] ICoreWebView2BasicAuthenticationRequestedEventHandler* eventHandler,
  1906. [out] EventRegistrationToken* token);
  1907. /// Remove an event handler previously added with add_BasicAuthenticationRequested.
  1908. HRESULT remove_BasicAuthenticationRequested(
  1909. [in] EventRegistrationToken token);
  1910. }
  1911. /// This interface is an extension of `ICoreWebView2_10` that supports sessionId
  1912. /// for CDP method calls and ContextMenuRequested event.
  1913. [uuid(0be78e56-c193-4051-b943-23b460c08bdb), object, pointer_default(unique)]
  1914. interface ICoreWebView2_11 : ICoreWebView2_10 {
  1915. /// Runs an asynchronous `DevToolsProtocol` method for a specific session of
  1916. /// an attached target.
  1917. /// There could be multiple `DevToolsProtocol` targets in a WebView.
  1918. /// Besides the top level page, iframes from different origin and web workers
  1919. /// are also separate targets. Attaching to these targets allows interaction with them.
  1920. /// When the DevToolsProtocol is attached to a target, the connection is identified
  1921. /// by a sessionId.
  1922. /// To use this API, you must set the `flatten` parameter to true when calling
  1923. /// `Target.attachToTarget` or `Target.setAutoAttach` `DevToolsProtocol` method.
  1924. /// Using `Target.setAutoAttach` is recommended as that would allow you to attach
  1925. /// to dedicated worker targets, which are not discoverable via other APIs like
  1926. /// `Target.getTargets`.
  1927. /// For more information about targets and sessions, navigate to
  1928. /// [DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/tot/Target).
  1929. /// For more information about available methods, navigate to
  1930. /// [DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/tot)
  1931. /// The `sessionId` parameter is the sessionId for an attached target.
  1932. /// nullptr or empty string is treated as the session for the default target for the top page.
  1933. /// The `methodName` parameter is the full name of the method in the
  1934. /// `{domain}.{method}` format. The `parametersAsJson` parameter is a JSON
  1935. /// formatted string containing the parameters for the corresponding method.
  1936. /// The `Invoke` method of the `handler` is run when the method
  1937. /// asynchronously completes. `Invoke` is run with the return object of the
  1938. /// method as a JSON string.
  1939. ///
  1940. /// \snippet ScriptComponent.cpp DevToolsProtocolMethodMultiSession
  1941. ///
  1942. /// \snippet ScriptComponent.cpp CallDevToolsProtocolMethodForSession
  1943. HRESULT CallDevToolsProtocolMethodForSession(
  1944. [in] LPCWSTR sessionId,
  1945. [in] LPCWSTR methodName,
  1946. [in] LPCWSTR parametersAsJson,
  1947. [in] ICoreWebView2CallDevToolsProtocolMethodCompletedHandler* handler);
  1948. /// Add an event handler for the `ContextMenuRequested` event.
  1949. /// `ContextMenuRequested` event is raised when a context menu is requested by the user
  1950. /// and the content inside WebView hasn't disabled context menus.
  1951. /// The host has the option to create their own context menu with the information provided in
  1952. /// the event or can add items to or remove items from WebView context menu.
  1953. /// If the host doesn't handle the event, WebView will display the default context menu.
  1954. ///
  1955. /// \snippet SettingsComponent.cpp EnableCustomMenu
  1956. HRESULT add_ContextMenuRequested(
  1957. [in] ICoreWebView2ContextMenuRequestedEventHandler* eventHandler,
  1958. [out] EventRegistrationToken* token);
  1959. /// Remove an event handler previously added with `add_ContextMenuRequested`.
  1960. HRESULT remove_ContextMenuRequested(
  1961. [in] EventRegistrationToken token);
  1962. }
  1963. /// This interface is an extension of `ICoreWebView2_11` that supports
  1964. /// StatusBarTextChanged event.
  1965. [uuid(35D69927-BCFA-4566-9349-6B3E0D154CAC), object, pointer_default(unique)]
  1966. interface ICoreWebView2_12 : ICoreWebView2_11 {
  1967. /// Add an event handler for the `StatusBarTextChanged` event.
  1968. /// `StatusBarTextChanged` fires when the WebView is showing a status message,
  1969. /// a URL, or an empty string (an indication to hide the status bar).
  1970. /// \snippet SettingsComponent.cpp StatusBarTextChanged
  1971. HRESULT add_StatusBarTextChanged(
  1972. [in] ICoreWebView2StatusBarTextChangedEventHandler* eventHandler,
  1973. [out] EventRegistrationToken* token);
  1974. /// Remove an event handler previously added with `add_StatusBarTextChanged`.
  1975. HRESULT remove_StatusBarTextChanged([in] EventRegistrationToken token);
  1976. /// The status message text.
  1977. ///
  1978. /// The caller must free the returned string with `CoTaskMemFree`. See
  1979. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  1980. [propget] HRESULT StatusBarText([out, retval] LPWSTR* value);
  1981. }
  1982. /// This interface is an extension of `ICoreWebView2_12` that supports Profile
  1983. /// API.
  1984. [uuid(F75F09A8-667E-4983-88D6-C8773F315E84), object, pointer_default(unique)]
  1985. interface ICoreWebView2_13 : ICoreWebView2_12 {
  1986. /// The associated `ICoreWebView2Profile` object. If this CoreWebView2 was created with a
  1987. /// CoreWebView2ControllerOptions, the CoreWebView2Profile will match those specified options.
  1988. /// Otherwise if this CoreWebView2 was created without a CoreWebView2ControllerOptions, then
  1989. /// this will be the default CoreWebView2Profile for the corresponding CoreWebView2Environment.
  1990. ///
  1991. /// \snippet AppWindow.cpp CoreWebView2Profile
  1992. [propget] HRESULT Profile([out, retval] ICoreWebView2Profile** value);
  1993. }
  1994. /// This interface is an extension of `ICoreWebView2_13` that adds
  1995. /// ServerCertificate support.
  1996. [uuid(6DAA4F10-4A90-4753-8898-77C5DF534165), object, pointer_default(unique)]
  1997. interface ICoreWebView2_14 : ICoreWebView2_13 {
  1998. /// Add an event handler for the ServerCertificateErrorDetected event.
  1999. /// The ServerCertificateErrorDetected event is raised when the WebView2
  2000. /// cannot verify server's digital certificate while loading a web page.
  2001. ///
  2002. /// This event will raise for all web resources and follows the `WebResourceRequested` event.
  2003. ///
  2004. /// If you don't handle the event, WebView2 will show the default TLS interstitial error page to the user
  2005. /// for navigations, and for non-navigations the web request is cancelled.
  2006. ///
  2007. /// WebView2 caches the response when action is `COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION_ALWAYS_ALLOW`
  2008. /// for the RequestUri's host and the server certificate in the session and the `ServerCertificateErrorDetected`
  2009. /// event won't be raised again.
  2010. ///
  2011. /// To raise the event again you must clear the cache using `ClearServerCertificateErrorActions`.
  2012. ///
  2013. /// \snippet SettingsComponent.cpp ServerCertificateErrorDetected1
  2014. HRESULT add_ServerCertificateErrorDetected(
  2015. [in] ICoreWebView2ServerCertificateErrorDetectedEventHandler*
  2016. eventHandler,
  2017. [out] EventRegistrationToken* token);
  2018. /// Remove an event handler previously added with add_ServerCertificateErrorDetected.
  2019. HRESULT remove_ServerCertificateErrorDetected([in] EventRegistrationToken token);
  2020. /// Clears all cached decisions to proceed with TLS certificate errors from the
  2021. /// ServerCertificateErrorDetected event for all WebView2's sharing the same session.
  2022. HRESULT ClearServerCertificateErrorActions(
  2023. [in] ICoreWebView2ClearServerCertificateErrorActionsCompletedHandler*
  2024. handler);
  2025. }
  2026. /// Receives `StatusBarTextChanged` events.
  2027. [uuid(A5E3B0D0-10DF-4156-BFAD-3B43867ACAC6), object, pointer_default(unique)]
  2028. interface ICoreWebView2StatusBarTextChangedEventHandler : IUnknown {
  2029. /// Called to provide the implementer with the event args for the
  2030. /// corresponding event. No event args exist and the `args`
  2031. /// parameter is set to `null`.
  2032. HRESULT Invoke(
  2033. [in] ICoreWebView2* sender,
  2034. [in] IUnknown* args);
  2035. }
  2036. /// The caller implements this interface to handle the BasicAuthenticationRequested event.
  2037. [uuid(58b4d6c2-18d4-497e-b39b-9a96533fa278), object, pointer_default(unique)]
  2038. interface ICoreWebView2BasicAuthenticationRequestedEventHandler : IUnknown {
  2039. /// Called to provide the implementer with the event args for the
  2040. /// corresponding event.
  2041. HRESULT Invoke(
  2042. [in] ICoreWebView2* sender,
  2043. [in] ICoreWebView2BasicAuthenticationRequestedEventArgs* args);
  2044. }
  2045. /// Implements the interface to receive `IsDefaultDownloadDialogOpenChanged`
  2046. /// events.
  2047. [uuid(3117da26-ae13-438d-bd46-edbeb2c4ce81), object, pointer_default(unique)]
  2048. interface ICoreWebView2IsDefaultDownloadDialogOpenChangedEventHandler : IUnknown {
  2049. /// Provides the event args for the corresponding event. No event args exist
  2050. /// and the `args` parameter is set to `null`.
  2051. HRESULT Invoke([in] ICoreWebView2* sender,
  2052. [in] IUnknown* args);
  2053. }
  2054. /// Receives the result of the `PrintToPdf` method. If the print to PDF
  2055. /// operation succeeds, `isSuccessful` is true. Otherwise, if the operation
  2056. /// failed, `isSuccessful` is set to false. An invalid path returns
  2057. /// `E_INVALIDARG`.
  2058. [uuid(ccf1ef04-fd8e-4d5f-b2de-0983e41b8c36), object, pointer_default(unique)]
  2059. interface ICoreWebView2PrintToPdfCompletedHandler : IUnknown {
  2060. /// Provides the result of the corresponding asynchronous method.
  2061. HRESULT Invoke([in] HRESULT errorCode, BOOL isSuccessful);
  2062. }
  2063. /// Settings used by the `PrintToPdf` method. Other programmatic printing is not
  2064. /// currently supported.
  2065. [uuid(377f3721-c74e-48ca-8db1-df68e51d60e2), object, pointer_default(unique)]
  2066. interface ICoreWebView2PrintSettings : IUnknown {
  2067. /// The orientation can be portrait or landscape. The default orientation is
  2068. /// portrait. See `COREWEBVIEW2_PRINT_ORIENTATION`.
  2069. [propget] HRESULT Orientation(
  2070. [out, retval] COREWEBVIEW2_PRINT_ORIENTATION* orientation);
  2071. /// Sets the `Orientation` property.
  2072. [propput] HRESULT Orientation(
  2073. [in] COREWEBVIEW2_PRINT_ORIENTATION orientation);
  2074. /// The scale factor is a value between 0.1 and 2.0. The default is 1.0.
  2075. [propget] HRESULT ScaleFactor([out, retval] double* scaleFactor);
  2076. /// Sets the `ScaleFactor` property. Returns `E_INVALIDARG` if an invalid
  2077. /// value is provided, and the current value is not changed.
  2078. [propput] HRESULT ScaleFactor([in] double scaleFactor);
  2079. /// The page width in inches. The default width is 8.5 inches.
  2080. [propget] HRESULT PageWidth([out, retval] double* pageWidth);
  2081. /// Sets the `PageWidth` property. Returns `E_INVALIDARG` if the page width is
  2082. /// less than or equal to zero, and the current value is not changed.
  2083. [propput] HRESULT PageWidth([in] double pageWidth);
  2084. /// The page height in inches. The default height is 11 inches.
  2085. [propget] HRESULT PageHeight([out, retval] double* pageHeight);
  2086. /// Sets the `PageHeight` property. Returns `E_INVALIDARG` if the page height
  2087. /// is less than or equal to zero, and the current value is not changed.
  2088. [propput] HRESULT PageHeight([in] double pageHeight);
  2089. /// The top margin in inches. The default is 1 cm, or ~0.4 inches.
  2090. [propget] HRESULT MarginTop([out, retval] double* marginTop);
  2091. /// Sets the `MarginTop` property. A margin cannot be less than zero.
  2092. /// Returns `E_INVALIDARG` if an invalid value is provided, and the current
  2093. /// value is not changed.
  2094. [propput] HRESULT MarginTop([in] double marginTop);
  2095. /// The bottom margin in inches. The default is 1 cm, or ~0.4 inches.
  2096. [propget] HRESULT MarginBottom([out, retval] double* marginBottom);
  2097. /// Sets the `MarginBottom` property. A margin cannot be less than zero.
  2098. /// Returns `E_INVALIDARG` if an invalid value is provided, and the current
  2099. /// value is not changed.
  2100. [propput] HRESULT MarginBottom([in] double marginBottom);
  2101. /// The left margin in inches. The default is 1 cm, or ~0.4 inches.
  2102. [propget] HRESULT MarginLeft([out, retval] double* marginLeft);
  2103. /// Sets the `MarginLeft` property. A margin cannot be less than zero.
  2104. /// Returns `E_INVALIDARG` if an invalid value is provided, and the current
  2105. /// value is not changed.
  2106. [propput] HRESULT MarginLeft([in] double marginLeft);
  2107. /// The right margin in inches. The default is 1 cm, or ~0.4 inches.
  2108. [propget] HRESULT MarginRight([out, retval] double* marginRight);
  2109. /// Set the `MarginRight` property.A margin cannot be less than zero.
  2110. /// Returns `E_INVALIDARG` if an invalid value is provided, and the current
  2111. /// value is not changed.
  2112. [propput] HRESULT MarginRight([in] double marginRight);
  2113. /// `TRUE` if background colors and images should be printed. The default value
  2114. /// is `FALSE`.
  2115. [propget] HRESULT ShouldPrintBackgrounds(
  2116. [out, retval] BOOL* shouldPrintBackgrounds);
  2117. /// Set the `ShouldPrintBackgrounds` property.
  2118. [propput] HRESULT ShouldPrintBackgrounds([in] BOOL shouldPrintBackgrounds);
  2119. /// `TRUE` if only the current end user's selection of HTML in the document
  2120. /// should be printed. The default value is `FALSE`.
  2121. [propget] HRESULT ShouldPrintSelectionOnly(
  2122. [out, retval] BOOL* shouldPrintSelectionOnly);
  2123. /// Set the `ShouldPrintSelectionOnly` property.
  2124. [propput] HRESULT ShouldPrintSelectionOnly(
  2125. [in] BOOL shouldPrintSelectionOnly);
  2126. /// `TRUE` if header and footer should be printed. The default value is `FALSE`.
  2127. /// The header consists of the date and time of printing, and the title of the
  2128. /// page. The footer consists of the URI and page number. The height of the
  2129. /// header and footer is 0.5 cm, or ~0.2 inches.
  2130. [propget] HRESULT ShouldPrintHeaderAndFooter(
  2131. [out, retval] BOOL* shouldPrintHeaderAndFooter);
  2132. /// Set the `ShouldPrintHeaderAndFooter` property.
  2133. [propput] HRESULT ShouldPrintHeaderAndFooter(
  2134. [in] BOOL shouldPrintHeaderAndFooter);
  2135. /// The title in the header if `ShouldPrintHeaderAndFooter` is `TRUE`. The
  2136. /// default value is the title of the current document.
  2137. ///
  2138. /// The caller must free the returned string with `CoTaskMemFree`. See
  2139. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  2140. [propget] HRESULT HeaderTitle([out, retval] LPWSTR* headerTitle);
  2141. /// Set the `HeaderTitle` property. If an empty string or null value is
  2142. /// provided, no title is shown in the header.
  2143. [propput] HRESULT HeaderTitle([in] LPCWSTR headerTitle);
  2144. /// The URI in the footer if `ShouldPrintHeaderAndFooter` is `TRUE`. The
  2145. /// default value is the current URI.
  2146. ///
  2147. /// The caller must free the returned string with `CoTaskMemFree`. See
  2148. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  2149. [propget] HRESULT FooterUri([out, retval] LPWSTR* footerUri);
  2150. /// Set the `FooterUri` property. If an empty string or null value is
  2151. /// provided, no URI is shown in the footer.
  2152. [propput] HRESULT FooterUri([in] LPCWSTR footerUri);
  2153. }
  2154. /// The caller implements this interface to receive the TrySuspend result.
  2155. [uuid(00F206A7-9D17-4605-91F6-4E8E4DE192E3), object, pointer_default(unique)]
  2156. interface ICoreWebView2TrySuspendCompletedHandler : IUnknown {
  2157. /// Provides the result of the TrySuspend operation.
  2158. /// See [Sleeping Tabs FAQ](https://techcommunity.microsoft.com/t5/articles/sleeping-tabs-faq/m-p/1705434)
  2159. /// for conditions that might prevent WebView from being suspended. In those situations,
  2160. /// isSuccessful will be false and errorCode is S_OK.
  2161. HRESULT Invoke([in] HRESULT errorCode, [in] BOOL isSuccessful);
  2162. }
  2163. /// The owner of the `CoreWebView2` object that provides support for resizing,
  2164. /// showing and hiding, focusing, and other functionality related to
  2165. /// windowing and composition. The `CoreWebView2Controller` owns the
  2166. /// `CoreWebView2`, and if all references to the `CoreWebView2Controller` go
  2167. /// away, the WebView is closed.
  2168. [uuid(4d00c0d1-9434-4eb6-8078-8697a560334f), object, pointer_default(unique)]
  2169. interface ICoreWebView2Controller : IUnknown {
  2170. /// The `IsVisible` property determines whether to show or hide the WebView2.
  2171. /// If `IsVisible` is set to `FALSE`, the WebView2 is transparent and is
  2172. /// not rendered. However, this does not affect the window containing the
  2173. /// WebView2 (the `HWND` parameter that was passed to
  2174. /// `CreateCoreWebView2Controller`). If you want that window to disappear
  2175. /// too, run `ShowWindow` on it directly in addition to modifying the
  2176. /// `IsVisible` property. WebView2 as a child window does not get window
  2177. /// messages when the top window is minimized or restored. For performance
  2178. /// reasons, developers should set the `IsVisible` property of the WebView to
  2179. /// `FALSE` when the app window is minimized and back to `TRUE` when the app
  2180. /// window is restored. The app window does this by handling
  2181. /// `SIZE_MINIMIZED and SIZE_RESTORED` command upon receiving `WM_SIZE`
  2182. /// message.
  2183. ///
  2184. /// There are CPU and memory benefits when the page is hidden. For instance,
  2185. /// Chromium has code that throttles activities on the page like animations
  2186. /// and some tasks are run less frequently. Similarly, WebView2 will
  2187. /// purge some caches to reduce memory usage.
  2188. ///
  2189. /// \snippet ViewComponent.cpp ToggleIsVisible
  2190. [propget] HRESULT IsVisible([out, retval] BOOL* isVisible);
  2191. /// Sets the `IsVisible` property.
  2192. ///
  2193. /// \snippet ViewComponent.cpp ToggleIsVisibleOnMinimize
  2194. [propput] HRESULT IsVisible([in] BOOL isVisible);
  2195. /// The WebView bounds. Bounds are relative to the parent `HWND`. The app
  2196. /// has two ways to position a WebView.
  2197. ///
  2198. /// * Create a child `HWND` that is the WebView parent `HWND`. Position
  2199. /// the window where the WebView should be. Use `(0, 0)` for the
  2200. /// top-left corner (the offset) of the `Bounds` of the WebView.
  2201. /// * Use the top-most window of the app as the WebView parent HWND. For
  2202. /// example, to position WebView correctly in the app, set the top-left
  2203. /// corner of the Bound of the WebView.
  2204. ///
  2205. /// The values of `Bounds` are limited by the coordinate space of the host.
  2206. [propget] HRESULT Bounds([out, retval] RECT* bounds);
  2207. /// Sets the `Bounds` property.
  2208. ///
  2209. /// \snippet ViewComponent.cpp ResizeWebView
  2210. [propput] HRESULT Bounds([in] RECT bounds);
  2211. /// The zoom factor for the WebView.
  2212. ///
  2213. /// \> [!NOTE]\n\> Changing zoom factor may cause `window.innerWidth`,
  2214. /// `window.innerHeight`, both, and page layout to change. A zoom factor
  2215. /// that is applied by the host by running `ZoomFactor` becomes the new
  2216. /// default zoom for the WebView. The zoom factor applies across navigations
  2217. /// and is the zoom factor WebView is returned to when the user chooses
  2218. /// Ctrl+0. When the zoom factor is changed by the user (resulting in
  2219. /// the app receiving `ZoomFactorChanged`), that zoom applies only for the
  2220. /// current page. Any user applied zoom is only for the current page and is
  2221. /// reset on a navigation. Specifying a `zoomFactor` less than or equal to
  2222. /// `0` is not allowed. WebView also has an internal supported zoom factor
  2223. /// range. When a specified zoom factor is out of that range, it is
  2224. /// normalized to be within the range, and a `ZoomFactorChanged` event is
  2225. /// triggered for the real applied zoom factor. When the range normalization
  2226. /// happens, the `ZoomFactor` property reports the zoom factor specified
  2227. /// during the previous modification of the `ZoomFactor` property until the
  2228. /// `ZoomFactorChanged` event is received after WebView applies the
  2229. /// normalized zoom factor.
  2230. [propget] HRESULT ZoomFactor([out, retval] double* zoomFactor);
  2231. /// Sets the `ZoomFactor` property.
  2232. [propput] HRESULT ZoomFactor([in] double zoomFactor);
  2233. /// Adds an event handler for the `ZoomFactorChanged` event.
  2234. /// `ZoomFactorChanged` runs when the `ZoomFactor` property of the WebView
  2235. /// changes. The event may run because the `ZoomFactor` property was
  2236. /// modified, or due to the user manually modifying the zoom. When it is
  2237. /// modified using the `ZoomFactor` property, the internal zoom factor is
  2238. /// updated immediately and no `ZoomFactorChanged` event is triggered.
  2239. /// WebView associates the last used zoom factor for each site. It is
  2240. /// possible for the zoom factor to change when navigating to a different
  2241. /// page. When the zoom factor changes due to a navigation change, the
  2242. /// `ZoomFactorChanged` event runs right after the `ContentLoading` event.
  2243. ///
  2244. /// \snippet ViewComponent.cpp ZoomFactorChanged
  2245. HRESULT add_ZoomFactorChanged(
  2246. [in] ICoreWebView2ZoomFactorChangedEventHandler* eventHandler,
  2247. [out] EventRegistrationToken* token);
  2248. /// Remove an event handler previously added with `add_ZoomFactorChanged`.
  2249. HRESULT remove_ZoomFactorChanged(
  2250. [in] EventRegistrationToken token);
  2251. /// Updates `Bounds` and `ZoomFactor` properties at the same time. This
  2252. /// operation is atomic from the perspective of the host. After returning
  2253. /// from this function, the `Bounds` and `ZoomFactor` properties are both
  2254. /// updated if the function is successful, or neither is updated if the
  2255. /// function fails. If `Bounds` and `ZoomFactor` are both updated by the
  2256. /// same scale (for example, `Bounds` and `ZoomFactor` are both doubled),
  2257. /// then the page does not display a change in `window.innerWidth` or
  2258. /// `window.innerHeight` and the WebView renders the content at the new size
  2259. /// and zoom without intermediate renderings. This function also updates
  2260. /// just one of `ZoomFactor` or `Bounds` by passing in the new value for one
  2261. /// and the current value for the other.
  2262. ///
  2263. /// \snippet ViewComponent.cpp SetBoundsAndZoomFactor
  2264. HRESULT SetBoundsAndZoomFactor([in] RECT bounds, [in] double zoomFactor);
  2265. /// Moves focus into WebView. WebView gets focus and focus is set to
  2266. /// correspondent element in the page hosted in the WebView. For
  2267. /// Programmatic reason, focus is set to previously focused element or the
  2268. /// default element if no previously focused element exists. For `Next`
  2269. /// reason, focus is set to the first element. For `Previous` reason, focus
  2270. /// is set to the last element. WebView changes focus through user
  2271. /// interaction including selecting into a WebView or Tab into it. For
  2272. /// tabbing, the app runs MoveFocus with Next or Previous to align with Tab
  2273. /// and Shift+Tab respectively when it decides the WebView is the next
  2274. /// element that may exist in a tab. Or, the app runs `IsDialogMessage`
  2275. /// as part of the associated message loop to allow the platform to auto
  2276. /// handle tabbing. The platform rotates through all windows with
  2277. /// `WS_TABSTOP`. When the WebView gets focus from `IsDialogMessage`, it is
  2278. /// internally put the focus on the first or last element for tab and
  2279. /// Shift+Tab respectively.
  2280. ///
  2281. /// \snippet App.cpp MoveFocus0
  2282. ///
  2283. /// \snippet ControlComponent.cpp MoveFocus1
  2284. ///
  2285. /// \snippet ControlComponent.cpp MoveFocus2
  2286. HRESULT MoveFocus([in] COREWEBVIEW2_MOVE_FOCUS_REASON reason);
  2287. /// Adds an event handler for the `MoveFocusRequested` event.
  2288. /// `MoveFocusRequested` runs when user tries to tab out of the WebView. The
  2289. /// focus of the WebView has not changed when this event is run.
  2290. ///
  2291. /// \snippet ControlComponent.cpp MoveFocusRequested
  2292. HRESULT add_MoveFocusRequested(
  2293. [in] ICoreWebView2MoveFocusRequestedEventHandler* eventHandler,
  2294. [out] EventRegistrationToken* token);
  2295. /// Removes an event handler previously added with `add_MoveFocusRequested`.
  2296. HRESULT remove_MoveFocusRequested(
  2297. [in] EventRegistrationToken token);
  2298. /// Adds an event handler for the `GotFocus` event. `GotFocus` runs when
  2299. /// WebView has focus.
  2300. HRESULT add_GotFocus(
  2301. [in] ICoreWebView2FocusChangedEventHandler* eventHandler,
  2302. [out] EventRegistrationToken* token);
  2303. /// Removes an event handler previously added with `add_GotFocus`.
  2304. HRESULT remove_GotFocus(
  2305. [in] EventRegistrationToken token);
  2306. /// Adds an event handler for the `LostFocus` event. `LostFocus` runs when
  2307. /// WebView loses focus. In the case where `MoveFocusRequested` event is
  2308. /// run, the focus is still on WebView when `MoveFocusRequested` event runs.
  2309. /// `LostFocus` only runs afterwards when code of the app or default action
  2310. /// of `MoveFocusRequested` event set focus away from WebView.
  2311. HRESULT add_LostFocus(
  2312. [in] ICoreWebView2FocusChangedEventHandler* eventHandler,
  2313. [out] EventRegistrationToken* token);
  2314. /// Removes an event handler previously added with `add_LostFocus`.
  2315. HRESULT remove_LostFocus(
  2316. [in] EventRegistrationToken token);
  2317. /// Adds an event handler for the `AcceleratorKeyPressed` event.
  2318. /// `AcceleratorKeyPressed` runs when an accelerator key or key combo is
  2319. /// pressed or released while the WebView is focused. A key is considered an
  2320. /// accelerator if either of the following conditions are true.
  2321. ///
  2322. /// * Ctrl or Alt is currently being held.
  2323. /// * The pressed key does not map to a character.
  2324. ///
  2325. /// A few specific keys are never considered accelerators, such as Shift.
  2326. /// The `Escape` key is always considered an accelerator.
  2327. ///
  2328. /// Auto-repeated key events caused by holding the key down also triggers
  2329. /// this event. Filter out the auto-repeated key events by verifying the
  2330. /// `KeyEventLParam` or `PhysicalKeyStatus` event args.
  2331. ///
  2332. /// In windowed mode, the event handler is run synchronously. Until you
  2333. /// run `Handled()` on the event args or the event handler returns, the
  2334. /// browser process is blocked and outgoing cross-process COM requests fail
  2335. /// with `RPC_E_CANTCALLOUT_ININPUTSYNCCALL`. All `CoreWebView2` API methods
  2336. /// work, however.
  2337. ///
  2338. /// In windowless mode, the event handler is run asynchronously. Further
  2339. /// input do not reach the browser until the event handler returns or
  2340. /// `Handled()` is run, but the browser process is not blocked, and outgoing
  2341. /// COM requests work normally.
  2342. ///
  2343. /// It is recommended to run `Handled(TRUE)` as early as are able to know
  2344. /// that you want to handle the accelerator key.
  2345. ///
  2346. /// \snippet ControlComponent.cpp AcceleratorKeyPressed
  2347. HRESULT add_AcceleratorKeyPressed(
  2348. [in] ICoreWebView2AcceleratorKeyPressedEventHandler* eventHandler,
  2349. [out] EventRegistrationToken* token);
  2350. /// Removes an event handler previously added with
  2351. /// `add_AcceleratorKeyPressed`.
  2352. HRESULT remove_AcceleratorKeyPressed(
  2353. [in] EventRegistrationToken token);
  2354. /// The parent window provided by the app that this WebView is using to
  2355. /// render content. This API initially returns the window passed into
  2356. /// `CreateCoreWebView2Controller`.
  2357. [propget] HRESULT ParentWindow([out, retval] HWND* parentWindow);
  2358. /// Sets the parent window for the WebView. This causes the WebView to
  2359. /// re-parent the main WebView window to the newly provided window.
  2360. [propput] HRESULT ParentWindow([in] HWND parentWindow);
  2361. /// This is a notification separate from `Bounds` that tells WebView that the
  2362. /// main WebView parent (or any ancestor) `HWND` moved. This is needed
  2363. /// for accessibility and certain dialogs in WebView to work correctly.
  2364. ///
  2365. /// \snippet ViewComponent.cpp NotifyParentWindowPositionChanged
  2366. HRESULT NotifyParentWindowPositionChanged();
  2367. /// Closes the WebView and cleans up the underlying browser instance.
  2368. /// Cleaning up the browser instance releases the resources powering the
  2369. /// WebView. The browser instance is shut down if no other WebViews are
  2370. /// using it.
  2371. ///
  2372. /// After running `Close`, most methods will fail and event handlers stop
  2373. /// running. Specifically, the WebView releases the associated references to
  2374. /// any associated event handlers when `Close` is run.
  2375. ///
  2376. /// `Close` is implicitly run when the `CoreWebView2Controller` loses the
  2377. /// final reference and is destructed. But it is best practice to
  2378. /// explicitly run `Close` to avoid any accidental cycle of references
  2379. /// between the WebView and the app code. Specifically, if you capture a
  2380. /// reference to the WebView in an event handler you create a reference cycle
  2381. /// between the WebView and the event handler. Run `Close` to break the
  2382. /// cycle by releasing all event handlers. But to avoid the situation, it is
  2383. /// best to both explicitly run `Close` on the WebView and to not capture a
  2384. /// reference to the WebView to ensure the WebView is cleaned up correctly.
  2385. /// `Close` is synchronous and won't trigger the `beforeunload` event.
  2386. ///
  2387. /// \snippet AppWindow.cpp Close
  2388. HRESULT Close();
  2389. /// Gets the `CoreWebView2` associated with this `CoreWebView2Controller`.
  2390. [propget] HRESULT CoreWebView2([out, retval] ICoreWebView2** coreWebView2);
  2391. }
  2392. /// A continuation of the ICoreWebView2Controller interface.
  2393. [uuid(c979903e-d4ca-4228-92eb-47ee3fa96eab), object, pointer_default(unique)]
  2394. interface ICoreWebView2Controller2 : ICoreWebView2Controller {
  2395. /// The `DefaultBackgroundColor` property is the color WebView renders
  2396. /// underneath all web content. This means WebView renders this color when
  2397. /// there is no web content loaded such as before the initial navigation or
  2398. /// between navigations. This also means web pages with undefined css
  2399. /// background properties or background properties containing transparent
  2400. /// pixels will render their contents over this color. Web pages with defined
  2401. /// and opaque background properties that span the page will obscure the
  2402. /// `DefaultBackgroundColor` and display normally. The default value for this
  2403. /// property is white to resemble the native browser experience.
  2404. ///
  2405. /// The Color is specified by the COREWEBVIEW2_COLOR that represents an RGBA
  2406. /// value. The `A` represents an Alpha value, meaning
  2407. /// `DefaultBackgroundColor` can be transparent. In the case of a transparent
  2408. /// `DefaultBackgroundColor` WebView will render hosting app content as the
  2409. /// background. This Alpha value is not supported on Windows 7. Any `A` value
  2410. /// other than 255 will result in E_INVALIDARG on Windows 7.
  2411. /// It is supported on all other WebView compatible platforms.
  2412. ///
  2413. /// Semi-transparent colors are not currently supported by this API and
  2414. /// setting `DefaultBackgroundColor` to a semi-transparent color will fail
  2415. /// with E_INVALIDARG. The only supported alpha values are 0 and 255, all
  2416. /// other values will result in E_INVALIDARG.
  2417. /// `DefaultBackgroundColor` can only be an opaque color or transparent.
  2418. ///
  2419. /// \snippet ViewComponent.cpp DefaultBackgroundColor
  2420. [propget] HRESULT DefaultBackgroundColor(
  2421. [out, retval] COREWEBVIEW2_COLOR* backgroundColor);
  2422. /// Sets the `DefaultBackgroundColor` property.
  2423. [propput] HRESULT DefaultBackgroundColor(
  2424. [in] COREWEBVIEW2_COLOR backgroundColor);
  2425. }
  2426. /// A continuation of the ICoreWebView2Controller2 interface.
  2427. [uuid(f9614724-5d2b-41dc-aef7-73d62b51543b), object, pointer_default(unique)]
  2428. interface ICoreWebView2Controller3 : ICoreWebView2Controller2 {
  2429. /// The rasterization scale for the WebView. The rasterization scale is the
  2430. /// combination of the monitor DPI scale and text scaling set by the user.
  2431. /// This value should be updated when the DPI scale of the app's top level
  2432. /// window changes (i.e. monitor DPI scale changes or window changes monitor)
  2433. /// or when the text scale factor of the system changes.
  2434. ///
  2435. /// \snippet AppWindow.cpp DPIChanged
  2436. ///
  2437. /// \snippet AppWindow.cpp TextScaleChanged1
  2438. ///
  2439. /// \snippet AppWindow.cpp TextScaleChanged2
  2440. ///
  2441. /// Rasterization scale applies to the WebView content, as well as
  2442. /// popups, context menus, scroll bars, and so on. Normal app scaling
  2443. /// scenarios should use the ZoomFactor property or SetBoundsAndZoomFactor
  2444. /// API which only scale the rendered HTML content and not popups, context
  2445. /// menus, scroll bars, and so on.
  2446. ///
  2447. /// \snippet ViewComponent.cpp RasterizationScale
  2448. [propget] HRESULT RasterizationScale([out, retval] double* scale);
  2449. /// Set the rasterization scale property.
  2450. [propput] HRESULT RasterizationScale([in] double scale);
  2451. /// ShouldDetectMonitorScaleChanges property determines whether the WebView
  2452. /// attempts to track monitor DPI scale changes. When true, the WebView will
  2453. /// track monitor DPI scale changes, update the RasterizationScale property,
  2454. /// and raises RasterizationScaleChanged event. When false, the WebView will
  2455. /// not track monitor DPI scale changes, and the app must update the
  2456. /// RasterizationScale property itself. RasterizationScaleChanged event will
  2457. /// never raise when ShouldDetectMonitorScaleChanges is false. Apps that want
  2458. /// to set their own rasterization scale should set this property to false to
  2459. /// avoid the WebView2 updating the RasterizationScale property to match the
  2460. /// monitor DPI scale.
  2461. [propget] HRESULT ShouldDetectMonitorScaleChanges([out, retval] BOOL* value);
  2462. /// Set the ShouldDetectMonitorScaleChanges property.
  2463. [propput] HRESULT ShouldDetectMonitorScaleChanges([in] BOOL value);
  2464. /// Add an event handler for the RasterizationScaleChanged event.
  2465. /// The event is raised when the WebView detects that the monitor DPI scale
  2466. /// has changed, ShouldDetectMonitorScaleChanges is true, and the WebView has
  2467. /// changed the RasterizationScale property.
  2468. ///
  2469. /// \snippet ViewComponent.cpp RasterizationScaleChanged
  2470. HRESULT add_RasterizationScaleChanged(
  2471. [in] ICoreWebView2RasterizationScaleChangedEventHandler* eventHandler,
  2472. [out] EventRegistrationToken* token);
  2473. /// Remove an event handler previously added with
  2474. /// add_RasterizationScaleChanged.
  2475. HRESULT remove_RasterizationScaleChanged(
  2476. [in] EventRegistrationToken token);
  2477. /// BoundsMode affects how setting the Bounds and RasterizationScale
  2478. /// properties work. Bounds mode can either be in COREWEBVIEW2_BOUNDS_MODE_USE_RAW_PIXELS
  2479. /// mode or COREWEBVIEW2_BOUNDS_MODE_USE_RASTERIZATION_SCALE mode.
  2480. ///
  2481. /// When the mode is in COREWEBVIEW2_BOUNDS_MODE_USE_RAW_PIXELS, setting the bounds
  2482. /// property will set the size of the WebView in raw screen pixels. Changing
  2483. /// the rasterization scale in this mode won't change the raw pixel size of
  2484. /// the WebView and will only change the rasterization scale.
  2485. ///
  2486. /// When the mode is in COREWEBVIEW2_BOUNDS_MODE_USE_RASTERIZATION_SCALE, setting the
  2487. /// bounds property will change the logical size of the WebView which can be
  2488. /// described by the following equation:
  2489. /// ```text
  2490. /// Logical size * rasterization scale = Raw Pixel size
  2491. /// ```
  2492. /// In this case, changing the rasterization scale will keep the logical size
  2493. /// the same and change the raw pixel size.
  2494. ///
  2495. /// \snippet ViewComponent.cpp BoundsMode
  2496. [propget] HRESULT BoundsMode(
  2497. [out, retval] COREWEBVIEW2_BOUNDS_MODE* boundsMode);
  2498. /// Set the BoundsMode property.
  2499. [propput] HRESULT BoundsMode([in] COREWEBVIEW2_BOUNDS_MODE boundsMode);
  2500. }
  2501. /// This is the ICoreWebView2Controller4 interface.
  2502. /// The ICoreWebView2Controller4 provides interface to enable/disable external drop.
  2503. [uuid(97d418d5-a426-4e49-a151-e1a10f327d9e), object, pointer_default(unique)]
  2504. interface ICoreWebView2Controller4 : ICoreWebView2Controller3 {
  2505. /// Gets the `AllowExternalDrop` property which is used to configure the
  2506. /// capability that dragging objects from outside the bounds of webview2 and
  2507. /// dropping into webview2 is allowed or disallowed. The default value is
  2508. /// TRUE.
  2509. ///
  2510. /// \snippet SettingsComponent.cpp ToggleAllowExternalDrop
  2511. [propget] HRESULT AllowExternalDrop([ out, retval ] BOOL * value);
  2512. /// Sets the `AllowExternalDrop` property which is used to configure the
  2513. /// capability that dragging objects from outside the bounds of webview2 and
  2514. /// dropping into webview2 is allowed or disallowed.
  2515. ///
  2516. /// \snippet SettingsComponent.cpp ToggleAllowExternalDrop
  2517. [propput] HRESULT AllowExternalDrop([in] BOOL value);
  2518. }
  2519. /// This interface is an extension of the ICoreWebView2Controller interface to
  2520. /// support visual hosting. An object implementing the
  2521. /// ICoreWebView2CompositionController interface will also implement
  2522. /// ICoreWebView2Controller. Callers are expected to use
  2523. /// ICoreWebView2Controller for resizing, visibility, focus, and so on, and
  2524. /// then use ICoreWebView2CompositionController to connect to a composition
  2525. /// tree and provide input meant for the WebView.
  2526. [uuid(3df9b733-b9ae-4a15-86b4-eb9ee9826469), object, pointer_default(unique)]
  2527. interface ICoreWebView2CompositionController : IUnknown {
  2528. /// The RootVisualTarget is a visual in the hosting app's visual tree. This
  2529. /// visual is where the WebView will connect its visual tree. The app uses
  2530. /// this visual to position the WebView within the app. The app still needs
  2531. /// to use the Bounds property to size the WebView. The RootVisualTarget
  2532. /// property can be an IDCompositionVisual or a
  2533. /// Windows::UI::Composition::ContainerVisual. WebView will connect its visual
  2534. /// tree to the provided visual before returning from the property setter. The
  2535. /// app needs to commit on its device setting the RootVisualTarget property.
  2536. /// The RootVisualTarget property supports being set to nullptr to disconnect
  2537. /// the WebView from the app's visual tree.
  2538. /// \snippet ViewComponent.cpp SetRootVisualTarget
  2539. /// \snippet ViewComponent.cpp BuildDCompTree
  2540. [propget] HRESULT RootVisualTarget([out, retval] IUnknown** target);
  2541. /// Set the RootVisualTarget property.
  2542. [propput] HRESULT RootVisualTarget([in] IUnknown* target);
  2543. /// If eventKind is COREWEBVIEW2_MOUSE_EVENT_KIND_HORIZONTAL_WHEEL or
  2544. /// COREWEBVIEW2_MOUSE_EVENT_KIND_WHEEL, then mouseData specifies the amount of
  2545. /// wheel movement. A positive value indicates that the wheel was rotated
  2546. /// forward, away from the user; a negative value indicates that the wheel was
  2547. /// rotated backward, toward the user. One wheel click is defined as
  2548. /// WHEEL_DELTA, which is 120.
  2549. /// If eventKind is COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_DOUBLE_CLICK
  2550. /// COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_DOWN, or
  2551. /// COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_UP, then mouseData specifies which X
  2552. /// buttons were pressed or released. This value should be 1 if the first X
  2553. /// button is pressed/released and 2 if the second X button is
  2554. /// pressed/released.
  2555. /// If eventKind is COREWEBVIEW2_MOUSE_EVENT_KIND_LEAVE, then virtualKeys,
  2556. /// mouseData, and point should all be zero.
  2557. /// If eventKind is any other value, then mouseData should be zero.
  2558. /// Point is expected to be in the client coordinate space of the WebView.
  2559. /// To track mouse events that start in the WebView and can potentially move
  2560. /// outside of the WebView and host application, calling SetCapture and
  2561. /// ReleaseCapture is recommended.
  2562. /// To dismiss hover popups, it is also recommended to send
  2563. /// COREWEBVIEW2_MOUSE_EVENT_KIND_LEAVE messages.
  2564. /// \snippet ViewComponent.cpp SendMouseInput
  2565. HRESULT SendMouseInput(
  2566. [in] COREWEBVIEW2_MOUSE_EVENT_KIND eventKind,
  2567. [in] COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS virtualKeys,
  2568. [in] UINT32 mouseData,
  2569. [in] POINT point);
  2570. /// SendPointerInput accepts touch or pen pointer input of types defined in
  2571. /// COREWEBVIEW2_POINTER_EVENT_KIND. Any pointer input from the system must be
  2572. /// converted into an ICoreWebView2PointerInfo first.
  2573. HRESULT SendPointerInput(
  2574. [in] COREWEBVIEW2_POINTER_EVENT_KIND eventKind,
  2575. [in] ICoreWebView2PointerInfo* pointerInfo);
  2576. /// The current cursor that WebView thinks it should be. The cursor should be
  2577. /// set in WM_SETCURSOR through \::SetCursor or set on the corresponding
  2578. /// parent/ancestor HWND of the WebView through \::SetClassLongPtr. The HCURSOR
  2579. /// can be freed so CopyCursor/DestroyCursor is recommended to keep your own
  2580. /// copy if you are doing more than immediately setting the cursor.
  2581. [propget] HRESULT Cursor([out, retval] HCURSOR* cursor);
  2582. /// The current system cursor ID reported by the underlying rendering engine
  2583. /// for WebView. For example, most of the time, when the cursor is over text,
  2584. /// this will return the int value for IDC_IBEAM. The systemCursorId is only
  2585. /// valid if the rendering engine reports a default Windows cursor resource
  2586. /// value. Navigate to
  2587. /// [LoadCursorW](/windows/win32/api/winuser/nf-winuser-loadcursorw) for more
  2588. /// details. Otherwise, if custom CSS cursors are being used, this will return
  2589. /// 0. To actually use systemCursorId in LoadCursor or LoadImage,
  2590. /// MAKEINTRESOURCE must be called on it first.
  2591. ///
  2592. /// \snippet ViewComponent.cpp SystemCursorId
  2593. [propget] HRESULT SystemCursorId([out, retval] UINT32* systemCursorId);
  2594. /// Add an event handler for the CursorChanged event.
  2595. /// The event is raised when WebView thinks the cursor should be changed. For
  2596. /// example, when the mouse cursor is currently the default cursor but is then
  2597. /// moved over text, it may try to change to the IBeam cursor.
  2598. ///
  2599. /// It is expected for the developer to send
  2600. /// COREWEBVIEW2_MOUSE_EVENT_KIND_LEAVE messages (in addition to
  2601. /// COREWEBVIEW2_MOUSE_EVENT_KIND_MOVE messages) through the SendMouseInput
  2602. /// API. This is to ensure that the mouse is actually within the WebView that
  2603. /// sends out CursorChanged events.
  2604. ///
  2605. /// \snippet ViewComponent.cpp CursorChanged
  2606. HRESULT add_CursorChanged(
  2607. [in] ICoreWebView2CursorChangedEventHandler* eventHandler,
  2608. [out] EventRegistrationToken* token);
  2609. /// Remove an event handler previously added with add_CursorChanged.
  2610. HRESULT remove_CursorChanged(
  2611. [in] EventRegistrationToken token);
  2612. }
  2613. /// A continuation of the ICoreWebView2CompositionController interface.
  2614. [uuid(0b6a3d24-49cb-4806-ba20-b5e0734a7b26), object, pointer_default(unique)]
  2615. interface ICoreWebView2CompositionController2 : ICoreWebView2CompositionController {
  2616. /// Returns the Automation Provider for the WebView. This object implements
  2617. /// IRawElementProviderSimple.
  2618. [propget] HRESULT AutomationProvider([out, retval] IUnknown** provider);
  2619. }
  2620. /// This interface is used to complete deferrals on event args that support
  2621. /// getting deferrals using the `GetDeferral` method.
  2622. [uuid(c10e7f7b-b585-46f0-a623-8befbf3e4ee0), object, pointer_default(unique)]
  2623. interface ICoreWebView2Deferral : IUnknown {
  2624. /// Completes the associated deferred event. Complete should only be run
  2625. /// once for each deferral taken.
  2626. HRESULT Complete();
  2627. }
  2628. /// Defines properties that enable, disable, or modify WebView features.
  2629. /// Changes to `IsGeneralAutofillEnabled` and `IsPasswordAutosaveEnabled`
  2630. /// apply immediately, while other setting changes made after `NavigationStarting`
  2631. /// event do not apply until the next top-level navigation.
  2632. [uuid(e562e4f0-d7fa-43ac-8d71-c05150499f00), object, pointer_default(unique)]
  2633. interface ICoreWebView2Settings : IUnknown {
  2634. /// Controls if running JavaScript is enabled in all future navigations in
  2635. /// the WebView. This only affects scripts in the document. Scripts
  2636. /// injected with `ExecuteScript` runs even if script is disabled.
  2637. /// The default value is `TRUE`.
  2638. ///
  2639. /// \snippet SettingsComponent.cpp IsScriptEnabled
  2640. [propget] HRESULT IsScriptEnabled(
  2641. [out, retval] BOOL* isScriptEnabled);
  2642. /// Sets the `IsScriptEnabled` property.
  2643. [propput] HRESULT IsScriptEnabled([in] BOOL isScriptEnabled);
  2644. /// The `IsWebMessageEnabled` property is used when loading a new HTML
  2645. /// document. If set to `TRUE`, communication from the host to the top-level
  2646. /// HTML document of the WebView is allowed using `PostWebMessageAsJson`,
  2647. /// `PostWebMessageAsString`, and message event of `window.chrome.webview`.
  2648. /// For more information, navigate to PostWebMessageAsJson. Communication
  2649. /// from the top-level HTML document of the WebView to the host is allowed
  2650. /// using the postMessage function of `window.chrome.webview` and
  2651. /// `add_WebMessageReceived` method. For more information, navigate to
  2652. /// [add_WebMessageReceived](/microsoft-edge/webview2/reference/win32/icorewebview2#add_webmessagereceived).
  2653. /// If set to false, then communication is disallowed. `PostWebMessageAsJson`
  2654. /// and `PostWebMessageAsString` fails with `E_ACCESSDENIED` and
  2655. /// `window.chrome.webview.postMessage` fails by throwing an instance of an
  2656. /// `Error` object. The default value is `TRUE`.
  2657. ///
  2658. /// \snippet ScenarioWebMessage.cpp IsWebMessageEnabled
  2659. [propget] HRESULT IsWebMessageEnabled(
  2660. [out, retval] BOOL* isWebMessageEnabled);
  2661. /// Sets the `IsWebMessageEnabled` property.
  2662. [propput] HRESULT IsWebMessageEnabled([in] BOOL isWebMessageEnabled);
  2663. /// `AreDefaultScriptDialogsEnabled` is used when loading a new HTML
  2664. /// document. If set to `FALSE`, WebView2 does not render the default JavaScript
  2665. /// dialog box (Specifically those displayed by the JavaScript alert,
  2666. /// confirm, prompt functions and `beforeunload` event). Instead, if an
  2667. /// event handler is set using `add_ScriptDialogOpening`, WebView sends an
  2668. /// event that contains all of the information for the dialog and allow the
  2669. /// host app to show a custom UI.
  2670. /// The default value is `TRUE`.
  2671. [propget] HRESULT AreDefaultScriptDialogsEnabled(
  2672. [out, retval] BOOL* areDefaultScriptDialogsEnabled);
  2673. /// Sets the `AreDefaultScriptDialogsEnabled` property.
  2674. [propput] HRESULT AreDefaultScriptDialogsEnabled(
  2675. [in] BOOL areDefaultScriptDialogsEnabled);
  2676. /// `IsStatusBarEnabled` controls whether the status bar is displayed. The
  2677. /// status bar is usually displayed in the lower left of the WebView and
  2678. /// shows things such as the URI of a link when the user hovers over it and
  2679. /// other information.
  2680. /// The default value is `TRUE`.
  2681. /// The status bar UI can be altered by web content and should not be considered secure.
  2682. [propget] HRESULT IsStatusBarEnabled([out, retval] BOOL* isStatusBarEnabled);
  2683. /// Sets the `IsStatusBarEnabled` property.
  2684. [propput] HRESULT IsStatusBarEnabled([in] BOOL isStatusBarEnabled);
  2685. /// `AreDevToolsEnabled` controls whether the user is able to use the context
  2686. /// menu or keyboard shortcuts to open the DevTools window.
  2687. /// The default value is `TRUE`.
  2688. [propget] HRESULT AreDevToolsEnabled([out, retval] BOOL* areDevToolsEnabled);
  2689. /// Sets the `AreDevToolsEnabled` property.
  2690. [propput] HRESULT AreDevToolsEnabled([in] BOOL areDevToolsEnabled);
  2691. /// The `AreDefaultContextMenusEnabled` property is used to prevent default
  2692. /// context menus from being shown to user in WebView.
  2693. /// The default value is `TRUE`.
  2694. ///
  2695. /// \snippet SettingsComponent.cpp DisableContextMenu
  2696. [propget] HRESULT AreDefaultContextMenusEnabled([out, retval] BOOL* enabled);
  2697. /// Sets the `AreDefaultContextMenusEnabled` property.
  2698. [propput] HRESULT AreDefaultContextMenusEnabled([in] BOOL enabled);
  2699. /// The `AreHostObjectsAllowed` property is used to control whether host
  2700. /// objects are accessible from the page in WebView.
  2701. /// The default value is `TRUE`.
  2702. ///
  2703. /// \snippet SettingsComponent.cpp HostObjectsAccess
  2704. [propget] HRESULT AreHostObjectsAllowed([out, retval] BOOL* allowed);
  2705. /// Sets the `AreHostObjectsAllowed` property.
  2706. [propput] HRESULT AreHostObjectsAllowed([in] BOOL allowed);
  2707. /// The `IsZoomControlEnabled` property is used to prevent the user from
  2708. /// impacting the zoom of the WebView. When disabled, the user is not able
  2709. /// to zoom using Ctrl++, Ctrl+-, or Ctrl+mouse wheel, but the zoom
  2710. /// is set using `ZoomFactor` API. The default value is `TRUE`.
  2711. ///
  2712. /// \snippet SettingsComponent.cpp DisableZoomControl
  2713. [propget] HRESULT IsZoomControlEnabled([out, retval] BOOL* enabled);
  2714. /// Sets the `IsZoomControlEnabled` property.
  2715. [propput] HRESULT IsZoomControlEnabled([in] BOOL enabled);
  2716. /// The `IsBuiltInErrorPageEnabled` property is used to disable built in
  2717. /// error page for navigation failure and render process failure. When
  2718. /// disabled, a blank page is displayed when the related error happens.
  2719. /// The default value is `TRUE`.
  2720. ///
  2721. /// \snippet SettingsComponent.cpp BuiltInErrorPageEnabled
  2722. [propget] HRESULT IsBuiltInErrorPageEnabled([out, retval] BOOL* enabled);
  2723. /// Sets the `IsBuiltInErrorPageEnabled` property.
  2724. [propput] HRESULT IsBuiltInErrorPageEnabled([in] BOOL enabled);
  2725. }
  2726. /// A continuation of the ICoreWebView2Settings interface that manages the user agent.
  2727. [uuid(ee9a0f68-f46c-4e32-ac23-ef8cac224d2a), object, pointer_default(unique)]
  2728. interface ICoreWebView2Settings2 : ICoreWebView2Settings {
  2729. /// Returns the User Agent. The default value is the default User Agent of the
  2730. /// Microsoft Edge browser.
  2731. ///
  2732. /// The caller must free the returned string with `CoTaskMemFree`. See
  2733. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  2734. ///
  2735. /// \snippet SettingsComponent.cpp UserAgent
  2736. [propget] HRESULT UserAgent([out, retval] LPWSTR* userAgent);
  2737. /// Sets the `UserAgent` property. This property may be overridden if
  2738. /// the User-Agent header is set in a request. If the parameter is empty
  2739. /// the User Agent will not be updated and the current User Agent will remain.
  2740. /// Returns `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)` if the owning WebView is
  2741. /// closed.
  2742. [propput] HRESULT UserAgent([in] LPCWSTR userAgent);
  2743. }
  2744. /// A continuation of the ICoreWebView2Settings interface that manages whether
  2745. /// browser accelerator keys are enabled.
  2746. [uuid(fdb5ab74-af33-4854-84f0-0a631deb5eba), object, pointer_default(unique)]
  2747. interface ICoreWebView2Settings3 : ICoreWebView2Settings2 {
  2748. /// When this setting is set to FALSE, it disables all accelerator keys that
  2749. /// access features specific to a web browser, including but not limited to:
  2750. /// - Ctrl-F and F3 for Find on Page
  2751. /// - Ctrl-P for Print
  2752. /// - Ctrl-R and F5 for Reload
  2753. /// - Ctrl-Plus and Ctrl-Minus for zooming
  2754. /// - Ctrl-Shift-C and F12 for DevTools
  2755. /// - Special keys for browser functions, such as Back, Forward, and Search
  2756. ///
  2757. /// It does not disable accelerator keys related to movement and text editing,
  2758. /// such as:
  2759. /// - Home, End, Page Up, and Page Down
  2760. /// - Ctrl-X, Ctrl-C, Ctrl-V
  2761. /// - Ctrl-A for Select All
  2762. /// - Ctrl-Z for Undo
  2763. ///
  2764. /// Those accelerator keys will always be enabled unless they are handled in
  2765. /// the `AcceleratorKeyPressed` event.
  2766. ///
  2767. /// This setting has no effect on the `AcceleratorKeyPressed` event. The event
  2768. /// will be fired for all accelerator keys, whether they are enabled or not.
  2769. ///
  2770. /// The default value for `AreBrowserAcceleratorKeysEnabled` is TRUE.
  2771. ///
  2772. /// \snippet SettingsComponent.cpp AreBrowserAcceleratorKeysEnabled
  2773. [propget] HRESULT AreBrowserAcceleratorKeysEnabled(
  2774. [out, retval] BOOL* areBrowserAcceleratorKeysEnabled);
  2775. /// Sets the `AreBrowserAcceleratorKeysEnabled` property.
  2776. [propput] HRESULT AreBrowserAcceleratorKeysEnabled(
  2777. [in] BOOL areBrowserAcceleratorKeysEnabled);
  2778. }
  2779. /// A continuation of the ICoreWebView2Settings interface to manage autofill.
  2780. [uuid(cb56846c-4168-4d53-b04f-03b6d6796ff2), object, pointer_default(unique)]
  2781. interface ICoreWebView2Settings4 : ICoreWebView2Settings3 {
  2782. /// IsPasswordAutosaveEnabled controls whether autosave for password
  2783. /// information is enabled. The IsPasswordAutosaveEnabled property behaves
  2784. /// independently of the IsGeneralAutofillEnabled property. When IsPasswordAutosaveEnabled is
  2785. /// false, no new password data is saved and no Save/Update Password prompts are displayed.
  2786. /// However, if there was password data already saved before disabling this setting,
  2787. /// then that password information is auto-populated, suggestions are shown and clicking on
  2788. /// one will populate the fields.
  2789. /// When IsPasswordAutosaveEnabled is true, password information is auto-populated,
  2790. /// suggestions are shown and clicking on one will populate the fields, new data
  2791. /// is saved, and a Save/Update Password prompt is displayed.
  2792. /// It will apply immediately after setting.
  2793. /// The default value is `FALSE`.
  2794. /// This property is linked with `CoreWebView2Profile.IsPasswordAutosaveEnabled`, so
  2795. /// changing one will change the other. And all WebView2s that created with the same
  2796. /// `CoreWebView2Profile` will share this property, so for the WebView2s with the same
  2797. /// profile, their `CoreWebView2Settings.IsPasswordAutosaveEnabled` and
  2798. /// `CoreWebView2Profile.IsPasswordAutosaveEnabled` are always in sync.
  2799. ///
  2800. /// \snippet SettingsComponent.cpp PasswordAutosaveEnabled
  2801. [propget] HRESULT IsPasswordAutosaveEnabled([out, retval] BOOL* value);
  2802. /// Set the IsPasswordAutosaveEnabled property.
  2803. [propput] HRESULT IsPasswordAutosaveEnabled([in] BOOL value);
  2804. /// IsGeneralAutofillEnabled controls whether autofill for information
  2805. /// like names, street and email addresses, phone numbers, and arbitrary input
  2806. /// is enabled. This excludes password and credit card information. When
  2807. /// IsGeneralAutofillEnabled is false, no suggestions appear, and no new information
  2808. /// is saved. When IsGeneralAutofillEnabled is true, information is saved, suggestions
  2809. /// appear and clicking on one will populate the form fields.
  2810. /// It will apply immediately after setting.
  2811. /// The default value is `TRUE`.
  2812. /// This property is linked with `CoreWebView2Profile.IsGeneralAutofillEnabled`, so
  2813. /// changing one will change the other. And all WebView2s that created with the same
  2814. /// `CoreWebView2Profile` will share this property, so for the WebView2s with the same
  2815. /// profile, their `CoreWebView2Settings.IsGeneralAutofillEnabled` and
  2816. /// `CoreWebView2Profile.IsGeneralAutofillEnabled` are always in sync.
  2817. ///
  2818. /// \snippet SettingsComponent.cpp GeneralAutofillEnabled
  2819. [propget] HRESULT IsGeneralAutofillEnabled([out, retval] BOOL* value);
  2820. /// Set the IsGeneralAutofillEnabled property.
  2821. [propput] HRESULT IsGeneralAutofillEnabled([in] BOOL value);
  2822. }
  2823. /// A continuation of the ICoreWebView2Settings interface to manage pinch zoom.
  2824. [uuid(183e7052-1d03-43a0-ab99-98e043b66b39), object, pointer_default(unique)]
  2825. interface ICoreWebView2Settings5 : ICoreWebView2Settings4 {
  2826. /// Pinch-zoom, referred to as "Page Scale" zoom, is performed as a post-rendering step,
  2827. /// it changes the page scale factor property and scales the surface the web page is
  2828. /// rendered onto when user performs a pinch zooming action. It does not change the layout
  2829. /// but rather changes the viewport and clips the web content, the content outside of the
  2830. /// viewport isn't visible onscreen and users can't reach this content using mouse.
  2831. ///
  2832. /// The `IsPinchZoomEnabled` property enables or disables the ability of
  2833. /// the end user to use a pinching motion on touch input enabled devices
  2834. /// to scale the web content in the WebView2. It defaults to `TRUE`.
  2835. /// When set to `FALSE`, the end user cannot pinch zoom after the next navigation.
  2836. /// Disabling/Enabling `IsPinchZoomEnabled` only affects the end user's ability to use
  2837. /// pinch motions and does not change the page scale factor.
  2838. /// This API only affects the Page Scale zoom and has no effect on the
  2839. /// existing browser zoom properties (`IsZoomControlEnabled` and `ZoomFactor`)
  2840. /// or other end user mechanisms for zooming.
  2841. ///
  2842. /// \snippet SettingsComponent.cpp TogglePinchZoomEnabled
  2843. [propget] HRESULT IsPinchZoomEnabled([out, retval] BOOL* enabled);
  2844. /// Set the `IsPinchZoomEnabled` property
  2845. [propput] HRESULT IsPinchZoomEnabled([in] BOOL enabled);
  2846. }
  2847. /// A continuation of the ICoreWebView2Settings interface to manage swipe navigation.
  2848. [uuid(11cb3acd-9bc8-43b8-83bf-f40753714f87), object, pointer_default(unique)]
  2849. interface ICoreWebView2Settings6 : ICoreWebView2Settings5 {
  2850. /// The `IsSwipeNavigationEnabled` property enables or disables the ability of the
  2851. /// end user to use swiping gesture on touch input enabled devices to
  2852. /// navigate in WebView2. It defaults to `TRUE`.
  2853. ///
  2854. /// When this property is `TRUE`, then all configured navigation gestures are enabled:
  2855. /// 1. Swiping left and right to navigate forward and backward is always configured.
  2856. /// 2. Swiping down to refresh is off by default and not exposed via our API currently,
  2857. /// it requires the "--pull-to-refresh" option to be included in the additional browser
  2858. /// arguments to be configured. (See put_AdditionalBrowserArguments.)
  2859. ///
  2860. /// When set to `FALSE`, the end user cannot swipe to navigate or pull to refresh.
  2861. /// This API only affects the overscrolling navigation functionality and has no
  2862. /// effect on the scrolling interaction used to explore the web content shown
  2863. /// in WebView2.
  2864. ///
  2865. /// Disabling/Enabling IsSwipeNavigationEnabled takes effect after the
  2866. /// next navigation.
  2867. ///
  2868. /// \snippet SettingsComponent.cpp ToggleSwipeNavigationEnabled
  2869. [propget] HRESULT IsSwipeNavigationEnabled([out, retval] BOOL* enabled);
  2870. /// Set the `IsSwipeNavigationEnabled` property
  2871. [propput] HRESULT IsSwipeNavigationEnabled([in] BOOL enabled);
  2872. }
  2873. /// A continuation of the ICoreWebView2Settings interface to hide Pdf toolbar items.
  2874. [uuid(488dc902-35ef-42d2-bc7d-94b65c4bc49c), object, pointer_default(unique)]
  2875. interface ICoreWebView2Settings7 : ICoreWebView2Settings6 {
  2876. /// `HiddenPdfToolbarItems` is used to customize the PDF toolbar items. By default, it is COREWEBVIEW2_PDF_TOOLBAR_ITEMS_NONE and so it displays all of the items.
  2877. /// Changes to this property apply to all CoreWebView2s in the same environment and using the same profile.
  2878. /// Changes to this setting apply only after the next navigation.
  2879. /// \snippet SettingsComponent.cpp ToggleHidePdfToolbarItems
  2880. [propget] HRESULT HiddenPdfToolbarItems([out, retval] COREWEBVIEW2_PDF_TOOLBAR_ITEMS* hidden_pdf_toolbar_items);
  2881. /// Set the `HiddenPdfToolbarItems` property.
  2882. [propput] HRESULT HiddenPdfToolbarItems([in] COREWEBVIEW2_PDF_TOOLBAR_ITEMS hidden_pdf_toolbar_items);
  2883. }
  2884. /// Event args for the `ProcessFailed` event.
  2885. [uuid(8155a9a4-1474-4a86-8cae-151b0fa6b8ca), object, pointer_default(unique)]
  2886. interface ICoreWebView2ProcessFailedEventArgs : IUnknown {
  2887. /// The kind of process failure that has occurred. `processFailedKind` is
  2888. /// `COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_EXITED` if the
  2889. /// failed process is the main frame's renderer, even if there were subframes
  2890. /// rendered by such process; all frames are gone when this happens.
  2891. [propget] HRESULT ProcessFailedKind(
  2892. [out, retval] COREWEBVIEW2_PROCESS_FAILED_KIND* processFailedKind);
  2893. }
  2894. /// Receives `ProcessFailed` events.
  2895. [uuid(79e0aea4-990b-42d9-aa1d-0fcc2e5bc7f1), object, pointer_default(unique)]
  2896. interface ICoreWebView2ProcessFailedEventHandler : IUnknown {
  2897. /// Provides the event args for the corresponding event.
  2898. HRESULT Invoke(
  2899. [in] ICoreWebView2* sender,
  2900. [in] ICoreWebView2ProcessFailedEventArgs* args);
  2901. }
  2902. /// Implements the interface to receive `ZoomFactorChanged` events. Use the
  2903. /// `ICoreWebView2Controller.ZoomFactor` property to get the modified zoom
  2904. /// factor.
  2905. [uuid(b52d71d6-c4df-4543-a90c-64a3e60f38cb), object, pointer_default(unique)]
  2906. interface ICoreWebView2ZoomFactorChangedEventHandler : IUnknown {
  2907. /// Provides the event args for the corresponding event. No event args exist
  2908. /// and the `args` parameter is set to `null`.
  2909. HRESULT Invoke([in] ICoreWebView2Controller* sender, [in] IUnknown* args);
  2910. }
  2911. /// Iterator for a collection of HTTP headers. For more information, navigate
  2912. /// to ICoreWebView2HttpRequestHeaders and ICoreWebView2HttpResponseHeaders.
  2913. ///
  2914. /// \snippet ScenarioWebViewEventMonitor.cpp HttpRequestHeaderIterator
  2915. [uuid(0702fc30-f43b-47bb-ab52-a42cb552ad9f), object, pointer_default(unique)]
  2916. interface ICoreWebView2HttpHeadersCollectionIterator : IUnknown {
  2917. /// Get the name and value of the current HTTP header of the iterator. If
  2918. /// the previous `MoveNext` operation set the `hasNext` parameter to `FALSE`,
  2919. /// this method fails.
  2920. ///
  2921. /// The caller must free the returned strings with `CoTaskMemFree`. See
  2922. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  2923. HRESULT GetCurrentHeader([out] LPWSTR* name, [out] LPWSTR* value);
  2924. /// `TRUE` when the iterator has not run out of headers. If the collection
  2925. /// over which the iterator is iterating is empty or if the iterator has gone
  2926. /// past the end of the collection then this is `FALSE`.
  2927. [propget] HRESULT HasCurrentHeader([out, retval] BOOL* hasCurrent);
  2928. /// Move the iterator to the next HTTP header in the collection.
  2929. ///
  2930. /// \> [!NOTE]\n \> If no more HTTP headers exist, the `hasNext` parameter is set to
  2931. /// `FALSE`. After this occurs the `GetCurrentHeader` method fails.
  2932. HRESULT MoveNext([out, retval] BOOL* hasNext);
  2933. }
  2934. /// HTTP request headers. Used to inspect the HTTP request on
  2935. /// `WebResourceRequested` event and `NavigationStarting` event.
  2936. ///
  2937. /// \> [!NOTE]\n\> It is possible to modify the HTTP request from a `WebResourceRequested`
  2938. /// event, but not from a `NavigationStarting` event.
  2939. [uuid(e86cac0e-5523-465c-b536-8fb9fc8c8c60), object, pointer_default(unique)]
  2940. interface ICoreWebView2HttpRequestHeaders : IUnknown {
  2941. /// Gets the header value matching the name.
  2942. ///
  2943. /// The caller must free the returned string with `CoTaskMemFree`. See
  2944. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  2945. HRESULT GetHeader([in] LPCWSTR name, [out, retval] LPWSTR* value);
  2946. /// Gets the header value matching the name using an iterator.
  2947. HRESULT GetHeaders([in] LPCWSTR name, [out, retval] ICoreWebView2HttpHeadersCollectionIterator** iterator);
  2948. /// Verifies that the headers contain an entry that matches the header name.
  2949. HRESULT Contains([in] LPCWSTR name, [out, retval] BOOL* contains);
  2950. /// Adds or updates header that matches the name.
  2951. HRESULT SetHeader([in] LPCWSTR name, [in] LPCWSTR value);
  2952. /// Removes header that matches the name.
  2953. HRESULT RemoveHeader([in] LPCWSTR name);
  2954. /// Gets an iterator over the collection of request headers.
  2955. HRESULT GetIterator(
  2956. [out, retval] ICoreWebView2HttpHeadersCollectionIterator** iterator);
  2957. }
  2958. /// HTTP response headers. Used to construct a `WebResourceResponse` for the
  2959. /// `WebResourceRequested` event.
  2960. [uuid(03c5ff5a-9b45-4a88-881c-89a9f328619c), object, pointer_default(unique)]
  2961. interface ICoreWebView2HttpResponseHeaders : IUnknown {
  2962. /// Appends header line with name and value.
  2963. HRESULT AppendHeader([in] LPCWSTR name, [in] LPCWSTR value);
  2964. /// Verifies that the headers contain entries that match the header name.
  2965. HRESULT Contains([in] LPCWSTR name, [out, retval] BOOL* contains);
  2966. /// Gets the first header value in the collection matching the name.
  2967. ///
  2968. /// The caller must free the returned string with `CoTaskMemFree`. See
  2969. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  2970. HRESULT GetHeader([in] LPCWSTR name, [out, retval] LPWSTR* value);
  2971. /// Gets the header values matching the name.
  2972. HRESULT GetHeaders([in] LPCWSTR name, [out, retval] ICoreWebView2HttpHeadersCollectionIterator** iterator);
  2973. /// Gets an iterator over the collection of entire response headers.
  2974. HRESULT GetIterator(
  2975. [out, retval] ICoreWebView2HttpHeadersCollectionIterator** iterator);
  2976. }
  2977. /// An HTTP request used with the `WebResourceRequested` event.
  2978. [uuid(97055cd4-512c-4264-8b5f-e3f446cea6a5), object, pointer_default(unique)]
  2979. interface ICoreWebView2WebResourceRequest : IUnknown {
  2980. /// The request URI.
  2981. ///
  2982. /// The caller must free the returned string with `CoTaskMemFree`. See
  2983. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  2984. [propget] HRESULT Uri([out, retval] LPWSTR* uri);
  2985. /// Sets the `Uri` property.
  2986. [propput] HRESULT Uri([in] LPCWSTR uri);
  2987. /// The HTTP request method.
  2988. ///
  2989. /// The caller must free the returned string with `CoTaskMemFree`. See
  2990. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  2991. [propget] HRESULT Method([out, retval] LPWSTR* method);
  2992. /// Sets the `Method` property.
  2993. [propput] HRESULT Method([in] LPCWSTR method);
  2994. /// The HTTP request message body as stream. POST data should be here. If a
  2995. /// stream is set, which overrides the message body, the stream must have
  2996. /// all the content data available by the time the `WebResourceRequested`
  2997. /// event deferral of this response is completed. Stream should be agile or
  2998. /// be created from a background STA to prevent performance impact to the UI
  2999. /// thread. `Null` means no content data. `IStream` semantics apply
  3000. /// (return `S_OK` to `Read` runs until all data is exhausted).
  3001. [propget] HRESULT Content([out, retval] IStream** content);
  3002. /// Sets the `Content` property.
  3003. [propput] HRESULT Content([in] IStream* content);
  3004. /// The mutable HTTP request headers
  3005. [propget] HRESULT Headers([out, retval] ICoreWebView2HttpRequestHeaders** headers);
  3006. }
  3007. /// An HTTP response used with the `WebResourceRequested` event.
  3008. [uuid(aafcc94f-fa27-48fd-97df-830ef75aaec9), object, pointer_default(unique)]
  3009. interface ICoreWebView2WebResourceResponse : IUnknown {
  3010. /// HTTP response content as stream. Stream must have all the content data
  3011. /// available by the time the `WebResourceRequested` event deferral of this
  3012. /// response is completed. Stream should be agile or be created from a
  3013. /// background thread to prevent performance impact to the UI thread. `Null`
  3014. /// means no content data. `IStream` semantics apply (return `S_OK` to
  3015. /// `Read` runs until all data is exhausted).
  3016. [propget] HRESULT Content([out, retval] IStream** content);
  3017. /// Sets the `Content` property.
  3018. [propput] HRESULT Content([in] IStream* content);
  3019. /// Overridden HTTP response headers.
  3020. [propget] HRESULT Headers([out, retval] ICoreWebView2HttpResponseHeaders** headers);
  3021. /// The HTTP response status code.
  3022. [propget] HRESULT StatusCode([out, retval] int* statusCode);
  3023. /// Sets the `StatusCode` property.
  3024. [propput] HRESULT StatusCode([in] int statusCode);
  3025. /// The HTTP response reason phrase.
  3026. ///
  3027. /// The caller must free the returned string with `CoTaskMemFree`. See
  3028. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3029. [propget] HRESULT ReasonPhrase([out, retval] LPWSTR* reasonPhrase);
  3030. /// Sets the `ReasonPhrase` property.
  3031. [propput] HRESULT ReasonPhrase([in] LPCWSTR reasonPhrase);
  3032. }
  3033. /// Event args for the `NavigationStarting` event.
  3034. [uuid(5b495469-e119-438a-9b18-7604f25f2e49), object, pointer_default(unique)]
  3035. interface ICoreWebView2NavigationStartingEventArgs : IUnknown {
  3036. /// The uri of the requested navigation.
  3037. ///
  3038. /// The caller must free the returned string with `CoTaskMemFree`. See
  3039. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3040. [propget] HRESULT Uri([out, retval] LPWSTR* uri);
  3041. /// `TRUE` when the navigation was initiated through a user gesture as
  3042. /// opposed to programmatic navigation by page script. Navigations initiated
  3043. /// via WebView2 APIs are considered as user initiated.
  3044. [propget] HRESULT IsUserInitiated([out, retval] BOOL* isUserInitiated);
  3045. /// `TRUE` when the navigation is redirected.
  3046. [propget] HRESULT IsRedirected([out, retval] BOOL* isRedirected);
  3047. /// The HTTP request headers for the navigation.
  3048. ///
  3049. /// \> [!NOTE]\n\> You are not able to modify the HTTP request headers in a
  3050. /// `NavigationStarting` event.
  3051. [propget] HRESULT RequestHeaders([out, retval] ICoreWebView2HttpRequestHeaders** requestHeaders);
  3052. /// The host may set this flag to cancel the navigation. If set, the
  3053. /// navigation is not longer present and the content of the current page is
  3054. /// intact. For performance reasons, `GET` HTTP requests may happen, while
  3055. /// the host is responding. You may set cookies and use part of a request
  3056. /// for the navigation. Cancellation for navigation to `about:blank` or
  3057. /// frame navigation to `srcdoc` is not supported. Such attempts are
  3058. /// ignored. A cancelled navigation will fire a `NavigationCompleted` event
  3059. /// with a `WebErrorStatus` of
  3060. /// `COREWEBVIEW2_WEB_ERROR_STATUS_OPERATION_CANCELED`.
  3061. [propget] HRESULT Cancel([out, retval] BOOL* cancel);
  3062. /// Sets the `Cancel` property.
  3063. [propput] HRESULT Cancel([in] BOOL cancel);
  3064. /// The ID of the navigation.
  3065. [propget] HRESULT NavigationId([out, retval] UINT64* navigationId);
  3066. }
  3067. /// The AdditionalAllowedFrameAncestors API that enable developers to provide additional allowed frame ancestors.
  3068. [uuid(9086BE93-91AA-472D-A7E0-579F2BA006AD), object, pointer_default(unique)]
  3069. interface ICoreWebView2NavigationStartingEventArgs2 : ICoreWebView2NavigationStartingEventArgs {
  3070. /// Get additional allowed frame ancestors set by the host app.
  3071. ///
  3072. /// The caller must free the returned string with `CoTaskMemFree`. See
  3073. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3074. [propget] HRESULT AdditionalAllowedFrameAncestors([out, retval] LPWSTR* value);
  3075. /// The app may set this property to allow a frame to be embedded by additional ancestors besides what is allowed by
  3076. /// http header [X-Frame-Options](https://developer.mozilla.org/docs/Web/HTTP/Headers/X-Frame-Options)
  3077. /// and [Content-Security-Policy frame-ancestors directive](https://developer.mozilla.org/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors).
  3078. /// If set, a frame ancestor is allowed if it is allowed by the additional allowed frame
  3079. /// ancestors or original http header from the site.
  3080. /// Whether an ancestor is allowed by the additional allowed frame ancestors is done the same way as if the site provided
  3081. /// it as the source list of the Content-Security-Policy frame-ancestors directive.
  3082. /// For example, if `https://example.com` and `https://www.example.com` are the origins of the top
  3083. /// page and intermediate iframes that embed a nested site-embedding iframe, and you fully trust
  3084. /// those origins, you should set this property to `https://example.com https://www.example.com`.
  3085. /// This property gives the app the ability to use iframe to embed sites that otherwise
  3086. /// could not be embedded in an iframe in trusted app pages.
  3087. /// This could potentially subject the embedded sites to [Clickjacking](https://en.wikipedia.org/wiki/Clickjacking)
  3088. /// attack from the code running in the embedding web page. Therefore, you should only
  3089. /// set this property with origins of fully trusted embedding page and any intermediate iframes.
  3090. /// Whenever possible, you should use the list of specific origins of the top and intermediate
  3091. /// frames instead of wildcard characters for this property.
  3092. /// This API is to provide limited support for app scenarios that used to be supported by
  3093. /// `<webview>` element in other solutions like JavaScript UWP apps and Electron.
  3094. /// You should limit the usage of this property to trusted pages, and specific navigation
  3095. /// target url, by checking the `Source` of the WebView2, and `Uri` of the event args.
  3096. ///
  3097. /// This property is ignored for top level document navigation.
  3098. ///
  3099. /// \snippet ScriptComponent.cpp AdditionalAllowedFrameAncestors_1
  3100. ///
  3101. /// \snippet ScriptComponent.cpp AdditionalAllowedFrameAncestors_2
  3102. [propput] HRESULT AdditionalAllowedFrameAncestors([in] LPCWSTR value);
  3103. }
  3104. /// Receives `NavigationStarting` events.
  3105. [uuid(9adbe429-f36d-432b-9ddc-f8881fbd76e3), object, pointer_default(unique)]
  3106. interface ICoreWebView2NavigationStartingEventHandler : IUnknown {
  3107. /// Provides the event args for the corresponding event.
  3108. HRESULT Invoke(
  3109. [in] ICoreWebView2* sender,
  3110. [in] ICoreWebView2NavigationStartingEventArgs* args);
  3111. }
  3112. /// Event args for the `ContentLoading` event.
  3113. [uuid(0c8a1275-9b6b-4901-87ad-70df25bafa6e), object, pointer_default(unique)]
  3114. interface ICoreWebView2ContentLoadingEventArgs : IUnknown {
  3115. /// `TRUE` if the loaded content is an error page.
  3116. [propget] HRESULT IsErrorPage([out, retval] BOOL* isErrorPage);
  3117. /// The ID of the navigation.
  3118. [propget] HRESULT NavigationId([out, retval] UINT64* navigationId);
  3119. }
  3120. /// Receives `ContentLoading` events.
  3121. [uuid(364471e7-f2be-4910-bdba-d72077d51c4b), object, pointer_default(unique)]
  3122. interface ICoreWebView2ContentLoadingEventHandler : IUnknown {
  3123. /// Provides the event args for the corresponding event.
  3124. HRESULT Invoke([in] ICoreWebView2* sender, [in] ICoreWebView2ContentLoadingEventArgs* args);
  3125. }
  3126. /// Event args for the `SourceChanged` event.
  3127. [uuid(31e0e545-1dba-4266-8914-f63848a1f7d7), object, pointer_default(unique)]
  3128. interface ICoreWebView2SourceChangedEventArgs : IUnknown {
  3129. /// `TRUE` if the page being navigated to is a new document.
  3130. [propget] HRESULT IsNewDocument([out, retval] BOOL* isNewDocument);
  3131. }
  3132. /// Receives `SourceChanged` events.
  3133. [uuid(3c067f9f-5388-4772-8b48-79f7ef1ab37c), object, pointer_default(unique)]
  3134. interface ICoreWebView2SourceChangedEventHandler : IUnknown {
  3135. /// Provides the event args for the corresponding event.
  3136. HRESULT Invoke([in] ICoreWebView2* sender, [in] ICoreWebView2SourceChangedEventArgs* args);
  3137. }
  3138. /// Receives `HistoryChanged` events.
  3139. [uuid(c79a420c-efd9-4058-9295-3e8b4bcab645), object, pointer_default(unique)]
  3140. interface ICoreWebView2HistoryChangedEventHandler : IUnknown {
  3141. /// Provides the event args for the corresponding event. No event args exist
  3142. /// and the `args` parameter is set to `null`.
  3143. HRESULT Invoke([in] ICoreWebView2* sender, [in] IUnknown* args);
  3144. }
  3145. /// Event args for the `ScriptDialogOpening` event.
  3146. [uuid(7390bb70-abe0-4843-9529-f143b31b03d6), object, pointer_default(unique)]
  3147. interface ICoreWebView2ScriptDialogOpeningEventArgs : IUnknown {
  3148. /// The URI of the page that requested the dialog box.
  3149. ///
  3150. /// The caller must free the returned string with `CoTaskMemFree`. See
  3151. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3152. [propget] HRESULT Uri([out, retval] LPWSTR* uri);
  3153. /// The kind of JavaScript dialog box. `alert`, `confirm`, `prompt`, or
  3154. /// `beforeunload`.
  3155. [propget] HRESULT Kind([out, retval] COREWEBVIEW2_SCRIPT_DIALOG_KIND* kind);
  3156. /// The message of the dialog box. From JavaScript this is the first
  3157. /// parameter passed to `alert`, `confirm`, and `prompt` and is empty for
  3158. /// `beforeunload`.
  3159. ///
  3160. /// The caller must free the returned string with `CoTaskMemFree`. See
  3161. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3162. [propget] HRESULT Message([out, retval] LPWSTR* message);
  3163. /// The host may run this to respond with **OK** to `confirm`, `prompt`, and
  3164. /// `beforeunload` dialogs. Do not run this method to indicate cancel.
  3165. /// From JavaScript, this means that the `confirm` and `beforeunload` function
  3166. /// returns `TRUE` if `Accept` is run. And for the prompt function it returns
  3167. /// the value of `ResultText` if `Accept` is run and otherwise returns
  3168. /// `FALSE`.
  3169. HRESULT Accept();
  3170. /// The second parameter passed to the JavaScript prompt dialog.
  3171. /// The result of the prompt JavaScript function uses this value as the
  3172. /// default value.
  3173. ///
  3174. /// The caller must free the returned string with `CoTaskMemFree`. See
  3175. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3176. [propget] HRESULT DefaultText([out, retval] LPWSTR* defaultText);
  3177. /// The return value from the JavaScript prompt function if `Accept` is run.
  3178. /// This value is ignored for dialog kinds other than prompt. If `Accept`
  3179. /// is not run, this value is ignored and `FALSE` is returned from prompt.
  3180. ///
  3181. /// The caller must free the returned string with `CoTaskMemFree`. See
  3182. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3183. [propget] HRESULT ResultText([out, retval] LPWSTR* resultText);
  3184. /// Sets the `ResultText` property.
  3185. [propput] HRESULT ResultText([in] LPCWSTR resultText);
  3186. /// Returns an `ICoreWebView2Deferral` object. Use this operation to
  3187. /// complete the event at a later time.
  3188. HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral);
  3189. }
  3190. /// Receives `ScriptDialogOpening` events.
  3191. [uuid(ef381bf9-afa8-4e37-91c4-8ac48524bdfb), object, pointer_default(unique)]
  3192. interface ICoreWebView2ScriptDialogOpeningEventHandler : IUnknown {
  3193. /// Provides the event args for the corresponding event.
  3194. HRESULT Invoke(
  3195. [in] ICoreWebView2* sender,
  3196. [in] ICoreWebView2ScriptDialogOpeningEventArgs* args);
  3197. }
  3198. /// Event args for the `NavigationCompleted` event.
  3199. [uuid(30d68b7d-20d9-4752-a9ca-ec8448fbb5c1), object, pointer_default(unique)]
  3200. interface ICoreWebView2NavigationCompletedEventArgs : IUnknown {
  3201. /// `TRUE` when the navigation is successful. `FALSE` for a navigation that
  3202. /// ended up in an error page (failures due to no network, DNS lookup
  3203. /// failure, HTTP server responds with 4xx), but may also be `FALSE` for
  3204. /// additional scenarios such as `window.stop()` run on navigated page.
  3205. [propget] HRESULT IsSuccess([out, retval] BOOL* isSuccess);
  3206. /// The error code if the navigation failed.
  3207. [propget] HRESULT WebErrorStatus([out, retval] COREWEBVIEW2_WEB_ERROR_STATUS*
  3208. webErrorStatus);
  3209. /// The ID of the navigation.
  3210. [propget] HRESULT NavigationId([out, retval] UINT64* navigationId);
  3211. }
  3212. /// This is an interface for the StatusCode property of
  3213. /// ICoreWebView2NavigationCompletedEventArgs
  3214. [uuid(FDF8B738-EE1E-4DB2-A329-8D7D7B74D792), object, pointer_default(unique)]
  3215. interface ICoreWebView2NavigationCompletedEventArgs2 : ICoreWebView2NavigationCompletedEventArgs {
  3216. /// The HTTP status code of the navigation if it involved an HTTP request.
  3217. /// For instance, this will usually be 200 if the request was successful, 404
  3218. /// if a page was not found, etc. See
  3219. /// https://developer.mozilla.org/docs/Web/HTTP/Status for a list of
  3220. /// common status codes.
  3221. ///
  3222. /// The `HttpStatusCode` property will be 0 in the following cases:
  3223. /// * The navigation did not involve an HTTP request. For instance, if it was
  3224. /// a navigation to a file:// URL, or if it was a same-document navigation.
  3225. /// * The navigation failed before a response was received. For instance, if
  3226. /// the hostname was not found, or if there was a network error.
  3227. ///
  3228. /// In those cases, you can get more information from the `IsSuccess` and
  3229. /// `WebErrorStatus` properties.
  3230. ///
  3231. /// If the navigation receives a successful HTTP response, but the navigated
  3232. /// page calls `window.stop()` before it finishes loading, then
  3233. /// `HttpStatusCode` may contain a success code like 200, but `IsSuccess` will
  3234. /// be FALSE and `WebErrorStatus` will be
  3235. /// `COREWEBVIEW2_WEB_ERROR_STATUS_CONNECTION_ABORTED`.
  3236. ///
  3237. /// Since WebView2 handles HTTP continuations and redirects automatically, it
  3238. /// is unlikely for `HttpStatusCode` to ever be in the 1xx or 3xx ranges.
  3239. [propget] HRESULT HttpStatusCode([out, retval] int* http_status_code);
  3240. }
  3241. /// Receives `NavigationCompleted` events.
  3242. [uuid(d33a35bf-1c49-4f98-93ab-006e0533fe1c), object, pointer_default(unique)]
  3243. interface ICoreWebView2NavigationCompletedEventHandler : IUnknown {
  3244. /// Provides the event args for the corresponding event.
  3245. HRESULT Invoke(
  3246. [in] ICoreWebView2* sender,
  3247. [in] ICoreWebView2NavigationCompletedEventArgs* args);
  3248. }
  3249. /// Event args for the `PermissionRequested` event.
  3250. [uuid(973ae2ef-ff18-4894-8fb2-3c758f046810), object, pointer_default(unique)]
  3251. interface ICoreWebView2PermissionRequestedEventArgs : IUnknown {
  3252. /// The origin of the web content that requests the permission.
  3253. ///
  3254. /// The caller must free the returned string with `CoTaskMemFree`. See
  3255. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3256. [propget] HRESULT Uri([out, retval] LPWSTR* uri);
  3257. /// The type of the permission that is requested.
  3258. [propget] HRESULT PermissionKind([out, retval] COREWEBVIEW2_PERMISSION_KIND* permissionKind);
  3259. /// `TRUE` when the permission request was initiated through a user gesture.
  3260. ///
  3261. /// \> [!NOTE]\n\> Being initiated through a user gesture does not mean that user intended
  3262. /// to access the associated resource.
  3263. [propget] HRESULT IsUserInitiated([out, retval] BOOL* isUserInitiated);
  3264. /// The status of a permission request, (for example is the request is granted).
  3265. /// The default value is `COREWEBVIEW2_PERMISSION_STATE_DEFAULT`.
  3266. [propget] HRESULT State([out, retval] COREWEBVIEW2_PERMISSION_STATE* state);
  3267. /// Sets the `State` property.
  3268. [propput] HRESULT State([in] COREWEBVIEW2_PERMISSION_STATE state);
  3269. /// Gets an `ICoreWebView2Deferral` object. Use the deferral object to make
  3270. /// the permission decision at a later time.
  3271. HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral);
  3272. }
  3273. /// Receives `PermissionRequested` events.
  3274. [uuid(15e1c6a3-c72a-4df3-91d7-d097fbec6bfd), object, pointer_default(unique)]
  3275. interface ICoreWebView2PermissionRequestedEventHandler : IUnknown {
  3276. /// Provides the event args for the corresponding event.
  3277. HRESULT Invoke(
  3278. [in] ICoreWebView2* sender,
  3279. [in] ICoreWebView2PermissionRequestedEventArgs* args);
  3280. }
  3281. /// Receives the result of the `AddScriptToExecuteOnDocumentCreated` method.
  3282. [uuid(b99369f3-9b11-47b5-bc6f-8e7895fcea17), object, pointer_default(unique)]
  3283. interface ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler : IUnknown {
  3284. /// Provide the completion status and result of the corresponding
  3285. /// asynchronous method.
  3286. HRESULT Invoke([in] HRESULT errorCode, [in] LPCWSTR id);
  3287. }
  3288. /// Receives the result of the `ExecuteScript` method.
  3289. [uuid(49511172-cc67-4bca-9923-137112f4c4cc), object, pointer_default(unique)]
  3290. interface ICoreWebView2ExecuteScriptCompletedHandler : IUnknown {
  3291. /// Provide the implementer with the completion status and result of the
  3292. /// corresponding asynchronous method.
  3293. HRESULT Invoke([in] HRESULT errorCode, [in] LPCWSTR resultObjectAsJson);
  3294. }
  3295. /// Event args for the `WebResourceRequested` event.
  3296. [uuid(453e667f-12c7-49d4-be6d-ddbe7956f57a), object, pointer_default(unique)]
  3297. interface ICoreWebView2WebResourceRequestedEventArgs : IUnknown {
  3298. /// The Web resource request. The request object may be missing some headers
  3299. /// that are added by network stack at a later time.
  3300. [propget] HRESULT Request([out, retval] ICoreWebView2WebResourceRequest** request);
  3301. /// A placeholder for the web resource response object. If this object is
  3302. /// set, the web resource request is completed with the specified response.
  3303. [propget] HRESULT Response([out, retval] ICoreWebView2WebResourceResponse** response);
  3304. /// Sets the `Response` property. Create an empty web resource response
  3305. /// object with `CreateWebResourceResponse` and then modify it to construct
  3306. /// the response.
  3307. [propput] HRESULT Response([in] ICoreWebView2WebResourceResponse* response);
  3308. /// Obtain an `ICoreWebView2Deferral` object and put the event into a
  3309. /// deferred state. Use the `ICoreWebView2Deferral` object to complete the
  3310. /// request at a later time.
  3311. HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral);
  3312. /// The web resource request context.
  3313. [propget] HRESULT ResourceContext([out, retval] COREWEBVIEW2_WEB_RESOURCE_CONTEXT* context);
  3314. }
  3315. /// Runs when a URL request (through network, file, and so on) is made in
  3316. /// the webview for a Web resource matching resource context filter and URL
  3317. /// specified in `AddWebResourceRequestedFilter`. The host views and modifies
  3318. /// the request or provide a response in a similar pattern to HTTP, in which
  3319. /// case the request immediately completed. This may not contain any request
  3320. /// headers that are added by the network stack, such as an `Authorization`
  3321. /// header.
  3322. [uuid(ab00b74c-15f1-4646-80e8-e76341d25d71), object, pointer_default(unique)]
  3323. interface ICoreWebView2WebResourceRequestedEventHandler : IUnknown {
  3324. /// Provides the event args for the corresponding event.
  3325. HRESULT Invoke(
  3326. [in] ICoreWebView2* sender,
  3327. [in] ICoreWebView2WebResourceRequestedEventArgs* args);
  3328. }
  3329. /// Receives the result of the `CapturePreview` method. The result is written
  3330. /// to the stream provided in the `CapturePreview` method.
  3331. [uuid(697e05e9-3d8f-45fa-96f4-8ffe1ededaf5), object, pointer_default(unique)]
  3332. interface ICoreWebView2CapturePreviewCompletedHandler : IUnknown {
  3333. /// Provides the completion status of the corresponding asynchronous method.
  3334. HRESULT Invoke([in] HRESULT errorCode);
  3335. }
  3336. /// Receives `GotFocus` and `LostFocus` events.
  3337. [uuid(05ea24bd-6452-4926-9014-4b82b498135d), object, pointer_default(unique)]
  3338. interface ICoreWebView2FocusChangedEventHandler : IUnknown {
  3339. /// Provides the event args for the corresponding event. No event args exist
  3340. /// and the `args` parameter is set to `null`.
  3341. HRESULT Invoke(
  3342. [in] ICoreWebView2Controller* sender,
  3343. [in] IUnknown* args);
  3344. }
  3345. /// Event args for the `MoveFocusRequested` event.
  3346. [uuid(2d6aa13b-3839-4a15-92fc-d88b3c0d9c9d), object, pointer_default(unique)]
  3347. interface ICoreWebView2MoveFocusRequestedEventArgs : IUnknown {
  3348. /// The reason for WebView to run the `MoveFocusRequested` event.
  3349. [propget] HRESULT Reason([out, retval] COREWEBVIEW2_MOVE_FOCUS_REASON* reason);
  3350. /// Indicates whether the event has been handled by the app. If the app has
  3351. /// moved the focus to another desired location, it should set the `Handled`
  3352. /// property to `TRUE`. When the `Handled` property is `FALSE` after the
  3353. /// event handler returns, default action is taken. The default action is to
  3354. /// try to find the next tab stop child window in the app and try to move
  3355. /// focus to that window. If no other window exists to move focus, focus is
  3356. /// cycled within the web content of the WebView.
  3357. [propget] HRESULT Handled([out, retval] BOOL* value);
  3358. /// Sets the `Handled` property.
  3359. [propput] HRESULT Handled([in] BOOL value);
  3360. }
  3361. /// Receives `MoveFocusRequested` events.
  3362. [uuid(69035451-6dc7-4cb8-9bce-b2bd70ad289f), object, pointer_default(unique)]
  3363. interface ICoreWebView2MoveFocusRequestedEventHandler : IUnknown {
  3364. /// Provides the event args for the corresponding event.
  3365. HRESULT Invoke(
  3366. [in] ICoreWebView2Controller* sender,
  3367. [in] ICoreWebView2MoveFocusRequestedEventArgs* args);
  3368. }
  3369. /// Event args for the `WebMessageReceived` event.
  3370. [uuid(0f99a40c-e962-4207-9e92-e3d542eff849), object, pointer_default(unique)]
  3371. interface ICoreWebView2WebMessageReceivedEventArgs : IUnknown {
  3372. /// The URI of the document that sent this web message.
  3373. ///
  3374. /// The caller must free the returned string with `CoTaskMemFree`. See
  3375. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3376. [propget] HRESULT Source([out, retval] LPWSTR* source);
  3377. /// The message posted from the WebView content to the host converted to a
  3378. /// JSON string. Run this operation to communicate using JavaScript objects.
  3379. ///
  3380. /// For example, the following `postMessage` runs result in the following
  3381. /// `WebMessageAsJson` values.
  3382. ///
  3383. /// ```json
  3384. /// postMessage({'a': 'b'}) L"{\"a\": \"b\"}"
  3385. /// postMessage(1.2) L"1.2"
  3386. /// postMessage('example') L"\"example\""
  3387. /// ```
  3388. ///
  3389. /// The caller must free the returned string with `CoTaskMemFree`. See
  3390. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3391. [propget] HRESULT WebMessageAsJson([out, retval] LPWSTR* webMessageAsJson);
  3392. /// If the message posted from the WebView content to the host is a string
  3393. /// type, this method returns the value of that string. If the message
  3394. /// posted is some other kind of JavaScript type this method fails with the
  3395. /// following error.
  3396. ///
  3397. /// ```text
  3398. /// E_INVALIDARG
  3399. /// ```
  3400. ///
  3401. /// Run this operation to communicate using simple strings.
  3402. ///
  3403. /// For example, the following `postMessage` runs result in the following
  3404. /// `WebMessageAsString` values.
  3405. ///
  3406. /// ```json
  3407. /// postMessage({'a': 'b'}) E_INVALIDARG
  3408. /// postMessage(1.2) E_INVALIDARG
  3409. /// postMessage('example') L"example"
  3410. /// ```
  3411. ///
  3412. /// The caller must free the returned string with `CoTaskMemFree`. See
  3413. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3414. HRESULT TryGetWebMessageAsString([out, retval] LPWSTR* webMessageAsString);
  3415. }
  3416. /// Receives `WebMessageReceived` events.
  3417. [uuid(57213f19-00e6-49fa-8e07-898ea01ecbd2), object, pointer_default(unique)]
  3418. interface ICoreWebView2WebMessageReceivedEventHandler : IUnknown {
  3419. /// Provides the event args for the corresponding event.
  3420. HRESULT Invoke(
  3421. [in] ICoreWebView2* sender,
  3422. [in] ICoreWebView2WebMessageReceivedEventArgs* args);
  3423. }
  3424. /// Event args for the `DevToolsProtocolEventReceived` event.
  3425. [uuid(653c2959-bb3a-4377-8632-b58ada4e66c4), object, pointer_default(unique)]
  3426. interface ICoreWebView2DevToolsProtocolEventReceivedEventArgs : IUnknown {
  3427. /// The parameter object of the corresponding `DevToolsProtocol` event
  3428. /// represented as a JSON string.
  3429. ///
  3430. /// The caller must free the returned string with `CoTaskMemFree`. See
  3431. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3432. [propget] HRESULT ParameterObjectAsJson([out, retval] LPWSTR*
  3433. parameterObjectAsJson);
  3434. }
  3435. /// This is a continuation of the `ICoreWebView2DevToolsProtocolEventReceivedEventArgs`
  3436. /// interface that provides the session ID of the target where the event originates from.
  3437. [uuid(2DC4959D-1494-4393-95BA-BEA4CB9EBD1B), object, pointer_default(unique)]
  3438. interface ICoreWebView2DevToolsProtocolEventReceivedEventArgs2 : ICoreWebView2DevToolsProtocolEventReceivedEventArgs {
  3439. /// The sessionId of the target where the event originates from.
  3440. /// Empty string is returned as sessionId if the event comes from the default
  3441. /// session for the top page.
  3442. ///
  3443. /// The caller must free the returned string with `CoTaskMemFree`. See
  3444. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3445. ///
  3446. /// \snippet ScriptComponent.cpp DevToolsProtocolEventReceivedSessionId
  3447. [propget] HRESULT SessionId([out, retval] LPWSTR* sessionId);
  3448. }
  3449. /// Receives `DevToolsProtocolEventReceived` events from the WebView.
  3450. [uuid(e2fda4be-5456-406c-a261-3d452138362c), object, pointer_default(unique)]
  3451. interface ICoreWebView2DevToolsProtocolEventReceivedEventHandler : IUnknown {
  3452. /// Provides the event args for the corresponding event.
  3453. HRESULT Invoke(
  3454. [in] ICoreWebView2* sender,
  3455. [in] ICoreWebView2DevToolsProtocolEventReceivedEventArgs* args);
  3456. }
  3457. /// Receives `CallDevToolsProtocolMethod` completion results.
  3458. [uuid(5c4889f0-5ef6-4c5a-952c-d8f1b92d0574), object, pointer_default(unique)]
  3459. interface ICoreWebView2CallDevToolsProtocolMethodCompletedHandler : IUnknown {
  3460. /// Provides the completion status and result of the corresponding
  3461. /// asynchronous method.
  3462. HRESULT Invoke([in] HRESULT errorCode, [in] LPCWSTR returnObjectAsJson);
  3463. }
  3464. /// Receives the `CoreWebView2Controller` created using `CreateCoreWebView2Controller`.
  3465. [uuid(6c4819f3-c9b7-4260-8127-c9f5bde7f68c), object, pointer_default(unique)]
  3466. interface ICoreWebView2CreateCoreWebView2ControllerCompletedHandler : IUnknown {
  3467. /// Provides the completion status and result of the corresponding
  3468. /// asynchronous method.
  3469. HRESULT Invoke(HRESULT errorCode, ICoreWebView2Controller* createdController);
  3470. }
  3471. /// The caller implements this interface to receive the CoreWebView2Controller
  3472. /// created via CreateCoreWebView2CompositionController.
  3473. [uuid(02fab84b-1428-4fb7-ad45-1b2e64736184), object, pointer_default(unique)]
  3474. interface ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler : IUnknown {
  3475. /// Called to provide the implementer with the completion status and result
  3476. /// of the corresponding asynchronous method call.
  3477. HRESULT Invoke(
  3478. HRESULT errorCode,
  3479. ICoreWebView2CompositionController* webView);
  3480. }
  3481. /// Event args for the `NewWindowRequested` event. The event is run when
  3482. /// content inside webview requested to a open a new window (through
  3483. /// `window.open()` and so on).
  3484. [uuid(34acb11c-fc37-4418-9132-f9c21d1eafb9), object, pointer_default(unique)]
  3485. interface ICoreWebView2NewWindowRequestedEventArgs : IUnknown {
  3486. /// The target uri of the new window requested.
  3487. ///
  3488. /// The caller must free the returned string with `CoTaskMemFree`. See
  3489. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3490. [propget] HRESULT Uri([out, retval] LPWSTR* uri);
  3491. /// Sets a CoreWebView2 as a result of the NewWindowRequested event. If the
  3492. /// `NewWindow` is set, the top-level window returns as the opened `WindowProxy`.
  3493. /// The NewWindow property should be set to a CoreWebView2 that has not been
  3494. /// navigated previously. Don't use methods that cause navigation or interact
  3495. /// with the DOM on this CoreWebView2. Setting event handlers, changing
  3496. /// Settings properties, or other methods are fine to call. Changes to
  3497. /// settings should be made before `put_NewWindow` is called to ensure that
  3498. /// those settings take effect for the newly setup WebView. Once the
  3499. /// NewWindow is set the underlying web contents of this CoreWebView2 will be
  3500. /// replaced and navigated as appropriate for the new window.
  3501. /// After setting new window it cannot be changed and error will be return otherwise.
  3502. ///
  3503. /// The methods which should affect the new web contents like
  3504. /// AddScriptToExecuteOnDocumentCreated and add_WebResourceRequested
  3505. /// have to be called after setting NewWindow.
  3506. ///
  3507. /// The new WebView must have the same profile as the opener WebView.
  3508. [propput] HRESULT NewWindow([in] ICoreWebView2* newWindow);
  3509. /// Gets the new window.
  3510. [propget] HRESULT NewWindow([out, retval] ICoreWebView2** newWindow);
  3511. /// Sets whether the `NewWindowRequested` event is handled by host. If this
  3512. /// is `FALSE` and no `NewWindow` is set, the WebView opens a popup window
  3513. /// and it returns as opened `WindowProxy`. If set to `TRUE` and no
  3514. /// `NewWindow` is set for `window.open`, the opened `WindowProxy` is for an
  3515. /// testing window object and no window loads.
  3516. /// The default value is `FALSE`.
  3517. [propput] HRESULT Handled([in] BOOL handled);
  3518. /// Gets whether the `NewWindowRequested` event is handled by host.
  3519. [propget] HRESULT Handled([out, retval] BOOL* handled);
  3520. /// `TRUE` when the new window request was initiated through a user gesture.
  3521. /// Examples of user initiated requests are:
  3522. ///
  3523. /// - Selecting an anchor tag with target
  3524. /// - Programmatic window open from a script that directly run as a result of
  3525. /// user interaction such as via onclick handlers.
  3526. ///
  3527. /// Non-user initiated requests are programmatic window opens from a script
  3528. /// that are not directly triggered by user interaction, such as those that
  3529. /// run while loading a new page or via timers.
  3530. /// The Microsoft Edge popup blocker is disabled for WebView so the app is
  3531. /// able to use this flag to block non-user initiated popups.
  3532. [propget] HRESULT IsUserInitiated([out, retval] BOOL* isUserInitiated);
  3533. /// Obtain an `ICoreWebView2Deferral` object and put the event into a
  3534. /// deferred state. Use the `ICoreWebView2Deferral` object to complete the
  3535. /// window open request at a later time. While this event is deferred the
  3536. /// opener window returns a `WindowProxy` to an un-navigated window, which
  3537. /// navigates when the deferral is complete.
  3538. HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral);
  3539. /// Window features specified by the `window.open`. The features should be
  3540. /// considered for positioning and sizing of new webview windows.
  3541. [propget] HRESULT WindowFeatures([out, retval] ICoreWebView2WindowFeatures** value);
  3542. }
  3543. /// This is a continuation of the `ICoreWebView2NewWindowRequestedEventArgs` interface.
  3544. [uuid(bbc7baed-74c6-4c92-b63a-7f5aeae03de3), object, pointer_default(unique)]
  3545. interface ICoreWebView2NewWindowRequestedEventArgs2 : ICoreWebView2NewWindowRequestedEventArgs {
  3546. /// Gets the name of the new window. This window can be created via `window.open(url, windowName)`,
  3547. /// where the windowName parameter corresponds to `Name` property.
  3548. /// If no windowName is passed to `window.open`, then the `Name` property
  3549. /// will be set to an empty string. Additionally, if window is opened through other means,
  3550. /// such as `<a target="windowName">...</a>` or `<iframe name="windowName">...</iframe>`,
  3551. /// then the `Name` property will be set accordingly. In the case of target=_blank,
  3552. /// the `Name` property will be an empty string.
  3553. /// Opening a window via ctrl+clicking a link would result in the `Name` property
  3554. /// being set to an empty string.
  3555. ///
  3556. /// The caller must free the returned string with `CoTaskMemFree`. See
  3557. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3558. [propget] HRESULT Name([out, retval] LPWSTR* value);
  3559. }
  3560. /// The window features for a WebView popup window. The fields match the
  3561. /// `windowFeatures` passed to `window.open` as specified in
  3562. /// [Window features](https://developer.mozilla.org/docs/Web/API/Window/open#Window_features)
  3563. /// on MDN.
  3564. ///
  3565. /// There is no requirement for you to respect the values. If your app does
  3566. /// not have corresponding UI features (for example, no toolbar) or if all
  3567. /// instance of WebView are opened in tabs and do not have distinct size or
  3568. /// positions, then your app does not respect the values. You may want to
  3569. /// respect values, but perhaps only some apply to the UI of you app.
  3570. /// Accordingly, you may respect all, some, or none of the properties as
  3571. /// appropriate for your app. For all numeric properties, if the value that is
  3572. /// passed to `window.open` is outside the range of an unsigned 32bit int, the
  3573. /// resulting value is the absolute value of the maximum for unsigned 32bit
  3574. /// integer. If you are not able to parse the value an integer, it is
  3575. /// considered `0`. If the value is a floating point value, it is rounded down
  3576. /// to an integer.
  3577. ///
  3578. /// In runtime versions 98 or later, the values of `ShouldDisplayMenuBar`,
  3579. /// `ShouldDisplayStatus`, `ShouldDisplayToolbar`, and `ShouldDisplayScrollBars`
  3580. /// will not directly depend on the equivalent fields in the `windowFeatures`
  3581. /// string. Instead, they will all be false if the window is expected to be a
  3582. /// popup, and true if it is not.
  3583. [uuid(5eaf559f-b46e-4397-8860-e422f287ff1e), object, pointer_default(unique)]
  3584. interface ICoreWebView2WindowFeatures : IUnknown {
  3585. /// Specifies left and top values.
  3586. [propget] HRESULT HasPosition([out, retval] BOOL* value);
  3587. /// Specifies height and width values.
  3588. [propget] HRESULT HasSize([out, retval] BOOL* value);
  3589. /// Specifies the left position of the window. If `HasPosition` is set to
  3590. /// `FALSE`, this field is ignored.
  3591. [propget] HRESULT Left([out, retval] UINT32* value);
  3592. /// Specifies the top position of the window. If `HasPosition` is set to
  3593. /// `FALSE`, this field is ignored.
  3594. [propget] HRESULT Top([out, retval] UINT32* value);
  3595. /// Specifies the height of the window. Minimum value is `100`. If
  3596. /// `HasSize` is set to `FALSE`, this field is ignored.
  3597. [propget] HRESULT Height([out, retval] UINT32* value);
  3598. /// Specifies the width of the window. Minimum value is `100`. If `HasSize`
  3599. /// is set to `FALSE`, this field is ignored.
  3600. [propget] HRESULT Width([out, retval] UINT32* value);
  3601. /// Indicates that the menu bar is displayed.
  3602. [propget] HRESULT ShouldDisplayMenuBar([out, retval] BOOL* value);
  3603. /// Indicates that the status bar is displayed.
  3604. [propget] HRESULT ShouldDisplayStatus([out, retval] BOOL* value);
  3605. /// Indicates that the browser toolbar is displayed.
  3606. [propget] HRESULT ShouldDisplayToolbar([out, retval] BOOL* value);
  3607. /// Indicates that the scroll bars are displayed.
  3608. [propget] HRESULT ShouldDisplayScrollBars([out, retval] BOOL* value);
  3609. }
  3610. /// Receives `NewWindowRequested` events.
  3611. [uuid(d4c185fe-c81c-4989-97af-2d3fa7ab5651), object, pointer_default(unique)]
  3612. interface ICoreWebView2NewWindowRequestedEventHandler : IUnknown {
  3613. /// Provides the event args for the corresponding event.
  3614. HRESULT Invoke(
  3615. [in] ICoreWebView2* sender,
  3616. [in] ICoreWebView2NewWindowRequestedEventArgs* args);
  3617. }
  3618. /// Receives `DocumentTitleChanged` events. Use the `DocumentTitle` property
  3619. /// to get the modified title.
  3620. [uuid(f5f2b923-953e-4042-9f95-f3a118e1afd4), object, pointer_default(unique)]
  3621. interface ICoreWebView2DocumentTitleChangedEventHandler : IUnknown {
  3622. /// Provides the event args for the corresponding event. No event args exist
  3623. /// and the `args` parameter is set to `null`.
  3624. HRESULT Invoke([in] ICoreWebView2* sender, [in] IUnknown* args);
  3625. }
  3626. /// Event args for the `AcceleratorKeyPressed` event.
  3627. [uuid(9f760f8a-fb79-42be-9990-7b56900fa9c7), object, pointer_default(unique)]
  3628. interface ICoreWebView2AcceleratorKeyPressedEventArgs : IUnknown {
  3629. /// The key event type that caused the event to run.
  3630. [propget] HRESULT KeyEventKind([out, retval] COREWEBVIEW2_KEY_EVENT_KIND* keyEventKind);
  3631. /// The Win32 virtual key code of the key that was pressed or released. It
  3632. /// is one of the Win32 virtual key constants such as `VK_RETURN` or an
  3633. /// (uppercase) ASCII value such as `A`. Verify whether Ctrl or Alt
  3634. /// are pressed by running `GetKeyState(VK_CONTROL)` or
  3635. /// `GetKeyState(VK_MENU)`.
  3636. [propget] HRESULT VirtualKey([out, retval] UINT* virtualKey);
  3637. /// The `LPARAM` value that accompanied the window message. For more
  3638. /// information, navigate to [WM_KEYDOWN](/windows/win32/inputdev/wm-keydown)
  3639. /// and [WM_KEYUP](/windows/win32/inputdev/wm-keyup).
  3640. [propget] HRESULT KeyEventLParam([out, retval] INT* lParam);
  3641. /// A structure representing the information passed in the `LPARAM` of the
  3642. /// window message.
  3643. [propget] HRESULT PhysicalKeyStatus(
  3644. [out, retval] COREWEBVIEW2_PHYSICAL_KEY_STATUS* physicalKeyStatus);
  3645. /// During `AcceleratorKeyPressedEvent` handler invocation the WebView is
  3646. /// blocked waiting for the decision of if the accelerator is handled by the
  3647. /// host (or not). If the `Handled` property is set to `TRUE` then this
  3648. /// prevents the WebView from performing the default action for this
  3649. /// accelerator key. Otherwise the WebView performs the default action for
  3650. /// the accelerator key.
  3651. [propget] HRESULT Handled([out, retval] BOOL* handled);
  3652. /// Sets the `Handled` property.
  3653. [propput] HRESULT Handled([in] BOOL handled);
  3654. }
  3655. /// Receives `AcceleratorKeyPressed` events.
  3656. [uuid(b29c7e28-fa79-41a8-8e44-65811c76dcb2), object, pointer_default(unique)]
  3657. interface ICoreWebView2AcceleratorKeyPressedEventHandler : IUnknown {
  3658. /// Provides the event args for the corresponding event.
  3659. HRESULT Invoke(
  3660. [in] ICoreWebView2Controller* sender,
  3661. [in] ICoreWebView2AcceleratorKeyPressedEventArgs* args);
  3662. }
  3663. /// Receives `NewBrowserVersionAvailable` events.
  3664. [uuid(f9a2976e-d34e-44fc-adee-81b6b57ca914), object, pointer_default(unique)]
  3665. interface ICoreWebView2NewBrowserVersionAvailableEventHandler : IUnknown {
  3666. /// Provides the event args for the corresponding event.
  3667. HRESULT Invoke([in] ICoreWebView2Environment* sender,
  3668. [in] IUnknown* args);
  3669. }
  3670. /// Receives `BrowserProcessExited` events.
  3671. [uuid(fa504257-a216-4911-a860-fe8825712861), object, pointer_default(unique)]
  3672. interface ICoreWebView2BrowserProcessExitedEventHandler : IUnknown {
  3673. /// Provides the event args for the corresponding event.
  3674. HRESULT Invoke(
  3675. [in] ICoreWebView2Environment* sender,
  3676. [in] ICoreWebView2BrowserProcessExitedEventArgs* args);
  3677. }
  3678. /// Receives `ContainsFullScreenElementChanged` events.
  3679. [uuid(e45d98b1-afef-45be-8baf-6c7728867f73), object, pointer_default(unique)]
  3680. interface ICoreWebView2ContainsFullScreenElementChangedEventHandler : IUnknown {
  3681. /// Provides the event args for the corresponding event. No event args exist
  3682. /// and the `args` parameter is set to `null`.
  3683. HRESULT Invoke([in] ICoreWebView2* sender, [in] IUnknown* args);
  3684. }
  3685. /// Receives `WindowCloseRequested` events.
  3686. [uuid(5c19e9e0-092f-486b-affa-ca8231913039), object, pointer_default(unique)]
  3687. interface ICoreWebView2WindowCloseRequestedEventHandler : IUnknown {
  3688. /// Provides the event args for the corresponding event. No event args exist
  3689. /// and the `args` parameter is set to `null`.
  3690. HRESULT Invoke([in] ICoreWebView2* sender, [in] IUnknown* args);
  3691. }
  3692. /// Receives `WebResourceResponseReceived` events.
  3693. [uuid(7DE9898A-24F5-40C3-A2DE-D4F458E69828), object, pointer_default(unique)]
  3694. interface ICoreWebView2WebResourceResponseReceivedEventHandler : IUnknown {
  3695. /// Provides the event args for the corresponding event.
  3696. HRESULT Invoke(
  3697. [in] ICoreWebView2* sender,
  3698. [in] ICoreWebView2WebResourceResponseReceivedEventArgs* args);
  3699. }
  3700. /// Event args for the `BrowserProcessExited` event.
  3701. [uuid(1f00663f-af8c-4782-9cdd-dd01c52e34cb), object, pointer_default(unique)]
  3702. interface ICoreWebView2BrowserProcessExitedEventArgs : IUnknown {
  3703. /// The kind of browser process exit that has occurred.
  3704. [propget] HRESULT BrowserProcessExitKind(
  3705. [out, retval] COREWEBVIEW2_BROWSER_PROCESS_EXIT_KIND* browserProcessExitKind);
  3706. /// The process ID of the browser process that has exited.
  3707. [propget] HRESULT BrowserProcessId([out, retval] UINT32* value);
  3708. }
  3709. /// Event args for the WebResourceResponseReceived event.
  3710. [uuid(D1DB483D-6796-4B8B-80FC-13712BB716F4), object, pointer_default(unique)]
  3711. interface ICoreWebView2WebResourceResponseReceivedEventArgs : IUnknown {
  3712. /// The request object for the web resource, as committed. This includes
  3713. /// headers added by the network stack that were not be included during the
  3714. /// associated WebResourceRequested event, such as Authentication headers.
  3715. /// Modifications to this object have no effect on how the request is
  3716. /// processed as it has already been sent.
  3717. [propget] HRESULT Request([out, retval] ICoreWebView2WebResourceRequest** request);
  3718. /// View of the response object received for the web resource.
  3719. [propget] HRESULT Response([out, retval] ICoreWebView2WebResourceResponseView** response);
  3720. }
  3721. /// View of the HTTP representation for a web resource response. The properties
  3722. /// of this object are not mutable. This response view is used with the
  3723. /// WebResourceResponseReceived event.
  3724. [uuid(79701053-7759-4162-8F7D-F1B3F084928D), object, pointer_default(unique)]
  3725. interface ICoreWebView2WebResourceResponseView : IUnknown {
  3726. /// The HTTP response headers as received.
  3727. [propget] HRESULT Headers(
  3728. [out, retval] ICoreWebView2HttpResponseHeaders** headers);
  3729. /// The HTTP response status code.
  3730. [propget] HRESULT StatusCode([out, retval] int* statusCode);
  3731. /// The HTTP response reason phrase.
  3732. ///
  3733. /// The caller must free the returned string with `CoTaskMemFree`. See
  3734. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3735. [propget] HRESULT ReasonPhrase([out, retval] LPWSTR* reasonPhrase);
  3736. /// Get the response content asynchronously. The handler will receive the
  3737. /// response content stream.
  3738. /// If this method is being called again before a first call has completed,
  3739. /// the handler will be invoked at the same time the handlers from prior calls
  3740. /// are invoked.
  3741. /// If this method is being called after a first call has completed, the
  3742. /// handler will be invoked immediately.
  3743. /// \snippet ScenarioWebViewEventMonitor.cpp GetContent
  3744. HRESULT GetContent(
  3745. [in] ICoreWebView2WebResourceResponseViewGetContentCompletedHandler* handler);
  3746. }
  3747. /// Receives the result of the
  3748. /// `ICoreWebView2WebResourceResponseView::GetContent` method.
  3749. [uuid(875738E1-9FA2-40E3-8B74-2E8972DD6FE7), object, pointer_default(unique)]
  3750. interface ICoreWebView2WebResourceResponseViewGetContentCompletedHandler : IUnknown {
  3751. /// Provides the completion status and result of the corresponding
  3752. /// asynchronous method call. A failure `errorCode` will be passed if the
  3753. /// content failed to load. `E_ABORT` means the response loading was blocked
  3754. /// (e.g., by CORS policy); `ERROR_CANCELLED` means the response loading was
  3755. /// cancelled. `ERROR_NO_DATA` means the response has no content data,
  3756. /// `content` is `null` in this case. Note content (if any) is ignored for
  3757. /// redirects, 204 No Content, 205 Reset Content, and HEAD-request responses.
  3758. HRESULT Invoke([in] HRESULT errorCode, [in] IStream* content);
  3759. }
  3760. /// Event args for the DOMContentLoaded event.
  3761. [uuid(16B1E21A-C503-44F2-84C9-70ABA5031283), object, pointer_default(unique)]
  3762. interface ICoreWebView2DOMContentLoadedEventArgs : IUnknown {
  3763. /// The ID of the navigation which corresponds to other navigation ID properties on other navigation events.
  3764. [propget] HRESULT NavigationId([out, retval] UINT64* navigationId);
  3765. }
  3766. /// Receives `DOMContentLoaded` events.
  3767. [uuid(4BAC7E9C-199E-49ED-87ED-249303ACF019), object, pointer_default(unique)]
  3768. interface ICoreWebView2DOMContentLoadedEventHandler : IUnknown {
  3769. /// Provides the event args for the corresponding event.
  3770. HRESULT Invoke(
  3771. [in] ICoreWebView2* sender,
  3772. [in] ICoreWebView2DOMContentLoadedEventArgs* args);
  3773. }
  3774. /// Provides a set of properties that are used to manage an
  3775. /// ICoreWebView2Cookie.
  3776. ///
  3777. /// \snippet ScenarioCookieManagement.cpp CookieObject
  3778. [uuid(AD26D6BE-1486-43E6-BF87-A2034006CA21), object, pointer_default(unique)]
  3779. interface ICoreWebView2Cookie : IUnknown {
  3780. /// Cookie name.
  3781. ///
  3782. /// The caller must free the returned string with `CoTaskMemFree`. See
  3783. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3784. [propget] HRESULT Name([out, retval] LPWSTR* name);
  3785. /// Cookie value.
  3786. ///
  3787. /// The caller must free the returned string with `CoTaskMemFree`. See
  3788. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3789. [propget] HRESULT Value([out, retval] LPWSTR* value);
  3790. /// Set the cookie value property.
  3791. [propput] HRESULT Value([in] LPCWSTR value);
  3792. /// The domain for which the cookie is valid.
  3793. /// The default is the host that this cookie has been received from.
  3794. /// Note that, for instance, ".bing.com", "bing.com", and "www.bing.com" are
  3795. /// considered different domains.
  3796. ///
  3797. /// The caller must free the returned string with `CoTaskMemFree`. See
  3798. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3799. [propget] HRESULT Domain([out, retval] LPWSTR* domain);
  3800. /// The path for which the cookie is valid. The default is "/", which means
  3801. /// this cookie will be sent to all pages on the Domain.
  3802. ///
  3803. /// The caller must free the returned string with `CoTaskMemFree`. See
  3804. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3805. [propget] HRESULT Path([out, retval] LPWSTR* path);
  3806. /// The expiration date and time for the cookie as the number of seconds since the UNIX epoch.
  3807. /// The default is -1.0, which means cookies are session cookies by default.
  3808. [propget] HRESULT Expires([out, retval] double* expires);
  3809. /// Set the Expires property. Cookies are session cookies and will not be
  3810. /// persistent if Expires is set to -1.0. NaN, infinity, and any negative
  3811. /// value set other than -1.0 is disallowed.
  3812. [propput] HRESULT Expires([in] double expires);
  3813. /// Whether this cookie is http-only.
  3814. /// True if a page script or other active content cannot access this
  3815. /// cookie. The default is false.
  3816. [propget] HRESULT IsHttpOnly([out, retval] BOOL* isHttpOnly);
  3817. /// Set the IsHttpOnly property.
  3818. [propput] HRESULT IsHttpOnly([in] BOOL isHttpOnly);
  3819. /// SameSite status of the cookie which represents the enforcement mode of the cookie.
  3820. /// The default is COREWEBVIEW2_COOKIE_SAME_SITE_KIND_LAX.
  3821. [propget] HRESULT SameSite([out, retval] COREWEBVIEW2_COOKIE_SAME_SITE_KIND* sameSite);
  3822. /// Set the SameSite property.
  3823. [propput] HRESULT SameSite([in] COREWEBVIEW2_COOKIE_SAME_SITE_KIND sameSite);
  3824. /// The security level of this cookie. True if the client is only to return
  3825. /// the cookie in subsequent requests if those requests use HTTPS.
  3826. /// The default is false.
  3827. /// Note that cookie that requests COREWEBVIEW2_COOKIE_SAME_SITE_KIND_NONE but
  3828. /// is not marked Secure will be rejected.
  3829. [propget] HRESULT IsSecure([out, retval] BOOL* isSecure);
  3830. /// Set the IsSecure property.
  3831. [propput] HRESULT IsSecure([in] BOOL isSecure);
  3832. /// Whether this is a session cookie. The default is false.
  3833. [propget] HRESULT IsSession([out, retval] BOOL* isSession);
  3834. }
  3835. /// Creates, adds or updates, gets, or or view the cookies. The changes would
  3836. /// apply to the context of the user profile. That is, other WebViews under the
  3837. /// same user profile could be affected.
  3838. [uuid(177CD9E7-B6F5-451A-94A0-5D7A3A4C4141), object, pointer_default(unique)]
  3839. interface ICoreWebView2CookieManager : IUnknown {
  3840. /// Create a cookie object with a specified name, value, domain, and path.
  3841. /// One can set other optional properties after cookie creation.
  3842. /// This only creates a cookie object and it is not added to the cookie
  3843. /// manager until you call AddOrUpdateCookie.
  3844. /// Leading or trailing whitespace(s), empty string, and special characters
  3845. /// are not allowed for name.
  3846. /// See ICoreWebView2Cookie for more details.
  3847. HRESULT CreateCookie(
  3848. [in] LPCWSTR name,
  3849. [in] LPCWSTR value,
  3850. [in] LPCWSTR domain,
  3851. [in] LPCWSTR path,
  3852. [out, retval] ICoreWebView2Cookie** cookie);
  3853. /// Creates a cookie whose params matches those of the specified cookie.
  3854. HRESULT CopyCookie(
  3855. [in] ICoreWebView2Cookie* cookieParam,
  3856. [out, retval] ICoreWebView2Cookie** cookie);
  3857. /// Gets a list of cookies matching the specific URI.
  3858. /// If uri is empty string or null, all cookies under the same profile are
  3859. /// returned.
  3860. /// You can modify the cookie objects by calling
  3861. /// ICoreWebView2CookieManager::AddOrUpdateCookie, and the changes
  3862. /// will be applied to the webview.
  3863. /// \snippet ScenarioCookieManagement.cpp GetCookies
  3864. HRESULT GetCookies(
  3865. [in] LPCWSTR uri,
  3866. [in] ICoreWebView2GetCookiesCompletedHandler* handler);
  3867. /// Adds or updates a cookie with the given cookie data; may overwrite
  3868. /// cookies with matching name, domain, and path if they exist.
  3869. /// This method will fail if the domain of the given cookie is not specified.
  3870. /// \snippet ScenarioCookieManagement.cpp AddOrUpdateCookie
  3871. HRESULT AddOrUpdateCookie([in] ICoreWebView2Cookie* cookie);
  3872. /// Deletes a cookie whose name and domain/path pair
  3873. /// match those of the specified cookie.
  3874. HRESULT DeleteCookie([in] ICoreWebView2Cookie* cookie);
  3875. /// Deletes cookies with matching name and uri.
  3876. /// Cookie name is required.
  3877. /// All cookies with the given name where domain
  3878. /// and path match provided URI are deleted.
  3879. HRESULT DeleteCookies([in] LPCWSTR name, [in] LPCWSTR uri);
  3880. /// Deletes cookies with matching name and domain/path pair.
  3881. /// Cookie name is required.
  3882. /// If domain is specified, deletes only cookies with the exact domain.
  3883. /// If path is specified, deletes only cookies with the exact path.
  3884. HRESULT DeleteCookiesWithDomainAndPath([in] LPCWSTR name, [in] LPCWSTR domain, [in] LPCWSTR path);
  3885. /// Deletes all cookies under the same profile.
  3886. /// This could affect other WebViews under the same user profile.
  3887. HRESULT DeleteAllCookies();
  3888. }
  3889. /// A list of cookie objects. See `ICoreWebView2Cookie`.
  3890. /// \snippet ScenarioCookieManagement.cpp GetCookies
  3891. [uuid(F7F6F714-5D2A-43C6-9503-346ECE02D186), object, pointer_default(unique)]
  3892. interface ICoreWebView2CookieList : IUnknown {
  3893. /// The number of cookies contained in the ICoreWebView2CookieList.
  3894. [propget] HRESULT Count([out, retval] UINT* count);
  3895. /// Gets the cookie object at the given index.
  3896. HRESULT GetValueAtIndex([in] UINT index, [out, retval] ICoreWebView2Cookie** cookie);
  3897. }
  3898. /// Receives the result of the `GetCookies` method. The result is written to
  3899. /// the cookie list provided in the `GetCookies` method call.
  3900. [uuid(5A4F5069-5C15-47C3-8646-F4DE1C116670), object, pointer_default(unique)]
  3901. interface ICoreWebView2GetCookiesCompletedHandler : IUnknown {
  3902. /// Provides the completion status of the corresponding asynchronous method
  3903. /// call.
  3904. HRESULT Invoke(HRESULT result, ICoreWebView2CookieList* cookieList);
  3905. }
  3906. /// Provides access to the certificate metadata
  3907. [uuid(e7188076-bcc3-11eb-8529-0242ac130003), object, pointer_default(unique)]
  3908. interface ICoreWebView2ClientCertificate : IUnknown {
  3909. /// Subject of the certificate.
  3910. ///
  3911. /// The caller must free the returned string with `CoTaskMemFree`. See
  3912. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3913. [propget] HRESULT Subject([out, retval] LPWSTR* value);
  3914. /// Name of the certificate authority that issued the certificate.
  3915. ///
  3916. /// The caller must free the returned string with `CoTaskMemFree`. See
  3917. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3918. [propget] HRESULT Issuer([out, retval] LPWSTR* value);
  3919. /// The valid start date and time for the certificate as the number of seconds since
  3920. /// the UNIX epoch.
  3921. [propget] HRESULT ValidFrom([out, retval] double* value);
  3922. /// The valid expiration date and time for the certificate as the number of seconds since
  3923. /// the UNIX epoch.
  3924. [propget] HRESULT ValidTo([out, retval] double* value);
  3925. /// DER encoded serial number of the certificate.
  3926. /// Read more about DER at [RFC 7468 DER]
  3927. /// (https://tools.ietf.org/html/rfc7468#appendix-B).
  3928. ///
  3929. /// The caller must free the returned string with `CoTaskMemFree`. See
  3930. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3931. [propget] HRESULT DerEncodedSerialNumber([out, retval] LPWSTR* value);
  3932. /// Display name for a certificate.
  3933. ///
  3934. /// The caller must free the returned string with `CoTaskMemFree`. See
  3935. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3936. [propget] HRESULT DisplayName([out, retval] LPWSTR* value);
  3937. /// PEM encoded data for the certificate.
  3938. /// Returns Base64 encoding of DER encoded certificate.
  3939. /// Read more about PEM at [RFC 1421 Privacy Enhanced Mail]
  3940. /// (https://tools.ietf.org/html/rfc1421).
  3941. ///
  3942. /// The caller must free the returned string with `CoTaskMemFree`. See
  3943. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3944. HRESULT ToPemEncoding([out, retval] LPWSTR* pemEncodedData);
  3945. /// Collection of PEM encoded client certificate issuer chain.
  3946. /// In this collection first element is the current certificate followed by
  3947. /// intermediate1, intermediate2...intermediateN-1. Root certificate is the
  3948. /// last element in collection.
  3949. [propget] HRESULT PemEncodedIssuerCertificateChain([out, retval]
  3950. ICoreWebView2StringCollection** value);
  3951. /// Kind of a certificate (eg., smart card, pin, other).
  3952. [propget] HRESULT Kind([out, retval]
  3953. COREWEBVIEW2_CLIENT_CERTIFICATE_KIND* value);
  3954. }
  3955. /// A collection of client certificate object.
  3956. [uuid(ef5674d2-bcc3-11eb-8529-0242ac130003), object, pointer_default(unique)]
  3957. interface ICoreWebView2ClientCertificateCollection : IUnknown {
  3958. /// The number of client certificates contained in the
  3959. /// ICoreWebView2ClientCertificateCollection.
  3960. [propget] HRESULT Count([out, retval] UINT* value);
  3961. /// Gets the certificate object at the given index.
  3962. HRESULT GetValueAtIndex([in] UINT index,
  3963. [out, retval] ICoreWebView2ClientCertificate** certificate);
  3964. }
  3965. /// A collection of strings.
  3966. [uuid(f41f3f8a-bcc3-11eb-8529-0242ac130003), object, pointer_default(unique)]
  3967. interface ICoreWebView2StringCollection : IUnknown {
  3968. /// The number of strings contained in ICoreWebView2StringCollection.
  3969. [propget] HRESULT Count([out, retval] UINT* value);
  3970. /// Gets the value at a given index.
  3971. ///
  3972. /// The caller must free the returned string with `CoTaskMemFree`. See
  3973. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3974. HRESULT GetValueAtIndex([in] UINT index, [out, retval] LPWSTR* value);
  3975. }
  3976. /// An event handler for the `ClientCertificateRequested` event.
  3977. [uuid(d7175ba2-bcc3-11eb-8529-0242ac130003), object, pointer_default(unique)]
  3978. interface ICoreWebView2ClientCertificateRequestedEventHandler : IUnknown {
  3979. /// Provides the event args for the corresponding event.
  3980. HRESULT Invoke([in] ICoreWebView2* sender,
  3981. [in] ICoreWebView2ClientCertificateRequestedEventArgs* args);
  3982. }
  3983. /// Event args for the `ClientCertificateRequested` event.
  3984. [uuid(bc59db28-bcc3-11eb-8529-0242ac130003), object, pointer_default(unique)]
  3985. interface ICoreWebView2ClientCertificateRequestedEventArgs : IUnknown {
  3986. /// Host name of the server that requested client certificate authentication.
  3987. /// Normalization rules applied to the hostname are:
  3988. /// * Convert to lowercase characters for ascii characters.
  3989. /// * Punycode is used for representing non ascii characters.
  3990. /// * Strip square brackets for IPV6 address.
  3991. ///
  3992. /// The caller must free the returned string with `CoTaskMemFree`. See
  3993. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  3994. [propget] HRESULT Host([out, retval] LPWSTR* value);
  3995. /// Port of the server that requested client certificate authentication.
  3996. [propget] HRESULT Port([out, retval] int* value);
  3997. /// Returns true if the server that issued this request is an http proxy.
  3998. /// Returns false if the server is the origin server.
  3999. [propget] HRESULT IsProxy([out, retval] BOOL* value);
  4000. /// Returns the `ICoreWebView2StringCollection`.
  4001. /// The collection contains distinguished names of certificate authorities
  4002. /// allowed by the server.
  4003. [propget] HRESULT AllowedCertificateAuthorities([out, retval]
  4004. ICoreWebView2StringCollection** value);
  4005. /// Returns the `ICoreWebView2ClientCertificateCollection` when client
  4006. /// certificate authentication is requested. The collection contains mutually
  4007. /// trusted CA certificates.
  4008. [propget] HRESULT MutuallyTrustedCertificates([out, retval]
  4009. ICoreWebView2ClientCertificateCollection** value);
  4010. /// Returns the selected certificate.
  4011. [propget] HRESULT SelectedCertificate([out, retval]
  4012. ICoreWebView2ClientCertificate** value);
  4013. /// Sets the certificate to respond to the server.
  4014. [propput] HRESULT SelectedCertificate(
  4015. [in] ICoreWebView2ClientCertificate* value);
  4016. /// You may set this flag to cancel the certificate selection. If canceled,
  4017. /// the request is aborted regardless of the `Handled` property. By default the
  4018. /// value is `FALSE`.
  4019. [propget] HRESULT Cancel([out, retval] BOOL* value);
  4020. /// Sets the `Cancel` property.
  4021. [propput] HRESULT Cancel([in] BOOL value);
  4022. /// You may set this flag to `TRUE` to respond to the server with or
  4023. /// without a certificate. If this flag is `TRUE` with a `SelectedCertificate`
  4024. /// it responds to the server with the selected certificate otherwise respond to the
  4025. /// server without a certificate. By default the value of `Handled` and `Cancel` are `FALSE`
  4026. /// and display default client certificate selection dialog prompt to allow the user to
  4027. /// choose a certificate. The `SelectedCertificate` is ignored unless `Handled` is set `TRUE`.
  4028. [propget] HRESULT Handled([out, retval] BOOL* value);
  4029. /// Sets the `Handled` property.
  4030. [propput] HRESULT Handled([in] BOOL value);
  4031. /// Returns an `ICoreWebView2Deferral` object. Use this operation to
  4032. /// complete the event at a later time.
  4033. HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral);
  4034. }
  4035. /// This mostly represents a combined win32
  4036. /// POINTER_INFO/POINTER_TOUCH_INFO/POINTER_PEN_INFO object. It takes fields
  4037. /// from all three and excludes some win32 specific data types like HWND and
  4038. /// HANDLE. Note, sourceDevice is taken out but we expect the PointerDeviceRect
  4039. /// and DisplayRect to cover the existing use cases of sourceDevice.
  4040. /// Another big difference is that any of the point or rect locations are
  4041. /// expected to be in WebView physical coordinates. That is, coordinates
  4042. /// relative to the WebView and no DPI scaling applied.
  4043. //
  4044. // The PointerId, PointerFlags, ButtonChangeKind, PenFlags, PenMask, TouchFlags,
  4045. // and TouchMask are all #defined flags or enums in the
  4046. // POINTER_INFO/POINTER_TOUCH_INFO/POINTER_PEN_INFO structure. We define those
  4047. // properties here as UINT32 or INT32 and expect the developer to know how to
  4048. // populate those values based on the Windows definitions.
  4049. [uuid(e6995887-d10d-4f5d-9359-4ce46e4f96b9), object, pointer_default(unique)]
  4050. interface ICoreWebView2PointerInfo : IUnknown {
  4051. /// Get the PointerKind of the pointer event. This corresponds to the
  4052. /// pointerKind property of the POINTER_INFO struct. The values are defined by
  4053. /// the POINTER_INPUT_KIND enum in the Windows SDK (winuser.h). Supports
  4054. /// PT_PEN and PT_TOUCH.
  4055. [propget] HRESULT PointerKind([out, retval] DWORD* pointerKind);
  4056. /// Set the PointerKind of the pointer event. This corresponds to the
  4057. /// pointerKind property of the POINTER_INFO struct. The values are defined by
  4058. /// the POINTER_INPUT_KIND enum in the Windows SDK (winuser.h). Supports
  4059. /// PT_PEN and PT_TOUCH.
  4060. [propput] HRESULT PointerKind([in] DWORD pointerKind);
  4061. /// Get the PointerId of the pointer event. This corresponds to the pointerId
  4062. /// property of the POINTER_INFO struct as defined in the Windows SDK
  4063. /// (winuser.h).
  4064. [propget] HRESULT PointerId([out, retval] UINT32* pointerId);
  4065. /// Set the PointerId of the pointer event. This corresponds to the pointerId
  4066. /// property of the POINTER_INFO struct as defined in the Windows SDK
  4067. /// (winuser.h).
  4068. [propput] HRESULT PointerId([in] UINT32 pointerId);
  4069. /// Get the FrameID of the pointer event. This corresponds to the frameId
  4070. /// property of the POINTER_INFO struct as defined in the Windows SDK
  4071. /// (winuser.h).
  4072. [propget] HRESULT FrameId([out, retval] UINT32* frameId);
  4073. /// Set the FrameID of the pointer event. This corresponds to the frameId
  4074. /// property of the POINTER_INFO struct as defined in the Windows SDK
  4075. /// (winuser.h).
  4076. [propput] HRESULT FrameId([in] UINT32 frameId);
  4077. /// Get the PointerFlags of the pointer event. This corresponds to the
  4078. /// pointerFlags property of the POINTER_INFO struct. The values are defined
  4079. /// by the POINTER_FLAGS constants in the Windows SDK (winuser.h).
  4080. [propget] HRESULT PointerFlags([out, retval] UINT32* pointerFlags);
  4081. /// Set the PointerFlags of the pointer event. This corresponds to the
  4082. /// pointerFlags property of the POINTER_INFO struct. The values are defined
  4083. /// by the POINTER_FLAGS constants in the Windows SDK (winuser.h).
  4084. [propput] HRESULT PointerFlags([in] UINT32 pointerFlags);
  4085. /// Get the PointerDeviceRect of the sourceDevice property of the
  4086. /// POINTER_INFO struct as defined in the Windows SDK (winuser.h).
  4087. [propget] HRESULT PointerDeviceRect([out, retval] RECT* pointerDeviceRect);
  4088. /// Set the PointerDeviceRect of the sourceDevice property of the
  4089. /// POINTER_INFO struct as defined in the Windows SDK (winuser.h).
  4090. [propput] HRESULT PointerDeviceRect([in] RECT pointerDeviceRect);
  4091. /// Get the DisplayRect of the sourceDevice property of the POINTER_INFO
  4092. /// struct as defined in the Windows SDK (winuser.h).
  4093. [propget] HRESULT DisplayRect([out, retval] RECT* displayRect);
  4094. /// Set the DisplayRect of the sourceDevice property of the POINTER_INFO
  4095. /// struct as defined in the Windows SDK (winuser.h).
  4096. [propput] HRESULT DisplayRect([in] RECT displayRect);
  4097. /// Get the PixelLocation of the pointer event. This corresponds to the
  4098. /// ptPixelLocation property of the POINTER_INFO struct as defined in the
  4099. /// Windows SDK (winuser.h).
  4100. [propget] HRESULT PixelLocation([out, retval] POINT* pixelLocation);
  4101. /// Set the PixelLocation of the pointer event. This corresponds to the
  4102. /// ptPixelLocation property of the POINTER_INFO struct as defined in the
  4103. /// Windows SDK (winuser.h).
  4104. [propput] HRESULT PixelLocation([in] POINT pixelLocation);
  4105. /// Get the HimetricLocation of the pointer event. This corresponds to the
  4106. /// ptHimetricLocation property of the POINTER_INFO struct as defined in the
  4107. /// Windows SDK (winuser.h).
  4108. [propget] HRESULT HimetricLocation([out, retval] POINT* himetricLocation);
  4109. /// Set the HimetricLocation of the pointer event. This corresponds to the
  4110. /// ptHimetricLocation property of the POINTER_INFO struct as defined in the
  4111. /// Windows SDK (winuser.h).
  4112. [propput] HRESULT HimetricLocation([in] POINT himetricLocation);
  4113. /// Get the PixelLocationRaw of the pointer event. This corresponds to the
  4114. /// ptPixelLocationRaw property of the POINTER_INFO struct as defined in the
  4115. /// Windows SDK (winuser.h).
  4116. [propget] HRESULT PixelLocationRaw([out, retval] POINT* pixelLocationRaw);
  4117. /// Set the PixelLocationRaw of the pointer event. This corresponds to the
  4118. /// ptPixelLocationRaw property of the POINTER_INFO struct as defined in the
  4119. /// Windows SDK (winuser.h).
  4120. [propput] HRESULT PixelLocationRaw([in] POINT pixelLocationRaw);
  4121. /// Get the HimetricLocationRaw of the pointer event. This corresponds to the
  4122. /// ptHimetricLocationRaw property of the POINTER_INFO struct as defined in
  4123. /// the Windows SDK (winuser.h).
  4124. [propget] HRESULT HimetricLocationRaw([out, retval] POINT* himetricLocationRaw);
  4125. /// Set the HimetricLocationRaw of the pointer event. This corresponds to the
  4126. /// ptHimetricLocationRaw property of the POINTER_INFO struct as defined in
  4127. /// the Windows SDK (winuser.h).
  4128. [propput] HRESULT HimetricLocationRaw([in] POINT himetricLocationRaw);
  4129. /// Get the Time of the pointer event. This corresponds to the dwTime property
  4130. /// of the POINTER_INFO struct as defined in the Windows SDK (winuser.h).
  4131. [propget] HRESULT Time([out, retval] DWORD* time);
  4132. /// Set the Time of the pointer event. This corresponds to the dwTime property
  4133. /// of the POINTER_INFO struct as defined in the Windows SDK (winuser.h).
  4134. [propput] HRESULT Time([in] DWORD time);
  4135. /// Get the HistoryCount of the pointer event. This corresponds to the
  4136. /// historyCount property of the POINTER_INFO struct as defined in the Windows
  4137. /// SDK (winuser.h).
  4138. [propget] HRESULT HistoryCount([out, retval] UINT32* historyCount);
  4139. /// Set the HistoryCount of the pointer event. This corresponds to the
  4140. /// historyCount property of the POINTER_INFO struct as defined in the Windows
  4141. /// SDK (winuser.h).
  4142. [propput] HRESULT HistoryCount([in] UINT32 historyCount);
  4143. /// Get the InputData of the pointer event. This corresponds to the InputData
  4144. /// property of the POINTER_INFO struct as defined in the Windows SDK
  4145. /// (winuser.h).
  4146. [propget] HRESULT InputData([out, retval] INT32* inputData);
  4147. /// Set the InputData of the pointer event. This corresponds to the InputData
  4148. /// property of the POINTER_INFO struct as defined in the Windows SDK
  4149. /// (winuser.h).
  4150. [propput] HRESULT InputData([in] INT32 inputData);
  4151. /// Get the KeyStates of the pointer event. This corresponds to the
  4152. /// dwKeyStates property of the POINTER_INFO struct as defined in the Windows
  4153. /// SDK (winuser.h).
  4154. [propget] HRESULT KeyStates([out, retval] DWORD* keyStates);
  4155. /// Set the KeyStates of the pointer event. This corresponds to the
  4156. /// dwKeyStates property of the POINTER_INFO struct as defined in the Windows
  4157. /// SDK (winuser.h).
  4158. [propput] HRESULT KeyStates([in] DWORD keyStates);
  4159. /// Get the PerformanceCount of the pointer event. This corresponds to the
  4160. /// PerformanceCount property of the POINTER_INFO struct as defined in the
  4161. /// Windows SDK (winuser.h).
  4162. [propget] HRESULT PerformanceCount([out, retval] UINT64* performanceCount);
  4163. /// Set the PerformanceCount of the pointer event. This corresponds to the
  4164. /// PerformanceCount property of the POINTER_INFO struct as defined in the
  4165. /// Windows SDK (winuser.h).
  4166. [propput] HRESULT PerformanceCount([in] UINT64 performanceCount);
  4167. /// Get the ButtonChangeKind of the pointer event. This corresponds to the
  4168. /// ButtonChangeKind property of the POINTER_INFO struct. The values are
  4169. /// defined by the POINTER_BUTTON_CHANGE_KIND enum in the Windows SDK
  4170. /// (winuser.h).
  4171. [propget] HRESULT ButtonChangeKind([out, retval] INT32* buttonChangeKind);
  4172. /// Set the ButtonChangeKind of the pointer event. This corresponds to the
  4173. /// ButtonChangeKind property of the POINTER_INFO struct. The values are
  4174. /// defined by the POINTER_BUTTON_CHANGE_KIND enum in the Windows SDK
  4175. /// (winuser.h).
  4176. [propput] HRESULT ButtonChangeKind([in] INT32 buttonChangeKind);
  4177. // Pen specific attributes
  4178. /// Get the PenFlags of the pointer event. This corresponds to the penFlags
  4179. /// property of the POINTER_PEN_INFO struct. The values are defined by the
  4180. /// PEN_FLAGS constants in the Windows SDK (winuser.h).
  4181. [propget] HRESULT PenFlags([out, retval] UINT32* penFLags);
  4182. /// Set the PenFlags of the pointer event. This corresponds to the penFlags
  4183. /// property of the POINTER_PEN_INFO struct. The values are defined by the
  4184. /// PEN_FLAGS constants in the Windows SDK (winuser.h).
  4185. [propput] HRESULT PenFlags([in] UINT32 penFLags);
  4186. /// Get the PenMask of the pointer event. This corresponds to the penMask
  4187. /// property of the POINTER_PEN_INFO struct. The values are defined by the
  4188. /// PEN_MASK constants in the Windows SDK (winuser.h).
  4189. [propget] HRESULT PenMask([out, retval] UINT32* penMask);
  4190. /// Set the PenMask of the pointer event. This corresponds to the penMask
  4191. /// property of the POINTER_PEN_INFO struct. The values are defined by the
  4192. /// PEN_MASK constants in the Windows SDK (winuser.h).
  4193. [propput] HRESULT PenMask([in] UINT32 penMask);
  4194. /// Get the PenPressure of the pointer event. This corresponds to the pressure
  4195. /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK
  4196. /// (winuser.h).
  4197. [propget] HRESULT PenPressure([out, retval] UINT32* penPressure);
  4198. /// Set the PenPressure of the pointer event. This corresponds to the pressure
  4199. /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK
  4200. /// (winuser.h).
  4201. [propput] HRESULT PenPressure([in] UINT32 penPressure);
  4202. /// Get the PenRotation of the pointer event. This corresponds to the rotation
  4203. /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK
  4204. /// (winuser.h).
  4205. [propget] HRESULT PenRotation([out, retval] UINT32* penRotation);
  4206. /// Set the PenRotation of the pointer event. This corresponds to the rotation
  4207. /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK
  4208. /// (winuser.h).
  4209. [propput] HRESULT PenRotation([in] UINT32 penRotation);
  4210. /// Get the PenTiltX of the pointer event. This corresponds to the tiltX
  4211. /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK
  4212. /// (winuser.h).
  4213. [propget] HRESULT PenTiltX([out, retval] INT32* penTiltX);
  4214. /// Set the PenTiltX of the pointer event. This corresponds to the tiltX
  4215. /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK
  4216. /// (winuser.h).
  4217. [propput] HRESULT PenTiltX([in] INT32 penTiltX);
  4218. /// Get the PenTiltY of the pointer event. This corresponds to the tiltY
  4219. /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK
  4220. /// (winuser.h).
  4221. [propget] HRESULT PenTiltY([out, retval] INT32* penTiltY);
  4222. /// Set the PenTiltY of the pointer event. This corresponds to the tiltY
  4223. /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK
  4224. /// (winuser.h).
  4225. [propput] HRESULT PenTiltY([in] INT32 penTiltY);
  4226. // Touch specific attributes
  4227. /// Get the TouchFlags of the pointer event. This corresponds to the
  4228. /// touchFlags property of the POINTER_TOUCH_INFO struct. The values are
  4229. /// defined by the TOUCH_FLAGS constants in the Windows SDK (winuser.h).
  4230. [propget] HRESULT TouchFlags([out, retval] UINT32* touchFlags);
  4231. /// Set the TouchFlags of the pointer event. This corresponds to the
  4232. /// touchFlags property of the POINTER_TOUCH_INFO struct. The values are
  4233. /// defined by the TOUCH_FLAGS constants in the Windows SDK (winuser.h).
  4234. [propput] HRESULT TouchFlags([in] UINT32 touchFlags);
  4235. /// Get the TouchMask of the pointer event. This corresponds to the
  4236. /// touchMask property of the POINTER_TOUCH_INFO struct. The values are
  4237. /// defined by the TOUCH_MASK constants in the Windows SDK (winuser.h).
  4238. [propget] HRESULT TouchMask([out, retval] UINT32* touchMask);
  4239. /// Set the TouchMask of the pointer event. This corresponds to the
  4240. /// touchMask property of the POINTER_TOUCH_INFO struct. The values are
  4241. /// defined by the TOUCH_MASK constants in the Windows SDK (winuser.h).
  4242. [propput] HRESULT TouchMask([in] UINT32 touchMask);
  4243. /// Get the TouchContact of the pointer event. This corresponds to the
  4244. /// rcContact property of the POINTER_TOUCH_INFO struct as defined in the
  4245. /// Windows SDK (winuser.h).
  4246. [propget] HRESULT TouchContact([out, retval] RECT* touchContact);
  4247. /// Set the TouchContact of the pointer event. This corresponds to the
  4248. /// rcContact property of the POINTER_TOUCH_INFO struct as defined in the
  4249. /// Windows SDK (winuser.h).
  4250. [propput] HRESULT TouchContact([in] RECT touchContact);
  4251. /// Get the TouchContactRaw of the pointer event. This corresponds to the
  4252. /// rcContactRaw property of the POINTER_TOUCH_INFO struct as defined in the
  4253. /// Windows SDK (winuser.h).
  4254. [propget] HRESULT TouchContactRaw([out, retval] RECT* touchContactRaw);
  4255. /// Set the TouchContactRaw of the pointer event. This corresponds to the
  4256. /// rcContactRaw property of the POINTER_TOUCH_INFO struct as defined in the
  4257. /// Windows SDK (winuser.h).
  4258. [propput] HRESULT TouchContactRaw([in] RECT touchContactRaw);
  4259. /// Get the TouchOrientation of the pointer event. This corresponds to the
  4260. /// orientation property of the POINTER_TOUCH_INFO struct as defined in the
  4261. /// Windows SDK (winuser.h).
  4262. [propget] HRESULT TouchOrientation([out, retval] UINT32* touchOrientation);
  4263. /// Set the TouchOrientation of the pointer event. This corresponds to the
  4264. /// orientation property of the POINTER_TOUCH_INFO struct as defined in the
  4265. /// Windows SDK (winuser.h).
  4266. [propput] HRESULT TouchOrientation([in] UINT32 touchOrientation);
  4267. /// Get the TouchPressure of the pointer event. This corresponds to the
  4268. /// pressure property of the POINTER_TOUCH_INFO struct as defined in the
  4269. /// Windows SDK (winuser.h).
  4270. [propget] HRESULT TouchPressure([out, retval] UINT32* touchPressure);
  4271. /// Set the TouchPressure of the pointer event. This corresponds to the
  4272. /// pressure property of the POINTER_TOUCH_INFO struct as defined in the
  4273. /// Windows SDK (winuser.h).
  4274. [propput] HRESULT TouchPressure([in] UINT32 touchPressure);
  4275. }
  4276. /// The caller implements this interface to receive CursorChanged events. Use
  4277. /// the Cursor property to get the new cursor.
  4278. [uuid(9da43ccc-26e1-4dad-b56c-d8961c94c571), object, pointer_default(unique)]
  4279. interface ICoreWebView2CursorChangedEventHandler : IUnknown {
  4280. /// Called to provide the implementer with the event args for the
  4281. /// corresponding event. There are no event args and the args
  4282. /// parameter will be null.
  4283. HRESULT Invoke([in] ICoreWebView2CompositionController* sender, [in] IUnknown* args);
  4284. }
  4285. /// Receives `RasterizationScaleChanged` events. Use the `RasterizationScale`
  4286. /// property to get the modified scale.
  4287. [uuid(9c98c8b1-ac53-427e-a345-3049b5524bbe), object, pointer_default(unique)]
  4288. interface ICoreWebView2RasterizationScaleChangedEventHandler : IUnknown {
  4289. /// Called to provide the implementer with the event args for the
  4290. /// corresponding event. There are no event args and the args
  4291. /// parameter will be null.
  4292. HRESULT Invoke(
  4293. [in] ICoreWebView2Controller* sender,
  4294. [in] IUnknown* args);
  4295. }
  4296. /// Represents the WebView2 Environment. WebViews created from an environment
  4297. /// run on the browser process specified with environment parameters and
  4298. /// objects created from an environment should be used in the same
  4299. /// environment. Using it in different environments are not guaranteed to be
  4300. /// compatible and may fail.
  4301. [uuid(b96d755e-0319-4e92-a296-23436f46a1fc), object, pointer_default(unique)]
  4302. interface ICoreWebView2Environment : IUnknown {
  4303. /// Asynchronously create a new WebView.
  4304. ///
  4305. /// `parentWindow` is the `HWND` in which the WebView should be displayed and
  4306. /// from which receive input. The WebView adds a child window to the
  4307. /// provided window before this function returns. Z-order and other things
  4308. /// impacted by sibling window order are affected accordingly. If you want to
  4309. /// move the WebView to a different parent after it has been created, you must
  4310. /// call put_ParentWindow to update tooltip positions, accessibility trees,
  4311. /// and such.
  4312. ///
  4313. /// HWND_MESSAGE is a valid parameter for `parentWindow` for an invisible
  4314. /// WebView for Windows 8 and above. In this case the window will never
  4315. /// become visible. You are not able to reparent the window after you have
  4316. /// created the WebView. This is not supported in Windows 7 or below.
  4317. /// Passing this parameter in Windows 7 or below will return
  4318. /// ERROR_INVALID_WINDOW_HANDLE in the controller callback.
  4319. ///
  4320. /// It is recommended that the app set Application User Model ID for the
  4321. /// process or the app window. If none is set, during WebView creation a
  4322. /// generated Application User Model ID is set to root window of
  4323. /// `parentWindow`.
  4324. ///
  4325. /// \snippet AppWindow.cpp CreateCoreWebView2Controller
  4326. ///
  4327. /// It is recommended that the app handles restart manager messages, to
  4328. /// gracefully restart it in the case when the app is using the WebView2
  4329. /// Runtime from a certain installation and that installation is being
  4330. /// uninstalled. For example, if a user installs a version of the WebView2
  4331. /// Runtime and opts to use another version of the WebView2 Runtime for
  4332. /// testing the app, and then uninstalls the 1st version of the WebView2
  4333. /// Runtime without closing the app, the app restarts to allow
  4334. /// un-installation to succeed.
  4335. ///
  4336. /// \snippet AppWindow.cpp RestartManager
  4337. ///
  4338. /// The app should retry `CreateCoreWebView2Controller` upon failure, unless the
  4339. /// error code is `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)`.
  4340. /// When the app retries `CreateCoreWebView2Controller` upon failure, it is
  4341. /// recommended that the app restarts from creating a new WebView2
  4342. /// Environment. If a WebView2 Runtime update happens, the version
  4343. /// associated with a WebView2 Environment may have been removed and causing
  4344. /// the object to no longer work. Creating a new WebView2 Environment works
  4345. /// since it uses the latest version.
  4346. ///
  4347. /// WebView creation fails with `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)` if a
  4348. /// running instance using the same user data folder exists, and the Environment
  4349. /// objects have different `EnvironmentOptions`. For example, if a WebView was
  4350. /// created with one language, an attempt to create a WebView with a different
  4351. /// language using the same user data folder will fail.
  4352. ///
  4353. /// The creation will fail with `E_ABORT` if `parentWindow` is destroyed
  4354. /// before the creation is finished. If this is caused by a call to
  4355. /// `DestroyWindow`, the creation completed handler will be invoked before
  4356. /// `DestroyWindow` returns, so you can use this to cancel creation and clean
  4357. /// up resources synchronously when quitting a thread.
  4358. HRESULT CreateCoreWebView2Controller(
  4359. HWND parentWindow,
  4360. ICoreWebView2CreateCoreWebView2ControllerCompletedHandler* handler);
  4361. /// Create a new web resource response object. The `headers` parameter is
  4362. /// the raw response header string delimited by newline. It is also possible
  4363. /// to create this object with null headers string and then use the
  4364. /// `ICoreWebView2HttpResponseHeaders` to construct the headers line by line.
  4365. /// For more information about other parameters, navigate to
  4366. /// [ICoreWebView2WebResourceResponse](/microsoft-edge/webview2/reference/win32/icorewebview2webresourceresponse).
  4367. ///
  4368. /// \snippet SettingsComponent.cpp WebResourceRequested0
  4369. /// \snippet SettingsComponent.cpp WebResourceRequested1
  4370. HRESULT CreateWebResourceResponse(
  4371. [in] IStream* content,
  4372. [in] int statusCode,
  4373. [in] LPCWSTR reasonPhrase,
  4374. [in] LPCWSTR headers,
  4375. [out, retval] ICoreWebView2WebResourceResponse** response);
  4376. /// The browser version info of the current `ICoreWebView2Environment`,
  4377. /// including channel name if it is not the WebView2 Runtime. It matches the
  4378. /// format of the `GetAvailableCoreWebView2BrowserVersionString` API.
  4379. /// Channel names are `beta`, `dev`, and `canary`.
  4380. ///
  4381. /// The caller must free the returned string with `CoTaskMemFree`. See
  4382. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  4383. ///
  4384. /// \snippet AppWindow.cpp GetBrowserVersionString
  4385. [propget] HRESULT BrowserVersionString([out, retval] LPWSTR* versionInfo);
  4386. /// Add an event handler for the `NewBrowserVersionAvailable` event.
  4387. /// `NewBrowserVersionAvailable` runs when a newer version of the WebView2
  4388. /// Runtime is installed and available using WebView2. To use the newer
  4389. /// version of the browser you must create a new environment and WebView.
  4390. /// The event only runs for new version from the same WebView2 Runtime from
  4391. /// which the code is running. When not running with installed WebView2
  4392. /// Runtime, no event is run.
  4393. ///
  4394. /// Because a user data folder is only able to be used by one browser
  4395. /// process at a time, if you want to use the same user data folder in the
  4396. /// WebView using the new version of the browser, you must close the
  4397. /// environment and instance of WebView that are using the older version of
  4398. /// the browser first. Or simply prompt the user to restart the app.
  4399. ///
  4400. /// \snippet AppWindow.cpp NewBrowserVersionAvailable
  4401. HRESULT add_NewBrowserVersionAvailable(
  4402. [in] ICoreWebView2NewBrowserVersionAvailableEventHandler* eventHandler,
  4403. [out] EventRegistrationToken* token);
  4404. /// Remove an event handler previously added with `add_NewBrowserVersionAvailable`.
  4405. HRESULT remove_NewBrowserVersionAvailable(
  4406. [in] EventRegistrationToken token);
  4407. }
  4408. /// A continuation of the ICoreWebView2Environment interface.
  4409. [uuid(41F3632B-5EF4-404F-AD82-2D606C5A9A21), object, pointer_default(unique)]
  4410. interface ICoreWebView2Environment2 : ICoreWebView2Environment {
  4411. /// Create a new web resource request object.
  4412. /// URI parameter must be absolute URI.
  4413. /// The headers string is the raw request header string delimited by CRLF
  4414. /// (optional in last header).
  4415. /// It's also possible to create this object with null headers string
  4416. /// and then use the ICoreWebView2HttpRequestHeaders to construct the headers
  4417. /// line by line.
  4418. /// For information on other parameters see ICoreWebView2WebResourceRequest.
  4419. ///
  4420. /// \snippet ScenarioNavigateWithWebResourceRequest.cpp NavigateWithWebResourceRequest
  4421. HRESULT CreateWebResourceRequest([in] LPCWSTR uri,
  4422. [in] LPCWSTR method,
  4423. [in] IStream* postData,
  4424. [in] LPCWSTR headers,
  4425. [out, retval] ICoreWebView2WebResourceRequest** request);
  4426. }
  4427. /// A continuation of the ICoreWebView2Environment2 interface.
  4428. [uuid(80a22ae3-be7c-4ce2-afe1-5a50056cdeeb), object, pointer_default(unique)]
  4429. interface ICoreWebView2Environment3 : ICoreWebView2Environment2 {
  4430. /// Asynchronously create a new WebView for use with visual hosting.
  4431. ///
  4432. /// parentWindow is the HWND in which the app will connect the visual tree of
  4433. /// the WebView. This will be the HWND that the app will receive pointer/
  4434. /// mouse input meant for the WebView (and will need to use SendMouseInput/
  4435. /// SendPointerInput to forward). If the app moves the WebView visual tree to
  4436. /// underneath a different window, then it needs to call put_ParentWindow to
  4437. /// update the new parent HWND of the visual tree.
  4438. ///
  4439. /// HWND_MESSAGE is not a valid parameter for `parentWindow` for visual hosting.
  4440. /// The underlying implementation of supporting HWND_MESSAGE would break
  4441. /// accessibility for visual hosting. This is supported in windowed
  4442. /// WebViews - see CreateCoreWebView2Controller.
  4443. ///
  4444. /// Use put_RootVisualTarget on the created CoreWebView2CompositionController to
  4445. /// provide a visual to host the browser's visual tree.
  4446. ///
  4447. /// It is recommended that the application set Application User Model ID for
  4448. /// the process or the application window. If none is set, during WebView
  4449. /// creation a generated Application User Model ID is set to root window of
  4450. /// parentWindow.
  4451. /// \snippet AppWindow.cpp CreateCoreWebView2Controller
  4452. ///
  4453. /// It is recommended that the application handles restart manager messages
  4454. /// so that it can be restarted gracefully in the case when the app is using
  4455. /// Edge for WebView from a certain installation and that installation is
  4456. /// being uninstalled. For example, if a user installs Edge from Dev channel
  4457. /// and opts to use Edge from that channel for testing the app, and then
  4458. /// uninstalls Edge from that channel without closing the app, the app will
  4459. /// be restarted to allow uninstallation of the dev channel to succeed.
  4460. /// \snippet AppWindow.cpp RestartManager
  4461. ///
  4462. /// The app should retry `CreateCoreWebView2CompositionController` upon failure,
  4463. /// unless the error code is `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)`.
  4464. /// When the app retries `CreateCoreWebView2CompositionController`
  4465. /// upon failure, it is recommended that the app restarts from creating a new
  4466. /// WebView2 Environment. If a WebView2 Runtime update happens, the version
  4467. /// associated with a WebView2 Environment may have been removed and causing
  4468. /// the object to no longer work. Creating a new WebView2 Environment works
  4469. /// since it uses the latest version.
  4470. ///
  4471. /// WebView creation fails with `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)` if a
  4472. /// running instance using the same user data folder exists, and the Environment
  4473. /// objects have different `EnvironmentOptions`. For example, if a WebView was
  4474. /// created with one language, an attempt to create a WebView with a different
  4475. /// language using the same user data folder will fail.
  4476. ///
  4477. /// The creation will fail with `E_ABORT` if `parentWindow` is destroyed
  4478. /// before the creation is finished. If this is caused by a call to
  4479. /// `DestroyWindow`, the creation completed handler will be invoked before
  4480. /// `DestroyWindow` returns, so you can use this to cancel creation and clean
  4481. /// up resources synchronously when quitting a thread.
  4482. ///
  4483. /// CreateCoreWebView2CompositionController is supported in the following versions of Windows:
  4484. ///
  4485. /// - Windows 11
  4486. /// - Windows 10
  4487. /// - Windows Server 2019
  4488. /// - Windows Server 2016
  4489. ///
  4490. HRESULT CreateCoreWebView2CompositionController(
  4491. HWND parentWindow,
  4492. ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler* handler);
  4493. /// Create an empty ICoreWebView2PointerInfo. The returned
  4494. /// ICoreWebView2PointerInfo needs to be populated with all of the relevant
  4495. /// info before calling SendPointerInput.
  4496. HRESULT CreateCoreWebView2PointerInfo(
  4497. [out, retval] ICoreWebView2PointerInfo** pointerInfo);
  4498. }
  4499. /// A continuation of the ICoreWebView2Environment3 interface.
  4500. [uuid(20944379-6dcf-41d6-a0a0-abc0fc50de0d), object, pointer_default(unique)]
  4501. interface ICoreWebView2Environment4 : ICoreWebView2Environment3 {
  4502. /// Returns the Automation Provider for the WebView that matches the provided
  4503. /// window. Host apps are expected to implement
  4504. /// IRawElementProviderHwndOverride. When GetOverrideProviderForHwnd is
  4505. /// called, the app can pass the HWND to GetAutomationProviderForWindow to
  4506. /// find the matching WebView Automation Provider.
  4507. HRESULT GetAutomationProviderForWindow([in] HWND hwnd,
  4508. [out, retval] IUnknown** provider);
  4509. }
  4510. /// A continuation of the `ICoreWebView2Environment4` interface that supports
  4511. /// the `BrowserProcessExited` event.
  4512. [uuid(319e423d-e0d7-4b8d-9254-ae9475de9b17), object, pointer_default(unique)]
  4513. interface ICoreWebView2Environment5 : ICoreWebView2Environment4 {
  4514. /// Add an event handler for the `BrowserProcessExited` event.
  4515. /// The `BrowserProcessExited` event is raised when the collection of WebView2
  4516. /// Runtime processes for the browser process of this environment terminate
  4517. /// due to browser process failure or normal shutdown (for example, when all
  4518. /// associated WebViews are closed), after all resources have been released
  4519. /// (including the user data folder). To learn about what these processes are,
  4520. /// go to [Process model](/microsoft-edge/webview2/concepts/process-model).
  4521. ///
  4522. /// A handler added with this method is called until removed with
  4523. /// `remove_BrowserProcessExited`, even if a new browser process is bound to
  4524. /// this environment after earlier `BrowserProcessExited` events are raised.
  4525. ///
  4526. /// Multiple app processes can share a browser process by creating their webviews
  4527. /// from a `ICoreWebView2Environment` with the same user data folder. When the entire
  4528. /// collection of WebView2Runtime processes for the browser process exit, all
  4529. /// associated `ICoreWebView2Environment` objects receive the `BrowserProcessExited`
  4530. /// event. Multiple processes sharing the same browser process need to coordinate
  4531. /// their use of the shared user data folder to avoid race conditions and
  4532. /// unnecessary waits. For example, one process should not clear the user data
  4533. /// folder at the same time that another process recovers from a crash by recreating
  4534. /// its WebView controls; one process should not block waiting for the event if
  4535. /// other app processes are using the same browser process (the browser process will
  4536. /// not exit until those other processes have closed their webviews too).
  4537. ///
  4538. /// Note this is an event from the `ICoreWebView2Environment3` interface, not
  4539. /// the `ICoreWebView2` one. The difference between `BrowserProcessExited` and
  4540. /// `ICoreWebView2`'s `ProcessFailed` is that `BrowserProcessExited` is
  4541. /// raised for any **browser process** exit (expected or unexpected, after all
  4542. /// associated processes have exited too), while `ProcessFailed` is raised for
  4543. /// **unexpected** process exits of any kind (browser, render, GPU, and all
  4544. /// other types), or for main frame **render process** unresponsiveness. To
  4545. /// learn more about the WebView2 Process Model, go to
  4546. /// [Process model](/microsoft-edge/webview2/concepts/process-model).
  4547. ///
  4548. /// In the case the browser process crashes, both `BrowserProcessExited` and
  4549. /// `ProcessFailed` events are raised, but the order is not guaranteed. These
  4550. /// events are intended for different scenarios. It is up to the app to
  4551. /// coordinate the handlers so they do not try to perform reliability recovery
  4552. /// while also trying to move to a new WebView2 Runtime version or remove the
  4553. /// user data folder.
  4554. ///
  4555. /// \snippet AppWindow.cpp Close
  4556. HRESULT add_BrowserProcessExited(
  4557. [in] ICoreWebView2BrowserProcessExitedEventHandler* eventHandler,
  4558. [out] EventRegistrationToken* token);
  4559. /// Remove an event handler previously added with `add_BrowserProcessExited`.
  4560. HRESULT remove_BrowserProcessExited([in] EventRegistrationToken token);
  4561. }
  4562. /// This interface is an extension of the ICoreWebView2Environment that supports
  4563. /// creating print settings for printing to PDF.
  4564. [uuid(e59ee362-acbd-4857-9a8e-d3644d9459a9), object, pointer_default(unique)]
  4565. interface ICoreWebView2Environment6 : ICoreWebView2Environment5 {
  4566. /// Creates the `ICoreWebView2lPrintSettings` used by the `PrintToPdf`
  4567. /// method.
  4568. HRESULT CreatePrintSettings(
  4569. [out, retval] ICoreWebView2PrintSettings** printSettings);
  4570. }
  4571. /// This interface is an extension of the ICoreWebView2Environment. An object
  4572. /// implementing the ICoreWebView2Environment7 interface will also
  4573. /// implement ICoreWebView2Environment.
  4574. [uuid(43C22296-3BBD-43A4-9C00-5C0DF6DD29A2), object, pointer_default(unique)]
  4575. interface ICoreWebView2Environment7 : ICoreWebView2Environment6 {
  4576. /// Returns the user data folder that all CoreWebView2's created from this
  4577. /// environment are using.
  4578. /// This could be either the value passed in by the developer when creating
  4579. /// the environment object or the calculated one for default handling. It
  4580. /// will always be an absolute path.
  4581. ///
  4582. /// The caller must free the returned string with `CoTaskMemFree`. See
  4583. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  4584. ///
  4585. /// \snippet AppWindow.cpp GetUserDataFolder
  4586. [propget] HRESULT UserDataFolder([ out, retval ] LPWSTR * value);
  4587. }
  4588. /// A continuation of the `ICoreWebView2Environment7` interface that supports
  4589. /// the `ProcessInfosChanged` event.
  4590. [uuid(D6EB91DD-C3D2-45E5-BD29-6DC2BC4DE9CF), object, pointer_default(unique)]
  4591. interface ICoreWebView2Environment8 : ICoreWebView2Environment7 {
  4592. /// Adds an event handler for the `ProcessInfosChanged` event.
  4593. ///
  4594. /// \snippet ProcessComponent.cpp ProcessInfosChanged
  4595. /// \snippet ProcessComponent.cpp ProcessInfosChanged1
  4596. HRESULT add_ProcessInfosChanged(
  4597. [in] ICoreWebView2ProcessInfosChangedEventHandler* eventHandler,
  4598. [out] EventRegistrationToken* token);
  4599. /// Remove an event handler previously added with `add_ProcessInfosChanged`.
  4600. HRESULT remove_ProcessInfosChanged(
  4601. [in] EventRegistrationToken token);
  4602. /// Returns the `ICoreWebView2ProcessInfoCollection`
  4603. /// Provide a list of all process using same user data folder except for crashpad process.
  4604. HRESULT GetProcessInfos([out, retval]ICoreWebView2ProcessInfoCollection** value);
  4605. }
  4606. /// Provides a set of properties for a process in the `ICoreWebView2Environment`.
  4607. [uuid(84FA7612-3F3D-4FBF-889D-FAD000492D72), object, pointer_default(unique)]
  4608. interface ICoreWebView2ProcessInfo : IUnknown {
  4609. /// The process id of the process.
  4610. [propget] HRESULT ProcessId([out, retval] INT32* value);
  4611. /// The kind of the process.
  4612. [propget] HRESULT Kind([out, retval] COREWEBVIEW2_PROCESS_KIND* kind);
  4613. }
  4614. /// A continuation of the ICoreWebView2Environment interface for
  4615. /// creating CoreWebView2 ContextMenuItem objects.
  4616. [uuid(f06f41bf-4b5a-49d8-b9f6-fa16cd29f274), object, pointer_default(unique)]
  4617. interface ICoreWebView2Environment9 : ICoreWebView2Environment8 {
  4618. /// Create a custom `ContextMenuItem` object to insert into the WebView context menu.
  4619. /// CoreWebView2 will rewind the icon stream before decoding.
  4620. /// There is a limit of 1000 active custom context menu items at a given time.
  4621. /// Attempting to create more before deleting existing ones will fail with
  4622. /// ERROR_NOT_ENOUGH_QUOTA.
  4623. /// It is recommended to reuse ContextMenuItems across ContextMenuRequested events
  4624. /// for performance.
  4625. /// The returned ContextMenuItem object's `IsEnabled` property will default to `TRUE`
  4626. /// and `IsChecked` property will default to `FALSE`. A `CommandId` will be assigned
  4627. /// to the ContextMenuItem object that's unique across active custom context menu items,
  4628. /// but command ID values of deleted ContextMenuItems can be reassigned.
  4629. HRESULT CreateContextMenuItem(
  4630. [in] LPCWSTR label,
  4631. [in] IStream* iconStream,
  4632. [in] COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND kind,
  4633. [out, retval] ICoreWebView2ContextMenuItem** item);
  4634. }
  4635. /// This interface is used to create `ICoreWebView2ControllerOptions` object, which
  4636. /// can be passed as a parameter in `CreateCoreWebView2ControllerWithOptions` and
  4637. /// `CreateCoreWebView2CompositionControllerWithOptions` function for multiple profiles support.
  4638. /// The profile will be created on disk or opened when calling `CreateCoreWebView2ControllerWithOptions` or
  4639. /// `CreateCoreWebView2CompositionControllerWithOptions` no matter InPrivate mode is enabled or not, and
  4640. /// it will be released in memory when the corresponding controller is closed but still remain on disk.
  4641. /// If you create a WebView2Controller with {ProfileName="name", InPrivate=false} and then later create another
  4642. /// one with {ProfileName="name", InPrivate=true}, these two controllers using the same profile would be allowed to
  4643. /// run at the same time.
  4644. /// As WebView2 is built on top of Edge browser, it follows Edge's behavior pattern. To create an InPrivate WebView,
  4645. /// we gets an off-the-record profile (an InPrivate profile) from a regular profile, then create the WebView with the
  4646. /// off-the-record profile.
  4647. ///
  4648. /// \snippet AppWindow.cpp CreateControllerWithOptions
  4649. [uuid(ee0eb9df-6f12-46ce-b53f-3f47b9c928e0), object, pointer_default(unique)]
  4650. interface ICoreWebView2Environment10 : ICoreWebView2Environment9 {
  4651. /// Create a new ICoreWebView2ControllerOptions to be passed as a parameter of
  4652. /// CreateCoreWebView2ControllerWithOptions and CreateCoreWebView2CompositionControllerWithOptions.
  4653. /// The 'options' is settable and in it the default value for profile name is the empty string,
  4654. /// and the default value for IsInPrivateModeEnabled is false.
  4655. /// Also the profile name can be reused.
  4656. HRESULT CreateCoreWebView2ControllerOptions(
  4657. [out, retval] ICoreWebView2ControllerOptions** options);
  4658. /// Create a new WebView with options.
  4659. HRESULT CreateCoreWebView2ControllerWithOptions(
  4660. [in] HWND parentWindow,
  4661. [in] ICoreWebView2ControllerOptions* options,
  4662. [in] ICoreWebView2CreateCoreWebView2ControllerCompletedHandler* handler);
  4663. /// Create a new WebView in visual hosting mode with options.
  4664. HRESULT CreateCoreWebView2CompositionControllerWithOptions(
  4665. [in] HWND parentWindow,
  4666. [in] ICoreWebView2ControllerOptions* options,
  4667. [in] ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler* handler);
  4668. }
  4669. /// A list containing process id and corresponding process type.
  4670. [uuid(402B99CD-A0CC-4FA5-B7A5-51D86A1D2339), object, pointer_default(unique)]
  4671. interface ICoreWebView2ProcessInfoCollection : IUnknown {
  4672. /// The number of process contained in the ICoreWebView2ProcessInfoCollection.
  4673. [propget] HRESULT Count([out, retval] UINT* count);
  4674. /// Gets the `ICoreWebView2ProcessInfo` located in the `ICoreWebView2ProcessInfoCollection`
  4675. /// at the given index.
  4676. HRESULT GetValueAtIndex([in] UINT32 index,
  4677. [out, retval] ICoreWebView2ProcessInfo** processInfo);
  4678. }
  4679. /// An event handler for the `ProcessInfosChanged` event.
  4680. [uuid(F4AF0C39-44B9-40E9-8B11-0484CFB9E0A1), object, pointer_default(unique)]
  4681. interface ICoreWebView2ProcessInfosChangedEventHandler : IUnknown {
  4682. /// Provides the event args for the corresponding event. No event args exist
  4683. /// and the `args` parameter is set to `null`.
  4684. HRESULT Invoke([in] ICoreWebView2Environment* sender, [in] IUnknown* args);
  4685. }
  4686. /// Options used to create WebView2 Environment. A default implementation is
  4687. /// provided in `WebView2EnvironmentOptions.h`.
  4688. ///
  4689. /// \snippet AppWindow.cpp CreateCoreWebView2EnvironmentWithOptions
  4690. [uuid(2fde08a8-1e9a-4766-8c05-95a9ceb9d1c5), object, pointer_default(unique)]
  4691. interface ICoreWebView2EnvironmentOptions : IUnknown {
  4692. /// Changes the behavior of the WebView. The arguments are passed to the
  4693. /// browser process as part of the command. For more information about
  4694. /// using command-line switches with Chromium browser processes, navigate to
  4695. /// [Run Chromium with Flags](https://www.chromium.org/developers/how-tos/run-chromium-with-flags).
  4696. /// The value appended to a switch is appended to the browser process, for
  4697. /// example, in `--edge-webview-switches=xxx` the value is `xxx`. If you
  4698. /// specify a switch that is important to WebView functionality, it is
  4699. /// ignored, for example, `--user-data-dir`. Specific features are disabled
  4700. /// internally and blocked from being enabled. If a switch is specified
  4701. /// multiple times, only the last instance is used.
  4702. ///
  4703. /// \> [!NOTE]\n\> A merge of the different values of the same switch is not attempted,
  4704. /// except for disabled and enabled features. The features specified by
  4705. /// `--enable-features` and `--disable-features` are merged with simple
  4706. /// logic.\n\> * The features is the union of the specified features
  4707. /// and built-in features. If a feature is disabled, it is removed from the
  4708. /// enabled features list.
  4709. ///
  4710. /// If you specify command-line switches and use the
  4711. /// `additionalBrowserArguments` parameter, the `--edge-webview-switches`
  4712. /// value takes precedence and is processed last. If a switch fails to
  4713. /// parse, the switch is ignored. The default state for the operation is
  4714. /// to run the browser process with no extra flags.
  4715. ///
  4716. /// The caller must free the returned string with `CoTaskMemFree`. See
  4717. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  4718. [propget] HRESULT AdditionalBrowserArguments([out, retval] LPWSTR* value);
  4719. /// Sets the `AdditionalBrowserArguments` property.
  4720. ///
  4721. /// Please note that calling this API twice will replace the previous value
  4722. /// rather than appending to it. If there are multiple switches, there
  4723. /// should be a space in between them. The one exception is if multiple
  4724. /// features are being enabled/disabled for a single switch, in which
  4725. /// case the features should be comma-seperated.
  4726. /// Ex. "--disable-features=feature1,feature2 --some-other-switch --do-something"
  4727. [propput] HRESULT AdditionalBrowserArguments([in] LPCWSTR value);
  4728. /// The default display language for WebView. It applies to browser UI such as
  4729. /// context menu and dialogs. It also applies to the `accept-languages` HTTP
  4730. /// header that WebView sends to websites. It is in the format of
  4731. /// `language[-country]` where `language` is the 2-letter code from [ISO
  4732. /// 639](https://www.iso.org/iso-639-language-codes.html) and `country` is the
  4733. /// 2-letter code from [ISO 3166](https://www.iso.org/standard/72482.html).
  4734. ///
  4735. /// The caller must free the returned string with `CoTaskMemFree`. See
  4736. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  4737. [propget] HRESULT Language([out, retval] LPWSTR* value);
  4738. /// Sets the `Language` property.
  4739. [propput] HRESULT Language([in] LPCWSTR value);
  4740. /// Specifies the version of the WebView2 Runtime binaries required to be
  4741. /// compatible with your app. This defaults to the WebView2 Runtime version
  4742. /// that corresponds with the version of the SDK the app is using. The
  4743. /// format of this value is the same as the format of the
  4744. /// `BrowserVersionString` property and other `BrowserVersion` values. Only
  4745. /// the version part of the `BrowserVersion` value is respected. The channel
  4746. /// suffix, if it exists, is ignored. The version of the WebView2 Runtime
  4747. /// binaries actually used may be different from the specified
  4748. /// `TargetCompatibleBrowserVersion`. The binaries are only guaranteed to be
  4749. /// compatible. Verify the actual version on the `BrowserVersionString`
  4750. /// property on the `ICoreWebView2Environment`.
  4751. ///
  4752. /// The caller must free the returned string with `CoTaskMemFree`. See
  4753. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  4754. [propget] HRESULT TargetCompatibleBrowserVersion([out, retval] LPWSTR* value);
  4755. /// Sets the `TargetCompatibleBrowserVersion` property.
  4756. [propput] HRESULT TargetCompatibleBrowserVersion([in] LPCWSTR value);
  4757. /// The `AllowSingleSignOnUsingOSPrimaryAccount` property is used to enable
  4758. /// single sign on with Azure Active Directory (AAD) and personal Microsoft
  4759. /// Account (MSA) resources inside WebView. All AAD accounts, connected to
  4760. /// Windows and shared for all apps, are supported. For MSA, SSO is only enabled
  4761. /// for the account associated for Windows account login, if any.
  4762. /// Default is disabled. Universal Windows Platform apps must also declare
  4763. /// `enterpriseCloudSSO`
  4764. /// [Restricted capabilities](/windows/uwp/packaging/app-capability-declarations\#restricted-capabilities)
  4765. /// for the single sign on (SSO) to work.
  4766. [propget] HRESULT AllowSingleSignOnUsingOSPrimaryAccount([out, retval] BOOL* allow);
  4767. /// Sets the `AllowSingleSignOnUsingOSPrimaryAccount` property.
  4768. [propput] HRESULT AllowSingleSignOnUsingOSPrimaryAccount([in] BOOL allow);
  4769. }
  4770. /// Additional options used to create WebView2 Environment. A default implementation is
  4771. /// provided in `WebView2EnvironmentOptions.h`.
  4772. ///
  4773. /// \snippet AppWindow.cpp CreateCoreWebView2EnvironmentWithOptions
  4774. // Note: ICoreWebView2EnvironmentOptions* interfaces derive from IUnknown to make moving
  4775. // the API from experimental to public smoothier. These interfaces are mostly internal to
  4776. // WebView's own code. Normal apps just use the objects we provided and never interact
  4777. // with the interfaces. Advanced apps might implement their own options object. In that
  4778. // case, it is also easier for them to implement the interface if it is derived from IUnknown.
  4779. [uuid(FF85C98A-1BA7-4A6B-90C8-2B752C89E9E2), object, pointer_default(unique)]
  4780. interface ICoreWebView2EnvironmentOptions2 : IUnknown {
  4781. /// Whether other processes can create WebView2 from WebView2Environment created with the
  4782. /// same user data folder and therefore sharing the same WebView browser process instance.
  4783. /// Default is FALSE.
  4784. [propget] HRESULT ExclusiveUserDataFolderAccess([out, retval] BOOL* value);
  4785. /// Sets the `ExclusiveUserDataFolderAccess` property.
  4786. /// The `ExclusiveUserDataFolderAccess` property specifies that the WebView environment
  4787. /// obtains exclusive access to the user data folder.
  4788. /// If the user data folder is already being used by another WebView environment with a
  4789. /// different value for `ExclusiveUserDataFolderAccess` property, the creation of a WebView2Controller
  4790. /// using the environment object will fail with `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)`.
  4791. /// When set as TRUE, no other WebView can be created from other processes using WebView2Environment
  4792. /// objects with the same UserDataFolder. This prevents other processes from creating WebViews
  4793. /// which share the same browser process instance, since sharing is performed among
  4794. /// WebViews that have the same UserDataFolder. When another process tries to create a
  4795. /// WebView2Controller from an WebView2Environment object created with the same user data folder,
  4796. /// it will fail with `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)`.
  4797. [propput] HRESULT ExclusiveUserDataFolderAccess([in] BOOL value);
  4798. }
  4799. /// Receives the `WebView2Environment` created using
  4800. /// `CreateCoreWebView2Environment`.
  4801. [uuid(4e8a3389-c9d8-4bd2-b6b5-124fee6cc14d), object, pointer_default(unique)]
  4802. interface ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler : IUnknown {
  4803. /// Provides the completion status and result of the corresponding
  4804. /// asynchronous method.
  4805. HRESULT Invoke(HRESULT errorCode, ICoreWebView2Environment* createdEnvironment);
  4806. }
  4807. /// A Receiver is created for a particular DevTools Protocol event and allows
  4808. /// you to subscribe and unsubscribe from that event. Obtained from the
  4809. /// WebView object using `GetDevToolsProtocolEventReceiver`.
  4810. [uuid(b32ca51a-8371-45e9-9317-af021d080367), object, pointer_default(unique)]
  4811. interface ICoreWebView2DevToolsProtocolEventReceiver : IUnknown {
  4812. /// Subscribe to a `DevToolsProtocol` event. The `Invoke` method of the
  4813. /// `handler` runs whenever the corresponding `DevToolsProtocol` event runs.
  4814. /// `Invoke` runs with an event args object containing the parameter object
  4815. /// of the DevTools Protocol event as a JSON string.
  4816. ///
  4817. /// \snippet ScriptComponent.cpp DevToolsProtocolEventReceived
  4818. HRESULT add_DevToolsProtocolEventReceived(
  4819. [in] ICoreWebView2DevToolsProtocolEventReceivedEventHandler* handler,
  4820. [out] EventRegistrationToken* token);
  4821. /// Remove an event handler previously added with
  4822. /// `add_DevToolsProtocolEventReceived`.
  4823. HRESULT remove_DevToolsProtocolEventReceived(
  4824. [in] EventRegistrationToken token);
  4825. }
  4826. /// WebView2Frame provides direct access to the iframes information.
  4827. [uuid(f1131a5e-9ba9-11eb-a8b3-0242ac130003), object, pointer_default(unique)]
  4828. interface ICoreWebView2Frame : IUnknown {
  4829. /// The name of the iframe from the iframe html tag declaring it.
  4830. /// You can access this property even if the iframe is destroyed.
  4831. ///
  4832. /// The caller must free the returned string with `CoTaskMemFree`. See
  4833. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  4834. [propget] HRESULT Name([ out, retval ] LPWSTR * name);
  4835. /// Raised when the iframe changes its window.name property.
  4836. HRESULT add_NameChanged(
  4837. [in] ICoreWebView2FrameNameChangedEventHandler * eventHandler,
  4838. [out] EventRegistrationToken * token);
  4839. /// Remove an event handler previously added with add_NameChanged.
  4840. HRESULT remove_NameChanged([in] EventRegistrationToken token);
  4841. /// Add the provided host object to script running in the iframe with the
  4842. /// specified name for the list of the specified origins. The host object
  4843. /// will be accessible for this iframe only if the iframe's origin during
  4844. /// access matches one of the origins which are passed. The provided origins
  4845. /// will be normalized before comparing to the origin of the document.
  4846. /// So the scheme name is made lower case, the host will be punycode decoded
  4847. /// as appropriate, default port values will be removed, and so on.
  4848. /// This means the origin's host may be punycode encoded or not and will match
  4849. /// regardless. If list contains malformed origin the call will fail.
  4850. /// The method can be called multiple times in a row without calling
  4851. /// RemoveHostObjectFromScript for the same object name. It will replace
  4852. /// the previous object with the new object and new list of origins.
  4853. /// List of origins will be treated as following:
  4854. /// 1. empty list - call will succeed and object will be added for the iframe
  4855. /// but it will not be exposed to any origin;
  4856. /// 2. list with origins - during access to host object from iframe the
  4857. /// origin will be checked that it belongs to this list;
  4858. /// 3. list with "*" element - host object will be available for iframe for
  4859. /// all origins. We suggest not to use this feature without understanding
  4860. /// security implications of giving access to host object from from iframes
  4861. /// with unknown origins.
  4862. /// Calling this method fails if it is called after the iframe is destroyed.
  4863. /// \snippet ScenarioAddHostObject.cpp AddHostObjectToScriptWithOrigins
  4864. /// For more information about host objects navigate to
  4865. /// ICoreWebView2::AddHostObjectToScript.
  4866. HRESULT AddHostObjectToScriptWithOrigins(
  4867. [in] LPCWSTR name,
  4868. [in] VARIANT * object,
  4869. [in] UINT32 originsCount,
  4870. [ in, size_is(originsCount) ] LPCWSTR * origins);
  4871. /// Remove the host object specified by the name so that it is no longer
  4872. /// accessible from JavaScript code in the iframe. While new access
  4873. /// attempts are denied, if the object is already obtained by JavaScript code
  4874. /// in the iframe, the JavaScript code continues to have access to that
  4875. /// object. Calling this method for a name that is already removed or was
  4876. /// never added fails. If the iframe is destroyed this method will return fail
  4877. /// also.
  4878. HRESULT RemoveHostObjectFromScript([in] LPCWSTR name);
  4879. /// The Destroyed event is raised when the iframe corresponding
  4880. /// to this CoreWebView2Frame object is removed or the document
  4881. /// containing that iframe is destroyed.
  4882. HRESULT add_Destroyed(
  4883. [in] ICoreWebView2FrameDestroyedEventHandler * eventHandler,
  4884. [out] EventRegistrationToken * token);
  4885. /// Remove an event handler previously added with add_Destroyed.
  4886. HRESULT remove_Destroyed([in] EventRegistrationToken token);
  4887. /// Check whether a frame is destroyed. Returns true during
  4888. /// the Destroyed event.
  4889. HRESULT IsDestroyed([ out, retval ] BOOL * destroyed);
  4890. }
  4891. /// A continuation of the ICoreWebView2Frame interface with navigation events,
  4892. /// executing script and posting web messages.
  4893. [uuid(7a6a5834-d185-4dbf-b63f-4a9bc43107d4), object, pointer_default(unique)]
  4894. interface ICoreWebView2Frame2 : ICoreWebView2Frame {
  4895. /// Add an event handler for the `NavigationStarting` event.
  4896. /// A frame navigation will raise a `NavigationStarting` event and
  4897. /// a `CoreWebView2.FrameNavigationStarting` event. All of the
  4898. /// `FrameNavigationStarting` event handlers for the current frame will be
  4899. /// run before the `NavigationStarting` event handlers. All of the event handlers
  4900. /// share a common `NavigationStartingEventArgs` object. Whichever event handler is
  4901. /// last to change the `NavigationStartingEventArgs.Cancel` property will
  4902. /// decide if the frame navigation will be cancelled. Redirects raise this
  4903. /// event as well, and the navigation id is the same as the original one.
  4904. ///
  4905. /// Navigations will be blocked until all `NavigationStarting` and
  4906. /// `CoreWebView2.FrameNavigationStarting` event handlers return.
  4907. HRESULT add_NavigationStarting(
  4908. [in] ICoreWebView2FrameNavigationStartingEventHandler* eventHandler,
  4909. [out] EventRegistrationToken* token);
  4910. /// Remove an event handler previously added with `add_NavigationStarting`.
  4911. HRESULT remove_NavigationStarting(
  4912. [in] EventRegistrationToken token);
  4913. /// Add an event handler for the `ContentLoading` event. `ContentLoading`
  4914. /// triggers before any content is loaded, including scripts added with
  4915. /// `AddScriptToExecuteOnDocumentCreated`. `ContentLoading` does not trigger
  4916. /// if a same page navigation occurs (such as through `fragment`
  4917. /// navigations or `history.pushState` navigations). This operation
  4918. /// follows the `NavigationStarting` and precedes `NavigationCompleted` events.
  4919. HRESULT add_ContentLoading(
  4920. [in] ICoreWebView2FrameContentLoadingEventHandler * eventHandler,
  4921. [out] EventRegistrationToken* token);
  4922. /// Remove an event handler previously added with `add_ContentLoading`.
  4923. HRESULT remove_ContentLoading(
  4924. [in] EventRegistrationToken token);
  4925. /// Add an event handler for the `NavigationCompleted` event.
  4926. /// `NavigationCompleted` runs when the CoreWebView2Frame has completely
  4927. /// loaded (concurrently when `body.onload` runs) or loading stopped with error.
  4928. HRESULT add_NavigationCompleted(
  4929. [in] ICoreWebView2FrameNavigationCompletedEventHandler *
  4930. eventHandler,
  4931. [out] EventRegistrationToken* token);
  4932. /// Remove an event handler previously added with `add_NavigationCompleted`.
  4933. HRESULT remove_NavigationCompleted(
  4934. [in] EventRegistrationToken token);
  4935. /// Add an event handler for the DOMContentLoaded event.
  4936. /// DOMContentLoaded is raised when the iframe html document has been parsed.
  4937. /// This aligns with the document's DOMContentLoaded event in html.
  4938. HRESULT add_DOMContentLoaded(
  4939. [in] ICoreWebView2FrameDOMContentLoadedEventHandler * eventHandler,
  4940. [out] EventRegistrationToken* token);
  4941. /// Remove an event handler previously added with add_DOMContentLoaded.
  4942. HRESULT remove_DOMContentLoaded(
  4943. [in] EventRegistrationToken token);
  4944. /// Run JavaScript code from the javascript parameter in the current frame.
  4945. /// The result of evaluating the provided JavaScript is passed to the completion handler.
  4946. /// The result value is a JSON encoded string. If the result is undefined,
  4947. /// contains a reference cycle, or otherwise is not able to be encoded into
  4948. /// JSON, then the result is considered to be null, which is encoded
  4949. /// in JSON as the string "null".
  4950. ///
  4951. /// \> [!NOTE]\n\> A function that has no explicit return value returns undefined. If the
  4952. /// script that was run throws an unhandled exception, then the result is
  4953. /// also "null". This method is applied asynchronously. If the method is
  4954. /// run before `ContentLoading`, the script will not be executed
  4955. /// and the string "null" will be returned.
  4956. /// This operation executes the script even if `ICoreWebView2Settings::IsScriptEnabled` is
  4957. /// set to `FALSE`.
  4958. ///
  4959. /// \snippet ScenarioDOMContentLoaded.cpp ExecuteScriptFrame
  4960. HRESULT ExecuteScript(
  4961. [in] LPCWSTR javaScript,
  4962. [in] ICoreWebView2ExecuteScriptCompletedHandler* handler);
  4963. /// Posts the specified webMessage to the frame.
  4964. /// The frame receives the message by subscribing to the `message` event of
  4965. /// the `window.chrome.webview` of the frame document.
  4966. ///
  4967. /// ```cpp
  4968. /// window.chrome.webview.addEventListener('message', handler)
  4969. /// window.chrome.webview.removeEventListener('message', handler)
  4970. /// ```
  4971. ///
  4972. /// The event args is an instances of `MessageEvent`. The
  4973. /// `ICoreWebView2Settings::IsWebMessageEnabled` setting must be `TRUE` or
  4974. /// this method fails with `E_INVALIDARG`. The `data` property of the event
  4975. /// args is the `webMessage` string parameter parsed as a JSON string into a
  4976. /// JavaScript object. The `source` property of the event args is a reference
  4977. /// to the `window.chrome.webview` object. For information about sending
  4978. /// messages from the HTML document in the WebView to the host, navigate to
  4979. /// [add_WebMessageReceived](/microsoft-edge/webview2/reference/win32/icorewebview2#add_webmessagereceived).
  4980. /// The message is delivered asynchronously. If a navigation occurs before the
  4981. /// message is posted to the page, the message is discarded.
  4982. HRESULT PostWebMessageAsJson([in] LPCWSTR webMessageAsJson);
  4983. /// Posts a message that is a simple string rather than a JSON string
  4984. /// representation of a JavaScript object. This behaves in exactly the same
  4985. /// manner as `PostWebMessageAsJson`, but the `data` property of the event
  4986. /// args of the `window.chrome.webview` message is a string with the same
  4987. /// value as `webMessageAsString`. Use this instead of
  4988. /// `PostWebMessageAsJson` if you want to communicate using simple strings
  4989. /// rather than JSON objects.
  4990. HRESULT PostWebMessageAsString([in] LPCWSTR webMessageAsString);
  4991. /// Add an event handler for the `WebMessageReceived` event.
  4992. /// `WebMessageReceived` runs when the
  4993. /// `ICoreWebView2Settings::IsWebMessageEnabled` setting is set and the
  4994. /// frame document runs `window.chrome.webview.postMessage`.
  4995. /// The `postMessage` function is `void postMessage(object)`
  4996. /// where object is any object supported by JSON conversion.
  4997. ///
  4998. /// \snippet assets\ScenarioWebMessage.html chromeWebView
  4999. ///
  5000. /// When the frame calls `postMessage`, the object parameter is converted to a
  5001. /// JSON string and is posted asynchronously to the host process. This will
  5002. /// result in the handlers `Invoke` method being called with the JSON string
  5003. /// as its parameter.
  5004. ///
  5005. /// \snippet ScenarioWebMessage.cpp WebMessageReceivedIFrame
  5006. HRESULT add_WebMessageReceived(
  5007. [in] ICoreWebView2FrameWebMessageReceivedEventHandler *
  5008. handler,
  5009. [out] EventRegistrationToken * token);
  5010. /// Remove an event handler previously added with `add_WebMessageReceived`.
  5011. HRESULT remove_WebMessageReceived([in] EventRegistrationToken token);
  5012. }
  5013. /// Receives `FrameCreated` event.
  5014. [uuid(38059770-9baa-11eb-a8b3-0242ac130003), object, pointer_default(unique)]
  5015. interface ICoreWebView2FrameCreatedEventHandler : IUnknown {
  5016. /// Provides the result for the iframe created event.
  5017. HRESULT Invoke([in] ICoreWebView2 * sender,
  5018. [in] ICoreWebView2FrameCreatedEventArgs * args);
  5019. }
  5020. /// Receives `FrameNameChanged` event.
  5021. [uuid(435c7dc8-9baa-11eb-a8b3-0242ac130003), object, pointer_default(unique)]
  5022. interface ICoreWebView2FrameNameChangedEventHandler : IUnknown {
  5023. /// Provides the result for the iframe name changed event.
  5024. /// No event args exist and the `args` parameter is set to `null`.
  5025. HRESULT Invoke([in] ICoreWebView2Frame * sender, [in] IUnknown * args);
  5026. }
  5027. /// Receives `NavigationStarting` events for iframe.
  5028. [uuid(e79908bf-2d5d-4968-83db-263fea2c1da3), object, pointer_default(unique)]
  5029. interface ICoreWebView2FrameNavigationStartingEventHandler : IUnknown {
  5030. /// Provides the event args for the corresponding event.
  5031. HRESULT Invoke(
  5032. [in] ICoreWebView2Frame* sender,
  5033. [in] ICoreWebView2NavigationStartingEventArgs* args);
  5034. }
  5035. /// Receives `ContentLoading` events for iframe.
  5036. [uuid(0d6156f2-d332-49a7-9e03-7d8f2feeee54), object, pointer_default(unique)]
  5037. interface ICoreWebView2FrameContentLoadingEventHandler : IUnknown {
  5038. /// Provides the event args for the corresponding event.
  5039. HRESULT Invoke(
  5040. [in] ICoreWebView2Frame* sender,
  5041. [in] ICoreWebView2ContentLoadingEventArgs* args);
  5042. }
  5043. /// Receives `NavigationCompleted` events for iframe.
  5044. [uuid(609302ad-0e36-4f9a-a210-6a45272842a9), object, pointer_default(unique)]
  5045. interface ICoreWebView2FrameNavigationCompletedEventHandler : IUnknown {
  5046. /// Provides the event args for the corresponding event.
  5047. HRESULT Invoke(
  5048. [in] ICoreWebView2Frame* sender,
  5049. [in] ICoreWebView2NavigationCompletedEventArgs* args);
  5050. }
  5051. /// Receives `DOMContentLoaded` events for iframe.
  5052. [uuid(38d9520d-340f-4d1e-a775-43fce9753683), object, pointer_default(unique)]
  5053. interface ICoreWebView2FrameDOMContentLoadedEventHandler : IUnknown {
  5054. /// Provides the event args for the corresponding event.
  5055. HRESULT Invoke(
  5056. [in] ICoreWebView2Frame* sender,
  5057. [in] ICoreWebView2DOMContentLoadedEventArgs* args);
  5058. }
  5059. /// Receives `WebMessageReceived` events for iframe.
  5060. [uuid(e371e005-6d1d-4517-934b-a8f1629c62a5), object, pointer_default(unique)]
  5061. interface ICoreWebView2FrameWebMessageReceivedEventHandler : IUnknown {
  5062. /// Provides the event args for the corresponding event.
  5063. HRESULT Invoke(
  5064. [in] ICoreWebView2Frame* sender,
  5065. [in] ICoreWebView2WebMessageReceivedEventArgs* args);
  5066. }
  5067. /// Event args for the `FrameCreated` events.
  5068. [uuid(4d6e7b5e-9baa-11eb-a8b3-0242ac130003), object, pointer_default(unique)]
  5069. interface ICoreWebView2FrameCreatedEventArgs : IUnknown {
  5070. /// The frame which was created.
  5071. [propget] HRESULT Frame([ out, retval ] ICoreWebView2Frame **frame);
  5072. }
  5073. /// Receives `FrameDestroyed` event.
  5074. [uuid(59dd7b4c-9baa-11eb-a8b3-0242ac130003), object, pointer_default(unique)]
  5075. interface ICoreWebView2FrameDestroyedEventHandler : IUnknown {
  5076. /// Provides the result for the iframe destroyed event.
  5077. /// No event args exist and the `args` parameter is set to `null`.
  5078. HRESULT Invoke([in] ICoreWebView2Frame * sender, [in] IUnknown * args);
  5079. }
  5080. /// Add an event handler for the `DownloadStarting` event.
  5081. [uuid(efedc989-c396-41ca-83f7-07f845a55724), object, pointer_default(unique)]
  5082. interface ICoreWebView2DownloadStartingEventHandler : IUnknown {
  5083. /// Provides the event args for the corresponding event.
  5084. HRESULT Invoke(
  5085. [in] ICoreWebView2* sender,
  5086. [in] ICoreWebView2DownloadStartingEventArgs* args);
  5087. }
  5088. /// Event args for the `DownloadStarting` event.
  5089. [uuid(e99bbe21-43e9-4544-a732-282764eafa60), object, pointer_default(unique)]
  5090. interface ICoreWebView2DownloadStartingEventArgs : IUnknown {
  5091. /// Returns the `ICoreWebView2DownloadOperation` for the download that
  5092. /// has started.
  5093. [propget] HRESULT DownloadOperation(
  5094. [out, retval] ICoreWebView2DownloadOperation** downloadOperation);
  5095. /// The host may set this flag to cancel the download. If canceled, the
  5096. /// download save dialog is not displayed regardless of the
  5097. /// `Handled` property.
  5098. [propget] HRESULT Cancel([out, retval] BOOL* cancel);
  5099. /// Sets the `Cancel` property.
  5100. [propput] HRESULT Cancel([in] BOOL cancel);
  5101. /// The path to the file. If setting the path, the host should ensure that it
  5102. /// is an absolute path, including the file name, and that the path does not
  5103. /// point to an existing file. If the path points to an existing file, the
  5104. /// file will be overwritten. If the directory does not exist, it is created.
  5105. ///
  5106. /// The caller must free the returned string with `CoTaskMemFree`. See
  5107. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5108. [propget] HRESULT ResultFilePath([out, retval] LPWSTR* resultFilePath);
  5109. /// Sets the `ResultFilePath` property.
  5110. [propput] HRESULT ResultFilePath([in] LPCWSTR resultFilePath);
  5111. /// The host may set this flag to `TRUE` to hide the default download dialog
  5112. /// for this download. The download will progress as normal if it is not
  5113. /// canceled, there will just be no default UI shown. By default the value is
  5114. /// `FALSE` and the default download dialog is shown.
  5115. [propget] HRESULT Handled([out, retval] BOOL* handled);
  5116. /// Sets the `Handled` property.
  5117. [propput] HRESULT Handled([in] BOOL handled);
  5118. /// Returns an `ICoreWebView2Deferral` object. Use this operation to
  5119. /// complete the event at a later time.
  5120. HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral);
  5121. }
  5122. /// Implements the interface to receive `BytesReceivedChanged` event. Use the
  5123. /// `ICoreWebView2DownloadOperation.BytesReceived` property to get the received
  5124. /// bytes count.
  5125. [uuid(828e8ab6-d94c-4264-9cef-5217170d6251), object, pointer_default(unique)]
  5126. interface ICoreWebView2BytesReceivedChangedEventHandler : IUnknown {
  5127. /// Provides the event args for the corresponding event. No event args exist
  5128. /// and the `args` parameter is set to `null`.
  5129. HRESULT Invoke(
  5130. [in] ICoreWebView2DownloadOperation* sender, [in] IUnknown* args);
  5131. }
  5132. /// Implements the interface to receive `EstimatedEndTimeChanged` event. Use the
  5133. /// `ICoreWebView2DownloadOperation.EstimatedEndTime` property to get the new
  5134. /// estimated end time.
  5135. [uuid(28f0d425-93fe-4e63-9f8d-2aeec6d3ba1e), object, pointer_default(unique)]
  5136. interface ICoreWebView2EstimatedEndTimeChangedEventHandler : IUnknown {
  5137. /// Provides the event args for the corresponding event. No event args exist
  5138. /// and the `args` parameter is set to `null`.
  5139. HRESULT Invoke(
  5140. [in] ICoreWebView2DownloadOperation* sender, [in] IUnknown* args);
  5141. }
  5142. /// Implements the interface to receive `StateChanged` event. Use the
  5143. /// `ICoreWebView2DownloadOperation.State` property to get the current state,
  5144. /// which can be in progress, interrupted, or completed. Use the
  5145. /// `ICoreWebView2DownloadOperation.InterruptReason` property to get the
  5146. /// interrupt reason if the download is interrupted.
  5147. [uuid(81336594-7ede-4ba9-bf71-acf0a95b58dd), object, pointer_default(unique)]
  5148. interface ICoreWebView2StateChangedEventHandler : IUnknown {
  5149. /// Provides the event args for the corresponding event. No event args exist
  5150. /// and the `args` parameter is set to `null`.
  5151. HRESULT Invoke(
  5152. [in] ICoreWebView2DownloadOperation* sender, [in] IUnknown* args);
  5153. }
  5154. /// Represents a download operation. Gives access to the download's metadata
  5155. /// and supports a user canceling, pausing, or resuming the download.
  5156. [uuid(3d6b6cf2-afe1-44c7-a995-c65117714336), object, pointer_default(unique)]
  5157. interface ICoreWebView2DownloadOperation : IUnknown {
  5158. /// Add an event handler for the `BytesReceivedChanged` event.
  5159. ///
  5160. /// \snippet ScenarioCustomDownloadExperience.cpp BytesReceivedChanged
  5161. HRESULT add_BytesReceivedChanged(
  5162. [in] ICoreWebView2BytesReceivedChangedEventHandler* eventHandler,
  5163. [out] EventRegistrationToken* token);
  5164. /// Remove an event handler previously added with `add_BytesReceivedChanged`.
  5165. HRESULT remove_BytesReceivedChanged(
  5166. [in] EventRegistrationToken token);
  5167. /// Add an event handler for the `EstimatedEndTimeChanged` event.
  5168. HRESULT add_EstimatedEndTimeChanged(
  5169. [in] ICoreWebView2EstimatedEndTimeChangedEventHandler* eventHandler,
  5170. [out] EventRegistrationToken* token);
  5171. /// Remove an event handler previously added with `add_EstimatedEndTimeChanged`.
  5172. HRESULT remove_EstimatedEndTimeChanged(
  5173. [in] EventRegistrationToken token);
  5174. /// Add an event handler for the `StateChanged` event.
  5175. ///
  5176. /// \snippet ScenarioCustomDownloadExperience.cpp StateChanged
  5177. HRESULT add_StateChanged(
  5178. [in] ICoreWebView2StateChangedEventHandler* eventHandler,
  5179. [out] EventRegistrationToken* token);
  5180. /// Remove an event handler previously added with `add_StateChanged`.
  5181. HRESULT remove_StateChanged(
  5182. [in] EventRegistrationToken token);
  5183. /// The URI of the download.
  5184. ///
  5185. /// The caller must free the returned string with `CoTaskMemFree`. See
  5186. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5187. [propget] HRESULT Uri([out, retval] LPWSTR* uri);
  5188. /// The Content-Disposition header value from the download's HTTP response.
  5189. ///
  5190. /// The caller must free the returned string with `CoTaskMemFree`. See
  5191. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5192. [propget] HRESULT ContentDisposition([out, retval] LPWSTR* contentDisposition);
  5193. /// MIME type of the downloaded content.
  5194. ///
  5195. /// The caller must free the returned string with `CoTaskMemFree`. See
  5196. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5197. [propget] HRESULT MimeType([out, retval] LPWSTR* mimeType);
  5198. /// The expected size of the download in total number of bytes based on the
  5199. /// HTTP Content-Length header. Returns -1 if the size is unknown.
  5200. [propget] HRESULT TotalBytesToReceive([out, retval] INT64* totalBytesToReceive);
  5201. /// The number of bytes that have been written to the download file.
  5202. [propget] HRESULT BytesReceived([out, retval] INT64* bytesReceived);
  5203. /// The estimated end time in [ISO 8601 Date and Time Format](https://www.iso.org/iso-8601-date-and-time-format.html).
  5204. ///
  5205. /// The caller must free the returned string with `CoTaskMemFree`. See
  5206. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5207. [propget] HRESULT EstimatedEndTime([out, retval] LPWSTR* estimatedEndTime);
  5208. /// The absolute path to the download file, including file name. Host can change
  5209. /// this from `ICoreWebView2DownloadStartingEventArgs`.
  5210. ///
  5211. /// The caller must free the returned string with `CoTaskMemFree`. See
  5212. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5213. [propget] HRESULT ResultFilePath([out, retval] LPWSTR* resultFilePath);
  5214. /// The state of the download. A download can be in progress, interrupted, or
  5215. /// completed. See `COREWEBVIEW2_DOWNLOAD_STATE` for descriptions of states.
  5216. [propget] HRESULT State([out, retval] COREWEBVIEW2_DOWNLOAD_STATE* downloadState);
  5217. /// The reason why connection with file host was broken.
  5218. [propget] HRESULT InterruptReason(
  5219. [out, retval] COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON* interruptReason);
  5220. /// Cancels the download. If canceled, the default download dialog shows
  5221. /// that the download was canceled. Host should set the `Cancel` property from
  5222. /// `ICoreWebView2SDownloadStartingEventArgs` if the download should be
  5223. /// canceled without displaying the default download dialog.
  5224. HRESULT Cancel();
  5225. /// Pauses the download. If paused, the default download dialog shows that the
  5226. /// download is paused. No effect if download is already paused. Pausing a
  5227. /// download changes the state to `COREWEBVIEW2_DOWNLOAD_STATE_INTERRUPTED`
  5228. /// with `InterruptReason` set to `COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_USER_PAUSED`.
  5229. HRESULT Pause();
  5230. /// Resumes a paused download. May also resume a download that was interrupted
  5231. /// for another reason, if `CanResume` returns true. Resuming a download changes
  5232. /// the state from `COREWEBVIEW2_DOWNLOAD_STATE_INTERRUPTED` to
  5233. /// `COREWEBVIEW2_DOWNLOAD_STATE_IN_PROGRESS`.
  5234. HRESULT Resume();
  5235. /// Returns true if an interrupted download can be resumed. Downloads with
  5236. /// the following interrupt reasons may automatically resume without you
  5237. /// calling any methods:
  5238. /// `COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE`,
  5239. /// `COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_HASH_MISMATCH`,
  5240. /// `COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_TOO_SHORT`.
  5241. /// In these cases download progress may be restarted with `BytesReceived`
  5242. /// reset to 0.
  5243. [propget] HRESULT CanResume([out, retval] BOOL* canResume);
  5244. }
  5245. /// A continuation of the ICoreWebView2ProcessFailedEventArgs interface.
  5246. [uuid(4dab9422-46fa-4c3e-a5d2-41d2071d3680), object, pointer_default(unique)]
  5247. interface ICoreWebView2ProcessFailedEventArgs2 : ICoreWebView2ProcessFailedEventArgs {
  5248. /// The reason for the process failure. The reason is always
  5249. /// `COREWEBVIEW2_PROCESS_FAILED_REASON_UNEXPECTED` when `ProcessFailedKind`
  5250. /// is `COREWEBVIEW2_PROCESS_FAILED_KIND_BROWSER_PROCESS_EXITED`, and
  5251. /// `COREWEBVIEW2_PROCESS_FAILED_REASON_UNRESPONSIVE` when `ProcessFailedKind`
  5252. /// is `COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_UNRESPONSIVE`.
  5253. /// For other process failure kinds, the reason may be any of the reason
  5254. /// values.
  5255. [propget] HRESULT Reason(
  5256. [out, retval] COREWEBVIEW2_PROCESS_FAILED_REASON* reason);
  5257. /// The exit code of the failing process, for telemetry purposes. The exit
  5258. /// code is always `STILL_ACTIVE` (`259`) when `ProcessFailedKind` is
  5259. /// `COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_UNRESPONSIVE`.
  5260. [propget] HRESULT ExitCode(
  5261. [out, retval] int* exitCode);
  5262. /// Description of the process assigned by the WebView2 Runtime. This is a
  5263. /// technical English term appropriate for logging or development purposes,
  5264. /// and not localized for the end user. It applies to utility processes (for
  5265. /// example, "Audio Service", "Video Capture") and plugin processes (for
  5266. /// example, "Flash"). The returned `processDescription` is empty if the
  5267. /// WebView2 Runtime did not assign a description to the process.
  5268. ///
  5269. /// The caller must free the returned string with `CoTaskMemFree`. See
  5270. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5271. [propget] HRESULT ProcessDescription(
  5272. [out, retval] LPWSTR* processDescription);
  5273. /// The collection of `FrameInfo`s for frames in the `ICoreWebView2` that were
  5274. /// being rendered by the failed process. The content in these frames is
  5275. /// replaced with an error page.
  5276. /// This is only available when `ProcessFailedKind` is
  5277. /// `COREWEBVIEW2_PROCESS_FAILED_KIND_FRAME_RENDER_PROCESS_EXITED`;
  5278. /// `frames` is `null` for all other process failure kinds, including the case
  5279. /// in which the failed process was the renderer for the main frame and
  5280. /// subframes within it, for which the failure kind is
  5281. /// `COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_EXITED`.
  5282. [propget] HRESULT FrameInfosForFailedProcess(
  5283. [out, retval] ICoreWebView2FrameInfoCollection** frames);
  5284. }
  5285. /// Collection of `FrameInfo`s (name and source). Used to list the affected
  5286. /// frames' info when a frame-only render process failure occurs in the
  5287. /// `ICoreWebView2`.
  5288. [uuid(8f834154-d38e-4d90-affb-6800a7272839), object, pointer_default(unique)]
  5289. interface ICoreWebView2FrameInfoCollection : IUnknown {
  5290. /// Gets an iterator over the collection of `FrameInfo`s.
  5291. HRESULT GetIterator(
  5292. [out, retval] ICoreWebView2FrameInfoCollectionIterator** iterator);
  5293. }
  5294. /// Iterator for a collection of `FrameInfo`s. For more info, see
  5295. /// `ICoreWebView2ProcessFailedEventArgs2` and
  5296. /// `ICoreWebView2FrameInfoCollection`.
  5297. [uuid(1bf89e2d-1b2b-4629-b28f-05099b41bb03), object, pointer_default(unique)]
  5298. interface ICoreWebView2FrameInfoCollectionIterator : IUnknown {
  5299. /// `TRUE` when the iterator has not run out of `FrameInfo`s. If the
  5300. /// collection over which the iterator is iterating is empty or if the
  5301. /// iterator has gone past the end of the collection, then this is `FALSE`.
  5302. [propget] HRESULT HasCurrent([out, retval] BOOL* hasCurrent);
  5303. /// Get the current `ICoreWebView2FrameInfo` of the iterator.
  5304. /// Returns `HRESULT_FROM_WIN32(ERROR_INVALID_INDEX)` if HasCurrent is
  5305. /// `FALSE`.
  5306. HRESULT GetCurrent([out, retval] ICoreWebView2FrameInfo** frameInfo);
  5307. /// Move the iterator to the next `FrameInfo` in the collection.
  5308. HRESULT MoveNext([out, retval] BOOL* hasNext);
  5309. }
  5310. /// Provides a set of properties for a frame in the `ICoreWebView2`.
  5311. [uuid(da86b8a1-bdf3-4f11-9955-528cefa59727), object, pointer_default(unique)]
  5312. interface ICoreWebView2FrameInfo : IUnknown {
  5313. /// The name attribute of the frame, as in `<iframe name="frame-name" ...>`.
  5314. /// The returned string is empty when the frame has no name attribute.
  5315. ///
  5316. /// The caller must free the returned string with `CoTaskMemFree`. See
  5317. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5318. [propget] HRESULT Name([out, retval] LPWSTR* name);
  5319. /// The URI of the document in the frame.
  5320. ///
  5321. /// The caller must free the returned string with `CoTaskMemFree`. See
  5322. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5323. [propget] HRESULT Source([out, retval] LPWSTR* source);
  5324. }
  5325. /// Represents a Basic HTTP authentication response that contains a user name
  5326. /// and a password as according to RFC7617 (https://tools.ietf.org/html/rfc7617)
  5327. [uuid(07023f7d-2d77-4d67-9040-6e7d428c6a40), object, pointer_default(unique)]
  5328. interface ICoreWebView2BasicAuthenticationResponse : IUnknown {
  5329. /// User name provided for authentication.
  5330. ///
  5331. /// The caller must free the returned string with `CoTaskMemFree`. See
  5332. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5333. [propget] HRESULT UserName([out, retval] LPWSTR* userName);
  5334. /// Set user name property
  5335. [propput] HRESULT UserName([in] LPCWSTR userName);
  5336. /// Password provided for authentication.
  5337. ///
  5338. /// The caller must free the returned string with `CoTaskMemFree`. See
  5339. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5340. [propget] HRESULT Password([out, retval] LPWSTR* password);
  5341. /// Set password property
  5342. [propput] HRESULT Password([in] LPCWSTR password);
  5343. }
  5344. /// Event args for the BasicAuthenticationRequested event. Will contain the
  5345. /// request that led to the HTTP authorization challenge, the challenge
  5346. /// and allows the host to provide authentication response or cancel the request.
  5347. [uuid(ef05516f-d897-4f9e-b672-d8e2307a3fb0), object, pointer_default(unique)]
  5348. interface ICoreWebView2BasicAuthenticationRequestedEventArgs : IUnknown {
  5349. /// The URI that led to the authentication challenge
  5350. ///
  5351. /// The caller must free the returned string with `CoTaskMemFree`. See
  5352. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5353. [propget] HRESULT Uri([out, retval] LPWSTR* value);
  5354. /// The authentication challenge string
  5355. ///
  5356. /// The caller must free the returned string with `CoTaskMemFree`. See
  5357. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5358. [propget] HRESULT Challenge([out, retval] LPWSTR* challenge);
  5359. /// Response to the authentication request with credentials. This object will be populated by the app
  5360. /// if the host would like to provide authentication credentials.
  5361. [propget] HRESULT Response([out, retval] ICoreWebView2BasicAuthenticationResponse** response);
  5362. /// Cancel the authentication request. False by default.
  5363. /// If set to true, Response will be ignored.
  5364. [propget] HRESULT Cancel([out, retval] BOOL* cancel);
  5365. /// Set the Cancel property.
  5366. [propput] HRESULT Cancel([in] BOOL cancel);
  5367. /// Returns an `ICoreWebView2Deferral` object. Use this deferral to
  5368. /// defer the decision to show the Basic Authentication dialog.
  5369. HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral);
  5370. }
  5371. /// Implements the interface to receive `IsDocumentPlayingAudioChanged` events. Use the
  5372. /// IsDocumentPlayingAudio property to get the audio playing state.
  5373. [uuid(5DEF109A-2F4B-49FA-B7F6-11C39E513328), object, pointer_default(unique)]
  5374. interface ICoreWebView2IsDocumentPlayingAudioChangedEventHandler : IUnknown {
  5375. /// Provides the event args for the corresponding event. No event args exist
  5376. /// and the `args` parameter is set to `null`.
  5377. HRESULT Invoke([in] ICoreWebView2* sender, [in] IUnknown* args);
  5378. }
  5379. /// Implements the interface to receive `IsMutedChanged` events. Use the
  5380. /// IsMuted property to get the mute state.
  5381. [uuid(57D90347-CD0E-4952-A4A2-7483A2756F08), object, pointer_default(unique)]
  5382. interface ICoreWebView2IsMutedChangedEventHandler : IUnknown {
  5383. /// Provides the event args for the corresponding event. No event args exist
  5384. /// and the `args` parameter is set to `null`.
  5385. HRESULT Invoke([in] ICoreWebView2* sender, [in] IUnknown* args);
  5386. }
  5387. /// This is an extension of the ICoreWebView2Frame interface that supports PermissionRequested
  5388. [uuid(b50d82cc-cc28-481d-9614-cb048895e6a0), object, pointer_default(unique)]
  5389. interface ICoreWebView2Frame3 : ICoreWebView2Frame2 {
  5390. /// Add an event handler for the `PermissionRequested` event.
  5391. /// `PermissionRequested` is raised when content in an iframe any of its
  5392. /// descendant iframes requests permission to privileged resources.
  5393. ///
  5394. /// This relates to the `PermissionRequested` event on the `CoreWebView2`.
  5395. /// Both these events will be raised in the case of an iframe requesting
  5396. /// permission. The `CoreWebView2Frame`'s event handlers will be invoked
  5397. /// before the event handlers on the `CoreWebView2`. If the `Handled` property
  5398. /// of the `PermissionRequestedEventArgs` is set to TRUE within the
  5399. /// `CoreWebView2Frame` event handler, then the event will not be
  5400. /// raised on the `CoreWebView2`, and it's event handlers will not be invoked.
  5401. ///
  5402. /// In the case of nested iframes, the 'PermissionRequested' event will
  5403. /// be raised from the top level iframe.
  5404. ///
  5405. /// If a deferral is not taken on the event args, the subsequent scripts are
  5406. /// blocked until the event handler returns. If a deferral is taken, the
  5407. /// scripts are blocked until the deferral is completed.
  5408. ///
  5409. /// \snippet ScenarioIFrameDevicePermission.cpp PermissionRequested0
  5410. /// \snippet ScenarioIFrameDevicePermission.cpp PermissionRequested1
  5411. HRESULT add_PermissionRequested(
  5412. [in] ICoreWebView2FramePermissionRequestedEventHandler* handler,
  5413. [out] EventRegistrationToken* token);
  5414. /// Remove an event handler previously added with `add_PermissionRequested`
  5415. HRESULT remove_PermissionRequested(
  5416. [in] EventRegistrationToken token);
  5417. }
  5418. /// Receives `PermissionRequested` events for iframes.
  5419. [uuid(845d0edd-8bd8-429b-9915-4821789f23e9), object, pointer_default(unique)]
  5420. interface ICoreWebView2FramePermissionRequestedEventHandler : IUnknown {
  5421. /// Provides the event args for the corresponding event.
  5422. HRESULT Invoke(
  5423. [in] ICoreWebView2Frame* sender,
  5424. [in] ICoreWebView2PermissionRequestedEventArgs2* args);
  5425. }
  5426. /// This is a continuation of the `ICoreWebView2PermissionRequestedEventArgs` interface.
  5427. [uuid(74d7127f-9de6-4200-8734-42d6fb4ff741), object, pointer_default(unique)]
  5428. interface ICoreWebView2PermissionRequestedEventArgs2: ICoreWebView2PermissionRequestedEventArgs {
  5429. /// By default, both the `PermissionRequested` event handlers on the
  5430. /// `CoreWebView2Frame' and the `CoreWebView2` will be invoked, with the
  5431. /// `CoreWebView2Frame' event handlers invoked first. The host may
  5432. /// set this flag to `TRUE` within the `CoreWebView2Frame' event handlers
  5433. /// to prevent the remaining `CoreWebView2` event handlers from being invoked.
  5434. ///
  5435. /// If a deferral is taken on the event args, then you must synchronously
  5436. /// set `Handled` to TRUE prior to taking your deferral to prevent the
  5437. /// `CoreWebView2`s event handlers from being invoked.
  5438. [propget] HRESULT Handled([out, retval] BOOL* handled);
  5439. /// Sets the `Handled` property.
  5440. [propput] HRESULT Handled([in] BOOL handled);
  5441. }
  5442. /// Represents a context menu item of a context menu displayed by WebView.
  5443. [uuid(7aed49e3-a93f-497a-811c-749c6b6b6c65), object, pointer_default(unique)]
  5444. interface ICoreWebView2ContextMenuItem : IUnknown {
  5445. /// Gets the unlocalized name for the `ContextMenuItem`. Use this to
  5446. /// distinguish between context menu item types. This will be the English
  5447. /// label of the menu item in lower camel case. For example, the "Save as"
  5448. /// menu item will be "saveAs". Extension menu items will be "extension",
  5449. /// custom menu items will be "custom" and spellcheck items will be
  5450. /// "spellCheck".
  5451. /// Some example context menu item names are:
  5452. /// - "saveAs"
  5453. /// - "copyImage"
  5454. /// - "openLinkInNewWindow"
  5455. /// - "cut"
  5456. /// - "copy"
  5457. /// - "paste"
  5458. ///
  5459. /// The caller must free the returned string with `CoTaskMemFree`. See
  5460. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5461. [propget] HRESULT Name([out, retval] LPWSTR* value);
  5462. /// Gets the localized label for the `ContextMenuItem`. Will contain an
  5463. /// ampersand for characters to be used as keyboard accelerator.
  5464. ///
  5465. /// The caller must free the returned string with `CoTaskMemFree`. See
  5466. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5467. [propget] HRESULT Label([out, retval] LPWSTR* value);
  5468. /// Gets the Command ID for the `ContextMenuItem`. Use this to report the
  5469. /// `SelectedCommandId` in `ContextMenuRequested` event.
  5470. [propget] HRESULT CommandId([out, retval] INT32* value);
  5471. /// Gets the localized keyboard shortcut for this ContextMenuItem. It will be
  5472. /// the empty string if there is no keyboard shortcut. This is text intended
  5473. /// to be displayed to the end user to show the keyboard shortcut. For example
  5474. /// this property is Ctrl+Shift+I for the "Inspect" `ContextMenuItem`.
  5475. ///
  5476. /// The caller must free the returned string with `CoTaskMemFree`. See
  5477. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5478. [propget] HRESULT ShortcutKeyDescription([out, retval] LPWSTR* value);
  5479. /// Gets the Icon for the `ContextMenuItem` in PNG, Bitmap or SVG formats in the form of an IStream.
  5480. /// Stream will be rewound to the start of the image data.
  5481. [propget] HRESULT Icon([out, retval] IStream** value);
  5482. /// Gets the `ContextMenuItem` kind.
  5483. [propget] HRESULT Kind([out, retval] COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND* value);
  5484. /// Sets the enabled property of the `ContextMenuItem`. Must only be used in the case of a
  5485. /// custom context menu item. The default value for this is `TRUE`.
  5486. [propput] HRESULT IsEnabled([in] BOOL value);
  5487. /// Gets the enabled property of the `ContextMenuItem`.
  5488. [propget] HRESULT IsEnabled([out, retval] BOOL* value);
  5489. /// Sets the checked property of the `ContextMenuItem`. Must only be used for custom context
  5490. /// menu items that are of kind Check box or Radio.
  5491. [propput] HRESULT IsChecked([in] BOOL value);
  5492. /// Gets the checked property of the `ContextMenuItem`, used if the kind is Check box or Radio.
  5493. [propget] HRESULT IsChecked([out, retval] BOOL* value);
  5494. /// Gets the list of children menu items through a `ContextMenuItemCollection`
  5495. /// if the kind is Submenu. If the kind is not submenu, will return null.
  5496. [propget] HRESULT Children([out, retval] ICoreWebView2ContextMenuItemCollection** value);
  5497. /// Add an event handler for the `CustomItemSelected` event.
  5498. /// `CustomItemSelected` event is raised when the user selects this `ContextMenuItem`.
  5499. /// Will only be raised for end developer created context menu items
  5500. HRESULT add_CustomItemSelected(
  5501. [in] ICoreWebView2CustomItemSelectedEventHandler* eventHandler,
  5502. [out] EventRegistrationToken* token);
  5503. /// Remove an event handler previously added with `add_CustomItemSelected`.
  5504. HRESULT remove_CustomItemSelected(
  5505. [in] EventRegistrationToken token);
  5506. }
  5507. /// Represents a collection of `ContextMenuItem` objects. Used to get, remove and add
  5508. /// `ContextMenuItem` objects at the specified index.
  5509. [uuid(f562a2f5-c415-45cf-b909-d4b7c1e276d3), object, pointer_default(unique)]
  5510. interface ICoreWebView2ContextMenuItemCollection : IUnknown {
  5511. /// Gets the number of `ContextMenuItem` objects contained in the `ContextMenuItemCollection`.
  5512. [propget] HRESULT Count([out, retval] UINT32* value);
  5513. /// Gets the `ContextMenuItem` at the specified index.
  5514. HRESULT GetValueAtIndex([in] UINT32 index,
  5515. [out, retval] ICoreWebView2ContextMenuItem** value);
  5516. /// Removes the `ContextMenuItem` at the specified index.
  5517. HRESULT RemoveValueAtIndex([in] UINT32 index);
  5518. /// Inserts the `ContextMenuItem` at the specified index.
  5519. HRESULT InsertValueAtIndex(
  5520. [in] UINT32 index,
  5521. [in] ICoreWebView2ContextMenuItem* value);
  5522. }
  5523. /// Receives `ContextMenuRequested` events.
  5524. [uuid(04d3fe1d-ab87-42fb-a898-da241d35b63c), object, pointer_default(unique)]
  5525. interface ICoreWebView2ContextMenuRequestedEventHandler : IUnknown {
  5526. /// Called to provide the event args when a context menu is requested on a
  5527. /// WebView element.
  5528. HRESULT Invoke(
  5529. [in] ICoreWebView2* sender,
  5530. [in] ICoreWebView2ContextMenuRequestedEventArgs* args);
  5531. }
  5532. /// Raised to notify the host that the end user selected a custom
  5533. /// `ContextMenuItem`. `CustomItemSelected` event is raised on the specific
  5534. /// `ContextMenuItem` that the end user selected.
  5535. [uuid(49e1d0bc-fe9e-4481-b7c2-32324aa21998), object, pointer_default(unique)]
  5536. interface ICoreWebView2CustomItemSelectedEventHandler : IUnknown {
  5537. /// Provides the event args for the corresponding event. No event args exist
  5538. /// and the `args` parameter is set to `null`.
  5539. HRESULT Invoke(
  5540. [in] ICoreWebView2ContextMenuItem* sender, [in] IUnknown* args);
  5541. }
  5542. /// Represents the information regarding the context menu target.
  5543. /// Includes the context selected and the appropriate data used for the actions of a context menu.
  5544. [uuid(b8611d99-eed6-4f3f-902c-a198502ad472), object, pointer_default(unique)]
  5545. interface ICoreWebView2ContextMenuTarget : IUnknown {
  5546. /// Gets the kind of context that the user selected.
  5547. [propget] HRESULT Kind([out, retval] COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND* value);
  5548. /// Returns TRUE if the context menu is requested on an editable component.
  5549. [propget] HRESULT IsEditable([out, retval] BOOL* value);
  5550. /// Returns TRUE if the context menu was requested on the main frame and
  5551. /// FALSE if invoked on another frame.
  5552. [propget] HRESULT IsRequestedForMainFrame([out, retval] BOOL* value);
  5553. /// Gets the uri of the page.
  5554. ///
  5555. /// The caller must free the returned string with `CoTaskMemFree`. See
  5556. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5557. [propget] HRESULT PageUri([out, retval] LPWSTR* value);
  5558. /// Gets the uri of the frame. Will match the PageUri if `IsRequestedForMainFrame` is TRUE.
  5559. ///
  5560. /// The caller must free the returned string with `CoTaskMemFree`. See
  5561. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5562. [propget] HRESULT FrameUri([out, retval] LPWSTR* value);
  5563. /// Returns TRUE if the context menu is requested on HTML containing an anchor tag.
  5564. [propget] HRESULT HasLinkUri([out, retval] BOOL* value);
  5565. /// Gets the uri of the link (if `HasLinkUri` is TRUE, null otherwise).
  5566. ///
  5567. /// The caller must free the returned string with `CoTaskMemFree`. See
  5568. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5569. [propget] HRESULT LinkUri([out, retval] LPWSTR* value);
  5570. /// Returns TRUE if the context menu is requested on text element that contains an anchor tag.
  5571. [propget] HRESULT HasLinkText([out, retval] BOOL* value);
  5572. /// Gets the text of the link (if `HasLinkText` is TRUE, null otherwise).
  5573. ///
  5574. /// The caller must free the returned string with `CoTaskMemFree`. See
  5575. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5576. [propget] HRESULT LinkText([out, retval] LPWSTR * value);
  5577. /// Returns TRUE if the context menu is requested on HTML containing a source uri.
  5578. [propget] HRESULT HasSourceUri([out, retval] BOOL* value);
  5579. /// Gets the active source uri of element (if `HasSourceUri` is TRUE, null otherwise).
  5580. ///
  5581. /// The caller must free the returned string with `CoTaskMemFree`. See
  5582. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5583. [propget] HRESULT SourceUri([out, retval] LPWSTR* value);
  5584. /// Returns TRUE if the context menu is requested on a selection.
  5585. [propget] HRESULT HasSelection([out, retval] BOOL* value);
  5586. /// Gets the selected text (if `HasSelection` is TRUE, null otherwise).
  5587. ///
  5588. /// The caller must free the returned string with `CoTaskMemFree`. See
  5589. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5590. [propget] HRESULT SelectionText([out, retval] LPWSTR* value);
  5591. }
  5592. /// Event args for the `ContextMenuRequested` event. Will contain the selection information
  5593. /// and a collection of all of the default context menu items that the WebView
  5594. /// would show. Allows the app to draw its own context menu or add/remove
  5595. /// from the default context menu.
  5596. [uuid(a1d309ee-c03f-11eb-8529-0242ac130003), object, pointer_default(unique)]
  5597. interface ICoreWebView2ContextMenuRequestedEventArgs : IUnknown {
  5598. /// Gets the collection of `ContextMenuItem` objects.
  5599. /// See `ICoreWebView2ContextMenuItemCollection` for more details.
  5600. [propget] HRESULT MenuItems([out, retval] ICoreWebView2ContextMenuItemCollection** value);
  5601. /// Gets the target information associated with the requested context menu.
  5602. /// See `ICoreWebView2ContextMenuTarget` for more details.
  5603. [propget] HRESULT ContextMenuTarget([out, retval] ICoreWebView2ContextMenuTarget** value);
  5604. /// Gets the coordinates where the context menu request occurred in relation to the upper
  5605. /// left corner of the WebView bounds.
  5606. [propget] HRESULT Location([out, retval] POINT* value);
  5607. /// Sets the selected context menu item's command ID. When this is set,
  5608. /// WebView will execute the selected command. This
  5609. /// value should always be obtained via the selected `ContextMenuItem`'s `CommandId` property.
  5610. /// The default value is -1 which means that no selection occurred. The app can
  5611. /// also report the selected command ID for a custom context menu item, which
  5612. /// will cause the `CustomItemSelected` event to be fired for the custom item, however
  5613. /// while command IDs for each custom context menu item is unique
  5614. /// during a ContextMenuRequested event, CoreWebView2 may reassign command ID
  5615. /// values of deleted custom ContextMenuItems to new objects and the command
  5616. /// ID assigned to the same custom item can be different between each app runtime.
  5617. [propput] HRESULT SelectedCommandId([in] INT32 value);
  5618. /// Gets the selected CommandId.
  5619. [propget] HRESULT SelectedCommandId([out, retval] INT32* value);
  5620. /// Sets whether the `ContextMenuRequested` event is handled by host after
  5621. /// the event handler completes or if there is a deferral then after the deferral is completed.
  5622. /// If `Handled` is set to TRUE then WebView will not display a context menu and will instead
  5623. /// use the `SelectedCommandId` property to indicate which, if any, context menu item command to invoke.
  5624. /// If after the event handler or deferral completes `Handled` is set to FALSE then WebView
  5625. /// will display a context menu based on the contents of the `MenuItems` property.
  5626. /// The default value is FALSE.
  5627. [propput] HRESULT Handled([in] BOOL value);
  5628. /// Gets whether the `ContextMenuRequested` event is handled by host.
  5629. [propget] HRESULT Handled([out, retval] BOOL* value);
  5630. /// Returns an `ICoreWebView2Deferral` object. Use this operation to
  5631. /// complete the event when the custom context menu is closed.
  5632. HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral);
  5633. }
  5634. /// This interface is used to manage profile options that created by 'CreateCoreWebView2ControllerOptions'.
  5635. ///
  5636. /// \snippet AppWindow.cpp CreateControllerWithOptions
  5637. [uuid(12aae616-8ccb-44ec-bcb3-eb1831881635), object, pointer_default(unique)]
  5638. interface ICoreWebView2ControllerOptions : IUnknown {
  5639. /// `ProfileName` property is to specify a profile name, which is only allowed to contain
  5640. /// the following ASCII characters. It has a maximum length of 64 characters excluding the null-terminator.
  5641. /// It is ASCII case insensitive.
  5642. ///
  5643. /// * alphabet characters: a-z and A-Z
  5644. /// * digit characters: 0-9
  5645. /// * and '#', '@', '$', '(', ')', '+', '-', '_', '~', '.', ' ' (space).
  5646. ///
  5647. /// Note: the text must not end with a period '.' or ' ' (space). And, although upper-case letters are
  5648. /// allowed, they're treated just as lower-case counterparts because the profile name will be mapped to
  5649. /// the real profile directory path on disk and Windows file system handles path names in a case-insensitive way.
  5650. ///
  5651. /// The caller must free the returned string with `CoTaskMemFree`. See
  5652. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5653. [propget] HRESULT ProfileName([out, retval] LPWSTR* value);
  5654. /// Sets the `ProfileName` property.
  5655. [propput] HRESULT ProfileName([in] LPCWSTR value);
  5656. /// `IsInPrivateModeEnabled` property is to enable/disable InPrivate mode.
  5657. [propget] HRESULT IsInPrivateModeEnabled([out, retval] BOOL* value);
  5658. /// Sets the `IsInPrivateModeEnabled` property.
  5659. [propput] HRESULT IsInPrivateModeEnabled([in] BOOL value);
  5660. }
  5661. /// Provides a set of properties to configure a Profile object.
  5662. ///
  5663. /// \snippet AppWindow.cpp OnCreateCoreWebView2ControllerCompleted
  5664. [uuid(79110ad3-cd5d-4373-8bc3-c60658f17a5f), object, pointer_default(unique)]
  5665. interface ICoreWebView2Profile : IUnknown {
  5666. /// Name of the profile.
  5667. ///
  5668. /// The caller must free the returned string with `CoTaskMemFree`. See
  5669. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5670. [propget] HRESULT ProfileName([out, retval] LPWSTR* value);
  5671. /// InPrivate mode is enabled or not.
  5672. [propget] HRESULT IsInPrivateModeEnabled([out, retval] BOOL* value);
  5673. /// Full path of the profile directory.
  5674. ///
  5675. /// The caller must free the returned string with `CoTaskMemFree`. See
  5676. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5677. [propget] HRESULT ProfilePath([out, retval] LPWSTR* value);
  5678. /// Gets the `DefaultDownloadFolderPath` property. The default value is the
  5679. /// system default download folder path for the user.
  5680. ///
  5681. /// The caller must free the returned string with `CoTaskMemFree`. See
  5682. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5683. [propget] HRESULT DefaultDownloadFolderPath([out, retval] LPWSTR* value);
  5684. /// Sets the `DefaultDownloadFolderPath` property. The default download folder
  5685. /// path is persisted in the user data folder across sessions. The value
  5686. /// should be an absolute path to a folder that the user and application can
  5687. /// write to. Returns `E_INVALIDARG` if the value is invalid, and the default
  5688. /// download folder path is not changed. Otherwise the path is changed
  5689. /// immediately. If the directory does not yet exist, it is created at the
  5690. /// time of the next download. If the host application does not have
  5691. /// permission to create the directory, then the user is prompted to provide a
  5692. /// new path through the Save As dialog. The user can override the default
  5693. /// download folder path for a given download by choosing a different path in
  5694. /// the Save As dialog.
  5695. [propput] HRESULT DefaultDownloadFolderPath([in] LPCWSTR value);
  5696. /// The PreferredColorScheme property sets the overall color scheme of the
  5697. /// WebView2s associated with this profile. This sets the color scheme for
  5698. /// WebView2 UI like dialogs, prompts, and context menus by setting the
  5699. /// media feature `prefers-color-scheme` for websites to respond to.
  5700. ///
  5701. /// The default value for this is COREWEBVIEW2_PREFERRED_COLOR_AUTO,
  5702. /// which will follow whatever theme the OS is currently set to.
  5703. ///
  5704. /// \snippet ViewComponent.cpp SetPreferredColorScheme
  5705. /// Returns the value of the `PreferredColorScheme` property.
  5706. [propget] HRESULT PreferredColorScheme(
  5707. [out, retval] COREWEBVIEW2_PREFERRED_COLOR_SCHEME* value);
  5708. /// Sets the `PreferredColorScheme` property.
  5709. [propput] HRESULT PreferredColorScheme(
  5710. [in] COREWEBVIEW2_PREFERRED_COLOR_SCHEME value);
  5711. }
  5712. /// Provides access to the certificate metadata.
  5713. [uuid(C5FB2FCE-1CAC-4AEE-9C79-5ED0362EAAE0), object, pointer_default(unique)]
  5714. interface ICoreWebView2Certificate : IUnknown {
  5715. /// Subject of the certificate.
  5716. ///
  5717. /// The caller must free the returned string with `CoTaskMemFree`. See
  5718. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5719. [propget] HRESULT Subject([out, retval] LPWSTR* value);
  5720. /// Name of the certificate authority that issued the certificate.
  5721. ///
  5722. /// The caller must free the returned string with `CoTaskMemFree`. See
  5723. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5724. [propget] HRESULT Issuer([out, retval] LPWSTR* value);
  5725. /// The valid start date and time for the certificate as the number of seconds since
  5726. /// the UNIX epoch.
  5727. [propget] HRESULT ValidFrom([out, retval] double* value);
  5728. /// The valid expiration date and time for the certificate as the number of seconds since
  5729. /// the UNIX epoch.
  5730. [propget] HRESULT ValidTo([out, retval] double* value);
  5731. /// DER encoded serial number of the certificate.
  5732. /// Read more about DER at [RFC 7468 DER]
  5733. /// (https://tools.ietf.org/html/rfc7468#appendix-B).
  5734. ///
  5735. /// The caller must free the returned string with `CoTaskMemFree`. See
  5736. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5737. [propget] HRESULT DerEncodedSerialNumber([out, retval] LPWSTR* value);
  5738. /// Display name for a certificate.
  5739. ///
  5740. /// The caller must free the returned string with `CoTaskMemFree`. See
  5741. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings)
  5742. [propget] HRESULT DisplayName([out, retval] LPWSTR* value);
  5743. /// PEM encoded data for the certificate.
  5744. /// Returns Base64 encoding of DER encoded certificate.
  5745. /// Read more about PEM at [RFC 1421 Privacy Enhanced Mail]
  5746. /// (https://tools.ietf.org/html/rfc1421).
  5747. ///
  5748. /// The caller must free the returned string with `CoTaskMemFree`. See
  5749. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings)
  5750. HRESULT ToPemEncoding([out, retval] LPWSTR* pemEncodedData);
  5751. /// Collection of PEM encoded certificate issuer chain.
  5752. /// In this collection first element is the current certificate followed by
  5753. /// intermediate1, intermediate2...intermediateN-1. Root certificate is the
  5754. /// last element in collection.
  5755. [propget] HRESULT PemEncodedIssuerCertificateChain([out, retval]
  5756. ICoreWebView2StringCollection** value);
  5757. }
  5758. /// An event handler for the `ServerCertificateErrorDetected` event.
  5759. [uuid(969B3A26-D85E-4795-8199-FEF57344DA22), object, pointer_default(unique)]
  5760. interface ICoreWebView2ServerCertificateErrorDetectedEventHandler : IUnknown {
  5761. /// Provides the event args for the corresponding event.
  5762. HRESULT Invoke([in] ICoreWebView2* sender,
  5763. [in] ICoreWebView2ServerCertificateErrorDetectedEventArgs*
  5764. args);
  5765. }
  5766. /// Event args for the `ServerCertificateErrorDetected` event.
  5767. [uuid(012193ED-7C13-48FF-969D-A84C1F432A14), object, pointer_default(unique)]
  5768. interface ICoreWebView2ServerCertificateErrorDetectedEventArgs : IUnknown {
  5769. /// The TLS error code for the invalid certificate.
  5770. [propget] HRESULT ErrorStatus([out, retval] COREWEBVIEW2_WEB_ERROR_STATUS* value);
  5771. /// URI associated with the request for the invalid certificate.
  5772. ///
  5773. /// The caller must free the returned string with `CoTaskMemFree`. See
  5774. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  5775. [propget] HRESULT RequestUri([out, retval] LPWSTR* value);
  5776. /// Returns the server certificate.
  5777. [propget] HRESULT ServerCertificate([out, retval] ICoreWebView2Certificate** value);
  5778. /// The action of the server certificate error detection.
  5779. /// The default value is `COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION_DEFAULT`.
  5780. [propget] HRESULT Action([out, retval] COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION* value);
  5781. /// Sets the `Action` property.
  5782. [propput] HRESULT Action([in] COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION value);
  5783. /// Returns an `ICoreWebView2Deferral` object. Use this operation to
  5784. /// complete the event at a later time.
  5785. HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral);
  5786. }
  5787. /// Receives the result of the `ClearServerCertificateErrorActions` method.
  5788. [uuid(3B40AAC6-ACFE-4FFD-8211-F607B96E2D5B), object, pointer_default(unique)]
  5789. interface ICoreWebView2ClearServerCertificateErrorActionsCompletedHandler : IUnknown {
  5790. /// Provides the result of the corresponding asynchronous method.
  5791. HRESULT Invoke([in] HRESULT errorCode);
  5792. }
  5793. /// Profile2 interface.
  5794. ///
  5795. [uuid(fa740d4b-5eae-4344-a8ad-74be31925397), object, pointer_default(unique)]
  5796. interface ICoreWebView2Profile2: ICoreWebView2Profile {
  5797. /// Clear browsing data based on a data type. This method takes two parameters,
  5798. /// the first being a mask of one or more `COREWEBVIEW2_BROWSING_DATA_KINDS`. OR
  5799. /// operation(s) can be applied to multiple `COREWEBVIEW2_BROWSING_DATA_KINDS` to
  5800. /// create a mask representing those data types. The browsing data kinds that are
  5801. /// supported are listed below. These data kinds follow a hierarchical structure in
  5802. /// which nested bullet points are included in their parent bullet point's data kind.
  5803. /// Ex: All DOM storage is encompassed in all site data which is encompassed in
  5804. /// all profile data.
  5805. /// * All Profile
  5806. /// * All Site Data
  5807. /// * All DOM Storage: File Systems, Indexed DB, Local Storage, Web SQL, Cache
  5808. /// Storage
  5809. /// * Cookies
  5810. /// * Disk Cache
  5811. /// * Download History
  5812. /// * General Autofill
  5813. /// * Password Autosave
  5814. /// * Browsing History
  5815. /// * Settings
  5816. /// The completed handler will be invoked when the browsing data has been cleared and
  5817. /// will indicate if the specified data was properly cleared. In the case in which
  5818. /// the operation is interrupted and the corresponding data is not fully cleared
  5819. /// the handler will return `E_ABORT` and otherwise will return `S_OK`.
  5820. /// Because this is an asynchronous operation, code that is dependent on the cleared
  5821. /// data must be placed in the callback of this operation.
  5822. /// If the WebView object is closed before the clear browsing data operation
  5823. /// has completed, the handler will be released, but not invoked. In this case
  5824. /// the clear browsing data operation may or may not be completed.
  5825. /// ClearBrowsingData clears the `dataKinds` regardless of timestamp.
  5826. HRESULT ClearBrowsingData(
  5827. [in] COREWEBVIEW2_BROWSING_DATA_KINDS dataKinds,
  5828. [in] ICoreWebView2ClearBrowsingDataCompletedHandler* handler);
  5829. /// ClearBrowsingDataInTimeRange behaves like ClearBrowsingData except that it
  5830. /// takes in two additional parameters for the start and end time for which it
  5831. /// should clear the data between. The `startTime` and `endTime`
  5832. /// parameters correspond to the number of seconds since the UNIX epoch.
  5833. /// `startTime` is inclusive while `endTime` is exclusive, therefore the data will
  5834. /// be cleared between [startTime, endTime).
  5835. HRESULT ClearBrowsingDataInTimeRange(
  5836. [in] COREWEBVIEW2_BROWSING_DATA_KINDS dataKinds,
  5837. [in] double startTime,
  5838. [in] double endTime,
  5839. [in] ICoreWebView2ClearBrowsingDataCompletedHandler* handler);
  5840. /// ClearBrowsingDataAll behaves like ClearBrowsingData except that it
  5841. /// clears the entirety of the data associated with the profile it is called on.
  5842. /// It clears the data regardless of timestamp.
  5843. ///
  5844. /// \snippet AppWindow.cpp ClearBrowsingData
  5845. HRESULT ClearBrowsingDataAll(
  5846. [in] ICoreWebView2ClearBrowsingDataCompletedHandler* handler);
  5847. }
  5848. /// The caller implements this interface to receive the ClearBrowsingData result.
  5849. [uuid(e9710a06-1d1d-49b2-8234-226f35846ae5), object, pointer_default(unique)]
  5850. interface ICoreWebView2ClearBrowsingDataCompletedHandler : IUnknown {
  5851. /// Provide the completion status of the corresponding asynchronous method.
  5852. HRESULT Invoke([in] HRESULT errorCode);
  5853. }
  5854. /// DLL export to create a WebView2 environment with a custom version of
  5855. /// WebView2 Runtime, user data folder, and with or without additional options.
  5856. ///
  5857. /// When WebView2 experimental APIs are used, make sure to provide a valid `environmentOptions`
  5858. /// so that WebView2 runtime knows which version of the SDK that the app is using. Otherwise,
  5859. /// WebView2 runtime assumes that the version of the SDK being used is the latest
  5860. /// version known to it, which might not be the version of the SDK being used.
  5861. /// This wrong SDK version assumption could result in some experimental APIs not being available.
  5862. ///
  5863. /// The WebView2 environment and all other WebView2 objects are single threaded
  5864. /// and have dependencies on Windows components that require COM to be
  5865. /// initialized for a single-threaded apartment. The app is expected to run
  5866. /// `CoInitializeEx` before running `CreateCoreWebView2EnvironmentWithOptions`.
  5867. ///
  5868. /// ```text
  5869. /// CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
  5870. /// ```
  5871. ///
  5872. /// If `CoInitializeEx` did not run or previously ran with
  5873. /// `COINIT_MULTITHREADED`, `CreateCoreWebView2EnvironmentWithOptions` fails
  5874. /// with one of the following errors.
  5875. ///
  5876. /// ```text
  5877. /// CO_E_NOTINITIALIZED - if CoInitializeEx was not called
  5878. /// RPC_E_CHANGED_MODE - if CoInitializeEx was previously called with
  5879. /// COINIT_MULTITHREADED
  5880. /// ```
  5881. ///
  5882. ///
  5883. /// Use `browserExecutableFolder` to specify whether WebView2 controls use a
  5884. /// fixed or installed version of the WebView2 Runtime that exists on a user
  5885. /// machine. To use a fixed version of the WebView2 Runtime, pass the
  5886. /// folder path that contains the fixed version of the WebView2 Runtime to
  5887. /// `browserExecutableFolder`. BrowserExecutableFolder supports both relative
  5888. /// (to the application's executable) and absolute files paths.
  5889. /// To create WebView2 controls that use the
  5890. /// installed version of the WebView2 Runtime that exists on user machines,
  5891. /// pass a `null` or empty string to `browserExecutableFolder`. In this
  5892. /// scenario, the API tries to find a compatible version of the WebView2
  5893. /// Runtime that is installed on the user machine (first at the machine level,
  5894. /// and then per user) using the selected channel preference. The path of
  5895. /// fixed version of the WebView2 Runtime should not contain
  5896. /// `\Edge\Application\`. When such a path is used, the API fails
  5897. /// with `HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)`.
  5898. ///
  5899. /// The default channel search order is the WebView2 Runtime, Beta, Dev, and
  5900. /// Canary. When an override `WEBVIEW2_RELEASE_CHANNEL_PREFERENCE` environment
  5901. /// variable or applicable `releaseChannelPreference` registry value is set to
  5902. /// `1`, the channel search order is reversed.
  5903. ///
  5904. /// You may specify the `userDataFolder` to change the default user data
  5905. /// folder location for WebView2. The path is either an absolute file path
  5906. /// or a relative file path that is interpreted as relative to the compiled
  5907. /// code for the current process. For UWP apps, the default user data
  5908. /// folder is the app data folder for the package. For non-UWP apps, the
  5909. /// default user data (`{Executable File Name}.WebView2`) folder is
  5910. /// created in the same directory next to the compiled code for the app.
  5911. /// WebView2 creation fails if the compiled code is running in a directory in
  5912. /// which the process does not have permission to create a new directory. The
  5913. /// app is responsible to clean up the associated user data folder when it
  5914. /// is done.
  5915. ///
  5916. /// \> [!NOTE]\n\> As a browser process may be shared among WebViews, WebView creation fails
  5917. /// with `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)` if the specified options
  5918. /// does not match the options of the WebViews that are currently running in
  5919. /// the shared browser process.
  5920. ///
  5921. /// `environmentCreatedHandler` is the handler result to the async operation
  5922. /// that contains the `WebView2Environment` that was created.
  5923. ///
  5924. /// The `browserExecutableFolder`, `userDataFolder` and
  5925. /// `additionalBrowserArguments` of the `environmentOptions` may be overridden
  5926. /// by values either specified in environment variables or in the registry.
  5927. ///
  5928. /// When creating a `WebView2Environment` the following environment variables
  5929. /// are verified.
  5930. ///
  5931. /// ```text
  5932. /// WEBVIEW2_BROWSER_EXECUTABLE_FOLDER
  5933. /// WEBVIEW2_USER_DATA_FOLDER
  5934. /// WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS
  5935. /// WEBVIEW2_RELEASE_CHANNEL_PREFERENCE
  5936. /// ```
  5937. ///
  5938. /// If you find an override environment variable, use the
  5939. /// `browserExecutableFolder` and `userDataFolder` values as replacements for
  5940. /// the corresponding values in `CreateCoreWebView2EnvironmentWithOptions`
  5941. /// parameters. If `additionalBrowserArguments` is specified in environment
  5942. /// variable or in the registry, it is appended to the corresponding values in
  5943. /// `CreateCoreWebView2EnvironmentWithOptions` parameters.
  5944. ///
  5945. /// While not strictly overrides, additional environment variables may be set.
  5946. ///
  5947. /// ```text
  5948. /// WEBVIEW2_WAIT_FOR_SCRIPT_DEBUGGER
  5949. /// ```
  5950. ///
  5951. /// When found with a non-empty value, this indicates that the WebView is being
  5952. /// launched under a script debugger. In this case, the WebView issues a
  5953. /// `Page.waitForDebugger` CDP command that runs the script inside the WebView
  5954. /// to pause on launch, until a debugger issues a corresponding
  5955. /// `Runtime.runIfWaitingForDebugger` CDP command to resume the runtime.
  5956. ///
  5957. /// \> [!NOTE]\n\> The following environment variable does not have a registry key
  5958. /// equivalent: `WEBVIEW2_WAIT_FOR_SCRIPT_DEBUGGER`.
  5959. ///
  5960. /// When found with a non-empty value, it indicates that the WebView is being
  5961. /// launched under a script debugger that also supports host apps that use
  5962. /// multiple WebViews. The value is used as the identifier for a named pipe
  5963. /// that is opened and written to when a new WebView is created by the host
  5964. /// app. The payload should match the payload of the `remote-debugging-port`
  5965. /// JSON target and an external debugger may use it to attach to a specific
  5966. /// WebView instance. The format of the pipe created by the debugger should be
  5967. /// `\\.\pipe\WebView2\Debugger\{app_name}\{pipe_name}`, where the following
  5968. /// are true.
  5969. ///
  5970. /// * `{app_name}` is the host app exe file name, for example,
  5971. /// `WebView2Example.exe`
  5972. /// * `{pipe_name}` is the value set for `WEBVIEW2_PIPE_FOR_SCRIPT_DEBUGGER`
  5973. ///
  5974. /// To enable debugging of the targets identified by the JSON, you must set the
  5975. /// `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS` environment variable to send
  5976. /// `--remote-debugging-port={port_num}`, where the following is true.
  5977. ///
  5978. /// * `{port_num}` is the port on which the CDP server binds.
  5979. ///
  5980. /// \> [!WARNING]\n\> If you set both `WEBVIEW2_PIPE_FOR_SCRIPT_DEBUGGER` and
  5981. /// `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS` environment variables, the
  5982. /// WebViews hosted in your app and associated contents may exposed to 3rd
  5983. /// party apps such as debuggers.
  5984. ///
  5985. /// \> [!NOTE]\n\> The following environment variable does not have a registry key
  5986. /// equivalent: `WEBVIEW2_PIPE_FOR_SCRIPT_DEBUGGER`.
  5987. ///
  5988. /// If none of those environment variables exist, then the registry is examined
  5989. /// next. The following registry values are verified.
  5990. ///
  5991. /// ```text
  5992. /// [{Root}]\Software\Policies\Microsoft\Edge\WebView2\BrowserExecutableFolder
  5993. /// "{AppId}"=""
  5994. ///
  5995. /// [{Root}]\Software\Policies\Microsoft\Edge\WebView2\ReleaseChannelPreference
  5996. /// "{AppId}"=""
  5997. ///
  5998. /// [{Root}]\Software\Policies\Microsoft\Edge\WebView2\AdditionalBrowserArguments
  5999. /// "{AppId}"=""
  6000. ///
  6001. /// [{Root}]\Software\Policies\Microsoft\Edge\WebView2\UserDataFolder
  6002. /// "{AppId}"=""
  6003. /// ```
  6004. ///
  6005. /// Use a group policy under **Administrative Templates** >
  6006. /// **Microsoft Edge WebView2** to configure `browserExecutableFolder` and
  6007. /// `releaseChannelPreference`.
  6008. ///
  6009. /// In the unlikely scenario where some instances of WebView are open during a
  6010. /// browser update, the deletion of the previous WebView2 Runtime may be
  6011. /// blocked. To avoid running out of disk space, a new WebView creation fails
  6012. /// with `HRESULT_FROM_WIN32(ERROR_DISK_FULL)` if it detects that too many
  6013. /// previous WebView2 Runtime versions exist.
  6014. ///
  6015. /// The default maximum number of WebView2 Runtime versions allowed is `20`.
  6016. /// To override the maximum number of the previous WebView2 Runtime versions
  6017. /// allowed, set the value of the following environment variable.
  6018. ///
  6019. /// ```text
  6020. /// WEBVIEW2_MAX_INSTANCES
  6021. /// ```
  6022. ///
  6023. /// If the Webview depends upon an installed WebView2 Runtime version and it is
  6024. /// uninstalled, any subsequent creation fails with
  6025. /// `HRESULT_FROM_WIN32(ERROR_PRODUCT_UNINSTALLED)`.
  6026. ///
  6027. /// First verify with Root as `HKLM` and then `HKCU`. `AppId` is first set to
  6028. /// the Application User Model ID of the process, then if no corresponding
  6029. /// registry key, the `AppId` is set to the compiled code name of the process,
  6030. /// or if that is not a registry key then `*`. If an override registry key is
  6031. /// found, use the `browserExecutableFolder` and `userDataFolder` registry
  6032. /// values as replacements and append `additionalBrowserArguments` registry
  6033. /// values for the corresponding values in
  6034. /// `CreateCoreWebView2EnvironmentWithOptions` parameters.
  6035. ///
  6036. /// The following summarizes the possible error values that can be returned from
  6037. /// `CreateCoreWebView2EnvironmentWithOptions` and a description of why these
  6038. /// errors occur.
  6039. ///
  6040. /// Error value | Description
  6041. /// ----------------------------------------------- | --------------------------
  6042. /// `CO_E_NOTINITIALIZED` | CoInitializeEx was not called.
  6043. /// `RPC_E_CHANGED_MODE` | CoInitializeEx was previously called with COINIT_MULTITHREADED.
  6044. /// `HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)` | *\\Edge\\Application* path used in browserExecutableFolder.
  6045. /// `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)` | Specified options do not match the options of the WebViews that are currently running in the shared browser process.
  6046. /// `HRESULT_FROM_WIN32(ERROR_DISK_FULL)` | In the unlikely scenario where some instances of WebView are open during a browser update, the deletion of the previous WebView2 Runtime may be blocked. To avoid running out of disk space, a new WebView creation fails with `HRESULT_FROM_WIN32(ERROR_DISK_FULL)` if it detects that too many previous WebView2 Runtime versions exist.
  6047. /// `HRESULT_FROM_WIN32(ERROR_PRODUCT_UNINSTALLED)` | If the Webview depends upon an installed WebView2 Runtime version and it is uninstalled.
  6048. /// `HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)` | Could not find Edge installation.
  6049. /// `HRESULT_FROM_WIN32(ERROR_FILE_EXISTS)` | User data folder cannot be created because a file with the same name already exists.
  6050. /// `E_ACCESSDENIED` | Unable to create user data folder, Access Denied.
  6051. /// `E_FAIL` | Edge runtime unable to start.
  6052. cpp_quote("STDAPI CreateCoreWebView2EnvironmentWithOptions(PCWSTR browserExecutableFolder, PCWSTR userDataFolder, ICoreWebView2EnvironmentOptions* environmentOptions, ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler* environmentCreatedHandler);")
  6053. /// Creates an evergreen WebView2 Environment using the installed WebView2
  6054. /// Runtime version. This is equivalent to running
  6055. /// `CreateCoreWebView2EnvironmentWithOptions` with `nullptr` for
  6056. /// `browserExecutableFolder`, `userDataFolder`, `additionalBrowserArguments`.
  6057. /// For more information, navigate to
  6058. /// `CreateCoreWebView2EnvironmentWithOptions`.
  6059. cpp_quote("STDAPI CreateCoreWebView2Environment(ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler* environmentCreatedHandler);")
  6060. /// Get the browser version info including channel name if it is not the
  6061. /// WebView2 Runtime. Channel names are Beta, Dev, and Canary.
  6062. /// If an override exists for the `browserExecutableFolder` or the channel
  6063. /// preference, the override is used. If an override is not specified, then
  6064. /// the parameter value passed to
  6065. /// `GetAvailableCoreWebView2BrowserVersionString` is used.
  6066. ///
  6067. /// The caller must free the returned string with `CoTaskMemFree`. See
  6068. /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
  6069. cpp_quote("STDAPI GetAvailableCoreWebView2BrowserVersionString(PCWSTR browserExecutableFolder, LPWSTR* versionInfo);")
  6070. /// This method is for anyone want to compare version correctly to determine
  6071. /// which version is newer, older or same. Use it to determine whether
  6072. /// to use webview2 or certain feature based upon version. Sets the value of
  6073. /// result to `-1`, `0` or `1` if `version1` is less than, equal or greater
  6074. /// than `version2` respectively. Returns `E_INVALIDARG` if it fails to parse
  6075. /// any of the version strings or any input parameter is `null`. Directly use
  6076. /// the `versionInfo` obtained from
  6077. /// `GetAvailableCoreWebView2BrowserVersionString` with input, channel
  6078. /// information is ignored.
  6079. cpp_quote("STDAPI CompareBrowserVersions(PCWSTR version1, PCWSTR version2, int* result);")
  6080. }