// Copyright 2021 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. module parent_access_ui.mojom; import "mojo/public/mojom/base/string16.mojom"; import "url/mojom/url.mojom"; enum GetOauthTokenStatus { kSuccess, kError, kOnlyOneFetchAtATime, }; // Types of messages sent in the ParentAccessCallback. enum ParentAccessServerMessageType { // Indicates that the parent's identity was verified. // Returned by either verification or consent flow. // In consent flow it also means that parent provided the consent and // that consent was recorded. kParentVerified, // An internal error occurred in any of the flows. // The user should be prompted with an unrecoverable error in this case. kError, // Indicates that the result type should be ignored. This can happen if the // server adds a new return type that we don't support. kIgnore, }; // Struct returned to the WebUI based on the parsed ParentAccessCallback proto. struct ParentAccessServerMessage { // The message type. ParentAccessServerMessageType type; }; // Struct containing pertinent information that is used to render the parent // access dialog. struct ParentAccessParams { enum FlowType { kWebsiteAccess, kExtensionAccess, }; // Defines the type of flow to invoke in the dialog. FlowType flow_type; FlowTypeParams? flow_type_params; // Indicates if the Parent Access disabled UI should be shown. This can be // determined differently depending on the flow type. For example, in the // extension approval flow, this value is true if the parent has disabled // the extension permissions setting for the supervised user. bool is_disabled; }; // Parameters for local web approvals feature. struct WebApprovalsParams { // The URL access is being requested for. url.mojom.Url url; // The child's name to be displayed to the parent. mojo_base.mojom.String16 child_display_name; // The PNG representation of the URL's favicon. array favicon_png_bytes; }; // Parameters for the local extension approvals V2 feature. struct ExtensionApprovalsParams { // Display name for the extension. mojo_base.mojom.String16 extension_name; // Extension icon, stored as an array of bytes. array icon_png_bytes; // The child's name to be displayed to the parent. mojo_base.mojom.String16 child_display_name; // Localized messages indicating the permissions requirements for an // extension. array permissions; }; // Permission required by an extension. // Permission messages are generated by the extension component from the set // of permissions listed in extensions/common/mojom/api_permission_id.mojom. struct ExtensionPermission { mojo_base.mojom.String16 permission; // Permission details. Can be empty. mojo_base.mojom.String16 details; }; union FlowTypeParams { WebApprovalsParams web_approvals_params; ExtensionApprovalsParams extension_approvals_params; }; // The result of the parent access request. enum ParentAccessResult { kApproved, kDeclined, kCanceled, kDisabled, kError, }; // Interface that supports integration between the ParentAccess WebUI and // ChromeOS. interface ParentAccessUiHandler { // Returns the oauth token to be passed to the server. GetOauthToken() => (GetOauthTokenStatus status, string oauth_token); // When called, signals that the server widget has provided a result. // Returns a ParentAccessServerMessage parsed from the encoded proto string. OnParentAccessCallbackReceived(string encoded_parent_access_callback_proto) => (ParentAccessServerMessage message); // Returns the FlowTypeParams pertinent to the current parent access flow. GetParentAccessParams() => (ParentAccessParams params); // Returns the URL for the parent access widget endpoint. GetParentAccessUrl() => (string url); // When called, indicates that that the request has completed with the // specified result, which will cause the Parent Access UI to close. OnParentAccessDone(ParentAccessResult result) => (); // Called when the UI has switched from the before screen to the // ParentAuthentication screen. OnBeforeScreenDone() => (); };