55import '../../ui/components/switch/switch.js' ;
66
77import * as Common from '../../core/common/common.js' ;
8+ import * as Host from '../../core/host/host.js' ;
89import * as i18n from '../../core/i18n/i18n.js' ;
10+ import type * as Platform from '../../core/platform/platform.js' ;
11+ import * as SDK from '../../core/sdk/sdk.js' ;
12+ import * as Buttons from '../../ui/components/buttons/buttons.js' ;
913import * as Cards from '../../ui/components/cards/cards.js' ; // eslint-disable-line @typescript-eslint/no-unused-vars
1014import * as Input from '../../ui/components/input/input.js' ;
1115import * as UI from '../../ui/legacy/legacy.js' ;
@@ -73,6 +77,18 @@ const UIStrings = {
7377 *@description Text used for link within the heuristicExplanation to let the user learn more about the heuristic exception
7478 */
7579 scenarios : 'predefined scenarios' ,
80+ /**
81+ *@description Note at the bottom of the controls tool telling the user that their organization has an enterprise policy that controls cookies. This may disable the tool
82+ */
83+ enterpriseDisclaimer : 'Your organization manages third-party cookie access for this site' ,
84+ /**
85+ *@description Tooltip that appears when the user hovers over the card's enterprise icon
86+ */
87+ enterpriseTooltip : 'This setting is managed by your organization' ,
88+ /**
89+ +*@description Button with the enterpise disclaimer that takes the user to the relevant enterprise cookie chrome setting
90+ */
91+ viewDetails : 'View details' ,
7692} ;
7793
7894const str_ = i18n . i18n . registerUIStrings ( 'panels/security/CookieControlsView.ts' , UIStrings ) ;
@@ -81,6 +97,7 @@ export const i18nFormatString = i18n.i18n.getFormatLocalizedString.bind(undefine
8197
8298export interface ViewInput {
8399 inputChanged : ( newValue : boolean , setting : Common . Settings . Setting < boolean > ) => void ;
100+ openChromeCookieSettings : ( ) => void ;
84101}
85102export interface ViewOutput { }
86103
@@ -90,6 +107,9 @@ export class CookieControlsView extends UI.Widget.VBox {
90107 #view: View ;
91108
92109 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 ;
112+
93113 const toggleSetting = Common . Settings . Settings . instance ( ) . moduleSetting ( 'cookie-control-override-enabled' ) ;
94114 const gracePeriodSetting = Common . Settings . Settings . instance ( ) . moduleSetting ( 'grace-period-mitigation-disabled' ) ;
95115 const heuristicSetting = Common . Settings . Settings . instance ( ) . moduleSetting ( 'heuristic-mitigation-disabled' ) ;
@@ -102,10 +122,19 @@ export class CookieControlsView extends UI.Widget.VBox {
102122 < div class ="card-title "> ${ i18nString ( UIStrings . cardTitle ) } </ div >
103123 < div class ="body "> ${ i18nString ( UIStrings . cardDisclaimer ) } </ div >
104124 </ div >
125+ ${ enterprisePresent ? html `
126+ < devtools-icon
127+ .name =${ 'domain' }
128+ ${ LitHtml . Directives . ref ( ( el : Element | undefined ) => {
129+ UI . Tooltip . Tooltip . install ( el as HTMLElement , i18nString ( UIStrings . enterpriseTooltip ) ) ;
130+ } ) } >
131+ </ devtools-icon > ` : LitHtml . nothing
132+ }
105133 </ div >
106134 < div >
107135 < devtools-switch
108136 .checked =${ Boolean ( toggleSetting . get ( ) ) }
137+ .disabled =${ enterprisePresent }
109138 @switchchange=${ ( e : Event ) => {
110139 input . inputChanged ( ( e . target as HTMLInputElement ) . checked , toggleSetting ) ;
111140 } } >
@@ -118,7 +147,7 @@ export class CookieControlsView extends UI.Widget.VBox {
118147 < div class ="card-row ">
119148 < label class ='checkbox-label '>
120149 < input type ='checkbox '
121- ?disabled =${ ! Boolean ( toggleSetting . get ( ) ) }
150+ ?disabled =${ enterprisePresent || ! Boolean ( toggleSetting . get ( ) ) }
122151 ?checked =${ ! Boolean ( gracePeriodSetting . get ( ) ) }
123152 @change=${ ( e : Event ) => {
124153 input . inputChanged ( ! ( e . target as HTMLInputElement ) . checked , gracePeriodSetting ) ;
@@ -128,7 +157,7 @@ export class CookieControlsView extends UI.Widget.VBox {
128157 < div class ="body "> ${ i18nString ( UIStrings . gracePeriodTitle ) } </ div >
129158 < div class ="body ">
130159 ${ i18nFormatString ( UIStrings . gracePeriodExplanation , {
131- PH1 : 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 > ` ,
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 > ` ,
132161 } ) }
133162 </ div >
134163 </ div >
@@ -140,7 +169,7 @@ export class CookieControlsView extends UI.Widget.VBox {
140169 < div class ="card-row ">
141170 < label class ='checkbox-label '>
142171 < input type ='checkbox '
143- ?disabled =${ ! Boolean ( toggleSetting . get ( ) ) }
172+ ?disabled =${ enterprisePresent || ! Boolean ( toggleSetting . get ( ) ) }
144173 ?checked =${ ! Boolean ( heuristicSetting . get ( ) ) }
145174 @change=${ ( e : Event ) => {
146175 input . inputChanged ( ! ( e . target as HTMLInputElement ) . checked , heuristicSetting ) ;
@@ -150,14 +179,30 @@ export class CookieControlsView extends UI.Widget.VBox {
150179 < div class ="body "> ${ i18nString ( UIStrings . heuristicTitle ) } </ div >
151180 < div class ="body ">
152181 ${ i18nFormatString ( UIStrings . heuristicExplanation , {
153- PH1 : 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 > ` ,
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 > ` ,
154183 } ) }
155184 </ div >
156185 </ div >
157186 </ label >
158187 </ div >
159188 ` ;
160189
190+ const enterpriseDisclaimer = html `
191+ < div class ="enterprise ">
192+ < div class ="text body "> ${ i18nString ( UIStrings . enterpriseDisclaimer ) } </ div >
193+ < devtools-icon
194+ .name =${ 'domain' }
195+ > </ devtools-icon >
196+ < devtools-button
197+ @click =${ input . openChromeCookieSettings }
198+ aria-label ="View details"
199+ .variant=${ Buttons . Button . Variant . OUTLINED }
200+ jslog=${ VisualLogging . action ( 'view-details' ) . track ( { click : true } ) } >
201+ ${ i18nString ( UIStrings . viewDetails ) }
202+ </ devtools-button >
203+ </ div >
204+ ` ;
205+
161206 render ( html `
162207 < div class ="overflow-auto ">
163208 < div class ="controls ">
@@ -166,7 +211,7 @@ export class CookieControlsView extends UI.Widget.VBox {
166211 < div class ="body "> ${ i18nString ( UIStrings . viewExplanation ) } </ div >
167212 </ div >
168213 < devtools-card >
169- < div slot ="content " class ='card ' >
214+ < div slot ="content " class =${ enterprisePresent ? 'card enterprise-disabled' : 'card' } >
170215 ${ cardHeader }
171216 < div >
172217 < div class ="card-row text ">
@@ -178,6 +223,7 @@ export class CookieControlsView extends UI.Widget.VBox {
178223 </ div >
179224 </ div >
180225 </ devtools-card >
226+ ${ enterprisePresent ? enterpriseDisclaimer : LitHtml . nothing }
181227 </ div >
182228 </ div >
183229 ` , target , { host : this } ) ;
@@ -199,6 +245,19 @@ export class CookieControlsView extends UI.Widget.VBox {
199245 this . update ( ) ;
200246 }
201247
248+ openChromeCookieSettings ( ) : void {
249+ const rootTarget = SDK . TargetManager . TargetManager . instance ( ) . rootTarget ( ) ;
250+ if ( rootTarget === null ) {
251+ return ;
252+ }
253+ const url = 'chrome://settings/cookies' as Platform . DevToolsPath . UrlString ;
254+ void rootTarget . targetAgent ( ) . invoke_createTarget ( { url} ) . then ( result => {
255+ if ( result . getError ( ) ) {
256+ Host . InspectorFrontendHost . InspectorFrontendHostInstance . openInNewTab ( url ) ;
257+ }
258+ } ) ;
259+ }
260+
202261 override wasShown ( ) : void {
203262 super . wasShown ( ) ;
204263 this . registerCSSFiles ( [ Input . checkboxStyles , cookieControlsViewStyles ] ) ;
0 commit comments