diff --git a/browser/components/contentanalysis/content/ContentAnalysis.sys.mjs b/browser/components/contentanalysis/content/ContentAnalysis.sys.mjs index dab78182d20c..9d9940caec88 100644 --- a/browser/components/contentanalysis/content/ContentAnalysis.sys.mjs +++ b/browser/components/contentanalysis/content/ContentAnalysis.sys.mjs @@ -187,6 +187,28 @@ lazy { } ; +XPCOMUtils +. +defineLazyServiceGetter +( +lazy +" +gContentAnalysis +" +" +mozilla +. +org +/ +contentanalysis +; +1 +" +Ci +. +nsIContentAnalysis +) +; ChromeUtils . defineESModuleGetters @@ -2236,7 +2258,27 @@ aOperation ) { return -false +! +( +aOperation += += +Ci +. +nsIContentAnalysisRequest +. +FILE_DOWNLOADED +| +| +aOperation += += +Ci +. +nsIContentAnalysisRequest +. +PRINT +) ; } / @@ -2696,6 +2738,12 @@ Ci nsIPromptService . BUTTON_TITLE_CANCEL ++ +Ci +. +nsIPromptService +. +SHOW_SPINNER null null null @@ -2809,6 +2857,15 @@ aRequestToken ) ) { +lazy +. +gContentAnalysis +. +cancelContentAnalysisRequest +( +aRequestToken +) +; let dlpBusyView = diff --git a/netwerk/base/nsIPrompt.idl b/netwerk/base/nsIPrompt.idl index 16099d4db342..c1b60defb6a8 100644 --- a/netwerk/base/nsIPrompt.idl +++ b/netwerk/base/nsIPrompt.idl @@ -207,6 +207,16 @@ BUTTON_DELAY_ENABLE const unsigned long +SHOW_SPINNER += +1 +< +< +27 +; +const +unsigned +long STD_OK_CANCEL_BUTTONS = ( diff --git a/toolkit/components/contentanalysis/ContentAnalysis.cpp b/toolkit/components/contentanalysis/ContentAnalysis.cpp index 5b39fc1e2921..c616536fe578 100644 --- a/toolkit/components/contentanalysis/ContentAnalysis.cpp +++ b/toolkit/components/contentanalysis/ContentAnalysis.cpp @@ -37,6 +37,15 @@ include " mozilla / +Components +. +h +" +# +include +" +mozilla +/ dom / Promise @@ -169,6 +178,81 @@ h # endif namespace +mozilla +: +: +contentanalysis +{ +LazyLogModule +gContentAnalysisLog +( +" +contentanalysis +" +) +; +# +define +LOGD +( +. +. +. +) +\ +MOZ_LOG +( +mozilla +: +: +contentanalysis +: +: +gContentAnalysisLog +\ +mozilla +: +: +LogLevel +: +: +Debug +( +__VA_ARGS__ +) +) +# +define +LOGE +( +. +. +. +) +\ +MOZ_LOG +( +mozilla +: +: +contentanalysis +: +: +gContentAnalysisLog +\ +mozilla +: +: +LogLevel +: +: +Error +( +__VA_ARGS__ +) +) +} +namespace { const char @@ -417,33 +501,6 @@ mozilla : contentanalysis { -LazyLogModule -gContentAnalysisLog -( -" -contentanalysis -" -) -; -# -define -LOGD -( -. -. -. -) -MOZ_LOG -( -gContentAnalysisLog -LogLevel -: -: -Debug -( -__VA_ARGS__ -) -) NS_IMETHODIMP ContentAnalysisRequest : @@ -673,80 +730,53 @@ return NS_OK ; } -StaticDataMutex -< -UniquePtr -< -content_analysis -: -: -sdk -: -: -Client -> -> -ContentAnalysis -: -: -sCaClient -( -" -ContentAnalysisClient -" -) -; nsresult ContentAnalysis : : -EnsureContentAnalysisClient +CreateContentAnalysisClient ( +nsCString +& +& +aPipePathName +bool +aIsPerUser ) { -auto -caClientRef -= -sCaClient -. -Lock +MOZ_ASSERT ( -) -; -auto -& -caClient -= -caClientRef -. -ref +! +NS_IsMainThread ( ) +) ; -if +MOZ_ASSERT +( +! +mCaClientPromise +- +> +IsResolved ( -caClient ) -{ -return -NS_OK -; -} -nsAutoCString -pipePathName +) ; -Preferences +std : : -GetCString -( -kPipePathNamePref -pipePathName -) -; -caClient -. -reset +shared_ptr +< +content_analysis +: +: +sdk +: +: +Client +> +client ( content_analysis : @@ -760,18 +790,12 @@ Client Create ( { -pipePathName +aPipePathName . Data ( ) -Preferences -: -: -GetBool -( -kIsPerUserPref -) +aIsPerUser } ) . @@ -789,7 +813,7 @@ is % s " -caClient +client ? " connected @@ -801,12 +825,17 @@ available " ) ; +mCaClientPromise +- +> +Resolve +( +client +__func__ +) +; return -caClient -? NS_OK -: -NS_ERROR_NOT_AVAILABLE ; } ContentAnalysisRequest @@ -3344,39 +3373,78 @@ NS_IMPL_ISUPPORTS ( ContentAnalysis nsIContentAnalysis +ContentAnalysis ) ; ContentAnalysis : : +ContentAnalysis +( +) +: +mCaClientPromise +( +new +ClientPromise +: +: +Private +( +" +ContentAnalysis +: +: +ContentAnalysis +" +) +) +mClientCreationAttempted +( +false +) +mCallbackMap +( +" +ContentAnalysis +: +: +mCallbackMap +" +) +{ +} +ContentAnalysis +: +: ~ ContentAnalysis ( ) { -auto -caClientRef -= -sCaClient -. -Lock +MOZ_ASSERT +( +NS_IsMainThread ( ) +) ; -auto -& -caClient -= -caClientRef -. -ref +if ( +! +mClientCreationAttempted +) +{ +mCaClientPromise +- +> +Reject +( +NS_ERROR_ILLEGAL_DURING_SHUTDOWN +__func__ ) ; -caClient -= -nullptr -; +} } NS_IMETHODIMP ContentAnalysis @@ -3396,6 +3464,13 @@ false ; MOZ_ASSERT ( +NS_IsMainThread +( +) +) +; +MOZ_ASSERT +( XRE_IsParentProcess ( ) @@ -3417,24 +3492,27 @@ kIsDLPEnabledPref ) ) { +LOGD +( +" +Local +DLP +Content +Analysis +is +not +active +" +) +; return NS_OK ; } -nsresult -rv -= -EnsureContentAnalysisClient -( -) -; * aIsActive = -NS_SUCCEEDED -( -rv -) +true ; LOGD ( @@ -3444,20 +3522,162 @@ DLP Content Analysis is -% -sactive +active " -* -aIsActive -? +) +; +if +( +! +mClientCreationAttempted +) +{ +mClientCreationAttempted += +true +; +LOGD +( " +Dispatching +background +task +to +create +Content +Analysis +client " +) +; +nsCString +pipePathName +; +nsresult +rv += +Preferences +: +: +GetCString +( +kPipePathNamePref +pipePathName +) +; +if +( +NS_WARN_IF +( +NS_FAILED +( +rv +) +) +) +{ +mCaClientPromise +- +> +Reject +( +rv +__func__ +) +; +return +rv +; +} +bool +isPerUser += +Preferences +: : +GetBool +( +kIsPerUserPref +) +; +rv += +NS_DispatchBackgroundTask +( +NS_NewCancelableRunnableFunction +( " -not +ContentAnalysis +: +: +CreateContentAnalysisClient " +[ +owner += +RefPtr +{ +this +} +pipePathName += +std +: +: +move +( +pipePathName +) +isPerUser +] +( +) +mutable +{ +owner +- +> +CreateContentAnalysisClient +( +std +: +: +move +( +pipePathName +) +isPerUser +) +; +} +) +) +; +if +( +NS_WARN_IF +( +NS_FAILED +( +rv +) ) +) +{ +mCaClientPromise +- +> +Reject +( +rv +__func__ +) +; +return +rv ; +} +} return NS_OK ; @@ -3498,75 +3718,238 @@ nsresult ContentAnalysis : : +CancelWithError +( +nsCString +aRequestToken +nsresult +aResult +) +{ +return +NS_DispatchToMainThread +( +NS_NewCancelableRunnableFunction +( +" +ContentAnalysis +: +: RunAnalyzeRequestTask +: +: +HandleResponse +" +[ +aResult +aRequestToken += +std +: +: +move ( +aRequestToken +) +] +{ RefPtr < -nsIContentAnalysisRequest +ContentAnalysis > -aRequest -RefPtr +owner += +GetContentAnalysisFromService +( +) +; +if +( +! +owner +) +{ +return +; +} +nsMainThreadPtrHandle < nsIContentAnalysisCallback > -aCallback -) -{ -nsresult -rv -= -NS_ERROR_FAILURE +callbackHolder ; +{ auto -callbackCopy +lock = -aCallback +owner +- +> +mCallbackMap +. +Lock +( +) ; auto -se +callbackData = -MakeScopeExit +lock +- +> +Extract ( -[ -& -] -{ +aRequestToken +) +; if ( -! -NS_SUCCEEDED +callbackData +. +isSome ( -rv ) ) { -LOGD +callbackHolder += +callbackData +- +> +TakeCallbackHolder ( -" -RunAnalyzeRequestTask -failed -" ) ; -callbackCopy +} +} +if +( +callbackHolder +) +{ +callbackHolder - > Error ( -rv +aResult ) ; } } ) +) ; +} RefPtr < ContentAnalysis > -owner -= -this +ContentAnalysis +: +: +GetContentAnalysisFromService +( +) +{ +RefPtr +< +ContentAnalysis +> +contentAnalysisService += +mozilla +: +: +components +: +: +nsIContentAnalysis +: +: +Service +( +) +; +if +( +! +contentAnalysisService +) +{ +return +nullptr +; +} +return +contentAnalysisService +; +} +nsresult +ContentAnalysis +: +: +RunAnalyzeRequestTask +( +RefPtr +< +nsIContentAnalysisRequest +> +aRequest +RefPtr +< +nsIContentAnalysisCallback +> +aCallback +) +{ +nsresult +rv += +NS_ERROR_FAILURE +; +auto +callbackCopy += +aCallback +; +auto +se += +MakeScopeExit +( +[ +& +] +{ +if +( +! +NS_SUCCEEDED +( +rv +) +) +{ +LOGE +( +" +RunAnalyzeRequestTask +failed +" +) +; +callbackCopy +- +> +Error +( +rv +) +; +} +} +) ; content_analysis : @@ -3609,6 +3992,39 @@ pbRequest nsCString requestToken ; +nsMainThreadPtrHandle +< +nsIContentAnalysisCallback +> +callbackHolderCopy +( +new +nsMainThreadPtrHolder +< +nsIContentAnalysisCallback +> +( +" +content +analysis +callback +" +aCallback +) +) +; +CallbackData +callbackData +( +std +: +: +move +( +callbackHolderCopy +) +) +; rv = aRequest @@ -3625,125 +4041,197 @@ rv rv ) ; -rv +{ +auto +lock = -NS_DispatchBackgroundTask +mCallbackMap +. +Lock ( -NS_NewRunnableFunction +) +; +lock +- +> +InsertOrUpdate ( -" -RunAnalyzeRequestTask -" -[ -pbRequest -= +requestToken std : : move ( +callbackData +) +) +; +} +LOGD +( +" +Issuing +ContentAnalysisRequest +for +token +% +s +" +requestToken +. +get +( +) +) +; +LogRequest +( +& pbRequest ) -aCallback -= -std -: -: -move +; +mCaClientPromise +- +> +Then +( +GetCurrentSerialEventTarget ( -aCallback ) +__func__ +[ requestToken +pbRequest = std : : move ( -requestToken +pbRequest ) -owner ] -{ -nsresult -rv -= -NS_ERROR_FAILURE -; +( +std +: +: +shared_ptr +< content_analysis : : sdk : : -ContentAnalysisResponse -pbResponse -; -auto -resolveOnMainThread -= -MakeScopeExit -( -[ -& -] +Client +> +client +) { -NS_DispatchToMainThread +NS_DispatchBackgroundTask ( -NS_NewRunnableFunction +NS_NewCancelableRunnableFunction ( -" -ResolveOnMainThread -" +__func__ [ -rv -owner -aCallback +requestToken +pbRequest = std : : move ( -aCallback +pbRequest ) -pbResponse +client +] +{ +RefPtr +< +ContentAnalysis +> +owner = -std -: -: -move +GetContentAnalysisFromService ( -pbResponse ) -requestToken -] +; +if ( +! +owner ) -mutable { +return +; +} if ( -NS_SUCCEEDED -( -rv -) +! +client ) { -LOGD +owner +- +> +CancelWithError +( +std +: +: +move +( +requestToken +) +NS_ERROR_NOT_AVAILABLE +) +; +return +; +} +{ +auto +callbackMap += +owner +- +> +mCallbackMap +. +Lock +( +) +; +if +( +! +callbackMap +- +> +Contains +( +requestToken +) +) +{ +LOGD ( " -Content -analysis -resolving -response -promise -for -" -" +RunAnalyzeRequestTask token % s +has +already +been +" +" +cancelled +- +not +issuing +request " requestToken . @@ -3752,6 +4240,132 @@ get ) ) ; +return +; +} +} +content_analysis +: +: +sdk +: +: +ContentAnalysisResponse +pbResponse +; +int +err += +client +- +> +Send +( +pbRequest +& +pbResponse +) +; +if +( +err +! += +0 +) +{ +LOGE +( +" +RunAnalyzeRequestTask +client +transaction +failed +" +) +; +owner +- +> +CancelWithError +( +std +: +: +move +( +requestToken +) +NS_ERROR_FAILURE +) +; +return +; +} +LOGD +( +" +Content +analysis +client +transaction +succeeded +" +) +; +LogResponse +( +& +pbResponse +) +; +NS_DispatchToMainThread +( +NS_NewCancelableRunnableFunction +( +" +ContentAnalysis +: +: +RunAnalyzeRequestTask +: +: +HandleResponse +" +[ +pbResponse += +std +: +: +move +( +pbResponse +) +] +( +) +mutable +{ +RefPtr +< +ContentAnalysis +> +owner += +GetContentAnalysisFromService +( +) +; +if +( +! +owner +) +{ +return +; +} RefPtr < ContentAnalysisResponse @@ -3772,17 +4386,205 @@ pbResponse ) ) ; -if +if +( +! +response +) +{ +LOGE +( +" +Content +analysis +got +invalid +response +! +" +) +; +return +; +} +nsCString +responseRequestToken +; +nsresult +requestRv += +response +- +> +GetRequestToken +( +responseRequestToken +) +; +if +( +NS_FAILED +( +requestRv +) +) +{ +LOGE +( +" +Content +analysis +couldn +' +t +get +request +token +" +" +from +response +! +" +) +; +return +; +} +Maybe +< +CallbackData +> +maybeCallbackData +; +{ +auto +callbackMap += +owner +- +> +mCallbackMap +. +Lock +( +) +; +maybeCallbackData += +callbackMap +- +> +Extract +( +responseRequestToken +) +; +} +if +( +maybeCallbackData +. +isNothing +( +) +) +{ +LOGD +( +" +Content +analysis +did +not +find +callback +for +" +" +token +% +s +" +responseRequestToken +. +get +( +) +) +; +return +; +} +response +- +> +SetOwner +( +owner +) +; +if +( +maybeCallbackData +- +> +Canceled +( +) +) +{ +LOGD +( +" +Content +analysis +got +response +but +ignoring +" +" +because +it +was +already +cancelled +for +token +% +s +" +responseRequestToken +. +get +( +) +) +; +return +; +} +LOGD ( +" +Content +analysis +resolving response -) -{ -response -- -> -SetOwner +promise +for +" +" +token +% +s +" +responseRequestToken +. +get ( -owner +) ) ; nsCOMPtr @@ -3815,68 +4617,43 @@ response nullptr ) ; -aCallback -- +nsMainThreadPtrHandle +< +nsIContentAnalysisCallback > -ContentResult -( -response -) -; -} -else -{ -aCallback +callbackHolder += +maybeCallbackData - > -Error +TakeCallbackHolder ( -NS_ERROR_FAILURE ) ; -} -} -else -{ -aCallback +callbackHolder - > -Error +ContentResult ( -rv +response ) ; } -} ) ) ; } ) -; -auto -caClientRef -= -sCaClient -. -Lock -( -) -; -auto -& -caClient -= -caClientRef -. -ref -( +NS_DISPATCH_EVENT_MAY_BLOCK ) ; -if +} +[ +requestToken +] ( -! -caClient +nsresult +rv ) { LOGD @@ -3890,76 +4667,42 @@ client " ) ; -rv -= -NS_ERROR_NOT_AVAILABLE -; -return -; -} -int -err -= -caClient -- +RefPtr +< +ContentAnalysis > -Send +owner += +GetContentAnalysisFromService ( -pbRequest -& -pbResponse ) ; if ( -err ! -= -0 +owner ) { -LOGD -( -" -RunAnalyzeRequestTask -client -transaction -failed -" -) -; -rv -= -NS_ERROR_FAILURE -; return ; } -LOGD +owner +- +> +CancelWithError ( -" -Content -analysis -client -transaction -succeeded -" -) -; -LogResponse +std +: +: +move ( -& -pbResponse +requestToken ) -; rv -= -NS_OK +) ; } ) -NS_DISPATCH_EVENT_MAY_BLOCK -) ; return rv @@ -4048,100 +4791,286 @@ get ) ; } -NS_IMETHODIMP -ContentAnalysis -: -: -AnalyzeContentRequestCallback +NS_IMETHODIMP +ContentAnalysis +: +: +AnalyzeContentRequestCallback +( +nsIContentAnalysisRequest +* +aRequest +nsIContentAnalysisCallback +* +aCallback +) +{ +NS_ENSURE_ARG +( +aRequest +) +; +NS_ENSURE_ARG +( +aCallback +) +; +bool +isActive +; +nsresult +rv += +GetIsActive +( +& +isActive +) +; +NS_ENSURE_SUCCESS +( +rv +rv +) +; +if +( +! +isActive +) +{ +return +NS_ERROR_NOT_AVAILABLE +; +} +nsCOMPtr +< +nsIObserverService +> +obsServ += +mozilla +: +: +services +: +: +GetObserverService +( +) +; +obsServ +- +> +NotifyObservers +( +aRequest +" +dlp +- +request +- +made +" +nullptr +) +; +rv += +RunAnalyzeRequestTask +( +aRequest +aCallback +) +; +return +rv +; +} +NS_IMETHODIMP +ContentAnalysis +: +: +CancelContentAnalysisRequest +( +const +nsACString +& +aRequestToken +) +{ +NS_DispatchToMainThread +( +NS_NewCancelableRunnableFunction +( +" +CancelContentAnalysisRequest +" +[ +requestToken += +nsCString +{ +aRequestToken +} +] ( -nsIContentAnalysisRequest -* -aRequest -nsIContentAnalysisCallback -* -aCallback ) { -NS_ENSURE_ARG +RefPtr +< +ContentAnalysis +> +self += +GetContentAnalysisFromService ( -aRequest ) ; -NS_ENSURE_ARG +if ( -aCallback +! +self ) +{ +return ; -bool -isActive +} +auto +callbackMap += +self +- +> +mCallbackMap +. +Lock +( +) ; -nsresult -rv +auto +entry = -GetIsActive +callbackMap +- +> +Lookup ( -& -isActive +requestToken ) ; -NS_ENSURE_SUCCESS +LOGD ( -rv -rv +" +Content +analysis +cancelling +request +% +s +" +requestToken +. +get +( +) ) ; if ( -! -isActive +entry ) { -return -NS_ERROR_NOT_AVAILABLE +entry +- +> +SetCanceled +( +) ; -} -nsCOMPtr +RefPtr < -nsIObserverService +ContentAnalysisResponse > -obsServ +cancelResponse = -mozilla +ContentAnalysisResponse : : -services +FromAction +( +nsIContentAnalysisResponse : : -GetObserverService +CANCELED +requestToken +) +; +cancelResponse +- +> +SetOwner ( +self ) ; -obsServ +nsMainThreadPtrHandle +< +nsIContentAnalysisCallback +> +callbackHolder += +entry - > -NotifyObservers +TakeCallbackHolder ( -aRequest -" -dlp +) +; +callbackHolder - +> +ContentResult +( +cancelResponse +. +get +( +) +) +; +} +else +{ +LOGD +( +" +Content +analysis request -- -made +not +found +when +trying +to +cancel +% +s " -nullptr +requestToken +. +get +( +) ) ; -rv -= -RunAnalyzeRequestTask -( -aRequest -aCallback +} +} +) ) ; return -rv +NS_OK ; } NS_IMETHODIMP @@ -4254,14 +5183,6 @@ LogAcknowledgement pbAck ) ; -RefPtr -< -ContentAnalysis -> -owner -= -this -; LOGD ( " @@ -4272,16 +5193,16 @@ task " ) ; -return -NS_DispatchBackgroundTask +mCaClientPromise +- +> +Then ( -NS_NewRunnableFunction +GetCurrentSerialEventTarget ( -" -RunAcknowledgeTask -" +) +__func__ [ -owner pbAck = std @@ -4292,54 +5213,73 @@ move pbAck ) ] +( +std +: +: +shared_ptr +< +content_analysis +: +: +sdk +: +: +Client +> +client +) { -auto -caClientRef +NS_DispatchBackgroundTask +( +NS_NewCancelableRunnableFunction +( +__func__ +[ +pbAck = -sCaClient -. -Lock +std +: +: +move ( +pbAck ) -; -auto -& -caClient +client +] +{ +RefPtr +< +ContentAnalysis +> +owner = -caClientRef -. -ref +GetContentAnalysisFromService ( ) ; if ( ! -caClient +owner ) { -LOGD +return +; +} +if ( -" -RunAcknowledgeTask -failed -to -get -the +! client -" ) -; +{ return ; } -DebugOnly -< int -> err = -caClient +client - > Acknowledge @@ -4363,12 +5303,46 @@ sent transaction acknowledgement " +" +err += +% +d +" +err ) ; } ) +NS_DISPATCH_EVENT_MAY_BLOCK +) +; +} +[ +] +( +nsresult +rv +) +{ +LOGD +( +" +RunAcknowledgeTask +failed +to +get +the +client +" +) +; +} ) ; +return +rv +; } NS_IMETHODIMP ContentAnalysisCallback @@ -4500,4 +5474,10 @@ aPromise ) { } +# +undef +LOGD +# +undef +LOGE } diff --git a/toolkit/components/contentanalysis/ContentAnalysis.h b/toolkit/components/contentanalysis/ContentAnalysis.h index c72f98137c76..5efee8f2d303 100644 --- a/toolkit/components/contentanalysis/ContentAnalysis.h +++ b/toolkit/components/contentanalysis/ContentAnalysis.h @@ -27,36 +27,39 @@ h # include " -mozilla -/ -Mutex +nsIContentAnalysis . h " # include " -nsIContentAnalysis +nsProxyRelease . h " # include " -nsProxyRelease +nsString . h " # include " -nsString +nsTHashMap . h " # include < +atomic +> +# +include +< string > namespace @@ -197,6 +200,29 @@ mWindowGlobalParent ; } ; +# +define +CONTENTANALYSIS_IID +\ +{ +\ +0xa37bed74 +0x4b50 +0x443a +{ +\ +0xbf +0x58 +0xf4 +0xeb +0xbd +0x30 +0x67 +0xb4 +\ +} +\ +} class ContentAnalysisResponse ; @@ -209,13 +235,15 @@ nsIContentAnalysis { public : +NS_DECLARE_STATIC_IID_ACCESSOR +( +CONTENTANALYSIS_IID +) NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSICONTENTANALYSIS ContentAnalysis ( ) -= -default ; private : @@ -245,8 +273,14 @@ ContentAnalysis delete ; nsresult -EnsureContentAnalysisClient +CreateContentAnalysisClient ( +nsCString +& +& +aPipePathName +bool +aIsPerUser ) ; nsresult @@ -276,10 +310,33 @@ nsACString aRequestToken ) ; +nsresult +CancelWithError +( +nsCString +aRequestToken +nsresult +aResult +) +; static -StaticDataMutex +RefPtr < -UniquePtr +ContentAnalysis +> +GetContentAnalysisFromService +( +) +; +using +ClientPromise += +MozPromise +< +std +: +: +shared_ptr < content_analysis : @@ -289,8 +346,103 @@ sdk : Client > +nsresult +false +> +; +RefPtr +< +ClientPromise +: +: +Private > -sCaClient +mCaClientPromise +; +bool +mClientCreationAttempted +; +class +CallbackData +{ +public +: +explicit +CallbackData +( +nsMainThreadPtrHandle +< +nsIContentAnalysisCallback +> +& +& +aCallbackHolder +) +: +mCallbackHolder +( +aCallbackHolder +) +{ +} +nsMainThreadPtrHandle +< +nsIContentAnalysisCallback +> +TakeCallbackHolder +( +) +{ +return +std +: +: +move +( +mCallbackHolder +) +; +} +void +SetCanceled +( +) +{ +mCallbackHolder += +nullptr +; +} +bool +Canceled +( +) +const +{ +return +! +mCallbackHolder +; +} +private +: +nsMainThreadPtrHandle +< +nsIContentAnalysisCallback +> +mCallbackHolder +; +} +; +DataMutex +< +nsTHashMap +< +nsCString +CallbackData +> +> +mCallbackMap ; friend class @@ -298,6 +450,11 @@ ContentAnalysisResponse ; } ; +NS_DEFINE_STATIC_IID_ACCESSOR +( +ContentAnalysis +CONTENTANALYSIS_IID +) class ContentAnalysisResponse final diff --git a/toolkit/components/contentanalysis/nsIContentAnalysis.idl b/toolkit/components/contentanalysis/nsIContentAnalysis.idl index d8989f48f8a5..222323fb7c42 100644 --- a/toolkit/components/contentanalysis/nsIContentAnalysis.idl +++ b/toolkit/components/contentanalysis/nsIContentAnalysis.idl @@ -154,6 +154,13 @@ ALLOW = 1000 ; +const +unsigned +long +CANCELED += +1001 +; [ infallible ] @@ -528,5 +535,13 @@ nsIContentAnalysisCallback callback ) ; +void +cancelContentAnalysisRequest +( +in +ACString +aRequestToken +) +; } ; diff --git a/toolkit/components/prompts/content/commonDialog.css b/toolkit/components/prompts/content/commonDialog.css index 196390b12a4a..e26e8b7f6c16 100644 --- a/toolkit/components/prompts/content/commonDialog.css +++ b/toolkit/components/prompts/content/commonDialog.css @@ -305,6 +305,30 @@ flex ; } # +spinnerContainer +{ +align +- +items +: +center +; +} +# +spinnerContainer +> +img +{ +width +: +16px +; +height +: +16px +; +} +# loginLabel # password1Label diff --git a/toolkit/components/prompts/content/commonDialog.js b/toolkit/components/prompts/content/commonDialog.js index 9c296a34b116..be2248b38951 100644 --- a/toolkit/components/prompts/content/commonDialog.js +++ b/toolkit/components/prompts/content/commonDialog.js @@ -566,6 +566,16 @@ getElementById infoIcon " ) +spinnerContainer +: +document +. +getElementById +( +" +spinnerContainer +" +) checkbox : document diff --git a/toolkit/components/prompts/content/commonDialog.xhtml b/toolkit/components/prompts/content/commonDialog.xhtml index 5e30630d3bd2..99080a327844 100644 --- a/toolkit/components/prompts/content/commonDialog.xhtml +++ b/toolkit/components/prompts/content/commonDialog.xhtml @@ -722,6 +722,96 @@ div id = " +spinnerContainer +" +class += +" +dialogRow +" +hidden += +" +hidden +" +> +< +img +src += +" +chrome +: +/ +/ +global +/ +skin +/ +icons +/ +loading +. +png +" +data +- +l10n +- +id += +" +common +- +dialog +- +spinner +" +srcset += +" +chrome +: +/ +/ +global +/ +skin +/ +icons +/ +loading +. +png +chrome +: +/ +/ +global +/ +skin +/ +icons +/ +loading +2x +. +png +1 +. +25x +" +/ +> +< +/ +div +> +< +div +id += +" loginContainer " class diff --git a/toolkit/components/prompts/src/CommonDialog.sys.mjs b/toolkit/components/prompts/src/CommonDialog.sys.mjs index d38dcff7e147..7f38c7d85023 100644 --- a/toolkit/components/prompts/src/CommonDialog.sys.mjs +++ b/toolkit/components/prompts/src/CommonDialog.sys.mjs @@ -963,6 +963,33 @@ title title ; } +if +( +this +. +ui +. +spinnerContainer +& +& +this +. +args +. +showSpinner +) +{ +this +. +ui +. +spinnerContainer +. +hidden += +false +; +} / / Set diff --git a/toolkit/components/prompts/src/Prompter.sys.mjs b/toolkit/components/prompts/src/Prompter.sys.mjs index 48de3654b554..b196d0e411dc 100644 --- a/toolkit/components/prompts/src/Prompter.sys.mjs +++ b/toolkit/components/prompts/src/Prompter.sys.mjs @@ -10994,6 +10994,24 @@ label2 } if ( +flags +& +Ci +. +nsIPrompt +. +SHOW_SPINNER +) +{ +args +. +showSpinner += +true +; +} +if +( this . async diff --git a/toolkit/components/windowwatcher/nsIPromptService.idl b/toolkit/components/windowwatcher/nsIPromptService.idl index f3723b212370..54bd6801dcd4 100644 --- a/toolkit/components/windowwatcher/nsIPromptService.idl +++ b/toolkit/components/windowwatcher/nsIPromptService.idl @@ -405,6 +405,16 @@ BUTTON_DELAY_ENABLE const unsigned long +SHOW_SPINNER += +1 +< +< +27 +; +const +unsigned +long STD_OK_CANCEL_BUTTONS = ( diff --git a/toolkit/locales/en-US/toolkit/global/commonDialog.ftl b/toolkit/locales/en-US/toolkit/global/commonDialog.ftl index 47a3b7b0e24b..7e25f5972cd2 100644 --- a/toolkit/locales/en-US/toolkit/global/commonDialog.ftl +++ b/toolkit/locales/en-US/toolkit/global/commonDialog.ftl @@ -102,6 +102,29 @@ title unknown = Unknown +# +An +indicator +showing +that +Firefox +is +waiting +for +an +operation +to +finish +common +- +dialog +- +spinner += +. +alt += +Busy common - dialog