@@ -10,6 +10,7 @@ import * as Common from '../../core/common/common.js';
1010import * as Host from '../../core/host/host.js' ;
1111import * as i18n from '../../core/i18n/i18n.js' ;
1212import type * as Platform from '../../core/platform/platform.js' ;
13+ import type * as Root from '../../core/root/root.js' ;
1314import * as SDK from '../../core/sdk/sdk.js' ;
1415import * as Buttons from '../../ui/components/buttons/buttons.js' ;
1516import * as ChromeLink from '../../ui/components/chrome_link/chrome_link.js' ;
@@ -131,35 +132,34 @@ export function showInfobar(): void {
131132export class CookieControlsView extends UI . Widget . VBox {
132133 #view: View ;
133134 #isGracePeriodActive: boolean ;
135+ #thirdPartyControlsDict: Root . Runtime . HostConfig [ 'thirdPartyCookieControls' ] ;
134136
135137 constructor ( element ?: HTMLElement , view : View = ( input , output , target ) => {
136- const thirdPartyControlsDict = Common . Settings . Settings . instance ( ) . getHostConfig ( ) . thirdPartyCookieControls ;
137-
138138 // createSetting() allows us to initialize the settings with the UI binding values the first
139139 // time that the browser starts, and use the existing setting value for all subsequent uses.
140140 const enterpriseEnabledSetting = Common . Settings . Settings . instance ( ) . createSetting (
141141 'enterprise-enabled' ,
142- thirdPartyControlsDict && thirdPartyControlsDict . managedBlockThirdPartyCookies &&
143- typeof thirdPartyControlsDict . managedBlockThirdPartyCookies === 'boolean' ?
144- thirdPartyControlsDict . managedBlockThirdPartyCookies :
142+ this . # thirdPartyControlsDict && this . # thirdPartyControlsDict. managedBlockThirdPartyCookies &&
143+ typeof this . # thirdPartyControlsDict. managedBlockThirdPartyCookies === 'boolean' ?
144+ this . # thirdPartyControlsDict. managedBlockThirdPartyCookies :
145145 false ,
146146 Common . Settings . SettingStorageType . GLOBAL ) ;
147147 const toggleEnabledSetting = Common . Settings . Settings . instance ( ) . createSetting (
148148 'cookie-control-override-enabled' ,
149- thirdPartyControlsDict && thirdPartyControlsDict . thirdPartyCookieRestrictionEnabled ?
150- thirdPartyControlsDict . thirdPartyCookieRestrictionEnabled :
149+ this . # thirdPartyControlsDict && this . # thirdPartyControlsDict. thirdPartyCookieRestrictionEnabled ?
150+ this . # thirdPartyControlsDict. thirdPartyCookieRestrictionEnabled :
151151 false ,
152152 Common . Settings . SettingStorageType . GLOBAL ) ;
153153 const gracePeriodDisabledSetting = Common . Settings . Settings . instance ( ) . createSetting (
154154 'grace-period-mitigation-disabled' ,
155- thirdPartyControlsDict && thirdPartyControlsDict . thirdPartyCookieMetadataEnabled ?
156- thirdPartyControlsDict . thirdPartyCookieMetadataEnabled :
155+ this . # thirdPartyControlsDict && this . # thirdPartyControlsDict. thirdPartyCookieMetadataEnabled ?
156+ this . # thirdPartyControlsDict. thirdPartyCookieMetadataEnabled :
157157 true ,
158158 Common . Settings . SettingStorageType . GLOBAL ) ;
159159 const heuristicsDisabledSetting = Common . Settings . Settings . instance ( ) . createSetting (
160160 'heuristic-mitigation-disabled' ,
161- thirdPartyControlsDict && thirdPartyControlsDict . thirdPartyCookieHeuristicsEnabled ?
162- thirdPartyControlsDict . thirdPartyCookieHeuristicsEnabled :
161+ this . # thirdPartyControlsDict && this . # thirdPartyControlsDict. thirdPartyCookieHeuristicsEnabled ?
162+ this . # thirdPartyControlsDict. thirdPartyCookieHeuristicsEnabled :
163163 true ,
164164 Common . Settings . SettingStorageType . GLOBAL ) ;
165165
@@ -196,7 +196,7 @@ export class CookieControlsView extends UI.Widget.VBox {
196196 ` ;
197197
198198 const gracePeriodControlDisabled =
199- ( thirdPartyControlsDict ? ( ! thirdPartyControlsDict . thirdPartyCookieMetadataEnabled ) : false ) ||
199+ ( this . # thirdPartyControlsDict ? ( ! this . # thirdPartyControlsDict. thirdPartyCookieMetadataEnabled ) : false ) ||
200200 enterpriseEnabledSetting . get ( ) || ! toggleEnabledSetting . get ( ) || ! this . #isGracePeriodActive;
201201 const gracePeriodControl = html `
202202 < div class ="card-row ">
@@ -214,7 +214,7 @@ export class CookieControlsView extends UI.Widget.VBox {
214214 i18nFormatString ( UIStrings . gracePeriodExplanation , {
215215 PH1 : i18nString ( UIStrings . gracePeriod ) ,
216216 } ) :
217- ( thirdPartyControlsDict ? ! thirdPartyControlsDict ?. thirdPartyCookieMetadataEnabled : false ) ?
217+ ( this . # thirdPartyControlsDict ? ! this . # thirdPartyControlsDict?. thirdPartyCookieMetadataEnabled : false ) ?
218218 i18nFormatString ( UIStrings . enableFlag , {
219219 PH1 : this . getChromeFlagsLink ( UIStrings . tpcdMetadataGrants ) ,
220220 } ) :
@@ -229,7 +229,7 @@ export class CookieControlsView extends UI.Widget.VBox {
229229 ` ;
230230
231231 const heuristicsControlDisabled =
232- ( thirdPartyControlsDict ? ( ! thirdPartyControlsDict . thirdPartyCookieHeuristicsEnabled ) : false ) ||
232+ ( this . # thirdPartyControlsDict ? ( ! this . # thirdPartyControlsDict. thirdPartyCookieHeuristicsEnabled ) : false ) ||
233233 enterpriseEnabledSetting . get ( ) || ! toggleEnabledSetting . get ( ) ;
234234 const heuristicControl = html `
235235 < div class ="card-row ">
@@ -247,7 +247,7 @@ export class CookieControlsView extends UI.Widget.VBox {
247247 i18nFormatString ( UIStrings . heuristicExplanation , {
248248 PH1 : i18nString ( UIStrings . scenarios ) ,
249249 } ) :
250- ( thirdPartyControlsDict ? ! thirdPartyControlsDict . thirdPartyCookieHeuristicsEnabled : false ) ?
250+ ( this . # thirdPartyControlsDict ? ! this . # thirdPartyControlsDict. thirdPartyCookieHeuristicsEnabled : false ) ?
251251 i18nFormatString ( UIStrings . enableFlag , {
252252 PH1 : this . getChromeFlagsLink ( UIStrings . tpcdHeuristicsGrants ) ,
253253 } ) :
@@ -308,6 +308,7 @@ export class CookieControlsView extends UI.Widget.VBox {
308308 super ( true , undefined , element ) ;
309309 this . #view = view ;
310310 this . #isGracePeriodActive = false ;
311+ this . #thirdPartyControlsDict = Common . Settings . Settings . instance ( ) . getHostConfig ( ) . thirdPartyCookieControls ;
311312 this . registerRequiredCSS ( Input . checkboxStylesRaw , cookieControlsViewStyles ) ;
312313
313314 SDK . TargetManager . TargetManager . instance ( ) . addModelListener (
@@ -357,6 +358,10 @@ export class CookieControlsView extends UI.Widget.VBox {
357358 }
358359
359360 async checkGracePeriodActive ( event ?: Common . EventTarget . EventTargetEvent < SDK . Resource . Resource > ) : Promise < void > {
361+ if ( ! this . #thirdPartyControlsDict || ! this . #thirdPartyControlsDict. thirdPartyCookieMetadataEnabled ) {
362+ return ;
363+ }
364+
360365 if ( this . #isGracePeriodActive) {
361366 return ;
362367 }
0 commit comments