@@ -107,12 +107,35 @@ export class CookieControlsView extends UI.Widget.VBox {
107107 #view: View ;
108108
109109 constructor ( element ?: HTMLElement , view : View = ( input , output , target ) => {
110- // TODO(crbug.com/365737493): Determine whether the enterprise is present based on UI bindings
111- const enterprisePresent = false ;
110+ const thirdPartyControlsDict = Common . Settings . Settings . instance ( ) . getHostConfig ( ) . thirdPartyCookieControls ;
112111
113- const toggleSetting = Common . Settings . Settings . instance ( ) . moduleSetting ( 'cookie-control-override-enabled' ) ;
114- const gracePeriodSetting = Common . Settings . Settings . instance ( ) . moduleSetting ( 'grace-period-mitigation-disabled' ) ;
115- const heuristicSetting = Common . Settings . Settings . instance ( ) . moduleSetting ( 'heuristic-mitigation-disabled' ) ;
112+ // createSetting() allows us to initialize the settings with the UI binding values the first
113+ // time that the browser starts, and use the existing setting value for all subsequent uses.
114+ const enterpriseEnabledSetting = Common . Settings . Settings . instance ( ) . createSetting (
115+ 'enterprise-enabled' ,
116+ thirdPartyControlsDict && thirdPartyControlsDict . managedBlockThirdPartyCookies &&
117+ typeof thirdPartyControlsDict . managedBlockThirdPartyCookies === 'boolean' ?
118+ thirdPartyControlsDict . managedBlockThirdPartyCookies :
119+ false ,
120+ Common . Settings . SettingStorageType . GLOBAL ) ;
121+ const toggleEnabledSetting = Common . Settings . Settings . instance ( ) . createSetting (
122+ 'cookie-control-override-enabled' ,
123+ thirdPartyControlsDict && thirdPartyControlsDict . thirdPartyCookieRestrictionEnabled ?
124+ thirdPartyControlsDict . thirdPartyCookieRestrictionEnabled :
125+ false ,
126+ Common . Settings . SettingStorageType . GLOBAL ) ;
127+ const gracePeriodDisabledSetting = Common . Settings . Settings . instance ( ) . createSetting (
128+ 'grace-period-mitigation-disabled' ,
129+ thirdPartyControlsDict && thirdPartyControlsDict . thirdPartyCookieMetadataEnabled ?
130+ thirdPartyControlsDict . thirdPartyCookieMetadataEnabled :
131+ true ,
132+ Common . Settings . SettingStorageType . GLOBAL ) ;
133+ const heuristicsDisabledSetting = Common . Settings . Settings . instance ( ) . createSetting (
134+ 'heuristic-mitigation-disabled' ,
135+ thirdPartyControlsDict && thirdPartyControlsDict . thirdPartyCookieHeuristicsEnabled ?
136+ thirdPartyControlsDict . thirdPartyCookieHeuristicsEnabled :
137+ true ,
138+ Common . Settings . SettingStorageType . GLOBAL ) ;
116139
117140 // clang-format off
118141 const cardHeader = html `
@@ -122,7 +145,7 @@ export class CookieControlsView extends UI.Widget.VBox {
122145 < div class ="card-title "> ${ i18nString ( UIStrings . cardTitle ) } </ div >
123146 < div class ="body "> ${ i18nString ( UIStrings . cardDisclaimer ) } </ div >
124147 </ div >
125- ${ enterprisePresent ? html `
148+ ${ Boolean ( enterpriseEnabledSetting . get ( ) ) ? html `
126149 < devtools-icon
127150 .name =${ 'domain' }
128151 ${ LitHtml . Directives . ref ( ( el : Element | undefined ) => {
@@ -133,10 +156,10 @@ export class CookieControlsView extends UI.Widget.VBox {
133156 </ div >
134157 < div >
135158 < devtools-switch
136- .checked =${ Boolean ( toggleSetting . get ( ) ) }
137- .disabled =${ enterprisePresent }
159+ .checked =${ Boolean ( toggleEnabledSetting . get ( ) ) }
160+ .disabled =${ Boolean ( enterpriseEnabledSetting . get ( ) ) }
138161 @switchchange=${ ( e : Event ) => {
139- input . inputChanged ( ( e . target as HTMLInputElement ) . checked , toggleSetting ) ;
162+ input . inputChanged ( ( e . target as HTMLInputElement ) . checked , toggleEnabledSetting ) ;
140163 } } >
141164 </ devtools-switch >
142165 </ div >
@@ -147,17 +170,17 @@ export class CookieControlsView extends UI.Widget.VBox {
147170 < div class ="card-row ">
148171 < label class ='checkbox-label '>
149172 < input type ='checkbox '
150- ? disabled =${ enterprisePresent || ! Boolean ( toggleSetting . get ( ) ) }
151- ? checked =${ ! Boolean ( gracePeriodSetting . get ( ) ) }
173+ . disabled =${ Boolean ( enterpriseEnabledSetting . get ( ) ) || ! Boolean ( toggleEnabledSetting . get ( ) ) }
174+ . checked =${ Boolean ( toggleEnabledSetting . get ( ) ) && ! Boolean ( gracePeriodDisabledSetting . get ( ) ) }
152175 @change=${ ( e : Event ) => {
153- input . inputChanged ( ! ( e . target as HTMLInputElement ) . checked , gracePeriodSetting ) ;
176+ input . inputChanged ( ( e . target as HTMLInputElement ) . checked , gracePeriodDisabledSetting ) ;
154177 } }
155178 >
156179 < div class ="text ">
157180 < div class ="body "> ${ i18nString ( UIStrings . gracePeriodTitle ) } </ div >
158181 < div class ="body ">
159182 ${ i18nFormatString ( UIStrings . gracePeriodExplanation , {
160- PH1 : enterprisePresent ? i18nString ( UIStrings . gracePeriod ) : UI . Fragment . html `< x-link class ="x-link " href ="https://developers.google.com/privacy-sandbox/cookies/temporary-exceptions/grace-period " jslog =${ VisualLogging . link ( 'grace-period-link' ) . track ( { click : true } ) } > ${ i18nString ( UIStrings . gracePeriod ) } </ x-link > ` ,
183+ PH1 : Boolean ( enterpriseEnabledSetting . get ( ) ) ? i18nString ( UIStrings . gracePeriod ) : UI . Fragment . html `< x-link class ="x-link " href ="https://developers.google.com/privacy-sandbox/cookies/temporary-exceptions/grace-period " jslog =${ VisualLogging . link ( 'grace-period-link' ) . track ( { click : true } ) } > ${ i18nString ( UIStrings . gracePeriod ) } </ x-link > ` ,
161184 } ) }
162185 </ div >
163186 </ div >
@@ -169,17 +192,17 @@ export class CookieControlsView extends UI.Widget.VBox {
169192 < div class ="card-row ">
170193 < label class ='checkbox-label '>
171194 < input type ='checkbox '
172- ? disabled =${ enterprisePresent || ! Boolean ( toggleSetting . get ( ) ) }
173- ? checked =${ ! Boolean ( heuristicSetting . get ( ) ) }
195+ . disabled =${ Boolean ( enterpriseEnabledSetting . get ( ) ) || ! Boolean ( toggleEnabledSetting . get ( ) ) }
196+ . checked =${ Boolean ( toggleEnabledSetting . get ( ) && ! Boolean ( heuristicsDisabledSetting . get ( ) ) ) }
174197 @change=${ ( e : Event ) => {
175- input . inputChanged ( ! ( e . target as HTMLInputElement ) . checked , heuristicSetting ) ;
198+ input . inputChanged ( ( e . target as HTMLInputElement ) . checked , heuristicsDisabledSetting ) ;
176199 } }
177200 >
178201 < div class ="text ">
179202 < div class ="body "> ${ i18nString ( UIStrings . heuristicTitle ) } </ div >
180203 < div class ="body ">
181204 ${ i18nFormatString ( UIStrings . heuristicExplanation , {
182- PH1 : enterprisePresent ? i18nString ( UIStrings . scenarios ) : UI . Fragment . html `< x-link class ="x-link " href ="https://developers.google.com/privacy-sandbox/cookies/temporary-exceptions/heuristics-based-exceptions " jslog =${ VisualLogging . link ( 'heuristic-link' ) . track ( { click : true } ) } > ${ i18nString ( UIStrings . scenarios ) } </ x-link > ` ,
205+ PH1 : Boolean ( enterpriseEnabledSetting . get ( ) ) ? i18nString ( UIStrings . scenarios ) : UI . Fragment . html `< x-link class ="x-link " href ="https://developers.google.com/privacy-sandbox/cookies/temporary-exceptions/heuristics-based-exceptions " jslog =${ VisualLogging . link ( 'heuristic-link' ) . track ( { click : true } ) } > ${ i18nString ( UIStrings . scenarios ) } </ x-link > ` ,
183206 } ) }
184207 </ div >
185208 </ div >
@@ -211,7 +234,7 @@ export class CookieControlsView extends UI.Widget.VBox {
211234 < div class ="body "> ${ i18nString ( UIStrings . viewExplanation ) } </ div >
212235 </ div >
213236 < devtools-card >
214- < div slot ="content " class =${ enterprisePresent ? 'card enterprise-disabled' : 'card' } >
237+ < div slot ="content " class =${ Boolean ( enterpriseEnabledSetting . get ( ) ) ? 'card enterprise-disabled' : 'card' } >
215238 ${ cardHeader }
216239 < div >
217240 < div class ="card-row text ">
@@ -223,7 +246,7 @@ export class CookieControlsView extends UI.Widget.VBox {
223246 </ div >
224247 </ div >
225248 </ devtools-card >
226- ${ enterprisePresent ? enterpriseDisclaimer : LitHtml . nothing }
249+ ${ Boolean ( enterpriseEnabledSetting . get ( ) ) ? enterpriseDisclaimer : LitHtml . nothing }
227250 </ div >
228251 </ div >
229252 ` , target , { host : this } ) ;
0 commit comments