diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f566388..c549f79 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,7 +17,7 @@ jobs: steps: - uses: subosito/flutter-action@v2 with: - channel: 'master' + channel: 'stable' - uses: actions/checkout@v4 - run: dart --version - run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 967765c..e569613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.3.0 + +- Regenerate the bindings based on Chrome v122 +- Update JS binding for Dart 3.3 +- Require Dart SDK >= 3.3 + ## 0.2.0 - Regenerate the bindings based on Chrome v116 diff --git a/extension_examples/dart/pubspec.lock b/extension_examples/dart/pubspec.lock index 61afb01..1b741b7 100644 --- a/extension_examples/dart/pubspec.lock +++ b/extension_examples/dart/pubspec.lock @@ -5,18 +5,18 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "36a321c3d2cbe01cbcb3540a87b8843846e0206df3e691fa7b23e19e78de6d49" + sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" url: "https://pub.dev" source: hosted - version: "65.0.0" + version: "67.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: dfe03b90ec022450e22513b5e5ca1f01c0c01de9c3fba2f7fd233cb57a6b9a07 + sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" url: "https://pub.dev" source: hosted - version: "6.3.0" + version: "6.4.1" args: dependency: transitive description: @@ -47,7 +47,7 @@ packages: path: "../.." relative: true source: path - version: "0.2.0" + version: "0.3.0" collection: dependency: transitive description: @@ -140,10 +140,10 @@ packages: dependency: transitive description: name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf url: "https://pub.dev" source: hosted - version: "0.6.7" + version: "0.7.1" lints: dependency: "direct dev" description: @@ -172,18 +172,18 @@ packages: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.12.0" mime: dependency: transitive description: name: mime - sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "1.0.5" node_preamble: dependency: transitive description: @@ -340,10 +340,10 @@ packages: dependency: "direct dev" description: name: test - sha256: "3d028996109ad5c253674c7f347822fb994a087614d6f353e6039704b4661ff2" + sha256: "7ee446762c2c50b3bd4ea96fe13ffac69919352bd3b4b17bac3f3465edc58073" url: "https://pub.dev" source: hosted - version: "1.25.0" + version: "1.25.2" test_api: dependency: transitive description: @@ -417,4 +417,4 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.3.0-0 <4.0.0" + dart: ">=3.3.0 <4.0.0" diff --git a/extension_examples/flutter/pubspec.lock b/extension_examples/flutter/pubspec.lock index f01b006..283fcc1 100644 --- a/extension_examples/flutter/pubspec.lock +++ b/extension_examples/flutter/pubspec.lock @@ -31,7 +31,7 @@ packages: path: "../.." relative: true source: path - version: "0.2.0" + version: "0.3.0" clock: dependency: transitive description: @@ -86,26 +86,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: f8cdf1383f5b4672a2693d875f1f239af6bd7e4a8925a17ef7219226db932624 + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" url: "https://pub.dev" source: hosted - version: "10.0.1" + version: "10.0.0" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: a2055640bf5bc903475e4bbdb34e04f8bf698542bee41edec47d337a5939e1ae + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 url: "https://pub.dev" source: hosted - version: "2.0.3" + version: "2.0.1" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: e62042d479c4c139dd774125ed4dfbde646b8f07ac228e3c1b57a3d91d6d9df4 + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.0.1" lints: dependency: "direct dev" description: @@ -216,5 +216,4 @@ packages: source: hosted version: "13.0.0" sdks: - dart: ">=3.3.0-0 <4.0.0" - flutter: ">=3.18.0-18.0.pre.54" + dart: ">=3.3.0 <4.0.0" diff --git a/idl/chrome/accessibility_private.json b/idl/chrome/accessibility_private.json index ea22e21..e11b674 100644 --- a/idl/chrome/accessibility_private.json +++ b/idl/chrome/accessibility_private.json @@ -6,7 +6,7 @@ { "namespace": "accessibilityPrivate", "compiler_options": { - "implemented_in": "chrome/browser/accessibility/accessibility_extension_api_chromeos.h" + "implemented_in": "chrome/browser/accessibility/accessibility_extension_api_ash.h" }, "description": "none", "platforms": ["chromeos"], @@ -186,6 +186,12 @@ "description": "Whether to stack focus rings above or below accessibility bubble panels. Note: focus rings will be stacked above most other UI in either case", "enum": ["aboveAccessibilityBubbles", "belowAccessibilityBubbles"] }, + { + "id": "AssistiveTechnologyType", + "type": "string", + "description": "The assistive technology type of this extension.", + "enum": ["chromeVox", "selectToSpeak", "switchAccess", "autoClick", "magnifier", "dictation"] + }, { "id": "FocusRingInfo", "type": "object", @@ -234,7 +240,7 @@ { "id": "AccessibilityFeature", "type": "string", - "enum": [ "googleTtsLanguagePacks", "dictationContextChecking", "chromevoxTabsDeprecation", "chromevoxSettingsMigration"], + "enum": [ "googleTtsLanguagePacks", "dictationContextChecking", "faceGaze", "googleTtsHighQualityVoices"], "description": "Subset of accessibility features." }, { @@ -286,6 +292,14 @@ } } }, + { + "id": "ToastType", + "type": "string", + "enum": [ + "dictationNoFocusedTextField", + "dictationMicMuted" + ] + }, { "id": "DlcType", "type": "string", @@ -315,6 +329,7 @@ "ttsNlNl", "ttsPlPl", "ttsPtBr", + "ttsPtPt", "ttsSiLk", "ttsSkSk", "ttsSvSe", @@ -326,6 +341,15 @@ ], "description": "Types of accessibility-specific DLCs." }, + { + "id": "TtsVariant", + "type": "string", + "enum": [ + "lite", + "standard" + ], + "description": "Variants of TTS voices." + }, { "id": "PumpkinData", "type": "object", @@ -383,6 +407,20 @@ "description": "The contents of the file as a Uint8Array." } } + }, + { + "id": "FaceGazeAssets", + "type": "object", + "properties": { + "model": { + "type": "binary", + "description": "The contents of the FaceLandmarker model as a Uint8Array." + }, + "wasm": { + "type": "binary", + "description": "The contents of the vision_wasm_internal.wasm file as a Uint8Array." + } + } } ], "properties": { @@ -445,6 +483,22 @@ ] } }, + { + "name": "installFaceGazeAssets", + "type": "function", + "description": "Called to request an install of the FaceGaze assets DLC, which contains files (e.g. the FaceLandmarker model) required for FaceGaze to work.", + "parameters": [], + "returns_async": { + "name": "callback", + "description": "Runs when the DLC download finishes.", + "parameters": [ + { + "name": "assets", + "$ref": "FaceGazeAssets" + } + ] + } + }, { "name": "setNativeAccessibilityEnabled", "type": "function", @@ -467,6 +521,11 @@ "type": "array", "items": { "$ref": "FocusRingInfo" }, "description": "Array of focus rings to draw." + }, + { + "name": "atType", + "$ref": "AssistiveTechnologyType", + "description": "Associates these focus rings with this feature type." } ] }, @@ -488,6 +547,18 @@ } ] }, + { + "name": "setSelectToSpeakFocus", + "type": "function", + "description": "Informs the system where Select to Speak's reading focus is in screen coordinates. Causes chrome.accessibilityPrivate.onSelectToSpeakFocusChanged to be fired within the AccessibilityCommon component extension.", + "parameters": [ + { + "name": "bounds", + "$ref": "ScreenRect", + "description": "Bounds of currently spoken word (if available) or node (if the spoken node is not a text node)." + } + ] + }, { "name": "setKeyboardListener", "type": "function", @@ -512,7 +583,7 @@ "parameters": [ { "type": "boolean", - "name": "enabled", + "name": "darken", "description": "True to darken screen; false to undarken screen." } ] @@ -623,6 +694,18 @@ } ] }, + { + "name": "setCursorPosition", + "type": "function", + "description": "Sets the cursor position on the screen in absolute screen coordinates.", + "parameters": [ + { + "name": "point", + "$ref": "ScreenPoint", + "description": "The screen point at which to put the cursor." + } + ] + }, { "name": "sendSyntheticMouseEvent", "type": "function", @@ -646,6 +729,17 @@ } ] }, + { + "name": "clipboardCopyInActiveLacrosGoogleDoc", + "type": "function", + "description": "Called by the Select-to-Speak extension to request a clipboard copy in the active Lacros Google Docs tab for the copy-paste fallback.", + "parameters": [ { + "name": "url", + "type": "string", + "description": "URL of the Google Docs tab." + } + ] + }, { "name": "handleScrollableBoundsForPointFound", "type": "function", @@ -784,6 +878,12 @@ "name": "description", "type": "string", "description": "The description to show within the confirmation dialog." + }, + { + "name": "cancelName", + "type": "string", + "description": "The human-readable name of the cancel button.", + "optional": true } ], "returns_async": { @@ -861,6 +961,52 @@ ] } }, + { + "name": "getTtsDlcContents", + "type": "function", + "description": "Returns the contents of a TTS DLC.", + "parameters": [ + { + "name": "dlc", + "$ref": "DlcType", + "description": "The DLC of interest." + }, + { + "name": "variant", + "$ref": "TtsVariant", + "description": "The TTS voice variant." + } + ], + "returns_async": { + "name": "callback", + "description": "A callback that is run when the contents are returned.", + "parameters": [ + { + "name": "contents", + "type": "binary", + "description": "The contents of the DLC as a Uint8Array." + } + ] + } + }, + { + "name": "getDisplayBounds", + "type": "function", + "description": "Returns the bounds of the displays in density-independent pixels in screen coordinates.", + "parameters": [], + "returns_async": { + "name": "callback", + "description": "A callback that is run when the result is returned.", + "parameters": [ + { + "type": "array", + "items": { "$ref": "ScreenRect" }, + "name": "rects", + "description": "Array of rects represeting the display bounds in screen coordinates for all displays." + } + ] + } + }, { "name": "isLacrosPrimary", "type": "function", @@ -877,6 +1023,16 @@ } ] } + }, + { + "name": "showToast", + "type": "function", + "description": "Displays an accessibility-related toast.", + "parameters": [{ + "name": "type", + "$ref": "ToastType", + "description": "The type of toast to show." + }] } ], "events": [ @@ -916,6 +1072,24 @@ "description": "Fired when the user is no longer holding down two fingers (including releasing one, holding down three, or moving them).", "parameters": [] }, + { + "name": "onSelectToSpeakContextMenuClicked", + "type": "function", + "description": "Fired when the Select to Speak context menu is clicked from outside the context of the Select to Speak extension.", + "parameters": [] + }, + { + "name": "onSelectToSpeakFocusChanged", + "type": "function", + "description": "Fired when the Select to Speak reading focus changes.", + "parameters": [ + { + "name": "bounds", + "$ref": "ScreenRect", + "description": "Select to Speak's focus bounds in global screen coordinates." + } + ] + }, { "name": "onSelectToSpeakStateChangeRequested", "type": "function", diff --git a/idl/chrome/accessibility_service_private.idl b/idl/chrome/accessibility_service_private.idl new file mode 100644 index 0000000..71adf7b --- /dev/null +++ b/idl/chrome/accessibility_service_private.idl @@ -0,0 +1,30 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// API which provides support for ChromeOS Accessibility features in the +// browser. + +[platforms=("chromeos", "lacros"), + implemented_in="chrome/browser/chromeos/extensions/accessibility_service_private.h"] + +namespace accessibilityServicePrivate { + callback VoidCallback = void(); + + interface Functions { + // Called when Select to Speak in ChromeOS should speak the current + // text selection; fired when the context menu option was clicked in + // a selection context. + [supportsPromises] static void speakSelectedText( + optional VoidCallback callback); + }; + + interface Events { + // Called when Select to Speak in ChromeOS wants a clipboard copy + // event to be performed on the active and focused tab with the + // given URL. This is fired when Select to Speak is trying to speak + // with search+s but cannot find a selection and the focused node + // is in a Google Docs page. + static void clipboardCopyInActiveGoogleDoc(DOMString url); + }; +}; \ No newline at end of file diff --git a/idl/chrome/action.json b/idl/chrome/action.json index 43e07d9..d488e65 100644 --- a/idl/chrome/action.json +++ b/idl/chrome/action.json @@ -194,7 +194,7 @@ }, { "name": "getBadgeText", "type": "function", - "description": "Gets the badge text of the action. If no tab is specified, the non-tab-specific badge text is returned. If displayActionCountAsBadgeText is enabled, a placeholder text will be returned unless the declarativeNetRequestFeedback permission is present or tab-specific badge text was provided.", + "description": "Gets the badge text of the action. If no tab is specified, the non-tab-specific badge text is returned. If displayActionCountAsBadgeText is enabled, a placeholder text will be returned unless the declarativeNetRequestFeedback permission is present or tab-specific badge text was provided.", "parameters": [{ "name": "details", "$ref": "TabDetails" diff --git a/idl/chrome/activity_log_private.json b/idl/chrome/activity_log_private.json index 46b94e9..c3516c9 100644 --- a/idl/chrome/activity_log_private.json +++ b/idl/chrome/activity_log_private.json @@ -6,9 +6,6 @@ { "namespace": "activityLogPrivate", "description": "none", - "compiler_options": { - "modernised_enums": true - }, "types": [ { "id": "ExtensionActivityType", diff --git a/idl/chrome/autofill_private.idl b/idl/chrome/autofill_private.idl index 423bf24..5420682 100644 --- a/idl/chrome/autofill_private.idl +++ b/idl/chrome/autofill_private.idl @@ -4,7 +4,6 @@ // Use the chrome.autofillPrivate API to add, remove, or update // autofill data from the settings UI. -[modernised_enums] namespace autofillPrivate { // Subset of properties from the user account (signin component, AccountInfo). dictionary AccountInfo { @@ -13,18 +12,105 @@ namespace autofillPrivate { boolean isEligibleForAddressAccountStorage; }; - // Fields used as part of an address. - enum AddressField { - HONORIFIC, // Honorific fields are not expected from getAddressComponents. - FULL_NAME, + // A copy of FieldType from + // chrome/common/extensions/api/autofill_private.idl + enum FieldType { + NO_SERVER_DATA, + UNKNOWN_TYPE, + EMPTY_TYPE, + NAME_FIRST, + NAME_MIDDLE, + NAME_LAST, + NAME_MIDDLE_INITIAL, + NAME_FULL, + NAME_SUFFIX, + EMAIL_ADDRESS, + PHONE_HOME_NUMBER, + PHONE_HOME_CITY_CODE, + PHONE_HOME_COUNTRY_CODE, + PHONE_HOME_CITY_AND_NUMBER, + PHONE_HOME_WHOLE_NUMBER, + ADDRESS_HOME_LINE1, + ADDRESS_HOME_LINE2, + ADDRESS_HOME_APT_NUM, + ADDRESS_HOME_CITY, + ADDRESS_HOME_STATE, + ADDRESS_HOME_ZIP, + ADDRESS_HOME_COUNTRY, + CREDIT_CARD_NAME_FULL, + CREDIT_CARD_NUMBER, + CREDIT_CARD_EXP_MONTH, + CREDIT_CARD_EXP_2_DIGIT_YEAR, + CREDIT_CARD_EXP_4_DIGIT_YEAR, + CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, + CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, + CREDIT_CARD_TYPE, + CREDIT_CARD_VERIFICATION_CODE, COMPANY_NAME, - ADDRESS_LINES, - ADDRESS_LEVEL_1, - ADDRESS_LEVEL_2, - ADDRESS_LEVEL_3, - POSTAL_CODE, - SORTING_CODE, - COUNTRY_CODE + FIELD_WITH_DEFAULT_VALUE, + MERCHANT_EMAIL_SIGNUP, + MERCHANT_PROMO_CODE, + PASSWORD, + ACCOUNT_CREATION_PASSWORD, + ADDRESS_HOME_STREET_ADDRESS, + ADDRESS_HOME_SORTING_CODE, + ADDRESS_HOME_DEPENDENT_LOCALITY, + ADDRESS_HOME_LINE3, + NOT_ACCOUNT_CREATION_PASSWORD, + USERNAME, + USERNAME_AND_EMAIL_ADDRESS, + NEW_PASSWORD, + PROBABLY_NEW_PASSWORD, + NOT_NEW_PASSWORD, + CREDIT_CARD_NAME_FIRST, + CREDIT_CARD_NAME_LAST, + PHONE_HOME_EXTENSION, + CONFIRMATION_PASSWORD, + AMBIGUOUS_TYPE, + SEARCH_TERM, + PRICE, + NOT_PASSWORD, + SINGLE_USERNAME, + NOT_USERNAME, + UPI_VPA, + ADDRESS_HOME_STREET_NAME, + ADDRESS_HOME_HOUSE_NUMBER, + ADDRESS_HOME_SUBPREMISE, + ADDRESS_HOME_OTHER_SUBUNIT, + NAME_LAST_FIRST, + NAME_LAST_CONJUNCTION, + NAME_LAST_SECOND, + NAME_HONORIFIC_PREFIX, + ADDRESS_HOME_ADDRESS, + ADDRESS_HOME_ADDRESS_WITH_NAME, + ADDRESS_HOME_FLOOR, + NAME_FULL_WITH_HONORIFIC_PREFIX, + BIRTHDATE_DAY, + BIRTHDATE_MONTH, + BIRTHDATE_4_DIGIT_YEAR, + PHONE_HOME_CITY_CODE_WITH_TRUNK_PREFIX, + PHONE_HOME_CITY_AND_NUMBER_WITHOUT_TRUNK_PREFIX, + PHONE_HOME_NUMBER_PREFIX, + PHONE_HOME_NUMBER_SUFFIX, + IBAN_VALUE, + CREDIT_CARD_STANDALONE_VERIFICATION_CODE, + NUMERIC_QUANTITY, + ONE_TIME_CODE, + DELIVERY_INSTRUCTIONS, + ADDRESS_HOME_OVERFLOW, + ADDRESS_HOME_LANDMARK, + ADDRESS_HOME_OVERFLOW_AND_LANDMARK, + ADDRESS_HOME_ADMIN_LEVEL2, + ADDRESS_HOME_STREET_LOCATION, + ADDRESS_HOME_BETWEEN_STREETS, + ADDRESS_HOME_BETWEEN_STREETS_OR_LANDMARK, + ADDRESS_HOME_BETWEEN_STREETS_1, + ADDRESS_HOME_BETWEEN_STREETS_2, + SINGLE_USERNAME_FORGOT_PASSWORD, + ADDRESS_HOME_APT, + ADDRESS_HOME_APT_TYPE, + SINGLE_USERNAME_WITH_INTERMEDIATE_VALUES, + MAX_VALID_FIELD_TYPE }; // The address source origin. Describes where the address is stored. @@ -73,57 +159,22 @@ namespace autofillPrivate { boolean? isVirtualCardEnrolled; }; + // Represents single entry of the autofill profile, containing field type and + // the corresponding field value. + dictionary AddressField { + FieldType type; + DOMString value; + }; + // An address entry which can be saved in the autofill section of the // settings UI. dictionary AddressEntry { // Globally unique identifier for this entry. DOMString? guid; - DOMString[]? fullNames; - - // A honorific title added to the name. E.g. "Mr.", "Dr.", "Her Royal - // Majesty". - DOMString? honorific; - - DOMString? companyName; - - // Street address (multiple lines, newlines preserved). - DOMString? addressLines; - - // The broadest administrative level in the address, i.e. the province - // within which the locality is found; for example, in the US, this would be - // the state; in Switzerland it would be the canton; in the UK, the post - // town. - DOMString? addressLevel1; - - // The second administrative level, in addresses with two or more - // administrative levels; in the countries with two administrative levels, - // this would typically be the city, town, village, or other locality within - // which the relevant street address is found. - DOMString? addressLevel2; - - // The third administrative level, in addresses with three or more - // administrative levels. - DOMString? addressLevel3; - - // Postal code, post code, ZIP code, CEDEX code (if CEDEX, append "CEDEX", - // and the arrondissement, if relevant, to the address-level2 field). - DOMString? postalCode; - - // A sorting code is similar to a postal code. However, whereas a postal - // code normally refers to a single geographical location, a sorting code - // often does not. Instead, a sorting code is assigned to an organization, - // which might be geographically distributed. The most prominent example of - // a sorting code system is CEDEX in France. - DOMString? sortingCode; - - // A two-character string representing the address' country. See - // autofill_country.cc for a list of valid codes. - DOMString? countryCode; - - DOMString[]? phoneNumbers; - - DOMString[]? emailAddresses; + // Fields have to be stored in the array with every field style stored only + // once. + AddressField[] fields; DOMString? languageCode; @@ -143,7 +194,7 @@ namespace autofillPrivate { // different components to their addresses. dictionary AddressComponent { // The field type. - AddressField field; + FieldType field; // The name of the field. DOMString fieldName; @@ -185,6 +236,9 @@ namespace autofillPrivate { // Globally unique identifier for this entry. DOMString? guid; + // The card's instrument ID from the GPay server, if applicable. + DOMString? instrumentId; + // Name of the person who owns the credit card. DOMString? name; @@ -206,6 +260,9 @@ namespace autofillPrivate { // Credit card's image source. DOMString? imageSrc; + // Credit card's masked cvc. + DOMString? cvc; + AutofillMetadata? metadata; }; @@ -224,31 +281,15 @@ namespace autofillPrivate { AutofillMetadata? metadata; }; - // Parameters to be passed to validatePhoneNumbers(). - dictionary ValidatePhoneParams { - // The phone numbers to validate. - DOMString[] phoneNumbers; - - // The index into |phoneNumbers| at which the newly-added/edited phone - // number resides. - long indexOfNewNumber; - - // A two-character string representing the address' country. See - // autofill_country.cc for a list of valid codes. - DOMString countryCode; - }; - callback GetAccountInfoCallback = void(optional AccountInfo accountInfo); callback GetCountryListCallback = void(CountryEntry[] countries); callback GetAddressComponentsCallback = void(AddressComponents components); callback GetAddressListCallback = void(AddressEntry[] entries); - callback ValidatePhoneNumbersCallback = - void(DOMString[] validatedPhoneNumbers); callback GetCreditCardListCallback = void(CreditCardEntry[] entries); callback GetIbanListCallback = void(IbanEntry[] entries); - callback GetUpiIdListCallback = void(DOMString[] entries); callback IsValidIbanCallback = void(boolean isValid); - callback CheckForUserAuthCallback = void(boolean isUserAuthSuccessful); + callback GetCreditCardCallback = void(optional CreditCardEntry card); + callback CheckForDeviceAuthCallback = void(boolean isDeviceAuthAvailable); interface Functions { // Gets currently signed-in user profile info, no value is returned if @@ -295,15 +336,6 @@ namespace autofillPrivate { // |guid|: ID of the entry to remove. static void removeEntry(DOMString guid); - // Validates a newly-added phone number and invokes the callback with a list - // of validated numbers. Note that if the newly-added number was invalid, it - // will not be returned in the list of valid numbers. - // |params|: The parameters to this function. - // |callback|: Callback which will be called with validated phone numbers. - [supportsPromises] static void validatePhoneNumbers( - ValidatePhoneParams params, - ValidatePhoneNumbersCallback callback); - // Gets the list of credit cards. // |callback|: Callback which will be called with the list of credit cards. [supportsPromises] static void getCreditCardList( @@ -335,10 +367,6 @@ namespace autofillPrivate { // Enables or disables FIDO Authentication for credit card unmasking. static void setCreditCardFIDOAuthEnabledState(boolean enabled); - // Gets the list of UPI IDs (a.k.a. Virtual Payment Addresses). - // |callback|: Callback which will be called with the list of UPI IDs. - [supportsPromises] static void getUpiIdList(GetUpiIdListCallback callback); - // Enrolls a credit card into virtual cards. // |cardId|: The server side id of the credit card to be enrolled. Note it // refers to the legacy server id of credit cards, not the instrument ids. @@ -354,10 +382,21 @@ namespace autofillPrivate { // will then flip the mandatory auth toggle. static void authenticateUserAndFlipMandatoryAuthToggle(); - // Authenticates the user via device authentication and it would return - // the result of user auth. If the auth was successful, we will show - // the edit card dialog for the Local card. - [supportsPromises] static void authenticateUserToEditLocalCard(CheckForUserAuthCallback callback); + // Returns the local card based on the `guid` provided. The user could + // also be challenged with a reauth if that is enabled. For a successful + // auth, the local card is returned otherwise return a null object. + [supportsPromises] static void getLocalCard( + DOMString guid, GetCreditCardCallback callback); + + // Returns true if there is authentication available on this device + // (biometric or screen lock), false otherwise. + [supportsPromises] static void checkIfDeviceAuthAvailable( + CheckForDeviceAuthCallback callback); + + // Bulk delete all the CVCs (server and local) from the local webdata + // database. For server CVCs, this will also clear them from the Chrome + // sync server and thus other devices. + static void bulkDeleteAllCvcs(); }; interface Events { diff --git a/idl/chrome/autotest_private.idl b/idl/chrome/autotest_private.idl index a3c876a..a97b99a 100644 --- a/idl/chrome/autotest_private.idl +++ b/idl/chrome/autotest_private.idl @@ -5,7 +5,6 @@ // API for integration testing. To be used on test images with a test component // extension. [platforms=("chromeos"), - modernised_enums, implemented_in="chrome/browser/ash/extensions/autotest_private/autotest_private_api.h"] namespace autotestPrivate { @@ -71,6 +70,16 @@ namespace autotestPrivate { UninstalledByMigration }; + // A mapping of arc::mojom::WakefulnessMode + enum WakefulnessMode { + Unknown, + Asleep, + Awake, + Dreaming, + Dozing + }; + callback WakefulnessModeCallback = void (WakefulnessMode mode); + // A subset of Window State types in ash::WindowStateType. We may add more // into the set in the future. enum WindowStateType { @@ -80,6 +89,8 @@ namespace autotestPrivate { Fullscreen, PrimarySnapped, SecondarySnapped, + Pinned, + TrustedPinned, PIP, Floated }; @@ -278,7 +289,8 @@ namespace autotestPrivate { Mounting, Unavailable, Stopped, - CreatingLogFile, + PreparingForLaunch, + WaitingOwnerFetch, PreLaunched, Starting, Running, @@ -288,8 +300,6 @@ namespace autotestPrivate { // A mapping of crosapi::browser_util::LacrosMode enum LacrosMode { Disabled, - SideBySide, - Primary, Only }; @@ -303,7 +313,11 @@ namespace autotestPrivate { DOMString lacrosPath; // Specifies the mode Lacros is currently running. // For a full list of supported mode, see LacrosMode enum definition. + // DEPRECATED: please use isEnabled. + // TODO(crbug.com/1494005): Remove this field after tests are fixed. LacrosMode mode; + // True iff Lacros is enabled for the current user session's primary user. + boolean isEnabled; }; callback GetLacrosInfoCallback = void (LacrosInfo info); @@ -362,7 +376,9 @@ namespace autotestPrivate { dictionary ArcAppTracingInfo { boolean success; double fps; + double perceivedFps; double commitDeviation; + double presentDeviation; double renderQuality; }; @@ -428,14 +444,6 @@ namespace autotestPrivate { callback GetAllInstalledAppsCallback = void (App[] apps); - dictionary CryptohomeRecoveryDataDict { - DOMString reauthProofToken; - DOMString refreshToken; - }; - - callback GetCryptohomeRecoveryDataCallback = void ( - CryptohomeRecoveryDataDict dict); - dictionary ShelfItem { DOMString appId; DOMString launchId; @@ -769,7 +777,7 @@ namespace autotestPrivate { // Event name DOMString name; // Number of frames actually shown for this animation. - long microsecnods_since_unix_epoch; + double microsecnods_since_unix_epoch; }; // Callback invoked to report the collection ui::LoginEventRecorder data @@ -819,6 +827,27 @@ namespace autotestPrivate { callback IsFeatureEnabledCallback = void(boolean enabled); + // Response data for getCurrentInputMethodDescriptor. + // Add more fields from ash/input_method/InputMethodDescriptor as needed. + dictionary GetCurrentInputMethodDescriptorData { + DOMString keyboardLayout; + }; + + // Response callback for current input method keyboard layout. + callback GetCurrentInputMethodDescriptorCallback = void + (GetCurrentInputMethodDescriptorData data); + + // Response callback to report if a field trial exists and has been activated. + callback IsFieldTrialActiveCallback = void(boolean active); + + // Request data containing the mock responses from + // overrideOrcaResponseForTesting. + dictionary OrcaResponseArray { + DOMString[] responses; + }; + + callback OverrideOrcaResponseForTestingCallback = void(boolean success); + interface Functions { // Must be called to allow autotestPrivateAPI events to be fired. static void initializeEvents(); @@ -942,10 +971,6 @@ namespace autotestPrivate { DOMString packageName, GetArcPackageCallback callback); - // Gets the data needed for Cryptohome Recovery. - [supportsPromises] static void getCryptohomeRecoveryData( - GetCryptohomeRecoveryDataCallback callback); - // Waits for system web apps to complete the installation. [supportsPromises] static void waitForSystemWebAppsInstall( VoidCallback callback); @@ -1084,12 +1109,6 @@ namespace autotestPrivate { DOMString display_id, TakeScreenshotCallback callback); - // Makes a basic request to ML Service, triggering 1. ML Service - // daemon startup, and 2. the initial D-Bus -> Mojo IPC bootstrap. - // |callback|: Called when the operation has completed. - [supportsPromises] static void bootstrapMachineLearningService( - VoidCallback callback); - // Triggers an on-demand update of smart dim component and checks whether // it's successfully loaded by smart dim ml_agent. // |callback|: Called when the operation has completed. @@ -1146,6 +1165,10 @@ namespace autotestPrivate { any value, VoidCallback callback); + // Clears value for the specified user pref in the pref tree. + [supportsPromises] static void clearAllowedPref(DOMString pref_name, + VoidCallback callback); + // DEPRECATED: use SetAllowedPref instead, see crbug/1262034 // Set value for the specified user pref in the pref tree. [supportsPromises] static void setWhitelistedPref(DOMString pref_name, @@ -1581,6 +1604,37 @@ namespace autotestPrivate { // a Chrome uprev into ChromeOS changed the default feature state. [supportsPromises] static void isFeatureEnabled( DOMString feature_name, IsFeatureEnabledCallback callback); + + // Returns keyboard layout used for current input method. + [supportsPromises] static void getCurrentInputMethodDescriptor( + GetCurrentInputMethodDescriptorCallback callback); + + // Overrides the response from Orca Provider and returns the boolean value + // that indicates if the overriding is successful or not. + [supportsPromises] static void overrideOrcaResponseForTesting( + OrcaResponseArray array, + OverrideOrcaResponseForTestingCallback callback); + + // ARC set interactive enable/disable state. + // |enabled|: Enable ARC interactive. + // |callback|: Called when the operation sent to ARC by mojo. + [supportsPromises] static void setArcInteractiveState( + boolean enabled, VoidCallback callback); + + // Returns whether a field trial exists and has been activated. + [supportsPromises] static void isFieldTrialActive( + DOMString trial_name, + DOMString group_name, + IsFieldTrialActiveCallback callback); + + // ARC get wakefulness mode. + [supportsPromises] static void getArcWakefulnessMode( + WakefulnessModeCallback callback); + + // Sets the default device language. + // A restart is required for this change to take effect. + // |value|: the locale of the language. + static void setDeviceLanguage(DOMString locale, VoidCallback callback); }; interface Events { diff --git a/idl/chrome/bookmarks.json b/idl/chrome/bookmarks.json index e523d06..4f23125 100644 --- a/idl/chrome/bookmarks.json +++ b/idl/chrome/bookmarks.json @@ -6,9 +6,6 @@ { "namespace": "bookmarks", "description": "Use the chrome.bookmarks API to create, organize, and otherwise manipulate bookmarks. Also see Override Pages, which you can use to create a custom Bookmark Manager page.", - "compiler_options": { - "modernised_enums": true - }, "properties": { "MAX_WRITE_OPERATIONS_PER_HOUR": { "value": 1000000, diff --git a/idl/chrome/braille_display_private.idl b/idl/chrome/braille_display_private.idl index 171c33d..d686809 100644 --- a/idl/chrome/braille_display_private.idl +++ b/idl/chrome/braille_display_private.idl @@ -3,7 +3,6 @@ // found in the LICENSE file. // Braille display access private API. -[modernised_enums] namespace brailleDisplayPrivate { // Braille display keyboard command. enum KeyCommand { diff --git a/idl/chrome/browser_action.json b/idl/chrome/browser_action.json index 7181559..939d48a 100644 --- a/idl/chrome/browser_action.json +++ b/idl/chrome/browser_action.json @@ -5,7 +5,7 @@ [ { "namespace": "browserAction", - "description": "Use browser actions to put icons in the main Google Chrome toolbar, to the right of the address bar. In addition to its icon, a browser action can have a tooltip, a badge, and a popup.", + "description": "Use browser actions to put icons in the main Google Chrome toolbar, to the right of the address bar. In addition to its icon, a browser action can have a tooltip, a badge, and a popup.", "compiler_options": { "implemented_in": "chrome/browser/extensions/api/extension_action/extension_action_api.h" }, diff --git a/idl/chrome/certificate_provider.idl b/idl/chrome/certificate_provider.idl index d4972fa..cf51548 100644 --- a/idl/chrome/certificate_provider.idl +++ b/idl/chrome/certificate_provider.idl @@ -8,28 +8,32 @@ namespace certificateProvider { // Types of supported cryptographic signature algorithms. enum Algorithm { - // RSASSA PKCS#1 v1.5 signature algorithm with the MD5-SHA-1 hashing. The - // extension must not prepend a DigestInfo prefix but only add PKCS#1 - // padding. This algorithm is deprecated and will never be requested by - // Chrome as of version 109. + // Specifies the RSASSA PKCS#1 v1.5 signature algorithm with the MD5-SHA-1 + // hashing. The extension must not prepend a DigestInfo prefix but only + // add PKCS#1 padding. This algorithm is deprecated and will never be requested + // by Chrome as of version 109. RSASSA_PKCS1_v1_5_MD5_SHA1, - // RSASSA PKCS#1 v1.5 signature algorithm with the SHA-1 hash function. + // Specifies the RSASSA PKCS#1 v1.5 signature algorithm + // with the SHA-1 hash function. RSASSA_PKCS1_v1_5_SHA1, - // RSASSA PKCS#1 v1.5 signature algorithm with the SHA-256 hashing function. + // Specifies the RSASSA PKCS#1 v1.5 signature algorithm + // with the SHA-256 hashing function. RSASSA_PKCS1_v1_5_SHA256, - // RSASSA PKCS#1 v1.5 signature algorithm with the SHA-384 hashing function. + // Specifies the RSASSA PKCS#1 v1.5 signature algorithm + // with the SHA-384 hashing function. RSASSA_PKCS1_v1_5_SHA384, - // RSASSA PKCS#1 v1.5 signature algorithm with the SHA-512 hashing function. + // Specifies the RSASSA PKCS#1 v1.5 signature algorithm + // with the SHA-512 hashing function. RSASSA_PKCS1_v1_5_SHA512, - // Since Chrome 89. RSASSA PSS signature algorithm with the SHA-256 hashing + // Specifies the RSASSA PSS signature algorithm with the SHA-256 hashing // function, MGF1 mask generation function and the salt of the same size as // the hash. RSASSA_PSS_SHA256, - // Since Chrome 89. RSASSA PSS signature algorithm with the SHA-384 hashing + // Specifies the RSASSA PSS signature algorithm with the SHA-384 hashing // function, MGF1 mask generation function and the salt of the same size as // the hash. RSASSA_PSS_SHA384, - // Since Chrome 89. RSASSA PSS signature algorithm with the SHA-512 hashing + // Specifies the RSASSA PSS signature algorithm with the SHA-512 hashing // function, MGF1 mask generation function and the salt of the same size as // the hash. RSASSA_PSS_SHA512 @@ -37,8 +41,8 @@ namespace certificateProvider { // Types of errors that the extension can report. enum Error { - // General error that cannot be represented by other more specific error - // codes. + // General error that cannot be represented by other more specific + // error codes. GENERAL_ERROR }; @@ -94,25 +98,36 @@ namespace certificateProvider { // Deprecated. Replaced by $(ref:Algorithm). enum Hash { + // Specifies the MD5 and SHA1 hashing algorithms. MD5_SHA1, + // Specifies the SHA1 hashing algorithm. SHA1, + // Specifies the SHA256 hashing algorithm. SHA256, + // Specifies the SHA384 hashing algorithm. SHA384, + // Specifies the SHA512 hashing algorithm. SHA512 }; // The type of code being requested by the extension with requestPin function. enum PinRequestType { + // Specifies the requested code is a PIN. PIN, + // Specifies the requested code is a PUK. PUK }; // The types of errors that can be presented to the user through the // requestPin function. enum PinRequestErrorType { + // Specifies the PIN is invalid. INVALID_PIN, + // Specifies the PUK is invalid. INVALID_PUK, + // Specifies the maximum attempt number has been exceeded. MAX_ATTEMPTS_EXCEEDED, + // Specifies that the error cannot be represented by the above types. UNKNOWN_ERROR }; diff --git a/idl/chrome/commands.json b/idl/chrome/commands.json index f3b512a..b13b3bb 100644 --- a/idl/chrome/commands.json +++ b/idl/chrome/commands.json @@ -51,7 +51,7 @@ { "name": "getAll", "type": "function", - "description": "Returns all the registered extension commands for this extension and their shortcut (if active).", + "description": "Returns all the registered extension commands for this extension and their shortcut (if active). Before Chrome 110, this command did not return _execute_action.", "parameters": [], "returns_async": { "name": "callback", diff --git a/idl/chrome/content_settings.json b/idl/chrome/content_settings.json index d0a438e..fac35d0 100644 --- a/idl/chrome/content_settings.json +++ b/idl/chrome/content_settings.json @@ -8,8 +8,7 @@ "namespace": "contentSettings", "description": "Use the chrome.contentSettings API to change settings that control whether websites can use features such as cookies, JavaScript, and plugins. More generally speaking, content settings allow you to customize Chrome's behavior on a per-site basis instead of globally.", "compiler_options": { - "generate_type_functions": true, - "modernised_enums": true + "generate_type_functions": true }, "types": [ { @@ -177,6 +176,11 @@ "type": "string", "enum": ["allow", "block"] }, + { + "id": "ClipboardContentSetting", + "type": "string", + "enum": ["allow", "block", "ask"] + }, { "id": "CookiesContentSetting", "type": "string", @@ -332,6 +336,14 @@ {"$ref":"MicrophoneContentSetting"} ] }, + "clipboard": { + "$ref": "ContentSetting", + "description": "Whether to allow sites to access the clipboard via advanced capabilities of the Async Clipboard API. \"Advanced\" capabilities include anything besides writing built-in formats after a user gesture, i.e. the ability to read, the ability to write custom formats, and the ability to write without a user gesture. One of
allow: Allow sites to use advanced clipboard capabilities,
block: Don't allow sites to use advanced clipboard capabilties,
ask: Ask when a site wants to use advanced clipboard capabilities.
Default is ask.
The primary URL is the URL of the document which requested clipboard access. The secondary URL is not used.", + "value": [ + "clipboard", + {"$ref":"ClipboardContentSetting"} + ] + }, "camera": { "$ref": "ContentSetting", "description": "Whether to allow sites to access the camera. One of
allow: Allow sites to access the camera,
block: Don't allow sites to access the camera,
ask: Ask when a site wants to access the camera.
Default is ask.
The primary URL is the URL of the document which requested camera access. The secondary URL is not used.
NOTE: The 'allow' setting is not valid if both patterns are ''.", diff --git a/idl/chrome/context_menus.json b/idl/chrome/context_menus.json index 939bc90..6d6584d 100644 --- a/idl/chrome/context_menus.json +++ b/idl/chrome/context_menus.json @@ -151,7 +151,7 @@ "onclick": { "type": "function", "optional": true, - "description": "A function that is called back when the menu item is clicked. Event pages cannot use this; instead, they should register a listener for $(ref:contextMenus.onClicked).", + "description": "A function that is called back when the menu item is clicked. This is not available inside of a service worker; instead, they should register a listener for $(ref:contextMenus.onClicked).", "parameters": [ { "name": "info", @@ -177,7 +177,7 @@ "type": "array", "items": {"type": "string"}, "optional": true, - "description": "Restricts the item to apply only to documents or frames whose URL matches one of the given patterns. For details on pattern formats, see Match Patterns." + "description": "Restricts the item to apply only to documents or frames whose URL matches one of the given patterns. For details on pattern formats, see Match Patterns." }, "targetUrlPatterns": { "type": "array", diff --git a/idl/chrome/cookies.json b/idl/chrome/cookies.json index 44302c2..05d29c4 100644 --- a/idl/chrome/cookies.json +++ b/idl/chrome/cookies.json @@ -6,9 +6,6 @@ { "namespace": "cookies", "description": "Use the chrome.cookies API to query and modify cookies, and to be notified when they change.", - "compiler_options": { - "modernised_enums": true - }, "types": [ { "id": "SameSiteStatus", @@ -16,6 +13,14 @@ "enum": ["no_restriction", "lax", "strict", "unspecified"], "description": "A cookie's 'SameSite' state (https://tools.ietf.org/html/draft-west-first-party-cookies). 'no_restriction' corresponds to a cookie set with 'SameSite=None', 'lax' to 'SameSite=Lax', and 'strict' to 'SameSite=Strict'. 'unspecified' corresponds to a cookie set without the SameSite attribute." }, + { + "id": "CookiePartitionKey", + "type": "object", + "description": "Represents a partitioned cookie's partition key.", + "properties": { + "topLevelSite": {"type": "string", "optional": true, "description": "The top-level site the partitioned cookie is available in."} + } + }, { "id": "Cookie", "type": "object", @@ -31,7 +36,8 @@ "sameSite": {"$ref": "SameSiteStatus", "description": "The cookie's same-site status (i.e. whether the cookie is sent with cross-site requests)."}, "session": {"type": "boolean", "description": "True if the cookie is a session cookie, as opposed to a persistent cookie with an expiration date."}, "expirationDate": {"type": "number", "optional": true, "description": "The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies."}, - "storeId": {"type": "string", "description": "The ID of the cookie store containing this cookie, as provided in getAllCookieStores()."} + "storeId": {"type": "string", "description": "The ID of the cookie store containing this cookie, as provided in getAllCookieStores()."}, + "partitionKey": {"$ref": "CookiePartitionKey", "optional": true, "description": "The partition key for reading or modifying cookies with the Partitioned attribute."} } }, { @@ -56,7 +62,8 @@ "properties": { "url": {"type": "string", "description": "The URL with which the cookie to access is associated. This argument may be a full URL, in which case any data following the URL path (e.g. the query string) is simply ignored. If host permissions for this URL are not specified in the manifest file, the API call will fail."}, "name": {"type": "string", "description": "The name of the cookie to access."}, - "storeId": {"type": "string", "optional": true, "description": "The ID of the cookie store in which to look for the cookie. By default, the current execution context's cookie store will be used."} + "storeId": {"type": "string", "optional": true, "description": "The ID of the cookie store in which to look for the cookie. By default, the current execution context's cookie store will be used."}, + "partitionKey": {"$ref": "CookiePartitionKey", "optional": true, "description": "The partition key for reading or modifying cookies with the Partitioned attribute."} } } ], @@ -83,7 +90,7 @@ { "name": "getAll", "type": "function", - "description": "Retrieves all cookies from a single cookie store that match the given information. The cookies returned will be sorted, with those with the longest path first. If multiple cookies have the same path length, those with the earliest creation time will be first.", + "description": "Retrieves all cookies from a single cookie store that match the given information. The cookies returned will be sorted, with those with the longest path first. If multiple cookies have the same path length, those with the earliest creation time will be first. This method only retrieves cookies for domains that the extension has host permissions to.", "parameters": [ { "type": "object", @@ -96,7 +103,8 @@ "path": {"type": "string", "optional": true, "description": "Restricts the retrieved cookies to those whose path exactly matches this string."}, "secure": {"type": "boolean", "optional": true, "description": "Filters the cookies by their Secure property."}, "session": {"type": "boolean", "optional": true, "description": "Filters out session vs. persistent cookies."}, - "storeId": {"type": "string", "optional": true, "description": "The cookie store to retrieve cookies from. If omitted, the current execution context's cookie store will be used."} + "storeId": {"type": "string", "optional": true, "description": "The cookie store to retrieve cookies from. If omitted, the current execution context's cookie store will be used."}, + "partitionKey": {"$ref": "CookiePartitionKey", "optional": true, "description": "The partition key for reading or modifying cookies with the Partitioned attribute."} } } ], @@ -128,7 +136,8 @@ "httpOnly": {"type": "boolean", "optional": true, "description": "Whether the cookie should be marked as HttpOnly. Defaults to false."}, "sameSite": {"$ref": "SameSiteStatus", "optional": true, "description": "The cookie's same-site status. Defaults to \"unspecified\", i.e., if omitted, the cookie is set without specifying a SameSite attribute."}, "expirationDate": {"type": "number", "optional": true, "description": "The expiration date of the cookie as the number of seconds since the UNIX epoch. If omitted, the cookie becomes a session cookie."}, - "storeId": {"type": "string", "optional": true, "description": "The ID of the cookie store in which to set the cookie. By default, the cookie is set in the current execution context's cookie store."} + "storeId": {"type": "string", "optional": true, "description": "The ID of the cookie store in which to set the cookie. By default, the cookie is set in the current execution context's cookie store."}, + "partitionKey": {"$ref": "CookiePartitionKey", "optional": true, "description": "The partition key for reading or modifying cookies with the Partitioned attribute."} } } ], @@ -166,7 +175,8 @@ "properties": { "url": {"type": "string", "description": "The URL associated with the cookie that's been removed."}, "name": {"type": "string", "description": "The name of the cookie that's been removed."}, - "storeId": {"type": "string", "description": "The ID of the cookie store from which the cookie was removed."} + "storeId": {"type": "string", "description": "The ID of the cookie store from which the cookie was removed."}, + "partitionKey": {"$ref": "CookiePartitionKey", "optional": true, "description": "The partition key for reading or modifying cookies with the Partitioned attribute."} } } ] diff --git a/idl/chrome/dashboard_private.json b/idl/chrome/dashboard_private.json index 9b75b92..3e6000a 100644 --- a/idl/chrome/dashboard_private.json +++ b/idl/chrome/dashboard_private.json @@ -6,9 +6,6 @@ { "namespace":"dashboardPrivate", "description": "none", - "compiler_options": { - "modernised_enums": true - }, "types": [ { "id": "Result", diff --git a/idl/chrome/debugger.json b/idl/chrome/debugger.json index 7b99b9f..70cb05a 100644 --- a/idl/chrome/debugger.json +++ b/idl/chrome/debugger.json @@ -6,9 +6,6 @@ { "namespace": "debugger", "description": "The chrome.debugger API serves as an alternate transport for Chrome's remote debugging protocol. Use chrome.debugger to attach to one or more tabs to instrument network interaction, debug JavaScript, mutate the DOM and CSS, etc. Use the Debuggee tabId to target tabs with sendCommand and route events by tabId from onEvent callbacks.", - "compiler_options": { - "modernised_enums": true - }, "types": [ { "id": "Debuggee", diff --git a/idl/chrome/declarative_content.json b/idl/chrome/declarative_content.json index ec474fd..fc35c7a 100644 --- a/idl/chrome/declarative_content.json +++ b/idl/chrome/declarative_content.json @@ -72,7 +72,7 @@ }, "isBookmarked": { "type": "boolean", - "description": "Matches if the bookmarked state of the page is equal to the specified value. Requres the bookmarks permission.", + "description": "Matches if the bookmarked state of the page is equal to the specified value. Requres the bookmarks permission.", "optional": true }, "instanceType": { @@ -83,7 +83,7 @@ }, { "id": "ShowPageAction", - "description": "Declarative event action that shows the extension's $(ref:pageAction page action) while the corresponding conditions are met. This action can be used without host permissions, but the extension must have a page action. If the extension has the activeTab permission, clicking the page action grants access to the active tab.", + "description": "A declarative event action that sets the extension's $(ref:pageAction page action) to an enabled state while the corresponding conditions are met. This action can be used without host permissions, but the extension must have a page action. If the extension has the activeTab permission, clicking the page action grants access to the active tab.

On pages where the conditions are not met the extension's toolbar action will be grey-scale, and clicking it will open the context menu, instead of triggering the action.

", "deprecated": "Please use $(ref:declarativeContent.ShowAction).", "type": "object", "properties": { @@ -95,7 +95,7 @@ }, { "id": "ShowAction", - "description": "Declarative event action that shows the extension's toolbar action ($(ref:pageAction page action) or $(ref:browserAction browser action)) while the corresponding conditions are met. This action can be used without host permissions. If the extension has the activeTab permission, clicking the page action grants access to the active tab.", + "description": "A declarative event action that sets the extension's toolbar $(ref:action action) to an enabled state while the corresponding conditions are met. This action can be used without host permissions. If the extension has the activeTab permission, clicking the page action grants access to the active tab.

On pages where the conditions are not met the extension's toolbar action will be grey-scale, and clicking it will open the context menu, instead of triggering the action.

", "type": "object", "properties": { "instanceType": { @@ -106,7 +106,7 @@ }, { "id": "SetIcon", - "description": "Declarative event action that sets the n-dip square icon for the extension's $(ref:pageAction page action) or $(ref:browserAction browser action) while the corresponding conditions are met. This action can be used without host permissions, but the extension must have a page or browser action.

Exactly one of imageData or path must be specified. Both are dictionaries mapping a number of pixels to an image representation. The image representation in imageData is an ImageData object; for example, from a canvas element, while the image representation in path is the path to an image file relative to the extension's manifest. If scale screen pixels fit into a device-independent pixel, the scale * n icon is used. If that scale is missing, another image is resized to the required size.

", + "description": "Declarative event action that sets the n-dip square icon for the extension's $(ref:pageAction page action) or $(ref:browserAction browser action) while the corresponding conditions are met. This action can be used without host permissions, but the extension must have a page or browser action.

Exactly one of imageData or path must be specified. Both are dictionaries mapping a number of pixels to an image representation. The image representation in imageData is an ImageData object; for example, from a canvas element, while the image representation in path is the path to an image file relative to the extension's manifest. If scale screen pixels fit into a device-independent pixel, the scale * n icon is used. If that scale is missing, another image is resized to the required size.

", "type": "object", "properties": { "instanceType": { diff --git a/idl/chrome/developer_private.idl b/idl/chrome/developer_private.idl index 190a47c..81f65a0 100644 --- a/idl/chrome/developer_private.idl +++ b/idl/chrome/developer_private.idl @@ -65,7 +65,6 @@ namespace developerPrivate { BACKGROUND_CONTENTS, COMPONENT, EXTENSION_BACKGROUND_PAGE, - EXTENSION_DIALOG, EXTENSION_GUEST, EXTENSION_POPUP, EXTENSION_SERVICE_WORKER_BACKGROUND, @@ -225,6 +224,10 @@ namespace developerPrivate { // Only populated for extensions that can be affected by the runtime host // permissions feature. RuntimeHostPermissions? runtimeHostPermissions; + + // True if the extension can access site data through host permissions or + // API permissions such as activeTab. + boolean canAccessSiteData; }; dictionary ExtensionInfo { @@ -265,6 +268,8 @@ namespace developerPrivate { DOMString webStoreUrl; boolean showSafeBrowsingAllowlistWarning; boolean showAccessRequestsInToolbar; + boolean acknowledgeSafetyCheckWarning; + boolean? pinnedToToolbar; }; dictionary ProfileInfo { @@ -325,6 +330,7 @@ namespace developerPrivate { HostAccess? hostAccess; boolean? showAccessRequestsInToolbar; boolean? acknowledgeSafetyCheckWarning; + boolean? pinnedToToolbar; }; dictionary ProfileConfigurationUpdate { @@ -434,11 +440,14 @@ namespace developerPrivate { // - ON_CLICK: The extension requested access to the site but its access is // withheld. // - ON_SPECIFIC_SITES: the extension is permitted to run on at least one - // site specified by the queried site but has its access withheld on at - // least one site in its host permissions. - // - ON_ALL_SITES: same as above except the extension has no withheld access - // to its specified sites. + // site specified by the queried site but it does not request access to + // all sites or it has its access withheld on at least one site in its + // host permissions. + // - ON_ALL_SITES: the extension is permitted to run on all sites. HostAccess siteAccess; + // Whether the matching extension requests access to all sites in its + // host permissions. + boolean canRequestAllSites; }; dictionary ExtensionSiteAccessUpdate { @@ -487,7 +496,9 @@ namespace developerPrivate { COMMAND_REMOVED, PERMISSIONS_CHANGED, SERVICE_WORKER_STARTED, - SERVICE_WORKER_STOPPED + SERVICE_WORKER_STOPPED, + CONFIGURATION_CHANGED, + PINNED_ACTIONS_CHANGED }; dictionary PackDirectoryResponse { @@ -830,6 +841,15 @@ namespace developerPrivate { ExtensionSiteAccessUpdate[] updates, optional VoidCallback callback); + // Removes multiple installed extensions. + [supportsPromises] static void removeMultipleExtensions( + DOMString[] extensionIds, + optional VoidCallback callback); + + // Dismisses the menu notification for the extensions module in Safety Hub + // if one is active. + static void dismissSafetyHubExtensionsMenuNotification(); + [nocompile, deprecated="Use openDevTools"] static void inspect(InspectOptions options, optional VoidCallback callback); diff --git a/idl/chrome/document_scan.idl b/idl/chrome/document_scan.idl index 4e25936..26c64e5 100644 --- a/idl/chrome/document_scan.idl +++ b/idl/chrome/document_scan.idl @@ -24,11 +24,477 @@ namespace documentScan { DOMString mimeType; }; + // OperationResult is an enum that indicates the result of each operation + // performed by the backend. It contains the same causes as SANE_Status plus + // additional statuses that come from the IPC layers and image conversion + // stages. + [nodoc] enum OperationResult { + // An unknown or generic failure occurred. + UNKNOWN, + + // Operation succeeded. + SUCCESS, + + // The operation is not supported. + UNSUPPORTED, + + // The operation was cancelled. + CANCELLED, + + // The device is busy. + DEVICE_BUSY, + + // Data or argument is invalid. + INVALID, + + // Value is the wrong type for the underlying option. + WRONG_TYPE, + + // No more data is available. + EOF, + + // The document feeder is jammed. + ADF_JAMMED, + + // The document feeder is empty. + ADF_EMPTY, + + // The flatbed cover is open. + COVER_OPEN, + + // An error occurred while communicating with the device. + IO_ERROR, + + // The device requires authentication. + ACCESS_DENIED, + + // Not enough memory was available to complete the operation. + NO_MEMORY, + + // The device was not reachable. + UNREACHABLE, + + // The device was disconnected. + MISSING, + + // An internal error occurred. + INTERNAL_ERROR + }; + + // How the scanner is connected to the computer. + [nodoc] enum ConnectionType { + UNSPECIFIED, + USB, + NETWORK + }; + + // ScannerInfo contains general information about a scanner device. It is + // intended for filtering and constructing user-facing information, not for + // configuring a scan. + [nodoc] dictionary ScannerInfo { + // For connecting with openScanner. + DOMString scannerId; + + // Printable name for displaying in the UI. + DOMString name; + + // Scanner manufacturer. + DOMString manufacturer; + + // Scanner model if available, or a generic description. + DOMString model; + + // For matching against other ScannerInfo entries that point + // to the same physical device. + DOMString deviceUuid; + + // How the scanner is connected to the computer. + ConnectionType connectionType; + + // If true, the scanner connection's transport cannot be intercepted by a + // passive listener, such as TLS or USB. + boolean secure; + + // MIME types that can be requested for returned scans. + DOMString[] imageFormats; + }; + + // The type of an option. This is the same set of types as SANE_Value_Type. + [nodoc] enum OptionType { + // Unknown option type. value will be unset. + UNKNOWN, + + // true/false only. value will be a boolean. + BOOL, + + // Signed 32-bit integer. value will be long or long[], + // depending on whether the option takes more than one value. + INT, + + // Double in the range -32768-32767.9999 with a resolution of 1/65535. + // value will be double or double[] depending on whether the + // option takes more than one value. + FIXED, + + // A sequence of any bytes except NUL ('\0'). value will be a + // DOMString. + STRING, + + // Hardware button or toggle. No value. + BUTTON, + + // Grouping option. No value. This is included for compatibility, but + // will not normally be returned in ScannerOption values. Use + // getOptionGroups() to retrieve the list of groups with their + // member options. + GROUP + }; + + // The unit of measurement for an option. This is the same set of units as + // SANE_Unit. + [nodoc] enum OptionUnit { + // Value is a unitless number, e.g. threshold. + UNITLESS, + + // Value is a number of pixels, e.g., scan dimensions. + PIXEL, + + // Value is the number of bits, e.g., color depth. + BIT, + + // Value is measured in millimeters, e.g., scan dimensions. + MM, + + // Value is measured in dots per inch, e.g., resolution. + DPI, + + // Value is a percent, e.g., brightness. + PERCENT, + + // Value is measured in microseconds, e.g., exposure time. + MICROSECOND + }; + + // The type of constraint represented by an OptionConstraint. + [nodoc] enum ConstraintType { + // Constraint represents a range of OptionType.INT values. + // min, max, and quant will be + // long, and list will be unset. + INT_RANGE, + + // Constraint represents a range of OptionType.FIXED values. + // min, max, and quant will be + // double, and list will be unset. + FIXED_RANGE, + + // Constraint represents a specific list of OptionType.INT + // values. list will contain long values, and + // the other fields will be unset. + INT_LIST, + + // Constraint represents a specific list of OptionType.FIXED + // values. list will contain double values, and + // the other fields will be unset. + FIXED_LIST, + + // Constraint represents a specific list of OptionType.STRING + // values. list will contain DOMString values, + // and the other fields will be unset. + STRING_LIST + }; + + // OptionConstraint represents the same set of value constraints + // as SANE_Constraint_Type, with the exception that an unconstrained value is + // represented by a lack of constraint rather than a special + // SANE_CONSTRAINT_NONE value. + [nodoc] dictionary OptionConstraint { + ConstraintType type; + (long or double)? min; + (long or double)? max; + (long or double)? quant; + (double[] or long[] or DOMString[])? list; + }; + + // How an option can be changed. + [nodoc] enum Configurability { + // Option is read-only and cannot be changed. + NOT_CONFIGURABLE, + + // Option can be set in software. + SOFTWARE_CONFIGURABLE, + + // Option can be set by the user toggling/pushing a hardware button. + HARDWARE_CONFIGURABLE + }; + + // A self-describing configurable scanner option and current value, in the + // same style as SANE's SANE_Option_Descriptor and sane_control_option(). + [nodoc] dictionary ScannerOption { + // Option name using lowercase a-z, numbers, and dashes. + DOMString name; + + // Printable one-line title. + DOMString title; + + // Longer description of the option. + DOMString description; + + // The type that value will contain and that is needed for + // setting this option. + OptionType type; + + // Unit of measurement for this option. + OptionUnit unit; + + // Current value of the option if relevant. Note the type passed here must + // match the type specified in type. + (boolean or double or double[] or long or long[] or DOMString)? value; + + // Constraint on possible values. + OptionConstraint? constraint; + + // Can be detected from software. + boolean isDetectable; + + // Whether/how the option can be changed. + Configurability configurability; + + // Can be automatically set by the backend. + boolean isAutoSettable; + + // Emulated by the backend if true. + boolean isEmulated; + + // Option is active and can be set/retrieved. If false, the + // value field will not be set. + boolean isActive; + + // UI should not display this option by default. + boolean isAdvanced; + + // Option is used for internal configuration and should never be displayed + // in the UI. + boolean isInternal; + }; + + // A set of criteria passed to getScannerList(). Only devices + // that match all of the criteria will be returned. + [nodoc] dictionary DeviceFilter { + // Only return scanners that are directly attached to the computer. + boolean? local; + + // Only return scanners that use a secure transport, such as USB or TLS. + boolean? secure; + }; + + // OptionGroup is a group containing a list of option names. The groups and + // their contents are determined by the backend and do not have any defined + // semantics or consistent membership. This structure is primarily intended + // for UI layout assistance; it does not affect the individual option + // behaviors. + [nodoc] dictionary OptionGroup { + // Printable title, e.g. "Geometry options". + DOMString title; + + // Names of contained options, in backend-provided order. + DOMString[] members; + }; + + // The response from getScannerList(). + [nodoc] dictionary GetScannerListResponse { + // The backend's enumeration result. Note that partial results could be + // returned even if this indicates an error. + OperationResult result; + + // A possibly-empty list of scanners that match the provided + // DeviceFilter. + ScannerInfo[] scanners; + }; + + // The response from openScanner(). + [nodoc] dictionary OpenScannerResponse { + // Same scanner ID passed to openScanner(). + DOMString scannerId; + + // Backend result of opening the scanner. + OperationResult result; + + // If result is OperationResult.SUCCESS, a handle + // to the scanner that can be used for further operations. + DOMString? scannerHandle; + + // If result is OperationResult.SUCCESS, a + // key-value mapping from option names to ScannerOption. + object? options; + }; + + // The response from getOptionGroups(). + [nodoc] dictionary GetOptionGroupsResponse { + // Same scanner handle passed to getOptionGroups(). + DOMString scannerHandle; + + // The backend's result of getting the option groups. + OperationResult result; + + // If result is OperationResult.SUCCESS, a list of + // option groups in the order supplied by the backend. + OptionGroup[]? groups; + }; + + // The response from closeScanner(). + [nodoc] dictionary CloseScannerResponse { + // Same scanner handle passed to closeScanner(). + DOMString scannerHandle; + + // Backend result of closing the scanner. Even if this value is not + // OperationResult.SUCCESS, the handle will be invalid and + // should not be used for any further operations. + OperationResult result; + }; + + // A subset of ScannerOption that contains enough information to + // set an option to a new value. + [nodoc] dictionary OptionSetting { + // Name of the option to set. + DOMString name; + + // Type of the option. The requested type must match the real type of the + // underlying option. + OptionType type; + + // Value to set. Leave unset to request automatic setting for options that + // have autoSettable enabled. The type supplied for + // value must match type. + (boolean or double or double[] or long or long[] or DOMString)? value; + }; + + // The result of setting an individual option. Each individual option + // supplied to setOptions() produces a separate result on the + // backend due to things like rounding and constraints. + [nodoc] dictionary SetOptionResult { + // Name of the option that was set. + DOMString name; + + // Backend result of setting the option. + OperationResult result; + }; + + // The response from a call to setOptions(). + [nodoc] dictionary SetOptionsResponse { + // The same scanner handle passed to setOptions(). + DOMString scannerHandle; + + // One result per passed-in OptionSetting. + SetOptionResult[] results; + + // Updated key-value mapping from option names to + // ScannerOption containing the new configuration after + // attempting to set all supplied options. This has the same structure as + // the options field in OpenScannerResponse. + // + // This field will be set even if some options were not set successfully, + // but will be unset if retrieving the updated configuration fails (e.g., + // if the scanner is disconnected in the middle). + object? options; + }; + + // Used to specify options for startScan(). + [nodoc] dictionary StartScanOptions { + // MIME type to return scanned data in. + DOMString format; + }; + + // The response from startScan(). + [nodoc] dictionary StartScanResponse { + // The same scanner handle that was passed to startScan(). + DOMString scannerHandle; + + // The backend's start scan result. + OperationResult result; + + // If result is OperationResult.SUCCESS, a handle + // that can be used to read scan data or cancel the job. + DOMString? job; + }; + + // The response from cancelScan(). + [nodoc] dictionary CancelScanResponse { + // The same job handle that was passed to cancelScan(). + DOMString job; + + // The backend's cancel scan result. + OperationResult result; + }; + + // The response from readScanData(). + [nodoc] dictionary ReadScanDataResponse { + // Same job handle passed to readScanData(). + DOMString job; + + // The backend result of reading data. If this is + // OperationResult.SUCCESS, data will contain the + // next (possibly zero-length) chunk of image data that was ready for + // reading. If this is OperationResult.EOF, data + // will contain the final chunk of image data. + OperationResult result; + + // If result is OperationResult.SUCCESS, the next chunk of + // scanned image data. + ArrayBuffer? data; + + // If result is OperationResult.SUCCESS, an estimate of how + // much of the total scan data has been delivered so far, in the range + // 0-100. + long? estimatedCompletion; + }; + // Callback from the scan method. // |result| The results from the scan, if successful. // Otherwise will return null and set runtime.lastError. callback ScanCallback = void (ScanResults result); + // Callback from the getScannerList method. + // |response| The response from enumeration, if the call was valid. + // Otherwise will return null and set runtime.lastError. + [nodoc] callback GetScannerListCallback = void (GetScannerListResponse response); + + // Callback from the openScanner method. + // |response| The response from opening the scanner, if the call was valid. + // Otherwise will return null and set runtime.lastError. + [nodoc] callback OpenScannerCallback = void (OpenScannerResponse response); + + // Callback from the getOptionGroups method. + // |response| The response from getting the option groups, if the call was + // valid. Otherwise will return null and set runtime.lastError. + [nodoc] callback GetOptionGroupsCallback = + void (GetOptionGroupsResponse response); + + // Callback from the closeScanner method. + // |response| The response from closing the scanner, if the call was valid. + // Otherwise will return null and set runtime.lastError. + [nodoc] callback CloseScannerCallback = void (CloseScannerResponse response); + + // Callback from the setOptions method. + // |response| The response from setting the options, if the call was valid. + // Otherwise will return null and set runtime.lastError. + [nodoc] callback SetOptionsCallback = void (SetOptionsResponse response); + + // Callback from the startScan method. + // |response| The response from starting the scan, if the call was valid. + // Otherwise will return null and set runtime.lastError. + [nodoc] callback StartScanCallback = void (StartScanResponse response); + + // Callback from the cancelScan method. + // |response| The response from canceling the scan, if the call was valid. + // Otherwise will return null and set runtime.lastError. + [nodoc] callback CancelScanCallback = void (CancelScanResponse response); + + // Callback from the readScanData method. + // |response| The response from reading the next chunk of scanned image data, + // if the call was valid. Otherwise will return null and set + // runtime.lastError. + [nodoc] callback ReadScanDataCallback = void (ReadScanDataResponse response); + interface Functions { // Performs a document scan. On success, the PNG data will be // sent to the callback. @@ -36,5 +502,93 @@ namespace documentScan { // |callback| : Called with the result and data from the scan. [supportsPromises] static void scan(ScanOptions options, ScanCallback callback); + + // Gets the list of available scanners. On success, the list will be + // sent to the callback. + // |filter| : DeviceFilter indicating which types of scanners + // should be returned. + // |callback| : Called with the result and list of scanners. + [nodoc, supportsPromises] static void getScannerList( + DeviceFilter filter, GetScannerListCallback callback); + + // Opens a scanner for exclusive access. On success, the response containing + // a scanner handle and configuration will be sent to the callback. + // |scannerId| : Scanner id previously returned from getScannerList + // indicating which scanner should be opened. + // |callback| : Called with the result. + [nodoc, supportsPromises] static void openScanner( + DOMString scannerId, OpenScannerCallback callback); + + // Gets the group names and member options from a scanner handle previously + // opened by openScanner. + // |scannerHandle| : Open scanner handle previously returned from + // openScanner. + // |callback| : Called with the result. + [nodoc, supportsPromises] static void getOptionGroups( + DOMString scannerHandle, GetOptionGroupsCallback callback); + + // Closes a previously opened scanner handle. A response indicating the + // outcome will be sent to the callback. Even if the response is not a + // success, the supplied handle will become invalid and should not be used + // for further operations. + // |scannerHandle| : Open scanner handle previously returned from + // openScanner. + // |callback| : Called with the result. + [nodoc, supportsPromises] static void closeScanner( + DOMString scannerHandle, CloseScannerCallback callback); + + // Sends the list of new option values in options as a bundle + // to be set on scannerHandle. Each option will be set by the + // backend the order specified. Returns a backend response indicating the + // result of each option setting and a new set of final option values after + // all options have been updated. + // |scannerHandle| : Open scanner handle previously returned from + // openScanner. + // |options| : A list of OptionSettings that will be applied to + // scannerHandle. + // |callback| : Called with the result. + [nodoc, supportsPromises] static void setOptions( + DOMString scannerHandle, OptionSetting[] options, + SetOptionsCallback callback); + + // Starts a scan using a previously opened scanner handle. A response + // indicating the outcome will be sent to the callback. If successful, the + // response will include a job handle that can be used in subsequent calls + // to read scan data or cancel a scan. + // |scannerHandle| : Open scanner handle previously returned from + // openScanner. + // |options| : StartScanOptions indicating what options are to + // be used for the scan. StartScanOptions.format must match + // one of the entries returned in the scanner's ScannerInfo. + // |callback| : Called with the result. + [nodoc, supportsPromises] static void startScan( + DOMString scannerHandle, StartScanOptions options, + StartScanCallback callback); + + // Cancels a scan that was previously started using startScan. + // The response is sent to the callback. + // |job| : An active scan job previously returned from + // startScan. + // |callback| : Called with the result. + [nodoc, supportsPromises] static void cancelScan( + DOMString job, CancelScanCallback callback); + + // Reads the next chunk of available image data from an active job handle. + // A response indicating the outcome will be sent to the callback. + // + // It is valid for a response to have result + // OperationResult.SUCCESS with a zero-length + // data member. This means the scanner is still working but + // does not yet have additional data ready. The caller should wait a short + // time and try again. + // + // When the scan job completes, the response will have the result + // OperationResult.EOF. This response may contain a final + // non-zero data member. + // |job| : Active job handle previously returned from + // startScan. + // |callback| : Called with the result. + [nodoc, supportsPromises] static void readScanData( + DOMString job, ReadScanDataCallback callback); }; }; \ No newline at end of file diff --git a/idl/chrome/downloads.idl b/idl/chrome/downloads.idl index de492fb..14b9547 100644 --- a/idl/chrome/downloads.idl +++ b/idl/chrome/downloads.idl @@ -132,6 +132,7 @@ namespace downloads { accepted, allowlistedByPolicy, asyncScanning, + asyncLocalPasswordScanning, passwordProtected, blockedTooLarge, sensitiveContentWarning, @@ -140,7 +141,8 @@ namespace downloads { deepScannedFailed, deepScannedSafe, deepScannedOpenedDangerous, - promptForScaning, + promptForScanning, + promptForLocalPasswordScanning, accountCompromise }; @@ -512,11 +514,12 @@ namespace downloads { optional GetFileIconOptions options, GetFileIconCallback callback); - // Open the downloaded file now if the $(ref:DownloadItem) is complete; - // otherwise returns an error through $(ref:runtime.lastError). Requires the - // "downloads.open" permission in addition to the - // "downloads" permission. An $(ref:onChanged) event will fire - // when the item is opened for the first time. + // Opens the downloaded file now if the $(ref:DownloadItem) is complete; + // otherwise returns an error through $(ref:runtime.lastError). This method + // requires the "downloads.open" permission in addition to the + // "downloads" permission. An $(ref:onChanged) event fires + // when the item is opened for the first time. This method can only be called + // in response to a user gesture. // |downloadId|: The identifier for the downloaded file. static void open(long downloadId); @@ -558,6 +561,7 @@ namespace downloads { // one other extension has disabled it will return an error through // $(ref:runtime.lastError). Requires the "downloads.shelf" // permission in addition to the "downloads" permission. + [deprecated="Use $(ref:setUiOptions) instead."] static void setShelfEnabled(boolean enabled); // Change the download UI of every window associated with the current diff --git a/idl/chrome/enterprise_kiosk_input.idl b/idl/chrome/enterprise_kiosk_input.idl new file mode 100644 index 0000000..e471dcc --- /dev/null +++ b/idl/chrome/enterprise_kiosk_input.idl @@ -0,0 +1,36 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Use the chrome.enterprise.kioskInput API to change input +// settings for Kiosk sessions. +// Note: This API is only available extensions and Chrome apps installed +// by enterprise policy in ChromeOS Kiosk sessions. +[platforms = ("chromeos"), + implemented_in = "chrome/browser/extensions/api/enterprise_kiosk_input/enterprise_kiosk_input_api.h"] +namespace enterprise.kioskInput { + dictionary SetCurrentInputMethodOptions { + // The input method ID to set as current input method. This input + // method has to be enabled by enterprise policies. Supported IDs + // are located in https://crsrc.org/c/chrome/browser/resources/chromeos/input_method. + DOMString inputMethodId; + }; + + callback SetCurrentInputMethodCallback = void(); + + interface Functions { + // Sets the current input method. This function only changes + // the current input method to an enabled input method. + // Input methods can be enabled by enterprise polices. + // If the input method ID is invalid, or not enabled, + // $(ref:runtime.lastError) will be set with a failure reason. + // |options|: Object containing the fields defined in + // $(ref:SetCurrentInputMethodOptions). + // |callback|: Called when the input method is changed or if + // there is an error. + [supportsPromises] static void setCurrentInputMethod( + SetCurrentInputMethodOptions options, + SetCurrentInputMethodCallback callback); +}; + +}; \ No newline at end of file diff --git a/idl/chrome/file_manager_private.idl b/idl/chrome/file_manager_private.idl index 232ae8b..51bd6e7 100644 --- a/idl/chrome/file_manager_private.idl +++ b/idl/chrome/file_manager_private.idl @@ -54,6 +54,9 @@ enum VolumeType { drive, downloads, removable, archive, provided, mtp, // Device type. Available if this is removable volume. enum DeviceType { usb, sd, optical, mobile, unknown }; +// List of device connection statuses. +enum DeviceConnectionState {OFFLINE, ONLINE}; + // List of connection types of drive. enum DriveConnectionStateType {OFFLINE, METERED, ONLINE}; @@ -97,7 +100,7 @@ enum FormatFileSystemType { vfat, exfat, ntfs }; enum TransferState { in_progress, queued, completed, failed }; // The response when starting installing a Linux package. -enum InstallLinuxPackageResponse { +enum InstallLinuxPackageStatus { started, failed, install_already_active @@ -304,7 +307,7 @@ enum SharesheetLaunchSource { unknown }; -enum IOTaskState { +enum IoTaskState { queued, scanning, in_progress, @@ -315,7 +318,7 @@ enum IOTaskState { cancelled }; -enum IOTaskType { +enum IoTaskType { copy, delete, empty_trash, @@ -407,9 +410,9 @@ enum BulkPinStage { success, // Final error stages. + not_enough_space, cannot_get_free_space, cannot_list_files, - not_enough_space, cannot_enable_docs_offline }; @@ -582,6 +585,16 @@ dictionary MountPointSizeStats { double remainingSize; }; +dictionary SearchDriveResponse { + // Search results. + [instanceOf=Entry] object[] entries; + + // ID of the feed that contains next chunk of the search result. + // Should be sent to the next searchDrive request to perform + // incremental search. + DOMString nextFeed; +}; + // Free and total space available in Drive relative to both the user and their // organization, if they belong to one. dictionary DriveQuotaMetadata { @@ -613,6 +626,18 @@ dictionary ProfileInfo { boolean isCurrentProfile; }; +// The return data for getProfiles() API. +dictionary ProfilesResponse { + // List of profile information. + ProfileInfo[] profiles; + + // ID of the profile that runs the application instance. + DOMString currentProfileId; + + // ID of the profile that shows the application window. + DOMString displayedProfileId; +}; + // Represents an icon in multiple dimensions. All are optional. dictionary IconSet { DOMString? icon16x16Url; @@ -815,7 +840,7 @@ dictionary GetVolumeRootOptions { dictionary Preferences { boolean driveEnabled; - boolean cellularDisabled; + boolean driveSyncEnabledOnMeteredNetwork; boolean searchSuggestEnabled; boolean use24hourClock; DOMString timezone; @@ -825,11 +850,12 @@ dictionary Preferences { boolean trashEnabled; double officeFileMovedOneDrive; double officeFileMovedGoogleDrive; + boolean driveFsBulkPinningAvailable; boolean driveFsBulkPinningEnabled; }; dictionary PreferencesChange { - boolean? cellularDisabled; + boolean? driveSyncEnabledOnMeteredNetwork; boolean? arcEnabled; boolean? arcRemovableMediaAccessEnabled; DOMString[]? folderShortcuts; @@ -899,13 +925,6 @@ dictionary DriveConnectionState { // Reasons of offline. DriveOfflineReason? reason; - - // Whether the device has a cellular network access or not. i.e. the |type| - // can be 'metered' or not. - boolean hasCellularNetworkAccess; - - // Whether or not hosted files can be pinned. - boolean canPinHostedFiles; }; // Device event dispatched to listeners of onDeviceChaged. See also @@ -980,6 +999,14 @@ dictionary CrostiniEvent { [instanceOf=Entry] object[] entries; }; +dictionary CrostiniSharedPathResponse { + // Entries shared with crostini container. + [instanceOf=Entry] object[] entries; + + // true the first time this is called for the session. + boolean firstForSession; +}; + // Represents an Android app (activity). dictionary AndroidApp { // Name of the app to be shown to the user (e.g. Photos). @@ -1074,6 +1101,19 @@ dictionary IOTaskParams { boolean? showNotification; }; +// Holds information about data protection policy errors, see file_manager::io_task::PolicyError. +dictionary PolicyError { + // Type of the error. + PolicyErrorType type; + // The number of files blocked by the policy. + long policyFileCount; + // The name of the first blocked file. Used for notifications. + DOMString fileName; + // Normally the review button is only shown when `policyFileCount` is >1, this option allows to force + // the display of the review button irrespective of other conditions. + boolean alwaysShowReview; +}; + // IO task state::PAUSED name conflict parameters, see file_manager::io_task::ConflictPauseParams. dictionary ConflictPauseParams { // The conflict file name. @@ -1091,7 +1131,15 @@ dictionary ConflictPauseParams { // IO task state::PAUSED policy parameters, see file_manager::io_task::PolicyPauseParams. dictionary PolicyPauseParams { + // One of DLP or Enterprise Connectors. PolicyErrorType type; + // The number of files under warning restriction. + long policyFileCount; + // The name of the first file under warning restriction. Used for notifications. + DOMString fileName; + // Normally the review button is only shown when `policyFileCount` is >1, this option allows to force + // the display of the review button irrespective of other conditions. + boolean alwaysShowReview; }; // IO task state::PAUSED parameters, see file_manager::io_task::PauseParams. @@ -1129,14 +1177,14 @@ dictionary ResumeParams { dictionary ProgressStatus { // Type of the task sending the progress. - IOTaskType type; + IoTaskType type; // Current state of the task sending the progress. - IOTaskState state; + IoTaskState state; // Type of policy error that occurred, if any. // Used only if Data Leak Prevention or Enterprise Connectors policies apply. - PolicyErrorType? policyError; + PolicyError? policyError; // Name of the first source entry. DOMString sourceName; @@ -1183,6 +1231,10 @@ dictionary ProgressStatus { // The files affected by the IOTask. Currently only returned for TrashIOTask. [instanceOf=Entry] object[]? outputs; + // List of files skipped during the operation because we couldn't decrypt + // them. + DOMString[] skippedEncryptedFiles; + // Volume id of the destination for operations that transfer files to a // directory (e.g. copy or move). DOMString destinationVolumeId; @@ -1246,7 +1298,7 @@ dictionary ParsedTrashInfoFile { }; // The current progress of the bulk pinning manager. This is a subset of the -// Progress struct in chromeos/ash/components/drivefs/drivefs_pin_manager.h +// Progress struct in chromeos/ash/components/drivefs/drivefs_pinning_manager.h dictionary BulkPinProgress { // The stage the bulk pin manager is in. BulkPinStage stage; @@ -1268,8 +1320,18 @@ dictionary BulkPinProgress { // Total number of files to pin. long filesToPin; + // Show the total number of files enumerated during the Listing files stage. + long listedFiles; + // Estimated time remaining to pin all the `bytesToPin`. double remainingSeconds; + + // Should the bulk-pinning manager actually pin files, or should it stop after + // checking the space requirements? + boolean shouldPin; + + // Has the bulk-pinning manager ever emptied its set of tracked items? + boolean emptiedQueue; }; // Callback that does not take arguments. @@ -1353,8 +1415,7 @@ callback GetPreferencesCallback = void(Preferences result); // |nextFeed| ID of the feed that contains next chunk of the search result. // Should be sent to the next searchDrive request to perform // incremental search. -callback SearchDriveCallback = - void([instanceOf=Entry] object[] entries, DOMString nextFeed); +callback SearchDriveCallback = void(SearchDriveResponse response); callback SearchDriveMetadataCallback = void(DriveMetadataSearchResult[] results); @@ -1366,17 +1427,14 @@ callback SearchFilesCallback = void([instanceOf=Entry] object[] entries); // contain at most one path per hash. callback SearchFilesByHashesCallback = void(object paths); +callback GetDeviceConnectionStateCallback = void(DeviceConnectionState result); + callback GetDriveConnectionStateCallback = void(DriveConnectionState result); // |result| true if the length is in the valid range, false otherwise. callback ValidatePathNameLengthCallback = void(boolean result); -// |profiles| List of profile information. -// |runningProfile| ID of the profile that runs the application instance. -// |showingProfile| ID of the profile that shows the application window. -callback GetProfilesCallback = void(ProfileInfo[] profiles, - DOMString runningProfile, - DOMString displayProfile); +callback GetProfilesCallback = void(ProfilesResponse response); // |entries| External entries. callback ResolveEntriesCallback = @@ -1401,23 +1459,14 @@ callback GetRecentFilesCallback = void([instanceOf=Entry] object[] entries); callback GetVolumeRootCallback = void([instanceOf=DirectoryEntry] object rootDir); -// |entries| Entries shared with crostini container. -// |firstForSession| true the first time this is called for the session. callback GetCrostiniSharedPathsCallback = - void([instanceOf=Entry] object[] entries, boolean firstForSession); + void(CrostiniSharedPathResponse response); // |linux_package_info| Package info for the queried package. callback GetLinuxPackageInfoCallback = void(LinuxPackageInfo linux_package_info); -// |status| Result of starting the install -// |failure_reason| Reason for failure for a 'failed' status -callback InstallLinuxPackageCallback = void( - InstallLinuxPackageResponse response, DOMString failure_reason); - -// |thumbnailDataUrl| A data URL for the thumbnail; |thumbnailDataUrl| is empty -// if no thumbnail was available. -callback GetThumbnailCallback = void(DOMString thumbnailDataUrl); +callback InstallLinuxPackageCallback = void(InstallLinuxPackageStatus status); // |apps| List of Android picker apps. callback GetAndroidPickerAppsCallback = void(AndroidApp[] apps); @@ -1440,7 +1489,7 @@ interface Functions { // |descriptor| The unique identifier of task to execute. // |entries| Array of entries // |callback| - [nocompile] + [nocompile, supportsPromises] static void executeTask(FileTaskDescriptor descriptor, [instanceOf=Entry] object[] entries, ExecuteTaskCallback callback); @@ -1452,7 +1501,7 @@ interface Functions { // |entries| Array of selected entries to extract path extensions from. // |mimeTypes| Array of selected file MIME types. // |callback| - [nocompile] + [nocompile, supportsPromises] static void setDefaultTask(FileTaskDescriptor descriptor, [instanceOf=Entry] object[] entries, DOMString[] mimeTypes, @@ -1463,7 +1512,7 @@ interface Functions { // |dlpSourceUrls| Array of source URLs corresponding to the entries, used to // check Data Leak Prevention (DLP) restrictions // |callback| - [nocompile] + [nocompile, supportsPromises] static void getFileTasks([instanceOf=Entry] object[] entries, DOMString[] dlpSourceUrls, GetFileTasksCallback callback); @@ -1471,14 +1520,14 @@ interface Functions { // Gets the MIME type of an entry. // |entry| The entry to be checked. // |callback| - [nocompile] + [nocompile, supportsPromises] static void getMimeType([instanceOf=Entry] object entry, GetMimeTypeCallback callback); // Gets the content sniffed MIME type of a file. // |fileEntry| The file entry to be checked. // |callback| - [nocompile] + [nocompile, supportsPromises] static void getContentMimeType([instanceOf=FileEntry] object fileEntry, GetContentMimeTypeCallback callback); @@ -1488,7 +1537,7 @@ interface Functions { // |includeImages| False returns metadata tags only. True returns // metadata tags and metadata (thumbnail) images. // |callback| - [nocompile] + [nocompile, supportsPromises] static void getContentMetadata([instanceOf=FileEntry] object fileEntry, DOMString mimeType, boolean includeImages, @@ -1496,19 +1545,20 @@ interface Functions { // Gets localized strings and initialization data. // |callback| + [supportsPromises] static void getStrings(GetStringsCallback callback); // Adds file watch. // |entry| Entry to watch // |callback| - [nocompile] + [nocompile, supportsPromises] static void addFileWatch([instanceOf=Entry] object entry, AddFileWatchCallback callback); // Removes file watch. // |entry| Watched entry // |callback| - [nocompile] + [nocompile, supportsPromises] static void removeFileWatch([instanceOf=Entry] object entry, RemoveFileWatchCallback callback); @@ -1521,12 +1571,14 @@ interface Functions { // invalid or not backed by the external file system. // |entryUrls| Urls for the entries to be accessed. // |callback| + [supportsPromises] static void grantAccess(DOMString[] entryUrls, SimpleCallback callback); // Selects multiple files. // |selectedPaths| Array of selected paths // |shouldReturnLocalPath| true if paths need to be resolved to local paths. // |callback| + [supportsPromises] static void selectFiles(DOMString[] selectedPaths, boolean shouldReturnLocalPath, SimpleCallback callback); @@ -1537,6 +1589,7 @@ interface Functions { // |forOpening| true if paths are selected for opening. false if for saving. // |shouldReturnLocalPath| true if paths need to be resolved to local paths. // |callback| + [supportsPromises] static void selectFile(DOMString selectedPath, long index, boolean forOpening, @@ -1549,7 +1602,7 @@ interface Functions { // |callback| Completion callback. May return less than requested properties // if some are not available. In the same time, it can return properties // which were not requested (if it's cheap to compute them). - [nocompile] + [nocompile, supportsPromises] static void getEntryProperties( [instanceOf=Entry] object[] entries, EntryPropertyName[] names, @@ -1560,7 +1613,7 @@ interface Functions { // |pin| Pass true to pin the file. // |callback| Completion callback. $(ref:runtime.lastError) will be set if // there was an error. - [nocompile] + [nocompile, supportsPromises] static void pinDriveFile([instanceOf=Entry] object entry, boolean pin, SimpleCallback callback); @@ -1569,7 +1622,7 @@ interface Functions { // entries in the external file system mounted to Chrome OS file manager // backend. If resolving entry fails, the entry will be just ignored and the // corresponding entry does not appear in the result. - [nocompile] + [nocompile, supportsPromises] static void resolveIsolatedEntries( [instanceOf=Entry] object[] entries, ResolveEntriesCallback callback); @@ -1578,20 +1631,24 @@ interface Functions { // |fileUrl| Mount point source. // |password| Optional password to decrypt the archive. // |callback| Callback called with the source path of the mount. + [supportsPromises] static void addMount(DOMString fileUrl, optional DOMString password, AddMountCallback callback); // Cancels an archive mounting operation. // |fileUrl| Mount point source. Should be same as the one passed to addMount. // |callback| + [supportsPromises] static void cancelMounting(DOMString fileUrl, SimpleCallback callback); // Unmounts a mounted resource. // |volumeId| An ID of the volume. + [supportsPromises] static void removeMount(DOMString volumeId, SimpleCallback callback); // Get the list of mounted volumes. // |callback| + [supportsPromises] static void getVolumeMetadataList(GetVolumeMetadataListCallback callback); // Returns the list of files not allowed to be transfered. @@ -1599,7 +1656,7 @@ interface Functions { // |destinationEntry| Entry for the destination (parent) directory. // |isMove| True if the operation is move, false otherwise. // |callback| Result callback. - [nocompile] + [nocompile, supportsPromises] static void getDisallowedTransfers( [instanceOf=Entry] object[] entries, [instanceOf=DirectoryEntry] object destinationEntry, @@ -1610,7 +1667,7 @@ interface Functions { // about the entries. // |entries| List of the source entries to be checked. // |callback| Result callback. - [nocompile] + [nocompile, supportsPromises] static void getDlpMetadata( [instanceOf=Entry] object[] entries, GetDlpMetadataCallback callback); @@ -1618,6 +1675,7 @@ interface Functions { // Retrieves Data Leak Prevention (DLP) restriction details. // |sourceUrl| Source URL of the Entry for which the details should be shown. // |callback| Result callback. + [supportsPromises] static void getDlpRestrictionDetails( DOMString sourceUrl, GetDlpRestrictionDetailsCallback callback); @@ -1626,17 +1684,20 @@ interface Functions { // is blocked by Data Leak Prevention (DLP) policy. // |sourceUrl| Source URL of the Entry that should be checked. // |callback| Result callback. + [supportsPromises] static void getDlpBlockedComponents( DOMString sourceUrl, GetDlpBlockedComponentsCallback callback); // Retrieves the caller that created the dialog (Save As/File Picker). // |callback| Result callback. + [supportsPromises] static void getDialogCaller(GetDialogCallerCallback callback); // Retrieves total and remaining size of a mount point. // |volumeId| ID of the volume to be checked. // |callback| + [supportsPromises] static void getSizeStats(DOMString volumeId, GetSizeStatsCallback callback); @@ -1644,7 +1705,7 @@ interface Functions { // |entry| If entry is within a Shared Drive, then the applicable shared // drive quota is returned, else the overall Drive quota is returned. // |callback| - [nocompile] + [nocompile, supportsPromises] static void getDriveQuotaMetadata([instanceOf=Entry] object entry, GetDriveQuotaMetadataCallback callback); @@ -1672,6 +1733,7 @@ interface Functions { // Retrieves file manager preferences. // |callback| + [supportsPromises] static void getPreferences(GetPreferencesCallback callback); // Sets file manager preferences. @@ -1681,34 +1743,42 @@ interface Functions { // Performs drive content search. // |searchParams| // |callback| + [supportsPromises] static void searchDrive(SearchParams searchParams, SearchDriveCallback callback); // Performs drive metadata search. // |searchParams| // |callback| + [supportsPromises] static void searchDriveMetadata(SearchMetadataParams searchParams, SearchDriveMetadataCallback callback); // Search files in the volume having |volumeId| by using |hashList|. + [supportsPromises] static void searchFilesByHashes(DOMString volumeId, DOMString[] hashList, SearchFilesByHashesCallback callback); // Search files in My Files. - [nocompile] + [nocompile, supportsPromises] static void searchFiles(SearchMetadataParams searchParams, SearchFilesCallback callback); + // Retrieves the current device connection status. + // |callback| + static void getDeviceConnectionState(GetDeviceConnectionStateCallback callback); + // Retrieves the state of the current drive connection. // |callback| + [supportsPromises] static void getDriveConnectionState(GetDriveConnectionStateCallback callback); // Checks whether the path name length fits in the limit of the filesystem. // |parentEntry| The entry of the parent directory entry. // |name| The name of the file. // |callback| Called back when the check is finished. - [nocompile] + [nocompile, supportsPromises] static void validatePathNameLength( [instanceOf=DirectoryEntry] object parentEntry, DOMString name, @@ -1719,6 +1789,7 @@ interface Functions { static void zoom(ZoomOperationType operation); // Obtains a list of profiles that are logged-in. + [supportsPromises] static void getProfiles(GetProfilesCallback callback); // Opens inspector window. @@ -1726,37 +1797,40 @@ interface Functions { static void openInspector(InspectionType type); // Opens page in Settings window. - // |sub_page| Name of a sub_page to show. - static void openSettingsSubpage(DOMString sub_page); + // |subPage| Name of a subPage to show. + static void openSettingsSubpage(DOMString subPage); // Computes an MD5 checksum for the given file. // |entry| The entry of the file to checksum. // |callback| - [nocompile] + [nocompile, supportsPromises] static void computeChecksum([instanceOf=Entry] object entry, ComputeChecksumCallback callback); // Returns list of available providers. + [supportsPromises] static void getProviders(GetProvidersCallback callback); // Requests adding a new provided file system. On failure, sets // $(ref:runtime.lastError). + [supportsPromises] static void addProvidedFileSystem(DOMString providerId, SimpleCallback callback); // Requests configuring an existing volume. On failure, sets // $(ref:runtime.lastError). + [supportsPromises] static void configureVolume(DOMString volumeId, SimpleCallback callback); // Requests list of custom actions for the specified entries. On failure, sets // $(ref:runtime.lastError). - [nocompile] + [nocompile, supportsPromises] static void getCustomActions([instanceOf=Entry] object[] entries, GetCustomActionsCallback callback); // Executes a custom action for a set of entries. On failure, sets // $(ref:runtime.lastError). - [nocompile] + [nocompile, supportsPromises] static void executeCustomAction([instanceOf=Entry] object[] entries, DOMString actionId, SimpleCallback callback); @@ -1764,28 +1838,33 @@ interface Functions { // Get the total size of a directory. // |entry| Entry of the target directory. // |callback| - [nocompile] + [nocompile, supportsPromises] static void getDirectorySize([instanceOf=DirectoryEntry] object entry, GetDirectorySizeCallback callback); // Gets recently modified files across file systems. // |restriction| Flag to restrict sources of recent files. // |fileType| Requested file type to filter recent files. - // |callback| - [nocompile] + // |query| When not empty, removes files with non-matching names. + // |cutoffDays| Specifies oldest modification time. + // |callback| Called with zero or more matched files. + [nocompile, supportsPromises] static void getRecentFiles(SourceRestriction restriction, + DOMString query, + long cutoffDays, FileCategory fileCategory, boolean invalidateCache, GetRecentFilesCallback callback); // Requests the root directory of the volume with the ID specified in // |options.volumeId|. - [nocompile] + [nocompile, supportsPromises] static void getVolumeRoot(GetVolumeRootOptions options, GetVolumeRootCallback callback); // Starts and mounts crostini container. // |callback| + [supportsPromises] static void mountCrostini(SimpleCallback callback); // Shares paths with crostini container. @@ -1793,33 +1872,37 @@ interface Functions { // |entries| Entries of the files or directories to share. // |persist| If true, shares will persist across restarts. // |callback| - [nocompile] static void sharePathsWithCrostini( - DOMString vmName, [instanceOf=Entry] object[] entries, boolean persist, - SimpleCallback callback); + [nocompile, supportsPromises] + static void sharePathsWithCrostini(DOMString vmName, + [instanceOf=Entry] object[] entries, + boolean persist, + SimpleCallback callback); // Unshares path with crostini container. // |vmName| VM to unshare path from. // |entry| Entry of the file or directory to unshare. // |callback| - [nocompile] static void unsharePathWithCrostini( - DOMString vmName, [instanceOf=Entry] object entry, - SimpleCallback callback); + [nocompile, supportsPromises] + static void unsharePathWithCrostini(DOMString vmName, + [instanceOf=Entry] object entry, + SimpleCallback callback); // Returns list of paths shared with crostini container. // |observeFirstForSession| If true, callback provides whether this is the // |vmName| VM to get shared paths of. // first time this function has been called with observeFirstForSession true. - [nocompile] static void getCrostiniSharedPaths( - boolean observeFirstForSession, DOMString vmName, - GetCrostiniSharedPathsCallback callback); + [nocompile, supportsPromises] + static void getCrostiniSharedPaths(boolean observeFirstForSession, + DOMString vmName, + GetCrostiniSharedPathsCallback callback); // Requests information about a Linux package. |entry| is a .deb file. - [nocompile] + [nocompile, supportsPromises] static void getLinuxPackageInfo([instanceOf=Entry] object entry, GetLinuxPackageInfoCallback callback); // Starts installation of a Linux package. - [nocompile] + [nocompile, supportsPromises] static void installLinuxPackage([instanceOf=Entry] object entry, InstallLinuxPackageCallback callback); @@ -1828,40 +1911,13 @@ interface Functions { [nocompile] static void importCrostiniImage([instanceOf=Entry] object entry); - // For a file in DriveFS, retrieves its thumbnail. If |cropToSquare| is true, - // returns a thumbnail appropriate for file list or grid views; otherwise, - // returns a thumbnail appropriate for quickview. - [nocompile] - static void getDriveThumbnail([instanceOf=FileEntry] object entry, - boolean cropToSquare, - GetThumbnailCallback callback); - - // For a local PDF file, retrieves its thumbnail with a given |width| and - // |height|. - [nocompile] - static void getPdfThumbnail([instanceOf=FileEntry] object entry, - long width, - long height, - GetThumbnailCallback callback); - - // Retrieves a thumbnail of an ARC DocumentsProvider file, closely matching - // the hinted size specified by |widthHint| and |heightHint|, but not - // necessarily the exact size. |callback| is called with thumbnail data - // encoded as a data URL. If the document does not support thumbnails, - // |callback| is called with an empty string. - // Note: The thumbnail data may originate from third-party application code, - // and is untrustworthy (Security). - [nocompile] - static void getArcDocumentsProviderThumbnail([instanceOf=FileEntry] object entry, - long widthHint, - long heightHint, - GetThumbnailCallback callback); - // Returns a list of Android picker apps to be shown in file selector. + [supportsPromises] static void getAndroidPickerApps(DOMString[] extensions, GetAndroidPickerAppsCallback callback); // Called when the user selects an Android picker app in file selector. + [supportsPromises] static void selectAndroidPickerApp(AndroidApp androidApp, SimpleCallback callback); @@ -1870,7 +1926,7 @@ interface Functions { // |callback| is called with error in case of failure and with no arguments // if successfully launched the Sharesheet dialog, but before user has // finished the sharing. - [nocompile] + [nocompile, supportsPromises] static void sharesheetHasTargets([instanceOf=Entry] object[] entries, BooleanCallback callback); @@ -1880,7 +1936,7 @@ interface Functions { // |dlpSourceUrls| Array of source URLs corresponding to the entries, used to // check Data Leak Prevention (DLP) restrictions // |callback| - [nocompile] + [nocompile, supportsPromises] static void invokeSharesheet([instanceOf=Entry] object[] entries, SharesheetLaunchSource launchSource, DOMString[] dlpSourceUrls, @@ -1892,7 +1948,7 @@ interface Functions { // |entries| The list of entries whose holding space needs to be updated. // |add| Whether items should be added or removed from the holding space. // |callback| Completion callback. - [nocompile] + [nocompile, supportsPromises] static void toggleAddedToHoldingSpace([instanceOf=Entry] object[] entries, boolean added, optional SimpleCallback callback); @@ -1900,9 +1956,11 @@ interface Functions { // Retrieves the current holding space state, for example the list of items // the holding space currently contains. // |callback| The result callback. + [supportsPromises] static void getHoldingSpaceState(HoldingSpaceStateCallback callback); // Returns true via `callback` if tablet mode is enabled, false otherwise. + [supportsPromises] static void isTabletModeEnabled(BooleanCallback callback); // Notifies the browser of the result of a dialog displayed earlier as a @@ -1913,6 +1971,7 @@ interface Functions { static void openURL(DOMString url); // Creates a new Files app window in the directory provided in `params`. + [supportsPromises] static void openWindow(OpenWindowParams params, BooleanCallback callback); // Opens the feedback report window. @@ -1920,9 +1979,9 @@ interface Functions { // Starts an I/O task of type |type| on |entries|. Task type specific // parameters are passed via |params|. - [nocompile] + [nocompile, supportsPromises] static void startIOTask( - IOTaskType type, + IoTaskType type, [instanceOf=Entry] object[] entries, IOTaskParams params, optional IOTaskIdCallback callback); @@ -1935,19 +1994,31 @@ interface Functions { // each I/O task's progress status. static void resumeIOTask(long taskId, ResumeParams params); + // Notifies the browser that any info still stored about an already completed + // I/O task identified by |taskId| can be cleared. + [supportsPromises] + static void dismissIOTask(long taskId, SimpleCallback callback); + // Shows a policy dialog for a task. Task ids are communicated to the Files // App in each I/O task's progress status. - static void showPolicyDialog(long taskId, PolicyDialogType type); + [supportsPromises] + static void showPolicyDialog( + long taskId, + PolicyDialogType type, + SimpleCallback callback); // Makes I/O tasks in state::PAUSED emit (broadcast) their current I/O task // progress status. - static void progressPausedTasks(); + [supportsPromises] + static void progressPausedTasks(SimpleCallback callback); // Lists mountable Guest OSs. + [supportsPromises] static void listMountableGuests(ListMountableGuestsCallback callback); // Starts and mounts the target Guest OS. // |callback| + [supportsPromises] static void mountGuest(long id, SimpleCallback callback); // Tells DriveFS to update its cached pin states of hosted files (once). @@ -1957,15 +2028,17 @@ interface Functions { static void openManageSyncSettings(); // Validates and parses the supplied `entries` as .trashinfo files. - [nocompile] + [nocompile, supportsPromises] static void parseTrashInfoFiles([instanceOf=Entry] object[] entries, ParseTrashInfoFilesCallback callback); // Returns the current progress of the bulk pinning manager. + [supportsPromises] static void getBulkPinProgress(GetBulkPinProgressCallback callback); // Starts calculating the space required to pin all the items in a users My // drive. + [supportsPromises] static void calculateBulkPinRequiredSpace(SimpleCallback callback); }; @@ -1985,6 +2058,8 @@ interface Events { static void onPreferencesChanged(); + static void onDeviceConnectionStatusChanged(DeviceConnectionState state); + static void onDriveConnectionStatusChanged(); static void onDeviceChanged(DeviceEvent event); diff --git a/idl/chrome/file_manager_private_internal.idl b/idl/chrome/file_manager_private_internal.idl index 939303b..be2b055 100644 --- a/idl/chrome/file_manager_private_internal.idl +++ b/idl/chrome/file_manager_private_internal.idl @@ -31,6 +31,10 @@ namespace fileManagerPrivateInternal { double modifiedTimestamp; fileManagerPrivate.FileCategory category; }; + dictionary CrostiniSharedPathResponse { + EntryDescription[] entries; + boolean firstForSession; + }; callback SimpleCallback = void(); callback ResolveIsolatedEntriesCallback = void(EntryDescription[] entries); @@ -57,11 +61,11 @@ namespace fileManagerPrivateInternal { callback GetDirectorySizeCallback = void(double size); callback GetRecentFilesCallback = void(EntryDescription[] entries); callback GetCrostiniSharedPathsCallback = - void(EntryDescription[] entries, boolean firstForSession); + void(CrostiniSharedPathResponse response); callback GetLinuxPackageInfoCallback = void(fileManagerPrivate.LinuxPackageInfo linux_package_info); callback InstallLinuxPackageCallback = - void(fileManagerPrivate.InstallLinuxPackageResponse response); + void(fileManagerPrivate.InstallLinuxPackageStatus status); callback GetThumbnailCallback = void(DOMString ThumbnailDataUrl); callback BooleanCallback = void(boolean result); callback GetVolumeRootCallback = void(EntryDescription rootDir); @@ -69,104 +73,123 @@ namespace fileManagerPrivateInternal { callback SearchFilesCallback = void(EntryDescription[] entries); interface Functions { - static void resolveIsolatedEntries(DOMString[] urls, - ResolveIsolatedEntriesCallback callback); - static void getEntryProperties( + [supportsPromises] static void resolveIsolatedEntries( + DOMString[] urls, + ResolveIsolatedEntriesCallback callback); + [supportsPromises] static void getEntryProperties( DOMString[] urls, fileManagerPrivate.EntryPropertyName[] names, GetEntryPropertiesCallback callback); - static void addFileWatch( + [supportsPromises] static void addFileWatch( DOMString url, AddFileWatchCallback callback); - static void removeFileWatch( + [supportsPromises] static void removeFileWatch( DOMString url, RemoveFileWatchCallback callback); - static void getCustomActions(DOMString[] urls, - GetCustomActionsCallback callback); - static void executeCustomAction(DOMString[] urls, - DOMString actionId, - SimpleCallback callback); - static void computeChecksum(DOMString url, - ComputeChecksumCallback callback); - static void getMimeType(DOMString url, - GetMimeTypeCallback callback); - static void getContentMimeType(DOMString blobUUID, - GetContentMimeTypeCallback callback); - static void getContentMetadata(DOMString blobUUID, - DOMString mimeType, - boolean includeImages, - GetContentMetadataCallback callback); - static void pinDriveFile(DOMString url, - boolean pin, - SimpleCallback callback); - static void executeTask(fileManagerPrivate.FileTaskDescriptor descriptor, - DOMString[] urls, - ExecuteTaskCallback callback); - static void searchFiles(SearchFilesParams searchParams, SearchFilesCallback callback); - static void setDefaultTask(fileManagerPrivate.FileTaskDescriptor descriptor, - DOMString[] urls, - DOMString[] mimeTypes, - SimpleCallback callback); - static void getFileTasks(DOMString[] urls, - DOMString[] dlpSourceUrls, - GetFileTasksCallback callback); - static void getDisallowedTransfers(DOMString[] entries, - DOMString destinationEntry, - boolean isMove, - GetDisallowedTransfersCallback callback); - static void getDlpMetadata(DOMString[] entries, - GetDlpMetadataCallback callback); - static void getDriveQuotaMetadata(DOMString url, - GetDriveQuotaMetadataCallback callback); - static void validatePathNameLength( + [supportsPromises] static void getCustomActions( + DOMString[] urls, + GetCustomActionsCallback callback); + [supportsPromises] static void executeCustomAction( + DOMString[] urls, + DOMString actionId, + SimpleCallback callback); + [supportsPromises] static void computeChecksum( + DOMString url, + ComputeChecksumCallback callback); + [supportsPromises] static void getMimeType( + DOMString url, + GetMimeTypeCallback callback); + [supportsPromises] static void getContentMimeType( + DOMString blobUUID, + GetContentMimeTypeCallback callback); + [supportsPromises] static void getContentMetadata( + DOMString blobUUID, + DOMString mimeType, + boolean includeImages, + GetContentMetadataCallback callback); + [supportsPromises] static void pinDriveFile( + DOMString url, + boolean pin, + SimpleCallback callback); + [supportsPromises] static void executeTask( + fileManagerPrivate.FileTaskDescriptor descriptor, + DOMString[] urls, + ExecuteTaskCallback callback); + [supportsPromises] static void searchFiles( + SearchFilesParams searchParams, SearchFilesCallback callback); + [supportsPromises] static void setDefaultTask( + fileManagerPrivate.FileTaskDescriptor descriptor, + DOMString[] urls, + DOMString[] mimeTypes, + SimpleCallback callback); + [supportsPromises] static void getFileTasks( + DOMString[] urls, + DOMString[] dlpSourceUrls, + GetFileTasksCallback callback); + [supportsPromises] static void getDisallowedTransfers( + DOMString[] entries, + DOMString destinationEntry, + boolean isMove, + GetDisallowedTransfersCallback callback); + [supportsPromises] static void getDlpMetadata( + DOMString[] entries, + GetDlpMetadataCallback callback); + [supportsPromises] static void getDriveQuotaMetadata( + DOMString url, + GetDriveQuotaMetadataCallback callback); + [supportsPromises] static void validatePathNameLength( DOMString parentUrl, DOMString name, ValidatePathNameLengthCallback callback); - static void getDirectorySize(DOMString url, - GetDirectorySizeCallback callback); - static void getVolumeRoot(fileManagerPrivate.GetVolumeRootOptions options, - GetVolumeRootCallback callback); - static void getRecentFiles(fileManagerPrivate.SourceRestriction restriction, - fileManagerPrivate.FileCategory file_category, - boolean invalidate_cache, - GetRecentFilesCallback callback); - static void sharePathsWithCrostini(DOMString vmName, DOMString[] urls, - boolean persist, - SimpleCallback callback); - static void unsharePathWithCrostini(DOMString vmName, DOMString url, - SimpleCallback callback); - static void getCrostiniSharedPaths(boolean observeFirstForSession, - DOMString vmName, - GetCrostiniSharedPathsCallback callback); - static void getLinuxPackageInfo(DOMString url, - GetLinuxPackageInfoCallback callback); - static void installLinuxPackage(DOMString url, - InstallLinuxPackageCallback callback); + [supportsPromises] static void getDirectorySize( + DOMString url, + GetDirectorySizeCallback callback); + [supportsPromises] static void getVolumeRoot( + fileManagerPrivate.GetVolumeRootOptions options, + GetVolumeRootCallback callback); + [supportsPromises] static void getRecentFiles( + fileManagerPrivate.SourceRestriction restriction, + DOMString query, + long cutoff_days, + fileManagerPrivate.FileCategory file_category, + boolean invalidate_cache, + GetRecentFilesCallback callback); + [supportsPromises] static void sharePathsWithCrostini( + DOMString vmName, DOMString[] urls, + boolean persist, + SimpleCallback callback); + [supportsPromises] static void unsharePathWithCrostini( + DOMString vmName, DOMString url, + SimpleCallback callback); + static void getCrostiniSharedPaths( + boolean observeFirstForSession, + DOMString vmName, + GetCrostiniSharedPathsCallback callback); + [supportsPromises] static void getLinuxPackageInfo( + DOMString url, + GetLinuxPackageInfoCallback callback); + [supportsPromises] static void installLinuxPackage( + DOMString url, + InstallLinuxPackageCallback callback); static void importCrostiniImage(DOMString url); - static void getDriveThumbnail(DOMString url, - boolean cropToSquare, - GetThumbnailCallback callback); - static void getPdfThumbnail(DOMString url, - long width, - long height, - GetThumbnailCallback callback); - static void getArcDocumentsProviderThumbnail(DOMString url, - long widthHint, - long heightHint, - GetThumbnailCallback callback); - static void sharesheetHasTargets(DOMString[] urls, BooleanCallback callback); - static void invokeSharesheet( + [supportsPromises] static void sharesheetHasTargets( + DOMString[] urls, + BooleanCallback callback); + [supportsPromises] static void invokeSharesheet( DOMString[] urls, fileManagerPrivate.SharesheetLaunchSource launchSource, DOMString[] dlpSourceUrls, SimpleCallback callback); - static void toggleAddedToHoldingSpace(DOMString[] urls, boolean add, + [supportsPromises] static void toggleAddedToHoldingSpace( + DOMString[] urls, boolean add, optional SimpleCallback callback); - static void startIOTask(fileManagerPrivate.IOTaskType type, - DOMString[] urls, - IOTaskParams params, - optional IOTaskIdCallback callback); - static void parseTrashInfoFiles(DOMString[] urls, - ParseTrashInfoFilesCallback callback); + [supportsPromises] static void startIOTask( + fileManagerPrivate.IoTaskType type, + DOMString[] urls, + IOTaskParams params, + optional IOTaskIdCallback callback); + [supportsPromises] static void parseTrashInfoFiles( + DOMString[] urls, + ParseTrashInfoFilesCallback callback); }; }; \ No newline at end of file diff --git a/idl/chrome/file_system_provider.idl b/idl/chrome/file_system_provider.idl index 51d112d..3f767db 100644 --- a/idl/chrome/file_system_provider.idl +++ b/idl/chrome/file_system_provider.idl @@ -52,6 +52,15 @@ namespace fileSystemProvider { SHARE }; + // Cloud storage representation of a file system entry. + dictionary CloudIdentifier { + // Identifier for the cloud storage provider (e.g. 'drive.google.com'). + DOMString providerName; + + // The provider's identifier for the given file/directory. + DOMString id; + }; + // Represents metadata of a file or a directory. dictionary EntryMetadata { // True if it is a directory. Must be provided if requested in @@ -78,6 +87,12 @@ namespace fileSystemProvider { // 32 KB in size. Optional, but can be provided only when explicitly // requested by the $(ref:onGetMetadataRequested) event. DOMString? thumbnail; + + // Cloud storage representation of this entry. Must be provided if requested + // in options and the file is backed by cloud storage. For + // local files not backed by cloud storage, it should be undefined when + // requested. + CloudIdentifier? cloudIdentifier; }; // Represents a watcher. @@ -110,7 +125,7 @@ namespace fileSystemProvider { // The identifier of the file system. DOMString fileSystemId; - // A human-readable name for the file system. + // A human-readable name for the file system. DOMString displayName; // Whether the file system supports operations which may change contents @@ -138,7 +153,7 @@ namespace fileSystemProvider { // extension. DOMString fileSystemId; - // A human-readable name for the file system. + // A human-readable name for the file system. DOMString displayName; // Whether the file system supports operations which may change contents @@ -200,8 +215,12 @@ namespace fileSystemProvider { // Set to true if mimeType value is requested. boolean mimeType; - // Set to true if the thumbnail is requested. + // Set to true if thumbnail value is requested. boolean thumbnail; + + // Set to true if cloudIdentifier value is + // requested. + boolean cloudIdentifier; }; // Options for the $(ref:onGetActionsRequested) event. @@ -224,7 +243,7 @@ namespace fileSystemProvider { // The unique identifier of this request. long requestId; - // The path of the directory which contents are requested. + // The path of the directory which contents are requested. DOMString directoryPath; // Set to true if is_directory value is requested. @@ -243,7 +262,7 @@ namespace fileSystemProvider { // Set to true if mimeType value is requested. boolean mimeType; - // Set to true if the thumbnail is requested. + // Set to true if thumbnail value is requested. boolean thumbnail; }; @@ -584,7 +603,7 @@ namespace fileSystemProvider { // Notifies about changes in the watched directory at // observedPath in recursive mode. If the file - // system is mounted with supportsNofityTag, then + // system is mounted with supportsNotifyTag, then // tag must be provided, and all changes since the last // notification always reported, even if the system was shutdown. The last // tag can be obtained with $(ref:getAll). @@ -785,4 +804,4 @@ namespace fileSystemProvider { ProviderSuccessCallback successCallback, ProviderErrorCallback errorCallback); }; -}; +}; \ No newline at end of file diff --git a/idl/chrome/history.json b/idl/chrome/history.json index 4898aa7..b209bca 100644 --- a/idl/chrome/history.json +++ b/idl/chrome/history.json @@ -5,7 +5,7 @@ [ { "namespace": "history", - "description": "Use the chrome.history API to interact with the browser's record of visited pages. You can add, remove, and query for URLs in the browser's history. To override the history page with your own version, see Override Pages.", + "description": "Use the chrome.history API to interact with the browser's record of visited pages. You can add, remove, and query for URLs in the browser's history. To override the history page with your own version, see Override Pages.", "types": [ { "id": "TransitionType", diff --git a/idl/chrome/identity.idl b/idl/chrome/identity.idl index 88ff6ec..1e17087 100644 --- a/idl/chrome/identity.idl +++ b/idl/chrome/identity.idl @@ -12,9 +12,9 @@ namespace identity { }; enum AccountStatus { - // Sync is enabled for the primary account. + // Specifies that Sync is enabled for the primary account. SYNC, - // Any primary account, if exists. + // Specifies the existence of a primary account, if any. ANY }; @@ -135,7 +135,7 @@ namespace identity { // Gets an OAuth2 access token using the client ID and scopes // specified in the oauth2 + // href="/docs/apps/app_identity#update_manifest">oauth2 // section of manifest.json. // // The Identity API caches access tokens in memory, so it's ok to diff --git a/idl/chrome/image_loader_private.idl b/idl/chrome/image_loader_private.idl new file mode 100644 index 0000000..f695fb4 --- /dev/null +++ b/idl/chrome/image_loader_private.idl @@ -0,0 +1,41 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// imageLoaderPrivate API. +// This is a private API used by the ChromeOS FilesApp ImageLoader extension. +[platforms=("chromeos"), + implemented_in="chrome/browser/ash/extensions/file_manager/image_loader_private_api.h"] +namespace imageLoaderPrivate { + // |thumbnailDataUrl| A data URL for the thumbnail; |thumbnailDataUrl| is + // empty if no thumbnail was available. + callback GetThumbnailCallback = void(DOMString thumbnailDataUrl); + + interface Functions { + // For a file in DriveFS, retrieves its thumbnail. If |cropToSquare| is + // true, returns a thumbnail appropriate for file list or grid views; + // otherwise, returns a thumbnail appropriate for quickview. + static void getDriveThumbnail(DOMString url, + boolean cropToSquare, + GetThumbnailCallback callback); + + // For a local PDF file, retrieves its thumbnail with a given |width| and + // |height|. + static void getPdfThumbnail(DOMString url, + long width, + long height, + GetThumbnailCallback callback); + + // Retrieves a thumbnail of an ARC DocumentsProvider file, closely matching + // the hinted size specified by |widthHint| and |heightHint|, but not + // necessarily the exact size. |callback| is called with thumbnail data + // encoded as a data URL. If the document does not support thumbnails, + // |callback| is called with an empty string. + // Note: The thumbnail data may originate from third-party application code, + // and is untrustworthy (Security). + static void getArcDocumentsProviderThumbnail(DOMString url, + long widthHint, + long heightHint, + GetThumbnailCallback callback); + }; +}; diff --git a/idl/chrome/image_writer_private.idl b/idl/chrome/image_writer_private.idl index e491487..9dfef5c 100644 --- a/idl/chrome/image_writer_private.idl +++ b/idl/chrome/image_writer_private.idl @@ -142,4 +142,4 @@ namespace imageWriterPrivate { static void onDeviceRemoved(RemovableStorageDevice device); }; -}; +}; \ No newline at end of file diff --git a/idl/chrome/input_method_private.json b/idl/chrome/input_method_private.json index ae67a46..b567c50 100644 --- a/idl/chrome/input_method_private.json +++ b/idl/chrome/input_method_private.json @@ -63,6 +63,41 @@ "description": "The auto-capitalize type of the text field.", "enum": ["off", "characters", "words", "sentences"] }, + { + "id": "LanguagePackStatus", + "type": "string", + "description": "The aggregated status of all language packs for a given input method.", + "enum": [ + // This should only be used when we have uninitialised data. + "unknown", + "notInstalled", + "inProgress", + // If there are no language packs associated with an input method, + // such as for input methods which aren't Google 1P, installed is + // returned. + "installed", + "errorOther", + "errorNeedsReboot" + ] + }, + { + "id": "LanguagePackStatusChange", + "type": "object", + "description": "Object returned by callbacks when the status of language packs change.", + "properties": { + "engineIds": { + "type": "array", + "items": { + "type": "string" + }, + "description": "All engine IDs for which this language pack status change applies to." + }, + "status": { + "$ref": "LanguagePackStatus", + "description": "The new language pack status." + } + } + }, { "id": "InputContext", "type": "object", @@ -94,6 +129,7 @@ "physicalKeyboardAutoCorrectionLevel": { "type": "integer", "optional": true, "description": "The level of auto correction for physical keyboard (0: Off, 1: Modest, 2: Aggressive)."}, "physicalKeyboardEnableCapitalization": { "type": "boolean", "optional": true, "description": "Whether to enable auto capitalization for physical keyboard."}, "physicalKeyboardEnableDiacriticsOnLongpress": { "type": "boolean", "optional": true, "description": "Whether to enable diacritics on longpress for physical keyboard."}, + "physicalKeyboardEnablePredictiveWriting" : {"type": "boolean", "optional": true, "description": "Whether to enable physical keyboard predictive writing"}, "virtualKeyboardAutoCorrectionLevel": { "type": "integer", "optional": true, "description": "The level of auto correction for virtual keyboard (0: Off, 1: Modest, 2: Aggressive)."}, "virtualKeyboardEnableCapitalization": { "type": "boolean", "optional": true, "description": "Whether enable auto capitalization for virtual keyboard."}, "xkbLayout": { "type": "string", "optional": true, "description": "The xkb keyboard (system provided keyboard) layout."}, @@ -131,7 +167,16 @@ }, "zhuyinKeyboardLayout": { "type": "string", "optional": true, "description": "The layout of zhuyin keyboard."}, "zhuyinPageSize": { "type": "integer", "optional": true, "description": "The page size of zhuyin candidate page."}, - "zhuyinSelectKeys": { "type": "string", "optional": true, "description": "The keys used to select candidates in zhuyin."} + "zhuyinSelectKeys": { "type": "string", "optional": true, "description": "The keys used to select candidates in zhuyin."}, + "vietnameseVniAllowFlexibleDiacritics": { "type": "boolean", "optional": true, "description": "Enable VNI flexible Vietnamese typing mode"}, + "vietnameseVniNewStyleToneMarkPlacement": { "type": "boolean", "optional": true, "description": "Enable VNI modern tone mark placement"}, + "vietnameseVniInsertDoubleHornOnUo": { "type": "boolean", "optional": true, "description": "Enable VNI insert-double-horn-on-UO shortcut"}, + "vietnameseVniShowUnderline": { "type": "boolean", "optional": true, "description": "Enable VNI showing underline on composition text"}, + "vietnameseTelexAllowFlexibleDiacritics": { "type": "boolean", "optional": true, "description": "Enable Telex flexible Vietnamese typing mode"}, + "vietnameseTelexNewStyleToneMarkPlacement": { "type": "boolean", "optional": true, "description": "Enable Telex modern tone mark placement"}, + "vietnameseTelexInsertDoubleHornOnUo": { "type": "boolean", "optional": true, "description": "Enable Telex insert-double-horn-on-UO horn shortcut"}, + "vietnameseTelexInsertUHornOnW": { "type": "boolean", "optional": true, "description": "Enable Telex inser-U-Horn-on-W shortcut"}, + "vietnameseTelexShowUnderline": { "type": "boolean", "optional": true, "description": "Enable Telex showing underline on composition text"} } } ], @@ -501,55 +546,33 @@ }] }, { - "name" : "getTextFieldBounds", + "name" : "notifyInputMethodReadyForTesting", "type" : "function", - "description" : "Get the bounds of the current text field", - "parameters" :[ + "description" : "Notifies Chrome that the current input method is ready to accept key events from Tast.", + "parameters": [] + }, + { + "name": "getLanguagePackStatus", + "type": "function", + "description": "Gets the aggregate status of all language packs for a given input method.", + "parameters": [ { - "name": "parameters", - "type": "object", - "properties": { - "contextID": { - "description": "ID of the context.", - "type": "integer" - } - } + "name": "inputMethodId", + "type": "string", + "description": "Fully qualified ID of the input method" } ], "returns_async": { "name": "callback", - "description": "Called with screen coordinates of the text field when the operation completes. On failure, $(ref:runtime.lastError) is set.", + "description": "Called with a LanguagePackStatus when the operation completes.", "parameters": [ { - "name": "textFieldBounds", - "type": "object", - "properties": { - "x": { - "description": "The x-coordinate of the text field's bounds.", - "type": "integer" - }, - "y": { - "description": "The y-coordinate of the text field's bounds.", - "type": "integer" - }, - "width": { - "description": "The width of the text field's bounds.", - "type": "integer" - }, - "height":{ - "description": "The height of the bounds.", - "type": "integer" - } - } + "name": "status", + "$ref": "LanguagePackStatus", + "description": "The aggregated status of all language packs for the given input method, or 'installed' if there are no language packs." } ] } - }, - { - "name" : "notifyInputMethodReadyForTesting", - "type" : "function", - "description" : "Notifies Chrome that the current input method is ready to accept key events from Tast.", - "parameters": [] } ], "events": [ @@ -654,17 +677,6 @@ "description": "Describes the text field that has acquired focus." } ] - }, { - "name": "onTouch", - "type": "function", - "description": "This event is sent when a touch occurs in a text field. Should only happen after onFocus()", - "parameters": [ - { - "$ref": "FocusReason", - "name": "pointerType", - "description": "Pointer type used to touch the text field" - } - ] }, { "name": "onSettingsChanged", "type": "function", @@ -717,6 +729,17 @@ "description": "The engine ID for the input method being changed." } ] + }, { + "name": "onLanguagePackStatusChanged", + "type": "function", + "description": "This event is sent when any IME's language pack status is changed.", + "parameters": [ + { + "name": "change", + "$ref": "LanguagePackStatusChange", + "description": "Information about what changed." + } + ] } ] } diff --git a/idl/chrome/login_state.idl b/idl/chrome/login_state.idl index 6819d20..fe65b8b 100644 --- a/idl/chrome/login_state.idl +++ b/idl/chrome/login_state.idl @@ -8,30 +8,30 @@ implemented_in="chrome/browser/chromeos/extensions/login_screen/login_state/login_state_api.h"] namespace loginState { enum ProfileType { - // The extension is in the signin profile. + // Specifies that the extension is in the signin profile. SIGNIN_PROFILE, - // The extension is in the user profile. + // Specifies that the extension is in the user profile. USER_PROFILE }; enum SessionState { - // The session state is unknown. + // Specifies that the session state is unknown. UNKNOWN, - // The user is in the out-of-box-experience screen. + // Specifies that the user is in the out-of-box-experience screen. IN_OOBE_SCREEN, - // The user is in the login screen. + // Specifies that the user is in the login screen. IN_LOGIN_SCREEN, - // The user is in the session. + // Specifies that the user is in the session. IN_SESSION, - // The user is in the lock screen. + // Specifies that the user is in the lock screen. IN_LOCK_SCREEN, - // The device is in RMA mode, finalizing repairs. + // Specifies that the device is in RMA mode, finalizing repairs. IN_RMA_SCREEN }; diff --git a/idl/chrome/manifest_types.json b/idl/chrome/manifest_types.json index 849a053..9bdb15e 100644 --- a/idl/chrome/manifest_types.json +++ b/idl/chrome/manifest_types.json @@ -8,7 +8,9 @@ { "namespace": "manifestTypes", "description": "Schemas for structured manifest entries", - "compiler_options": { "generate_error_messages": true }, + "compiler_options": { + "generate_error_messages": true + }, "types": [ { "id": "ChromeSettingsOverrides", diff --git a/idl/chrome/notifications.idl b/idl/chrome/notifications.idl index 2d30def..fe8c649 100644 --- a/idl/chrome/notifications.idl +++ b/idl/chrome/notifications.idl @@ -6,27 +6,30 @@ // using templates and show these notifications to users in the system tray. namespace notifications { [noinline_doc] enum TemplateType { - // icon, title, message, expandedMessage, up to two buttons + // Contains an icon, title, message, expandedMessage, and up to two + // buttons. basic, - // icon, title, message, expandedMessage, image, up to two buttons + // Contains an icon, title, message, expandedMessage, image, and up + // to two buttons. [deprecated="The image is not visible for Mac OS X users."] image, - // icon, title, message, items, up to two buttons. Users on Mac OS X only - // see the first item. + // Contains an icon, title, message, items, and up to two buttons. + // Users on Mac OS X only see the first item. list, - // icon, title, message, progress, up to two buttons + // Contains an icon, title, message, progress, and up to two buttons. progress }; enum PermissionLevel { - // User has elected to show notifications from the app or extension. - // This is the default at install time. + // Specifies that the user has elected to show notifications + // from the app or extension. This is the default at install time. granted, - // User has elected not to show notifications from the app or extension. + // Specifies that the user has elected not to show notifications + // from the app or extension. denied }; diff --git a/idl/chrome/odfs_config_private.idl b/idl/chrome/odfs_config_private.idl new file mode 100644 index 0000000..e16ef6f --- /dev/null +++ b/idl/chrome/odfs_config_private.idl @@ -0,0 +1,57 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Use the chrome.odfsConfigPrivate API to configure the +// Microsoft OneDrive integration. +[implemented_in = "chrome/browser/chromeos/extensions/odfs_config_private/odfs_config_private_api.h", +modernised_enums] +namespace odfsConfigPrivate { + + enum Mount { + allowed, + disallowed, + automated + }; + + dictionary MountInfo { + Mount mode; + }; + + dictionary AccountRestrictionsInfo { + DOMString[] restrictions; + }; + + callback GetMountCallback = void(MountInfo mount); + callback GetAccountRestrictionsCallback = void( + AccountRestrictionsInfo restrictions); + callback ShowAutomatedMountErrorCallback = void(); + + interface Functions { + // Returns the OneDrive mount mode from the admin policy. + // |callback|: Invoked when the policy value was retrieved. + static void getMount( + GetMountCallback callback); + + // Returns the OneDrive account restrictions from the admin policy. + // |callback|: Invoked when the policy value was retrieved. + static void getAccountRestrictions( + GetAccountRestrictionsCallback callback); + + // Shows a notification that the automated mount failed. + static void showAutomatedMountError( + ShowAutomatedMountErrorCallback callback); + }; + + interface Events { + // Fired when the OneDrive mount mode changed. + // |event|: A OneDrive mount mode changed event. + static void onMountChanged(MountInfo event); + + // Fired when the OneDrive restrictions changed. + // |event|: A OneDrive restrictions changed event. + static void onAccountRestrictionsChanged( + AccountRestrictionsInfo event); + }; + +}; \ No newline at end of file diff --git a/idl/chrome/passwords_private.idl b/idl/chrome/passwords_private.idl index 03eb500..2fafbe1 100644 --- a/idl/chrome/passwords_private.idl +++ b/idl/chrome/passwords_private.idl @@ -118,6 +118,44 @@ namespace passwordsPrivate { VALID }; + enum FamilyFetchStatus { + // Unknown or network error. + UNKNOWN_ERROR, + // No family members found. + NO_MEMBERS, + // At least one family member found. + SUCCESS + }; + + dictionary PublicKey { + // The value of the public key. + DOMString value; + // The version of the public key. + long version; + }; + + dictionary RecipientInfo { + // User ID of the recipient. + DOMString userId; + // Email of the recipient. + DOMString email; + // Name of the recipient. + DOMString displayName; + // Profile image URL of the recipient. + DOMString profileImageUrl; + // Whether the user can receive passwords. + boolean isEligible; + // The public key of the recipient. + PublicKey? publicKey; + }; + + dictionary FamilyFetchResults { + // Status of the family members fetch. + FamilyFetchStatus status; + // List of family members. + RecipientInfo[] familyMembers; + }; + dictionary ImportEntry { // The parsing status of individual row that represents // credential during import process. @@ -190,10 +228,7 @@ namespace passwordsPrivate { // Entry used to display a password in the settings UI. dictionary PasswordUiEntry { // The URL collection corresponding to this saved password entry. - // TODO(crbug.com/1383972): remove |urls| when old Password Manager UI is - // deprecated. - UrlCollection urls; - DomainInfo[]? affiliatedDomains; + DomainInfo[] affiliatedDomains; // The username used in conjunction with the saved password. DOMString username; @@ -214,9 +249,6 @@ namespace passwordsPrivate { // Corresponds to where the credential is stored. PasswordStoreSet storedIn; - // Indicates whether this credential belongs to an Android app. - boolean isAndroidCredential; - // Indicates whether this credential is a passkey. boolean isPasskey; @@ -305,25 +337,12 @@ namespace passwordsPrivate { boolean useAccountStore; }; - // Object describing the changes for a password entry. - dictionary ChangeSavedPasswordParams { - // The new username of the password. - DOMString username; - - // The password value to be saved. - DOMString password; - - // The note attached to the password. Omitting the note will clear it. - DOMString? note; - }; - // An object holding an array of PasswordUiEntries. dictionary PasswordUiEntryList { PasswordUiEntry[] entries; }; callback PlaintextPasswordCallback = void(DOMString password); - callback ChangeSavedPasswordCallback = void(long newId); callback PasswordListCallback = void(PasswordUiEntry[] entries); callback CredentialsGroupCallback = void(CredentialGroup[] entries); callback ExceptionListCallback = void(ExceptionEntry[] exceptions); @@ -332,6 +351,7 @@ namespace passwordsPrivate { callback OptInCallback = void(boolean optedIn); callback PasswordCheckStatusCallback = void(PasswordCheckStatus status); callback ImportPasswordsCallback = void(ImportResults results); + callback FetchFamilyResultsCallback = void(FamilyFetchResults results); callback IsAccountStoreDefaultCallback = void(boolean isDefault); callback GetUrlCollectionCallback = void(UrlCollection urlCollection); callback CredentialsWithReusedPasswordCallback = @@ -342,17 +362,6 @@ namespace passwordsPrivate { // Settings WebUI. static void recordPasswordsPageAccessInSettings(); - // Changes the saved password corresponding to |id|. Invokes |callback| or - // raises an error depending on whether the operation succeeded. - // |id|: The id for the password entry being updated. - // |params|: The dictionary which holds the changed parameters. - // |callback|: The callback that gets invoked in the end. - // TODO(crbug.com/1420597): clean up after old password manager is removed. - [supportsPromises] static void changeSavedPassword( - long id, - ChangeSavedPasswordParams params, - optional ChangeSavedPasswordCallback callback); - // Changes the credential. Not all attributes can be updated. // Optional attributes that are not set will be unchanged. // Returns a promise that resolves if successful, and rejects otherwise. @@ -422,6 +431,19 @@ namespace passwordsPrivate { // |ids|: The ids for the password entries being moved. static void movePasswordsToAccount(long[] ids); + // Fetches family members (password share recipients). + [supportsPromises] static void fetchFamilyMembers( + FetchFamilyResultsCallback callback); + + // Sends sharing invitations to the recipients. + // |id|: The id of the password entry to be shared. + // |recipients|: The list of selected recipients. + // |callback|: The callback that gets invoked on success. + [supportsPromises] static void sharePassword( + long id, + RecipientInfo[] recipients, + optional VoidCallback callback); + // Triggers the Password Manager password import functionality. [supportsPromises] static void importPasswords( PasswordStoreSet toStore, @@ -456,10 +478,6 @@ namespace passwordsPrivate { [supportsPromises] static void requestExportProgressStatus( ExportProgressStatusCallback callback); - // Stops exporting passwords and cleans up any passwords, which were already - // written to the filesystem. - static void cancelExportPasswords(); - // Requests the account-storage opt-in state of the current user. [supportsPromises] static void isOptedInForAccountStorage( OptInCallback callback); @@ -486,22 +504,10 @@ namespace passwordsPrivate { [supportsPromises] static void unmuteInsecureCredential( PasswordUiEntry credential, optional VoidCallback callback); - // Records that a change password flow was started for |credential|. - // |credential|: The credential for which the flow was triggered. - // |isAutomatedFlow|: Whether the flow is a manual one. - // Invokes |callback| on completion. - [supportsPromises] static void recordChangePasswordFlowStarted( - PasswordUiEntry credential, - optional VoidCallback callback); - // Starts a check for insecure passwords. Invokes |callback| on completion. [supportsPromises] static void startPasswordCheck( optional VoidCallback callback); - // Stops checking for insecure passwords. Invokes |callback| on completion. - [supportsPromises] static void stopPasswordCheck( - optional VoidCallback callback); - // Returns the current status of the check via |callback|. [supportsPromises] static void getPasswordCheckStatus( PasswordCheckStatusCallback callback); diff --git a/idl/chrome/pdf_viewer_private.idl b/idl/chrome/pdf_viewer_private.idl index 96136ca..cecd250 100644 --- a/idl/chrome/pdf_viewer_private.idl +++ b/idl/chrome/pdf_viewer_private.idl @@ -6,11 +6,47 @@ // functionality that the PDF Viewer needs from outside the PDF plugin. This API // is exclusively for the PDF Viewer. namespace pdfViewerPrivate { + // Nearly identical to mimeHandlerPrivate.StreamInfo, but without a mime type + // nor a response header field. Those fields are unused by the PDF viewer. + dictionary StreamInfo { + // The original URL that was intercepted. + DOMString originalUrl; + + // The URL that the stream can be read from. + DOMString streamUrl; + + // The ID of the tab that opened the stream. If the stream is not opened in + // a tab, it will be -1. + long tabId; + + // Whether the stream is embedded within another document. + boolean embedded; + }; + + // Identical to mimeHandlerPrivate.StreamInfo. + dictionary PdfPluginAttributes { + // The background color in ARGB format for painting. Since the background + // color is an unsigned 32-bit integer which can be outside the range of + // "long" type, define it as a "double" type here. + double backgroundColor; + + // Indicates whether the plugin allows to execute JavaScript and maybe XFA. + // Loading XFA for PDF forms will automatically be disabled if this flag is + // false. + boolean allowJavascript; + }; + + callback GetStreamInfoCallback = void(StreamInfo streamInfo); callback IsAllowedLocalFileAccessCallback = void(boolean result); callback IsPdfOcrAlwaysActiveCallback = void(boolean result); callback OnPdfOcrPrefSetCallback = void(boolean result); + callback VoidCallback = void(); interface Functions { + // Returns the StreamInfo for the stream for this context if there is one. + [supportsPromises] static void getStreamInfo( + GetStreamInfoCallback callback); + // Determines if the given URL should be allowed to access local files from // the PDF Viewer. |callback|: Called with true if URL should be allowed to // access local files from the PDF Viewer, false otherwise. @@ -29,11 +65,21 @@ namespace pdfViewerPrivate { // |callback|: The callback for whether the pref was set or not. [supportsPromises] static void setPdfOcrPref( boolean value, OnPdfOcrPrefSetCallback callback); + + // Sets PDF plugin attributes in the stream for this context if there is + // one. + [supportsPromises] static void setPdfPluginAttributes( + PdfPluginAttributes attributes, + optional VoidCallback callback); }; interface Events { // Fired when a pref value for PDF OCR has changed. // |value| The pref value that changed. static void onPdfOcrPrefChanged(boolean value); + + // Fired when the browser wants the listener to perform a save. + // `streamUrl`: Unique ID for the instance that should perform the save. + static void onSave(DOMString streamUrl); }; }; \ No newline at end of file diff --git a/idl/chrome/permissions.json b/idl/chrome/permissions.json index c18a4a6..9213992 100644 --- a/idl/chrome/permissions.json +++ b/idl/chrome/permissions.json @@ -5,7 +5,7 @@ [ { "namespace": "permissions", - "description": "Use the chrome.permissions API to request declared optional permissions at run time rather than install time, so users understand why the permissions are needed and grant only those that are necessary.", + "description": "Use the chrome.permissions API to request declared optional permissions at run time rather than install time, so users understand why the permissions are needed and grant only those that are necessary.", "types": [ { "id": "Permissions", diff --git a/idl/chrome/platform_keys.idl b/idl/chrome/platform_keys.idl index c34cfd6..966cd27 100644 --- a/idl/chrome/platform_keys.idl +++ b/idl/chrome/platform_keys.idl @@ -132,9 +132,11 @@ namespace platformKeys { // apply PKCS#1 v1.5 padding but not hash the given data. //

Currently, this method only supports the "RSASSA-PKCS1-v1_5" and // "ECDSA" algorithms.

- [nocompile] static void getKeyPair(ArrayBuffer certificate, - object parameters, - GetKeyPairCallback callback); + [nocompile, doesNotSupportPromises= + "Multi-parameter callback crbug.com/1313625"] + static void getKeyPair(ArrayBuffer certificate, + object parameters, + GetKeyPairCallback callback); // Passes the key pair identified by publicKeySpkiDer for // usage with $(ref:platformKeys.subtleCrypto) to callback. @@ -155,9 +157,11 @@ namespace platformKeys { // named-curve P-256 and "RSASSA-PKCS1-v1_5" algorithm with one of the // hashing algorithms "none", "SHA-1", "SHA-256", "SHA-384", and // "SHA-512".

- [nocompile] static void getKeyPairBySpki(ArrayBuffer publicKeySpkiDer, - object parameters, - GetKeyPairCallback callback); + [nocompile, doesNotSupportPromises= + "Multi-parameter callback crbug.com/1313625"] + static void getKeyPairBySpki(ArrayBuffer publicKeySpkiDer, + object parameters, + GetKeyPairCallback callback); // An implementation of WebCrypto's // diff --git a/idl/chrome/platform_keys_internal.idl b/idl/chrome/platform_keys_internal.idl index 008672d..5780720 100644 --- a/idl/chrome/platform_keys_internal.idl +++ b/idl/chrome/platform_keys_internal.idl @@ -56,6 +56,7 @@ namespace platformKeysInternal { // KeyAlgorithm dictionary describing the key's algorithm. The // name property will equal algorithmName. // Otherwise, calls back with an error. + [doesNotSupportPromises="Multi-parameter callback crbug.com/1313625"] static void getPublicKey(ArrayBuffer certificate, DOMString algorithmName, GetPublicKeyCallback callback); @@ -67,6 +68,7 @@ namespace platformKeysInternal { // KeyAlgorithm dictionary describing the key's algorithm. The // name property will equal algorithmName. // Otherwise, calls back with an error. + [doesNotSupportPromises="Multi-parameter callback crbug.com/1313625"] static void getPublicKeyBySpki(ArrayBuffer publicKeySpkiDer, DOMString algorithmName, GetPublicKeyCallback callback); diff --git a/idl/chrome/printing.idl b/idl/chrome/printing.idl index 4aeca11..18afd73 100644 --- a/idl/chrome/printing.idl +++ b/idl/chrome/printing.idl @@ -9,9 +9,11 @@ implemented_in="chrome/browser/extensions/api/printing/printing_api.h"] namespace printing { dictionary SubmitJobRequest { // The print job to be submitted. - // The only supported content type is "application/pdf", and the CJT ticket - // shouldn't include FitToPageTicketItem, PageRangeTicketItem, - // ReverseOrderTicketItem and VendorTicketItem fields since they are + // The only supported content type is "application/pdf", and the + // Cloud Job Ticket + // shouldn't include FitToPageTicketItem, + // PageRangeTicketItem, ReverseOrderTicketItem + // and VendorTicketItem fields since they are // irrelevant for native printing. All other fields must be present. printerProvider.PrintJob job; @@ -153,9 +155,11 @@ namespace printing { callback GetPrinterInfoCallback = void(GetPrinterInfoResponse response); interface Functions { - // Submits the job for print. - // If the extension is not listed in PrintingAPIExtensionsAllowlist policy, - // the user will be prompted to accept the print job. + // Submits the job for printing. If the extension is not listed in + // the + // PrintingAPIExtensionsAllowlist policy, + // the user is prompted to accept the print job.
+ // Before Chrome 120, this function did not return a promise. [supportsPromises] static void submitJob(SubmitJobRequest request, SubmitJobCallback callback); diff --git a/idl/chrome/printing_metrics.idl b/idl/chrome/printing_metrics.idl index 4742199..9e36115 100644 --- a/idl/chrome/printing_metrics.idl +++ b/idl/chrome/printing_metrics.idl @@ -9,53 +9,57 @@ namespace printingMetrics { // The source of the print job. enum PrintJobSource { - // The job was created from the Print Preview page initiated by the user. + // Specifies that the job was created from the Print Preview page + // initiated by the user. PRINT_PREVIEW, - // The job was created from an Android App. + // Specifies that the job was created from an Android App. ANDROID_APP, - // The job was created by extension via Chrome API. - EXTENSION + // Specifies that the job was created by extension via Chrome API. + EXTENSION, + + // Specifies that the job was created by an Isolated Web App via API. + ISOLATED_WEB_APP }; - // The final status of the print job. + // Specifies the final status of the print job. enum PrintJobStatus { - // Print job was interrupted due to some error. + // Specifies that the print job was interrupted due to some error. FAILED, - // Print job was canceled by the user or via API. + // Specifies that the print job was canceled by the user or via API. CANCELED, - // Print job was printed without any errors. + // Specifies that the print job was printed without any errors. PRINTED }; // The source of the printer. enum PrinterSource { - // Printer was added by user. + // Specifies that the printer was added by user. USER, - // Printer was added via policy. + // Specifies that the printer was added via policy. POLICY }; enum ColorMode { - // Black and white mode was used. + // Specifies that black and white mode was used. BLACK_AND_WHITE, - // Color mode was used. + // Specifies that color mode was used. COLOR }; enum DuplexMode { - // One-sided printing was used. + // Specifies that one-sided printing was used. ONE_SIDED, - // Two-sided printing was used, flipping on long edge. + // Specifies that two-sided printing was used, flipping on long edge. TWO_SIDED_LONG_EDGE, - // Two-sided printing was used, flipping on short edge. + // Specifies that two-sided printing was used, flipping on short edge. TWO_SIDED_SHORT_EDGE }; diff --git a/idl/chrome/privacy.json b/idl/chrome/privacy.json index 494e3f4..9a3b60f 100644 --- a/idl/chrome/privacy.json +++ b/idl/chrome/privacy.json @@ -100,12 +100,6 @@ "value": ["thirdPartyCookiesAllowed", {"type": "boolean"}], "description": "If disabled, Chrome blocks third-party sites from setting cookies. The value of this preference is of type boolean, and the default value is true." }, - "privacySandboxEnabled": { - "$ref": "types.ChromeSetting", - "value": ["privacySandboxEnabled", {"type": "boolean"}], - "deprecated": "We’re deprecating the API chrome.privacy.websites.privacySandboxEnabled, though it will remain active for backward compatibility until release M113. Instead, please use chrome.privacy.websites.topicsEnabled, chrome.privacy.websites.fledgeEnabled and chrome.privacy.websites.adMeasurementEnabled. During the migration period: 1. Enabling privacySandboxEnabled will CLEAR the new APIs listed above because extensions aren’t allowed to enable them; 2. Disabling privacySandboxEnabled will also disable the new APIs; 3. Clearing privacySandboxEnabled will also clear the new APIs.", - "description": "If enabled, the experimental Privacy Sandbox features are active. The value of this preference is of type boolean, and the default value is true." - }, "topicsEnabled": { "$ref": "types.ChromeSetting", "value": ["topicsEnabled", {"type": "boolean"}], @@ -141,6 +135,11 @@ "value": ["protectedContentEnabled", {"type":"boolean"}], "description": "Available on Windows and ChromeOS only: If enabled, Chrome provides a unique ID to plugins in order to run protected content. The value of this preference is of type boolean, and the default value is true.", "platforms": ["win", "chromeos", "lacros"] + }, + "relatedWebsiteSetsEnabled": { + "$ref": "types.ChromeSetting", + "value": ["relatedWebsiteSetsEnabled", {"type": "boolean"}], + "description": "If disabled, Related Website Sets is deactivated. The value of this preference is of type boolean, and the default value is true. Extensions may only disable this API by setting the value to false. If you try setting this API to true, it will throw an error." } } } diff --git a/idl/chrome/proxy.json b/idl/chrome/proxy.json index b47ef7c..c677647 100644 --- a/idl/chrome/proxy.json +++ b/idl/chrome/proxy.json @@ -5,7 +5,7 @@ [ { "namespace": "proxy", - "description": "Use the chrome.proxy API to manage Chrome's proxy settings. This API relies on the ChromeSetting prototype of the type API for getting and setting the proxy configuration.", + "description": "Use the chrome.proxy API to manage Chrome's proxy settings. This API relies on the ChromeSetting prototype of the type API for getting and setting the proxy configuration.", "types": [ { "id": "Scheme", diff --git a/idl/chrome/reading_list.idl b/idl/chrome/reading_list.idl new file mode 100644 index 0000000..819c899 --- /dev/null +++ b/idl/chrome/reading_list.idl @@ -0,0 +1,116 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Use the chrome.readingList API to read from and modify +// the items in the +// Reading List. +namespace readingList{ + dictionary ReadingListEntry { + // The url of the entry. + DOMString url; + + // The title of the entry. + DOMString title; + + // Will be true if the entry has been read. + boolean hasBeenRead; + + // The last time the entry was updated. + // This value is in milliseconds since Jan 1, 1970. + double lastUpdateTime; + + // The time the entry was created. + // Recorded in milliseconds since Jan 1, 1970. + double creationTime; + }; + + dictionary AddEntryOptions { + // The url of the entry. + DOMString url; + + // The title of the entry. + DOMString title; + + // Will be true if the entry has been read. + boolean hasBeenRead; + }; + + dictionary RemoveOptions { + // The url to remove. + DOMString url; + }; + + dictionary UpdateEntryOptions { + // The url that will be updated. + DOMString url; + + // The new title. The existing tile remains if a value isn't provided. + DOMString? title; + + // The updated read status. The existing status remains if a value + // isn't provided. + boolean? hasBeenRead; + }; + + dictionary QueryInfo { + // A url to search for. + DOMString? url; + + // A title to search for. + DOMString? title; + + // Indicates whether to search for read (true) or unread + // (false) items. + boolean? hasBeenRead; + }; + + callback AddEntryCallback = void (); + callback RemoveEntryCallback = void(); + callback UpdateEntryCallback = void(); + callback QueryCallback = void(ReadingListEntry[] entries); + + interface Functions { + // Adds an entry to the reading list if it does not exist. + // |entry|: The entry to add to the reading list. + // |callback|: Invoked once the entry has been added. + [supportsPromises] static void addEntry( + AddEntryOptions entry, + optional AddEntryCallback callback); + + // Removes an entry from the reading list if it exists. + // |info|: The entry to remove from the reading list. + // |callback|: Invoked once the entry has been removed. + [supportsPromises] static void removeEntry( + RemoveOptions info, + optional RemoveEntryCallback callback); + + // Updates a reading list entry if it exists. + // |info|: The entry to update. + // |callback|: Invoked once the matched entries have been updated. + [supportsPromises] static void updateEntry( + UpdateEntryOptions info, + optional UpdateEntryCallback callback); + + // Retrieves all entries that match the QueryInfo properties. + // Properties that are not provided will not be matched. + // |info|: The properties to search for. + // |callback|: Invoked once the entries have been matched. + [supportsPromises] static void query(QueryInfo info, + QueryCallback callback); + }; + + interface Events { + // Triggered when a ReadingListEntry is added to the reading list. + // |entry|: The entry that was added. + static void onEntryAdded(ReadingListEntry entry); + + // Triggered when a ReadingListEntry is removed from the reading list. + // |entry|: The entry that was removed. + static void onEntryRemoved(ReadingListEntry entry); + + // Triggered when a ReadingListEntry is updated in the reading list. + // |entry|: The entry that was updated. + static void onEntryUpdated(ReadingListEntry entry); + }; +}; \ No newline at end of file diff --git a/idl/chrome/safe_browsing_private.idl b/idl/chrome/safe_browsing_private.idl index 414c83a..691cd0b 100644 --- a/idl/chrome/safe_browsing_private.idl +++ b/idl/chrome/safe_browsing_private.idl @@ -41,7 +41,10 @@ namespace safeBrowsingPrivate { // Navigation is initiated by the browser process and it is believed the // navigation is the result of the user copy and paste the address from the // browser into the address bar. - COPY_PASTE_USER_INITIATED + COPY_PASTE_USER_INITIATED, + + // Navigation is initiated by a click on a Push Notification. + NOTIFICATION_INITIATED }; dictionary PolicySpecifiedPasswordReuse { diff --git a/idl/chrome/scripting.idl b/idl/chrome/scripting.idl index e2d4b9f..ba3a2e0 100644 --- a/idl/chrome/scripting.idl +++ b/idl/chrome/scripting.idl @@ -17,9 +17,11 @@ namespace scripting { // The JavaScript world for a script to execute within. enum ExecutionWorld { - // The isolated world, unique to this extension. + // Specifies the isolated world, which is the execution environment unique + // to this extension. ISOLATED, - // The main world of the DOM, shared with the page's JavaScript. + // Specifies the main world of the DOM, which is the execution environment + // shared with the host page's JavaScript. MAIN }; @@ -46,11 +48,11 @@ namespace scripting { // A JavaScript function to inject. This function will be serialized, and // then deserialized for injection. This means that any bound parameters // and execution context will be lost. - // Exactly one of files and func must be + // Exactly one of files or func must be // specified. [serializableFunction]InjectedFunction? func; - // The arguments to curry into a provided function. This is only valid if + // The arguments to pass to the provided function. This is only valid if // the func parameter is specified. These arguments must be // JSON-serializable. any[]? args; @@ -64,7 +66,7 @@ namespace scripting { // The path of the JS or CSS files to inject, relative to the extension's // root directory. - // Exactly one of files and func must be + // Exactly one of files or func must be // specified. DOMString[]? files; @@ -119,13 +121,13 @@ namespace scripting { // with a '_' as it's reserved as a prefix for generated script IDs. DOMString id; // Specifies which pages this content script will be injected into. See - // Match Patterns for more details on the - // syntax of these strings. Must be specified for + // Match Patterns for more + // details on the syntax of these strings. Must be specified for // $(ref:registerContentScripts). DOMString[]? matches; // Excludes pages that this content script would otherwise be injected into. - // See Match Patterns for more details on the - // syntax of these strings. + // See Match Patterns for + // more details on the syntax of these strings. DOMString[]? excludeMatches; // The list of CSS files to be injected into matching pages. These are // injected in the order they appear in this array, before any DOM is @@ -140,9 +142,13 @@ namespace scripting { // requirements are not met. Defaults to false, meaning that only the top // frame is matched. boolean? allFrames; - // TODO(devlin): Add documentation once the implementation is complete. See - // crbug.com/55084. - [nodoc] + // Indicates whether the script can be injected into frames where the URL + // contains an unsupported scheme; specifically: about:, data:, blob:, or + // filesystem:. In these cases, the URL's origin is checked to determine if + // the script should be injected. If the origin is `null` (as is the case + // for data: URLs) then the used origin is either the frame that created + // the current frame or the frame that initiated the navigation to this + // frame. Note that this may not be the parent frame. boolean? matchOriginAsFallback; // Specifies when JavaScript files are injected into the web page. The // preferred and default value is document_idle. diff --git a/idl/chrome/search.idl b/idl/chrome/search.idl index 607e5a2..51a84b2 100644 --- a/idl/chrome/search.idl +++ b/idl/chrome/search.idl @@ -5,13 +5,14 @@ // Use the chrome.search API to search via the default provider. namespace search { enum Disposition { - // Display results in the calling tab or the tab from the active browser. + // Specifies that the search results display in the calling tab or the tab + // from the active browser. CURRENT_TAB, - // Display search results in a new tab. + // Specifies that the search results display in a new tab. NEW_TAB, - // Display search results in a new window. + // Specifies that the search results display in a new window. NEW_WINDOW }; diff --git a/idl/chrome/side_panel.idl b/idl/chrome/side_panel.idl index 57e6f15..6e7fff5 100644 --- a/idl/chrome/side_panel.idl +++ b/idl/chrome/side_panel.idl @@ -47,13 +47,13 @@ namespace sidePanel { }; // Options for opening the side panel. - // At least one of `tabId` and `windowId` must be specified. + // At least one of `tabId` or `windowId` must be specified. dictionary OpenOptions { // The window in which to open the side panel. This is only applicable if // the extension has a global (non-tab-specific) side panel or // tabId is also specified. This will override any // currently-active global side panel the user has open in the given - // window. At least one of this and tabId must be provided. + // window. At least one of this or tabId must be provided. long? windowId; // The tab in which to open the side panel. If the corresponding tab has @@ -62,7 +62,7 @@ namespace sidePanel { // the specified tab and any other tabs without a currently-open tab- // specific panel. This will override any currently-active side panel // (global or tab-specific) in the corresponding tab. At least one of this - // and windowId must be provided. + // or windowId must be provided. long? tabId; }; diff --git a/idl/chrome/smart_card_provider_private.idl b/idl/chrome/smart_card_provider_private.idl index c82e969..a0ad331 100644 --- a/idl/chrome/smart_card_provider_private.idl +++ b/idl/chrome/smart_card_provider_private.idl @@ -120,11 +120,18 @@ namespace smartCardProviderPrivate { dictionary ReaderStateIn { DOMString reader; ReaderStateFlags currentState; + // Number of card insertion and removal events that happened in this reader, + // as known by the application. + long currentCount; }; dictionary ReaderStateOut { DOMString reader; ReaderStateFlags eventState; + // The actual number of card insertion and removal events that happened in + // this reader. + // Set to zero if not supported. + long eventCount; ArrayBuffer atr; }; @@ -209,6 +216,18 @@ namespace smartCardProviderPrivate { // reportStatusResult. [maxListeners=1] static void onStatusRequested(long requestId, long scardHandle); + + // Browser requested a SCardBeginTransaction call. + // Extension must report the result to the browser by calling + // reportPlainResult. + [maxListeners=1] static void onBeginTransactionRequested(long requestId, + long scardHandle); + + // Browser requested a SCardEndTransaction call. + // Extension must report the result to the browser by calling + // reportPlainResult. + [maxListeners=1] static void onEndTransactionRequested(long requestId, + long scardHandle, Disposition disposition); }; interface Functions { diff --git a/idl/chrome/tab_capture.idl b/idl/chrome/tab_capture.idl index c082097..97e92b2 100644 --- a/idl/chrome/tab_capture.idl +++ b/idl/chrome/tab_capture.idl @@ -91,6 +91,7 @@ namespace tabCapture { // null. null indicates an error has occurred // and the client may query $(ref:runtime.lastError) to access the error // details. + [doesNotSupportPromises="Custom hook sets lastError crbug.com/1504349"] static void capture(CaptureOptions options, GetTabMediaCallback callback); diff --git a/idl/chrome/tabs.json b/idl/chrome/tabs.json index 031f7d3..7919cba 100644 --- a/idl/chrome/tabs.json +++ b/idl/chrome/tabs.json @@ -55,6 +55,7 @@ "windowId": {"type": "integer", "minimum": 0, "description": "The ID of the window that contains the tab."}, "openerTabId": {"type": "integer", "minimum": 0, "optional": true, "description": "The ID of the tab that opened this tab, if any. This property is only present if the opener tab still exists."}, "selected": {"type": "boolean", "description": "Whether the tab is selected.", "deprecated": "Please use $(ref:tabs.Tab.highlighted)."}, + "lastAccessed": {"type": "number", "optional": true, "description": "The last time the tab was accessed as the number of milliseconds since epoch."}, "highlighted": {"type": "boolean", "description": "Whether the tab is highlighted."}, "active": {"type": "boolean", "description": "Whether the tab is active in its window. Does not necessarily mean the window is focused."}, "pinned": {"type": "boolean", "description": "Whether the tab is pinned."}, @@ -172,7 +173,7 @@ { "name": "getCurrent", "type": "function", - "description": "Gets the tab that this script call is being made from. May be undefined if called from a non-tab context (for example, a background page or popup view).", + "description": "Gets the tab that this script call is being made from. Returns undefined if called from a non-tab context (for example, a background page or popup view).", "parameters": [], "returns_async": { "name": "callback", @@ -826,7 +827,7 @@ { "name": "captureVisibleTab", "type": "function", - "description": "Captures the visible area of the currently active tab in the specified window. In order to call this method, the extension must have either the permission or the activeTab permission. In addition to sites that extensions can normally access, this method allows extensions to capture sensitive sites that are otherwise restricted, including chrome:-scheme pages, other extensions' pages, and data: URLs. These sensitive sites can only be captured with the activeTab permission. File URLs may be captured only if the extension has been granted file access.", + "description": "Captures the visible area of the currently active tab in the specified window. In order to call this method, the extension must have either the permission or the activeTab permission. In addition to sites that extensions can normally access, this method allows extensions to capture sensitive sites that are otherwise restricted, including chrome:-scheme pages, other extensions' pages, and data: URLs. These sensitive sites can only be captured with the activeTab permission. File URLs may be captured only if the extension has been granted file access.", "parameters": [ { "type": "integer", @@ -856,7 +857,7 @@ "name": "executeScript", "deprecated": "Replaced by $(ref:scripting.executeScript) in Manifest V3.", "type": "function", - "description": "Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.", + "description": "Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.", "parameters": [ {"type": "integer", "name": "tabId", "minimum": 0, "optional": true, "description": "The ID of the tab in which to run the script; defaults to the active tab of the current window."}, { @@ -884,7 +885,7 @@ "name": "insertCSS", "deprecated": "Replaced by $(ref:scripting.insertCSS) in Manifest V3.", "type": "function", - "description": "Injects CSS into a page. Styles inserted with this method can be removed with $(ref:scripting.removeCSS). For details, see the programmatic injection section of the content scripts doc.", + "description": "Injects CSS into a page. Styles inserted with this method can be removed with $(ref:scripting.removeCSS). For details, see the programmatic injection section of the content scripts doc.", "parameters": [ {"type": "integer", "name": "tabId", "minimum": 0, "optional": true, "description": "The ID of the tab in which to insert the CSS; defaults to the active tab of the current window."}, { diff --git a/idl/chrome/vpn_provider.idl b/idl/chrome/vpn_provider.idl index 3e3ecd8..f2ed2f3 100644 --- a/idl/chrome/vpn_provider.idl +++ b/idl/chrome/vpn_provider.idl @@ -60,25 +60,25 @@ namespace vpnProvider { // The enum is used by the platform to notify the client of the VPN session // status. enum PlatformMessage { - // VPN configuration connected. + // Indicates that the VPN configuration connected. connected, - // VPN configuration disconnected. + // Indicates that the VPN configuration disconnected. disconnected, - // An error occurred in VPN connection, for example a timeout. A description + // Indicates that an error occurred in VPN connection, for example a timeout. A description // of the error is given as the // error argument to onPlatformMessage. error, - // The default physical network connection is down. + // Indicates that the default physical network connection is down. linkDown, - // The default physical network connection is back up. + // Indicates that the default physical network connection is back up. linkUp, - // The default physical network connection changed, e.g. wifi->mobile. + // Indicates that the default physical network connection changed, e.g. wifi->mobile. linkChanged, - // The OS is preparing to suspend, so the VPN should drop its connection. + // Indicates that the OS is preparing to suspend, so the VPN should drop its connection. // The extension is not guaranteed to receive this event prior to // suspending. suspend, - // The OS has resumed and the user has logged back in, so the VPN should + // Indicates that the OS has resumed and the user has logged back in, so the VPN should // try to reconnect. resume }; @@ -87,18 +87,20 @@ namespace vpnProvider { // of its current state. This helps provide meaningful messages // to the user. enum VpnConnectionState { - // VPN connection was successful. + // Specifies that VPN connection was successful. connected, - // VPN connection failed. + // Specifies that VPN connection has failed. failure }; // The enum is used by the platform to indicate the event that triggered // onUIEvent. enum UIEvent { - // Request the VPN client to show add configuration dialog to the user. + // Requests that the VPN client show the add configuration dialog box to + // the user. showAddDialog, - // Request the VPN client to show configuration settings dialog to the user. + // Requests that the VPN client show the configuration settings dialog box + // to the user. showConfigureDialog }; diff --git a/idl/chrome/webrtc_desktop_capture_private.idl b/idl/chrome/webrtc_desktop_capture_private.idl index 60e9e00..5410f61 100644 --- a/idl/chrome/webrtc_desktop_capture_private.idl +++ b/idl/chrome/webrtc_desktop_capture_private.idl @@ -23,6 +23,7 @@ namespace webrtcDesktopCapturePrivate { interface Functions { // Shows desktop media picker UI with the specified set of sources. + [doesNotSupportPromises="Synchronous return and callback crbug.com/1143032"] static long chooseDesktopMedia(DesktopCaptureSourceType[] sources, RequestInfo request, chooseDesktopMediaCallback callback); diff --git a/idl/chrome/webrtc_logging_private.idl b/idl/chrome/webrtc_logging_private.idl index bfa5c90..d286b89 100644 --- a/idl/chrome/webrtc_logging_private.idl +++ b/idl/chrome/webrtc_logging_private.idl @@ -180,6 +180,7 @@ namespace webrtcLoggingPrivate { // Returns the directory entry for the "WebRTC Logs" directory. If the // directory doesn't exist yet, this will create it. If the directory // cannot be created, this call will fail with a runtime error. + [doesNotSupportPromises="Custom hook sets lastError crbug.com/1504349"] static void getLogsDirectory(GetLogsDirectoryCallback callback); }; }; \ No newline at end of file diff --git a/idl/chrome/webstore_private.json b/idl/chrome/webstore_private.json index 68cfaa9..e246b2d 100644 --- a/idl/chrome/webstore_private.json +++ b/idl/chrome/webstore_private.json @@ -121,14 +121,13 @@ "name": "expected_id", "type": "string", "description": "The id of the extension to install." - }, - { - "name": "callback", - "type": "function", - "optional": true, - "parameters": [] } - ] + ], + "returns_async": { + "name": "callback", + "optional": true, + "parameters": [] + } }, { "name": "beginInstallWithManifest3", @@ -186,22 +185,20 @@ } }, "additionalProperties": { "type": "any" } - }, - { - "name": "callback", - "type": "function", - "description": "Called when the user has either accepted/rejected the dialog, or some error occurred (such as invalid manifest or icon image data).", - "optional": true, - "parameters": [ - { - "name": "result", - "$ref": "Result", - "description": "A string result code, which will be empty upon success. The possible values in the case of errors include 'unknown_error', 'user_cancelled', 'manifest_error', 'icon_error', 'invalid_id', 'permission_denied', 'invalid_icon_url' and 'already_installed'." - } - ] } - ] - + ], + "returns_async": { + "name": "callback", + "description": "Called when the user has either accepted/rejected the dialog, or some error occurred (such as invalid manifest or icon image data).", + "optional": true, + "parameters": [ + { + "name": "result", + "$ref": "Result", + "description": "A string result code, which will be empty upon success. The possible values in the case of errors include 'unknown_error', 'user_cancelled', 'manifest_error', 'icon_error', 'invalid_id', 'permission_denied', 'invalid_icon_url' and 'already_installed'." + } + ] + } }, { "name": "completeInstall", @@ -211,149 +208,99 @@ "name": "expected_id", "type": "string", "description": "The id of the extension to be installed. This should match a previous call to beginInstallWithManifest3." - }, - { - "name": "callback", - "type": "function", - "optional": true, - "parameters": [] } - ] + ], + "returns_async": { + "name": "callback", + "optional": true, + "parameters": [] + } }, { "name": "enableAppLauncher", "description": "", - "parameters": [ - { - "name": "callback", - "type": "function", - "optional": true, - "parameters": [] - } - ] + "parameters": [], + "returns_async": { + "name": "callback", + "optional": true, + "parameters": [] + } }, { "name": "getBrowserLogin", "description": "Returns the logged-in sync user login if there is one, or the empty string otherwise.", - "parameters": [ - { - "name": "callback", - "type": "function", - "parameters": [ - { - "name": "info", - "type": "object", - "properties": { - "login": { "type": "string" } - } + "parameters": [], + "returns_async": { + "name": "callback", + "parameters": [ + { + "name": "info", + "type": "object", + "properties": { + "login": { "type": "string" } } - ] - } - ] + } + ] + } }, { "name": "getStoreLogin", "description": "Returns the previous value set by setStoreLogin, or the empty string if there is none.", - "parameters": [ - { - "name": "callback", - "type": "function", - "parameters": [ - { "name": "login", "type": "string" } - ] - } - ] + "parameters": [], + "returns_async": { + "name": "callback", + "parameters": [ + { "name": "login", "type": "string" } + ] + } }, { "name": "setStoreLogin", "description": "Sets a preference value with the store login.", "parameters": [ - { "name": "login", "type": "string" }, - { - "name": "callback", - "type": "function", - "optional": true, - "parameters": [] - } - ] + { "name": "login", "type": "string" } + ], + "returns_async": { + "name": "callback", + "optional": true, + "parameters": [] + } }, { "name": "getWebGLStatus", "description": "Invokes a callback that returns whether WebGL is blacklisted or not.", - "parameters": [ - { - "name": "callback", - "type": "function", - "parameters": [ - { - "name": "webgl_status", - "$ref": "WebGlStatus" - } - ] - } - ] + "parameters": [], + "returns_async": { + "name": "callback", + "parameters": [ + { + "name": "webgl_status", + "$ref": "WebGlStatus" + } + ] + } }, { "name": "getIsLauncherEnabled", "description": "Returns whether the apps launcher is enabled or not.", - "parameters": [ - { - "name": "callback", - "type": "function", - "parameters": [ - { "name": "is_enabled", "type": "boolean" } - ] - } - ] + "parameters": [], + "returns_async": { + "name": "callback", + "parameters": [ + { "name": "is_enabled", "type": "boolean" } + ] + } }, { "name": "isInIncognitoMode", "description": "Returns whether the browser is in incognito mode or not.", - "parameters": [ - { - "name": "callback", - "type": "function", - "parameters": [ - { "name": "is_incognito", "type": "boolean" } - ] - } - ] - }, - { - "name": "getEphemeralAppsEnabled", - "description": "Returns whether the ephemeral apps feature is enabled.", - "parameters": [ - { - "name": "callback", - "type": "function", - "parameters": [ - { "name": "is_enabled", "type": "boolean" } - ] - } - ] - }, - { - "name": "launchEphemeralApp", - "description": "Installs an app ephemerally in Chrome (if not already fully installed) and launches the app. A user gesture is required.", - "parameters": [ - { - "name": "id", - "type": "string", - "description": "The extension id of the app to launch." - }, - { - "name": "callback", - "type": "function", - "optional": true, - "parameters": [ - { - "name": "result", - "$ref": "Result", - "description": "Whether an attempt to launch an app succeeded, or the reason for failure." - } - ] - } - ] + "parameters": [], + "returns_async": { + "name": "callback", + "parameters": [ + { "name": "is_incognito", "type": "boolean" } + ] + } }, { "name": "isPendingCustodianApproval", @@ -363,28 +310,25 @@ "name": "id", "type": "string", "description": "The extension id of the extension to be checked." - }, - { - "name": "callback", - "type": "function", - "parameters": [ - { "name": "is_pending_approval", "type": "boolean" } - ] } - ] + ], + "returns_async": { + "name": "callback", + "parameters": [ + { "name": "is_pending_approval", "type": "boolean" } + ] + } }, { "name": "getReferrerChain", "description": "Returns a base-64 encoded referrer chain leading to the webstore page. Should only be used for extension anti-abuse purposes.", - "parameters": [ - { - "name": "callback", - "type": "function", - "parameters": [ - { "name": "referrerChain", "type": "string" } - ] - } - ] + "parameters": [], + "returns_async": { + "name": "callback", + "parameters": [ + { "name": "referrerChain", "type": "string" } + ] + } }, { "name": "getExtensionStatus", @@ -399,15 +343,14 @@ "type": "string", "optional": true, "description": "The manifest of the extension" - }, - { - "name": "callback", - "type": "function", - "parameters": [ - { "name": "status", "$ref": "ExtensionInstallStatus" } - ] } - ] + ], + "returns_async": { + "name": "callback", + "parameters": [ + { "name": "status", "$ref": "ExtensionInstallStatus" } + ] + } } ] } diff --git a/idl/chrome/windows.json b/idl/chrome/windows.json index 375d667..8a5c031 100644 --- a/idl/chrome/windows.json +++ b/idl/chrome/windows.json @@ -88,7 +88,20 @@ "id": "CreateType", "type": "string", "description": "Specifies what type of browser window to create. 'panel' is deprecated and is available only to existing allowlisted extensions on Chrome OS.", - "enum": ["normal", "popup", "panel"] + "enum": [ + { + "name": "normal", + "description": "Specifies the window as a standard window." + }, + { + "name": "popup", + "description": "Specifies the window as a popup window." + }, + { + "name": "panel", + "description": "Specifies the window as a panel." + } + ] }, { "id": "QueryOptions", @@ -106,7 +119,7 @@ }, "WINDOW_ID_CURRENT": { "value": -2, - "description": "The windowId value that represents the current window." + "description": "The windowId value that represents the current window." } }, "functions": [ diff --git a/idl/chrome/wm_desks_private.idl b/idl/chrome/wm_desks_private.idl index fcd070a..6922736 100644 --- a/idl/chrome/wm_desks_private.idl +++ b/idl/chrome/wm_desks_private.idl @@ -21,6 +21,9 @@ namespace wmDesksPrivate { // Define whether close all windows on the desk and combine them to the // active desk to the left. boolean combineDesks; + + // Define whether removed desk is retrievable. + boolean? allowUndo; }; dictionary Desk { @@ -83,8 +86,9 @@ namespace wmDesksPrivate { // Removes a desk as specified in `deskId`. If `combineDesks` of // `RemoveDeskOptions` is present or set to true, remove the desk and - // combine windows to the active desk to the left. Otherwise close all - // windows on the desk. + // combine windows to the active desk to the left. If `allowUndo` is + // present or set to true, prompt the user with a notification allowing for + // the desk to be retrieved. Otherwise close all windows on the desk. [supportsPromises] static void removeDesk( DOMString deskId, optional RemoveDeskOptions removeDeskOptions, @@ -127,7 +131,7 @@ namespace wmDesksPrivate { interface Events { // Fires when new desks is added. - static void OnDeskAdded(DOMString deskId); + static void OnDeskAdded(DOMString deskId, boolean fromUndo); // Fires when desk removal is finalized. static void OnDeskRemoved(DOMString deskId); diff --git a/idl/extensions/alarms.idl b/idl/extensions/alarms.idl index 7101d7f..b6a33bf 100644 --- a/idl/extensions/alarms.idl +++ b/idl/extensions/alarms.idl @@ -52,12 +52,12 @@ namespace alarms { // replaced by this alarm. // // In order to reduce the load on the user's machine, Chrome limits alarms - // to at most once every 1 minute but may delay them an arbitrary amount + // to at most once every 30 seconds but may delay them an arbitrary amount // more. That is, setting delayInMinutes or - // periodInMinutes to less than 1 will not be + // periodInMinutes to less than 0.5 will not be // honored and will cause a warning. when can be set to less - // than 1 minute after "now" without warning but won't actually cause the - // alarm to fire for at least 1 minute. + // than 30 seconds after "now" without warning but won't actually cause the + // alarm to fire for at least 30 seconds. // // To help you debug your app or extension, when you've loaded it unpacked, // there's no limit to how often the alarm can fire. diff --git a/idl/extensions/app_runtime.idl b/idl/extensions/app_runtime.idl index a758e51..c297b3b 100644 --- a/idl/extensions/app_runtime.idl +++ b/idl/extensions/app_runtime.idl @@ -5,7 +5,6 @@ // Use the chrome.app.runtime API to manage the app lifecycle. // The app runtime manages app installation, controls the event page, and can // shut down the app at anytime. -[modernised_enums] namespace app.runtime { [inline_doc] dictionary LaunchItem { diff --git a/idl/extensions/app_window.idl b/idl/extensions/app_window.idl index 725dfeb..97b4dfb 100644 --- a/idl/extensions/app_window.idl +++ b/idl/extensions/app_window.idl @@ -7,7 +7,6 @@ // associated with any Chrome browser windows. See the // Window State Sample for a demonstration of these options. -[modernised_enums] namespace app.window { // Previously named Bounds. @@ -448,9 +447,9 @@ namespace app.window { // window with the same id. If you need to open a window with an id at a // location other than the remembered default, you can create it hidden, // move it to the desired location, then show it. - static void create(DOMString url, - optional CreateWindowOptions options, - optional CreateWindowCallback callback); + [supportsPromises] static void create(DOMString url, + optional CreateWindowOptions options, + optional CreateWindowCallback callback); // Returns an $(ref:AppWindow) object for the // current script context (ie JavaScript 'window' object). This can also be diff --git a/idl/extensions/audio.idl b/idl/extensions/audio.idl index 7b83f11..ab775b7 100644 --- a/idl/extensions/audio.idl +++ b/idl/extensions/audio.idl @@ -6,7 +6,6 @@ // get information about and control the audio devices attached to the // system. // This API is currently only available in kiosk mode for ChromeOS. -[modernised_enums] namespace audio { // Type of stream an audio device provides. diff --git a/idl/extensions/automation.idl b/idl/extensions/automation.idl index 897718e..14ca879 100644 --- a/idl/extensions/automation.idl +++ b/idl/extensions/automation.idl @@ -7,7 +7,7 @@ // tree, but only exposes the semantic structure of a page. It can be // used to programmatically interact with a page by examining names, roles, and // states, listening for events, and performing actions on nodes. -[nocompile, modernised_enums] namespace automation { +[nocompile] namespace automation { // Keep the following enums in sync with 'ui/accessibility/ax_enums.mojom'. // They are kept here purely for extension docs generation. @@ -16,7 +16,10 @@ accessKeyChanged, activeDescendantChanged, alert, - ariaAttributeChanged, + // TODO(crbug.com/1464633) Fully remove ariaAttributeChangedDeprecated + // starting in 122, because although it was removed in 118, it is still + // present in earlier versions of LaCros. + ariaAttributeChangedDeprecated, ariaCurrentChanged, atomicChanged, autoCompleteChanged, @@ -89,6 +92,7 @@ multiselectableStateChanged, nameChanged, objectAttributeChanged, + orientationChanged, otherAttributeChanged, parentChanged, placeholderChanged, @@ -173,6 +177,7 @@ dialog, directory, disclosureTriangle, + disclosureTriangleGrouped, // -------------------------------------------------------------- // DPub Roles: // https://www.w3.org/TR/dpub-aam-1.0/#mapping_role_table @@ -306,7 +311,7 @@ pluginObject, popUpButton, portal, - pre, + preDeprecated, progressIndicator, radioButton, radioGroup, @@ -418,6 +423,7 @@ showContextMenu, signalEndOfTest, showTooltip, + stitchChildTree, startDuckingMedia, stopDuckingMedia, suspendMedia @@ -705,9 +711,6 @@ enum PositionType { long focusOffset; }; - // Called when the result for a query is available. - callback QueryCallback = void(AutomationNode node); - [nocompile, noinline_doc] dictionary AutomationIntent { // A command associated with this AutomationIntent. IntentCommandType command; @@ -776,22 +779,6 @@ enum PositionType { DOMString description; }; - // The string which the indices are relative to is not included in this - // structure. See documentation on $(ref:languageAnnotationForStringAttribute) - // for details on how to associate this object with a string. - // Also, the start and end indices always point to the first code unit of a - // valid code-point. - [nocompile, noinline_doc] dictionary LanguageSpan { - // Inclusive start index of substring that contains language. - long startIndex; - // Exclusive end index of substring that contains language. - long endIndex; - // Detected language for substring. - DOMString language; - // Probability that language is correct. - double probability; - }; - // A marker associated with an AutomationNode. [nocompile, noinline_doc] dictionary Marker { // The start offset within the text of the associated node. @@ -1027,8 +1014,8 @@ enum PositionType { // A node that provides more details about the current node. AutomationNode[]? details; - // A node that provides an error message for a current node. - AutomationNode? errorMessage; + // The nodes, if any, that provide an error message for the current node. + AutomationNode[]? errorMessages; // Reverse relationship for details. AutomationNode[]? detailsFor; @@ -1514,22 +1501,6 @@ enum PositionType { static void removeEventListener( EventType eventType, AutomationListener listener, boolean capture); - // Gets the first node in this node's subtree which matches the given CSS - // selector and is within the same DOM context. - // - // If this node doesn't correspond directly with an HTML node in the DOM, - // querySelector will be run on this node's nearest HTML node ancestor. Note - // that this may result in the query returning a node which is not a - // descendant of this node. - // - // If the selector matches a node which doesn't directly correspond to an - // automation node (for example an element within an ARIA widget, where the - // ARIA widget forms one node of the automation tree, or an element which - // is hidden from accessibility via hiding it using CSS or using - // aria-hidden), this will return the nearest ancestor which does correspond - // to an automation node. - static void domQuerySelector(DOMString selector, QueryCallback callback); - // Finds the first AutomationNode in this node's subtree which matches the // given search parameters. static AutomationNode find(FindParams params); @@ -1544,17 +1515,6 @@ enum PositionType { static AutomationNode getNextTextMatch( DOMString searchStr, boolean backward); - // Returns the detected languages for the provided string attribute as an - // array of LanguageSpan objects. There are several guarantees about the - // format of the LanguageSpan array: - // 1. Is either empty or contains LanguageSpans that cover all indices in - // the associated string attribute value. - // 2. Is sorted by increasing startIndex (those with smaller startIndex - // appear first). - // 3. LanguageSpans are non-overlapping and contain exactly one language. - static LanguageSpan[] languageAnnotationForStringAttribute( - DOMString attribute); - // Creates a position object backed by Chrome's accessibility position support. static AutomationPosition createPosition(PositionType type, long offset, optional boolean isUpstream); }; @@ -1570,14 +1530,6 @@ enum PositionType { callback AccessibilityFocusCallback = void(AutomationNode focusedNode); interface Functions { - // Get the automation tree for the tab with the given tabId, or the current - // tab if no tabID is given, enabling automation if necessary. Returns a - // tree with a placeholder root node; listen for the "loadComplete" event to - // get a notification that the tree has fully loaded (the previous root node - // reference will stop working at or before this point). - [nocompile] static void getTree(optional long tabId, - optional RootCallback callback); - // Get the automation tree for the whole desktop which consists of all on // screen views. Note this API is currently only supported on Chrome OS. [nocompile] static void getDesktop(RootCallback callback); @@ -1596,11 +1548,13 @@ enum PositionType { // listen to changes across all trees. Pass a filter to determine what // specific tree changes to listen to, and note that listnening to all // tree changes can be expensive. - [nocompile] static void addTreeChangeObserver( + [nocompile, doesNotSupportPromises="Event callback"] + static void addTreeChangeObserver( TreeChangeObserverFilter filter, TreeChangeObserver observer); // Remove a tree change observer. - [nocompile] static void removeTreeChangeObserver( + [nocompile, doesNotSupportPromises="Event callback"] + static void removeTreeChangeObserver( TreeChangeObserver observer); // Sets the selection in a tree. This creates a selection in a single diff --git a/idl/extensions/automation_internal.idl b/idl/extensions/automation_internal.idl index 5437c75..bb14dbe 100644 --- a/idl/extensions/automation_internal.idl +++ b/idl/extensions/automation_internal.idl @@ -98,18 +98,6 @@ namespace automationInternal { long y; }; - // Arguments for the querySelector function. - dictionary QuerySelectorRequiredParams { - DOMString treeID; - long automationNodeID; - DOMString selector; - }; - - // Arguments for the enableTab function. - dictionary EnableTabParams { - long? tabID; - }; - // Arguments for the getImageData action. dictionary GetImageDataParams { long maxWidth; @@ -129,16 +117,6 @@ namespace automationInternal { long endIndex; }; - // Info returned for the EnableTabCallback. - dictionary EnableTabCallbackInfo { - DOMString treeID; - long tabId; - }; - - // Returns the accessibility tree id of the web contents who's accessibility - // was enabled using enableTab(). - callback EnableTabCallback = void(EnableTabCallbackInfo info); - // Callback called when enableDesktop() returns. Returns the accessibility // tree id of the desktop tree. callback EnableDesktopCallback = void(DOMString tree_id); @@ -147,16 +125,7 @@ namespace automationInternal { // accessibility api state at that point. callback DisableDesktopCallback = void(); - // Callback called when querySelector() returns. - callback QuerySelectorCallback = void(long resultAutomationNodeID); - interface Functions { - // Enable automation of the tab with the given id, or the active tab if no - // tab id is given, and retrieves accessibility tree id for use in - // future updates. - [supportsPromises] static void enableTab(EnableTabParams args, - EnableTabCallback callback); - // Enable automation of the tree with the given id. static void enableTree(DOMString tree_id); @@ -170,11 +139,6 @@ namespace automationInternal { // Performs an action on an automation node. static void performAction(PerformActionRequiredParams args, object opt_args); - - // Performs a query selector query. - [supportsPromises] static void querySelector( - QuerySelectorRequiredParams args, - QuerySelectorCallback callback); }; interface Events { diff --git a/idl/extensions/bluetooth.idl b/idl/extensions/bluetooth.idl index 7423209..0e95092 100644 --- a/idl/extensions/bluetooth.idl +++ b/idl/extensions/bluetooth.idl @@ -4,7 +4,6 @@ // Use the chrome.bluetooth API to connect to a Bluetooth // device. All functions report failures via chrome.runtime.lastError. -[modernised_enums] namespace bluetooth { // Allocation authorities for Vendor IDs. enum VendorIdSource {bluetooth, usb}; diff --git a/idl/extensions/bluetooth_low_energy.idl b/idl/extensions/bluetooth_low_energy.idl index f42c7f0..d4eaf3f 100644 --- a/idl/extensions/bluetooth_low_energy.idl +++ b/idl/extensions/bluetooth_low_energy.idl @@ -6,7 +6,6 @@ // Bluetooth Smart (Low Energy) devices using the // // Generic Attribute Profile (GATT). -[modernised_enums] namespace bluetoothLowEnergy { // Values representing the possible properties of a characteristic. // Characteristic permissions are inferred from these properties. diff --git a/idl/extensions/bluetooth_private.idl b/idl/extensions/bluetooth_private.idl index f3ea202..1fe8b89 100644 --- a/idl/extensions/bluetooth_private.idl +++ b/idl/extensions/bluetooth_private.idl @@ -6,8 +6,7 @@ // adapter state and handle device pairing. // NOTE: This IDL is dependent on bluetooth.idl. -[implemented_in = "extensions/browser/api/bluetooth/bluetooth_private_api.h", -modernised_enums] +[implemented_in = "extensions/browser/api/bluetooth/bluetooth_private_api.h"] namespace bluetoothPrivate { // Events that can occur during pairing. The method used for pairing varies // depending on the capability of the two devices. diff --git a/idl/extensions/bluetooth_socket.idl b/idl/extensions/bluetooth_socket.idl index 0675268..659edda 100644 --- a/idl/extensions/bluetooth_socket.idl +++ b/idl/extensions/bluetooth_socket.idl @@ -4,7 +4,6 @@ // Use the chrome.bluetoothSocket API to send and receive data // to Bluetooth devices using RFCOMM and L2CAP connections. -[modernised_enums] namespace bluetoothSocket { // The socket properties specified in the $ref:create or $ref:update // function. Each property is optional. If a property value is not specified, diff --git a/idl/extensions/cec_private.idl b/idl/extensions/cec_private.idl index 5a78e2e..db7bb07 100644 --- a/idl/extensions/cec_private.idl +++ b/idl/extensions/cec_private.idl @@ -3,7 +3,7 @@ // found in the LICENSE file. // Private API for HDMI CEC functionality. -[modernised_enums, platforms=("chromeos")] +[platforms=("chromeos")] namespace cecPrivate { enum DisplayCecPowerState { diff --git a/idl/extensions/clipboard.idl b/idl/extensions/clipboard.idl index 9ac721d..131da74 100644 --- a/idl/extensions/clipboard.idl +++ b/idl/extensions/clipboard.idl @@ -6,7 +6,7 @@ // access data of the clipboard. This is a temporary solution for // chromeos platform apps until open-web alternative is available. It will be // deprecated once open-web solution is available, which could be in 2017 Q4. -[modernised_enums, platforms=("chromeos", "lacros"), +[platforms=("chromeos", "lacros"), implemented_in="extensions/browser/api/clipboard/clipboard_api.h"] namespace clipboard { // Supported image types. diff --git a/idl/extensions/content_scripts.idl b/idl/extensions/content_scripts.idl index d231af9..4115840 100644 --- a/idl/extensions/content_scripts.idl +++ b/idl/extensions/content_scripts.idl @@ -3,7 +3,7 @@ // found in the LICENSE file. // Stub namespace for the "content_scripts" manifest key. -[generate_error_messages, modernised_enums] +[generate_error_messages] namespace contentScripts { // The stage in the document lifecycle when the javascript file is injected. enum RunAt { @@ -28,12 +28,12 @@ namespace contentScripts { // Describes a content script to be injected into a web page. dictionary ContentScript { // Specifies which pages this content script will be injected into. See - // Match Patterns for more details on the - // syntax of these strings. + // Match Patterns for more + // details on the syntax of these strings. DOMString[] matches; // Excludes pages that this content script would otherwise be injected into. - // See Match Patterns for more details on the - // syntax of these strings. + // See Match Patterns for more + // details on the syntax of these strings. DOMString[]? exclude_matches; // The list of CSS files to be injected into matching pages. These are // injected in the order they appear in this array, before any DOM is diff --git a/idl/extensions/declarative_net_request.idl b/idl/extensions/declarative_net_request.idl index 3f5f9d0..d965c21 100644 --- a/idl/extensions/declarative_net_request.idl +++ b/idl/extensions/declarative_net_request.idl @@ -6,7 +6,7 @@ // network requests by specifying declarative rules. This lets extensions // modify network requests without intercepting them and viewing their content, // thus providing more privacy. -[generate_error_messages, modernised_enums] +[generate_error_messages] namespace declarativeNetRequest { // This describes the resource type of the network request. enum ResourceType { @@ -170,6 +170,18 @@ namespace declarativeNetRequest { DOMString? regexSubstitution; }; + // TODO(crbug.com/1141166): Add documentation once feature is complete. + [nodoc] dictionary HeaderInfo { + // The name of the header. + DOMString header; + // If specified, match this rule if the header's value contains at least one + // element in this list. + DOMString[]? values; + // If specified, the rule is not matched if the header exists but its value + // contains at least one element in this list. + DOMString[]? excludedValues; + }; + [noinline_doc] dictionary RuleCondition { // The pattern which is matched against the network request url. @@ -221,7 +233,7 @@ namespace declarativeNetRequest { DOMString? regexFilter; // Whether the urlFilter or regexFilter - // (whichever is specified) is case sensitive. Default is true. + // (whichever is specified) is case sensitive. Default is false. boolean? isUrlFilterCaseSensitive; // The rule will only match network requests originating from the list of @@ -338,6 +350,15 @@ namespace declarativeNetRequest { // $(ref:tabs.TAB_ID_NONE) excludes requests which don't originate from a // tab. Only supported for session-scoped rules. long[]? excludedTabIds; + + // Rule matches if the request matches any response header in this list (if + // specified). + // TODO(crbug,com/1141166): Add documentation once feature is complete. + [nodoc] HeaderInfo[]? responseHeaders; + + // Rule does not match if the request has any of the specified headers. + // TODO(crbug,com/1141166): Add documentation once feature is complete. + [nodoc] DOMString[]? excludedResponseHeaders; }; dictionary ModifyHeaderInfo { @@ -689,7 +710,7 @@ namespace declarativeNetRequest { // |callback|: Called once the update is complete. In case of an error, // $(ref:runtime.lastError) will be set and no change will be made to the // enabled static rules. - [nodoc, supportsPromises] static void updateStaticRules( + [supportsPromises] static void updateStaticRules( UpdateStaticRulesOptions options, optional EmptyCallback callback); @@ -698,7 +719,7 @@ namespace declarativeNetRequest { // |options|: Specifies the ruleset to query. // |callback|: Called with a list of ids that correspond to the disabled // rules in that ruleset. - [nodoc, supportsPromises] static void getDisabledRuleIds( + [supportsPromises] static void getDisabledRuleIds( GetDisabledRuleIdsOptions options, GetDisabledRuleIdsCallback callback); @@ -758,13 +779,22 @@ namespace declarativeNetRequest { // the global static rule limit. [value=30000] static long GUARANTEED_MINIMUM_STATIC_RULES(); - // The maximum number of dynamic rules that an extension can add. - [nodoc, deprecated="Use $(ref:MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES) instead", value=5000] - static long MAX_NUMBER_OF_DYNAMIC_RULES(); - // The maximum number of combined dynamic and session scoped rules an // extension can add. - [value=5000] static long MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES(); + [nodoc, value=5000] static long MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES(); + + // The maximum number of dynamic rules that an extension can add. + [value=30000] static long MAX_NUMBER_OF_DYNAMIC_RULES(); + + // The maximum number of "unsafe" dynamic rules that an extension can add. + [value=5000] static long MAX_NUMBER_OF_UNSAFE_DYNAMIC_RULES(); + + // The maximum number of session scoped rules that an extension can add. + [value=5000] static long MAX_NUMBER_OF_SESSION_RULES(); + + // The maximum number of "unsafe" session scoped rules that an extension can + // add. + [value=5000] static long MAX_NUMBER_OF_UNSAFE_SESSION_RULES(); // Time interval within which MAX_GETMATCHEDRULES_CALLS_PER_INTERVAL // getMatchedRules calls can be made, specified in minutes. @@ -784,11 +814,11 @@ namespace declarativeNetRequest { // The maximum number of static Rulesets an extension can // specify as part of the "rule_resources" manifest key. - [value=50] static long MAX_NUMBER_OF_STATIC_RULESETS(); + [value=100] static long MAX_NUMBER_OF_STATIC_RULESETS(); // The maximum number of static Rulesets an extension can // enable at any one time. - [value=10] static long MAX_NUMBER_OF_ENABLED_STATIC_RULESETS(); + [value=50] static long MAX_NUMBER_OF_ENABLED_STATIC_RULESETS(); // Ruleset ID for the dynamic rules added by the extension. [value="_dynamic"] static DOMString DYNAMIC_RULESET_ID(); diff --git a/idl/extensions/extension_types.json b/idl/extensions/extension_types.json index 9ba1b5f..7c1578a 100644 --- a/idl/extensions/extension_types.json +++ b/idl/extensions/extension_types.json @@ -6,9 +6,6 @@ { "namespace": "extensionTypes", "description": "The chrome.extensionTypes API contains type declarations for Chrome extensions.", - "compiler_options": { - "modernised_enums": true - }, "types": [ { "id": "ImageFormat", @@ -120,8 +117,12 @@ "id": "ExecutionWorld", "type": "string", "nodoc": true, - "enum": ["ISOLATED", "MAIN"], - "description": "The JavaScript world for a script to execute within. Can either be an isolated world, unique to this extension, or the main world of the DOM which is shared with the page's JavaScript." + "enum": [ + "ISOLATED", + "MAIN", + "USER_SCRIPT" + ], + "description": "The JavaScript world for a script to execute within. Can either be an isolated world unique to this extension, the main world of the DOM which is shared with the page's JavaScript, or a user scripts world that is only available for scripts registered with the User Scripts API." } ] } diff --git a/idl/extensions/extensions_manifest_types.json b/idl/extensions/extensions_manifest_types.json index e37ef21..42c87f3 100644 --- a/idl/extensions/extensions_manifest_types.json +++ b/idl/extensions/extensions_manifest_types.json @@ -28,11 +28,6 @@ "optional": true, "type": "array", "items": { "type": "string" } - }, - "interact": { - "description": "Whether the extension is allowed interactive access (true) or read-only access (false; default) to the automation tree.", - "optional": true, - "type": "boolean" } } } diff --git a/idl/extensions/feedback_private.idl b/idl/extensions/feedback_private.idl index cf0a069..cd4a227 100644 --- a/idl/extensions/feedback_private.idl +++ b/idl/extensions/feedback_private.idl @@ -4,7 +4,6 @@ // Use the chrome.feedbackPrivate API to provide Chrome [OS] // feedback to the Google Feedback servers. -[modernised_enums] namespace feedbackPrivate { dictionary AttachedFile { @@ -31,7 +30,10 @@ namespace feedbackPrivate { sadTabCrash, // Flow for internal Google users. - googleInternal + googleInternal, + + // Flow for AI features. + ai }; dictionary FeedbackInfo { @@ -112,6 +114,12 @@ namespace feedbackPrivate { // Whether or not |autofillMetadata| should be included in the feedback // report. boolean? sendAutofillMetadata; + + // Whether or not the content is offensive or unsafe. + boolean? isOffensiveOrUnsafe; + + // A JSON formatted string containing ai metadata. + DOMString? aiMetadata; }; // Possible statuses that can result from sending feedback. diff --git a/idl/extensions/file_handlers.idl b/idl/extensions/file_handlers.idl index b347746..de3b881 100644 --- a/idl/extensions/file_handlers.idl +++ b/idl/extensions/file_handlers.idl @@ -43,8 +43,8 @@ Icon[]? icons; // Whether multiple files should be opened in a single client or multiple. - // Defaults to `single-client`, which opens one window containing one array - // with each file. `multiple-clients` opens a new window for each file. + // Defaults to `single-client`, which makes all files available in only one + // tab. `multiple-client` opens a new tab for each file. DOMString? launch_type; }; diff --git a/idl/extensions/file_system.idl b/idl/extensions/file_system.idl index e42fd47..68cf1eb 100644 --- a/idl/extensions/file_system.idl +++ b/idl/extensions/file_system.idl @@ -7,7 +7,6 @@ // read and write to a user-selected location. For example, a text editor app // can use the API to read and write local documents. All failures are notified // via chrome.runtime.lastError. -[modernised_enums] namespace fileSystem { dictionary AcceptOption { // This is the optional text description for this option. If not present, @@ -113,32 +112,41 @@ namespace fileSystem { // Get the display path of an Entry object. The display path is based on // the full path of the file or directory on the local file system, but may // be made more readable for display purposes. - static void getDisplayPath([instanceOf=Entry] object entry, - GetDisplayPathCallback callback); + [supportsPromises] static void getDisplayPath( + [instanceOf=Entry] object entry, + GetDisplayPathCallback callback); // Get a writable Entry from another Entry. This call will fail with a // runtime error if the application does not have the 'write' permission // under 'fileSystem'. If entry is a DirectoryEntry, this call will fail if // the application does not have the 'directory' permission under // 'fileSystem'. - static void getWritableEntry([instanceOf=Entry] object entry, - EntryCallback callback); + [doesNotSupportPromises="Custom hook sets lastError crbug.com/1504349"] + static void getWritableEntry( + [instanceOf=Entry] object entry, + EntryCallback callback); // Gets whether this Entry is writable or not. - static void isWritableEntry([instanceOf=Entry] object entry, - IsWritableCallback callback); + [supportsPromises] static void isWritableEntry( + [instanceOf=Entry] object entry, + IsWritableCallback callback); // Ask the user to choose a file or directory. + [doesNotSupportPromises="Multi-parameter callback crbug.com/1313625, + Custom hook sets lastError crbug.com/1504349"] static void chooseEntry(optional ChooseEntryOptions options, EntriesCallback callback); // Returns the file entry with the given id if it can be restored. This call // will fail with a runtime error otherwise. - static void restoreEntry(DOMString id, EntryCallback callback); + [doesNotSupportPromises="Custom hook sets lastError crbug.com/1504349"] + static void restoreEntry(DOMString id, + EntryCallback callback); // Returns whether the app has permission to restore the entry with the // given id. - static void isRestorable(DOMString id, IsRestorableCallback callback); + [supportsPromises] static void isRestorable(DOMString id, + IsRestorableCallback callback); // Returns an id that can be passed to restoreEntry to regain access to a // given file entry. Only the 500 most recently used entries are retained, @@ -157,15 +165,17 @@ namespace fileSystem { // confirmation dialog will be shown on top of the active app window. // In case of an error, fileSystem will be undefined, and // chrome.runtime.lastError will be set. - static void requestFileSystem(RequestFileSystemOptions options, - RequestFileSystemCallback callback); + [supportsPromises] static void requestFileSystem( + RequestFileSystemOptions options, + RequestFileSystemCallback callback); // Returns a list of volumes available for requestFileSystem(). // The "fileSystem": {"requestFileSystem"} manifest permission // is required. Available to kiosk apps running in the kiosk session only. // In case of an error, volumes will be undefined, and // chrome.runtime.lastError will be set. - static void getVolumeList(GetVolumeListCallback callback); + [supportsPromises] static void getVolumeList( + GetVolumeListCallback callback); }; interface Events { diff --git a/idl/extensions/guest_view_internal.json b/idl/extensions/guest_view_internal.json index ead1747..029a6e9 100644 --- a/idl/extensions/guest_view_internal.json +++ b/idl/extensions/guest_view_internal.json @@ -56,6 +56,10 @@ "name": "viewType", "nodoc": true }, + { + "type": "string", + "name": "ownerFrameToken" + }, { "type": "object", "name": "createParams", @@ -66,13 +70,22 @@ "name": "callback", "parameters": [ { - "type": "object", - "name": "returnParams", - "additionalProperties": {"type": "any"} + "type": "integer", + "name": "instanceId" } ] } }, + { + "name": "destroyUnattachedGuest", + "type": "function", + "parameters": [ + { + "type": "integer", + "name": "instanceId" + } + ] + }, { "name": "setSize", "type": "function", diff --git a/idl/extensions/hid.idl b/idl/extensions/hid.idl index 816f997..56514d8 100644 --- a/idl/extensions/hid.idl +++ b/idl/extensions/hid.idl @@ -85,22 +85,24 @@ namespace hid { interface Functions { // Enumerate connected HID devices. // |options|: The properties to search for on target devices. - static void getDevices(GetDevicesOptions options, - GetDevicesCallback callback); + [supportsPromises] static void getDevices(GetDevicesOptions options, + GetDevicesCallback callback); // Open a connection to an HID device for communication. // |deviceId|: The $(ref:HidDeviceInfo.deviceId) of the device to open. - static void connect(long deviceId, - ConnectCallback callback); + [supportsPromises] static void connect(long deviceId, + ConnectCallback callback); // Disconnect from a device. Invoking operations on a device after calling // this is safe but has no effect. // |connectionId|: The connectionId returned by $(ref:connect). - static void disconnect(long connectionId, - optional DisconnectCallback callback); + [supportsPromises] static void disconnect( + long connectionId, + optional DisconnectCallback callback); // Receive the next input report from the device. // |connectionId|: The connectionId returned by $(ref:connect). + [doesNotSupportPromises="Multi-parameter callback crbug.com/1313625"] static void receive(long connectionId, ReceiveCallback callback); @@ -111,17 +113,18 @@ namespace hid { // |connectionId|: The connectionId returned by $(ref:connect). // |reportId|: The report ID to use, or 0 if none. // |data|: The report data. - static void send(long connectionId, - long reportId, - ArrayBuffer data, - SendCallback callback); + [supportsPromises] static void send(long connectionId, + long reportId, + ArrayBuffer data, + SendCallback callback); // Request a feature report from the device. // |connectionId|: The connectionId returned by $(ref:connect). // |reportId|: The report ID, or 0 if none. - static void receiveFeatureReport(long connectionId, - long reportId, - ReceiveFeatureReportCallback callback); + [supportsPromises] static void receiveFeatureReport( + long connectionId, + long reportId, + ReceiveFeatureReportCallback callback); // Send a feature report to the device. // @@ -130,10 +133,10 @@ namespace hid { // |connectionId|: The connectionId returned by $(ref:connect). // |reportId|: The report ID to use, or 0 if none. // |data|: The report data. - static void sendFeatureReport(long connectionId, - long reportId, - ArrayBuffer data, - SendCallback callback); + [supportsPromises] static void sendFeatureReport(long connectionId, + long reportId, + ArrayBuffer data, + SendCallback callback); }; interface Events { diff --git a/idl/extensions/i18n.json b/idl/extensions/i18n.json index a0d6f41..6483f8a 100644 --- a/idl/extensions/i18n.json +++ b/idl/extensions/i18n.json @@ -35,7 +35,7 @@ { "type": "string", "name": "messageName", - "description": "The name of the message, as specified in the messages.json file." + "description": "The name of the message, as specified in the messages.json file." }, { "type": "any", diff --git a/idl/extensions/incognito.json b/idl/extensions/incognito.json index 664d654..3e9e76b 100644 --- a/idl/extensions/incognito.json +++ b/idl/extensions/incognito.json @@ -5,10 +5,7 @@ [ { "namespace": "incognito", - "description": "Dummy namepsace for the incognito manifest key.", - "compiler_options": { - "modernised_enums": true - }, + "description": "Dummy namespace for the incognito manifest key.", "types": [ { "id": "IncognitoMode", diff --git a/idl/extensions/management.json b/idl/extensions/management.json index 5ed069f..94d1c58 100644 --- a/idl/extensions/management.json +++ b/idl/extensions/management.json @@ -5,10 +5,7 @@ [ { "namespace":"management", - "description": "The chrome.management API provides ways to manage the list of extensions/apps that are installed and running. It is particularly useful for extensions that override the built-in New Tab page.", - "compiler_options": { - "modernised_enums": true - }, + "description": "The chrome.management API provides ways to manage the list of extensions/apps that are installed and running. It is particularly useful for extensions that override the built-in New Tab page.", "types": [ { "id": "IconInfo", @@ -65,11 +62,11 @@ "type": "string" }, "version": { - "description": "The version of this extension, app, or theme.", + "description": "The version of this extension, app, or theme.", "type": "string" }, "versionName": { - "description": "The version name of this extension, app, or theme if the manifest specified one.", + "description": "The version name of this extension, app, or theme if the manifest specified one.", "type": "string", "optional": true }, @@ -124,7 +121,7 @@ "type": "string" }, "icons": { - "description": "A list of icon information. Note that this just reflects what was declared in the manifest, and the actual image at that url may be larger or smaller than what was declared, so you might consider using explicit width and height attributes on img tags referencing these images. See the manifest documentation on icons for more details.", + "description": "A list of icon information. Note that this just reflects what was declared in the manifest, and the actual image at that url may be larger or smaller than what was declared, so you might consider using explicit width and height attributes on img tags referencing these images. See the manifest documentation on icons for more details.", "type": "array", "optional": true, "items": { @@ -234,7 +231,7 @@ }, { "name": "getPermissionWarningsById", - "description": "Returns a list of permission warnings for the given extension id.", + "description": "Returns a list of permission warnings for the given extension id.", "parameters": [ { "name": "id", "type": "string", @@ -255,7 +252,7 @@ }, { "name": "getPermissionWarningsByManifest", - "description": "Returns a list of permission warnings for the given extension manifest string. Note: This function can be used without requesting the 'management' permission in the manifest.", + "description": "Returns a list of permission warnings for the given extension manifest string. Note: This function can be used without requesting the 'management' permission in the manifest.", "parameters": [ { "name": "manifestStr", @@ -413,30 +410,6 @@ ] } }, - { - "name": "canInstallReplacementAndroidApp", - "description": "Checks if the replacement android app can be installed. Errors generated by this API are reported by setting $(ref:runtime.lastError) and executing the function's regular callback.", - "parameters": [], - "returns_async": { - "name": "callback", - "parameters": [ - { - "name": "result", - "type": "boolean" - } - ] - } - }, - { - "name": "installReplacementAndroidApp", - "description": "Prompts the user to install the replacement Android app from the manifest. Errors generated by this API are reported by setting $(ref:runtime.lastError) and executing the function's regular callback.", - "parameters": [], - "returns_async": { - "name": "callback", - "optional": true, - "parameters": [] - } - }, { "name": "installReplacementWebApp", "description": "Launches the replacement_web_app specified in the manifest. Prompts the user to install if not already installed.", diff --git a/idl/extensions/media_perception_private.idl b/idl/extensions/media_perception_private.idl index 30ad69d..d9a9efa 100644 --- a/idl/extensions/media_perception_private.idl +++ b/idl/extensions/media_perception_private.idl @@ -3,7 +3,7 @@ // found in the LICENSE file. // Private API for receiving real-time media perception information. -[platforms=("chromeos"), modernised_enums] +[platforms=("chromeos")] namespace mediaPerceptionPrivate { enum Status { // The media analytics process is waiting to be launched. diff --git a/idl/extensions/metrics_private.json b/idl/extensions/metrics_private.json index 4bc29dc..a104b45 100644 --- a/idl/extensions/metrics_private.json +++ b/idl/extensions/metrics_private.json @@ -6,9 +6,6 @@ { "namespace": "metricsPrivate", "description": "none", - "compiler_options": { - "modernised_enums": true - }, "types": [ { "id": "MetricTypeType", diff --git a/idl/extensions/mime_handler_private.idl b/idl/extensions/mime_handler_private.idl index 2734316..e343343 100644 --- a/idl/extensions/mime_handler_private.idl +++ b/idl/extensions/mime_handler_private.idl @@ -45,7 +45,9 @@ interface Functions { // Returns the StreamInfo for the stream for this context if there is one. - [nocompile] static void getStreamInfo(GetStreamDetailsCallback callback); + [nocompile, doesNotSupportPromises= + "Custom hook sets lastError crbug.com/1504349"] + static void getStreamInfo(GetStreamDetailsCallback callback); // Sets PDF plugin attributes in the stream for this context if there is // one. @@ -54,7 +56,9 @@ // Instructs the PluginDocument, if running in one, to show a dialog in // response to beforeunload events. - [nocompile] static void setShowBeforeUnloadDialog( + [nocompile, doesNotSupportPromises= + "Custom hook sets lastError crbug.com/1504349"] + static void setShowBeforeUnloadDialog( boolean showDialog, optional SetShowBeforeUnloadDialogCallback callback); }; diff --git a/idl/extensions/networking_private.idl b/idl/extensions/networking_private.idl index bc71dfe..c4fd63e 100644 --- a/idl/extensions/networking_private.idl +++ b/idl/extensions/networking_private.idl @@ -27,7 +27,6 @@ // TODO(stevenjb/pneubeck): Merge the ONC documentation with this document and // use it as the ONC specification. -[modernised_enums] namespace networkingPrivate { enum ActivationStateType { Activated, Activating, NotActivated, PartiallyActivated @@ -325,7 +324,9 @@ namespace networkingPrivate { EAPProperties? EAP; DOMString? Group; long? IKEVersion; + DOMString? LocalIdentity; DOMString? PSK; + DOMString? RemoteIdentity; boolean? SaveCredentials; DOMString[]? ServerCAPEMs; DOMString[]? ServerCARefs; diff --git a/idl/extensions/offscreen.idl b/idl/extensions/offscreen.idl index cec419e..875b5e8 100644 --- a/idl/extensions/offscreen.idl +++ b/idl/extensions/offscreen.idl @@ -3,40 +3,49 @@ // found in the LICENSE file. // Use the offscreen API to create and manage offscreen documents. -[modernised_enums] namespace offscreen { enum Reason { // A reason used for testing purposes only. TESTING, - // The offscreen document is responsible for playing audio. + // Specifies that the offscreen document is responsible for playing audio. AUDIO_PLAYBACK, - // The offscreen document needs to embed and script an iframe in order to - // modify the iframe's content. + // Specifies that the offscreen document needs to embed and script an + // iframe in order to modify the iframe's content. IFRAME_SCRIPTING, - // The offscreen document needs to embed an iframe and scrape its DOM to - // extract information. + // Specifies that the offscreen document needs to embed an iframe and + // scrape its DOM to extract information. DOM_SCRAPING, - // The offscreen document needs to interact with Blob objects (including - // URL.createObjectURL()). + // Specifies that the offscreen document needs to interact with Blob + // objects (including URL.createObjectURL()). BLOBS, - // The offscreen document needs to use the DOMParser API. + // Specifies that the offscreen document needs to use the + // WebRTC APIs. WEB_RTC, - // The offscreen document needs to interact with the clipboard APIs - // (e.g. Navigator.clipboard). + // Specifies that the offscreen document needs to interact with the + // localStorage. + // Specifies that the offscreen document needs access to + // localStorage. LOCAL_STORAGE, - // The offscreen document needs to spawn workers. + // Specifies that the offscreen document needs to spawn workers. WORKERS, - // The offscreen document needs to use navigator.geolocation + // Specifies that the offscreen document needs to use + // navigator.getBattery. + BATTERY_STATUS, + // Specifies that the offscreen document needs to use + // window.matchMedia. + MATCH_MEDIA, + // Specifies that the offscreen document needs to use + // navigator.geolocation. GEOLOCATION }; diff --git a/idl/extensions/power.idl b/idl/extensions/power.idl index ba0b11d..e10a881 100644 --- a/idl/extensions/power.idl +++ b/idl/extensions/power.idl @@ -8,10 +8,10 @@ namespace power { callback VoidCallback = void (); [noinline_doc] enum Level { - // Prevent the system from sleeping in response to user inactivity. + // Prevents the system from sleeping in response to user inactivity. system, - // Prevent the display from being turned off or dimmed or the system + // Prevents the display from being turned off or dimmed, or the system // from sleeping in response to user inactivity. display }; diff --git a/idl/extensions/printer_provider.idl b/idl/extensions/printer_provider.idl index 9c4007e..83b836e 100644 --- a/idl/extensions/printer_provider.idl +++ b/idl/extensions/printer_provider.idl @@ -5,23 +5,22 @@ // The chrome.printerProvider API exposes events used by print // manager to query printers controlled by extensions, to query their // capabilities and to submit print jobs to these printers. -[modernised_enums] namespace printerProvider { // Error codes returned in response to $(ref:onPrintRequested) event. enum PrintError { - // Operation completed successfully. + // Specifies that the operation was completed successfully. OK, - // General failure. + // Specifies that a general failure occured. FAILED, - // Print ticket is invalid. For example, ticket is inconsistent with - // capabilities or extension is not able to handle all settings from the - // ticket. + // Specifies that the print ticket is invalid. For example, the ticket is + // inconsistent with some capabilities, or the extension is not able to + // handle all settings from the ticket. INVALID_TICKET, - // Document is invalid. For example, data may be corrupted or the format is - // incompatible with the extension. + // Specifies that the document is invalid. For example, data may be + // corrupted or the format is incompatible with the extension. INVALID_DATA }; @@ -48,6 +47,12 @@ namespace printerProvider { // Print ticket in // // CJT format. + // object ticket; // The document content type. Supported formats are diff --git a/idl/extensions/printer_provider_internal.idl b/idl/extensions/printer_provider_internal.idl index 342198a..afbb47d 100644 --- a/idl/extensions/printer_provider_internal.idl +++ b/idl/extensions/printer_provider_internal.idl @@ -12,7 +12,7 @@ // is internally dispatched having a requestId argument (which is removed from // the argument list before the event actually reaches the event listeners). The // requestId is forwarded to the chrome.printerProviderInternal API functions. -[modernised_enums, implemented_in="extensions/browser/api/printer_provider/printer_provider_internal_api.h"] +[implemented_in="extensions/browser/api/printer_provider/printer_provider_internal_api.h"] namespace printerProviderInternal { // Same as in printerProvider.PrintError enum API. enum PrintError { OK, FAILED, INVALID_TICKET, INVALID_DATA }; diff --git a/idl/extensions/requirements.json b/idl/extensions/requirements.json index 02792ed..e32487a 100644 --- a/idl/extensions/requirements.json +++ b/idl/extensions/requirements.json @@ -5,9 +5,8 @@ [ { "namespace": "requirements", - "description": "Stub namepsace for the 'requirements' manifest key.", + "description": "Stub namespace for the 'requirements' manifest key.", "compiler_options": { - "modernised_enums": true, "generate_error_messages": true }, "types": [ @@ -42,16 +41,6 @@ "items": { "$ref": "3DFeature" } } } - }, - "window": { - "type": "object", - "optional": true, - "properties": { - "shape": { - "type": "boolean", - "optional": true - } - } } } } diff --git a/idl/extensions/runtime.json b/idl/extensions/runtime.json index 753fd0e..95e37c9 100644 --- a/idl/extensions/runtime.json +++ b/idl/extensions/runtime.json @@ -8,10 +8,7 @@ [ { "namespace": "runtime", - "description": "Use the chrome.runtime API to retrieve the background page, return details about the manifest, and listen for and respond to events in the app or extension lifecycle. You can also use this API to convert the relative path of URLs to fully-qualified URLs.", - "compiler_options": { - "modernised_enums": true - }, + "description": "Use the chrome.runtime API to retrieve the service worker, return details about the manifest, and listen for and respond to events in the app or extension lifecycle. You can also use this API to convert the relative path of URLs to fully-qualified URLs.", "types": [ { "id": "Port", @@ -83,26 +80,39 @@ "type": "string", "description": "The operating system Chrome is running on.", "enum": [ - "mac", - "win", - "android", - "cros", - "linux", - "openbsd", - "fuchsia" + {"name": "mac", "description": "Specifies the MacOS operating system."}, + {"name": "win", "description": "Specifies the Windows operating system."}, + {"name": "android", "description": "Specifies the Android operating system."}, + {"name": "cros", "description": "Specifies the Chrome operating system."}, + {"name": "linux", "description": "Specifies the Linux operating system."}, + {"name": "openbsd", "description": "Specifies the OpenBSD operating system."}, + {"name": "fuchsia", "description": "Specifies the Fuchsia operating system."} ] }, { "id": "PlatformArch", "type": "string", - "enum": ["arm", "arm64", "x86-32", "x86-64", "mips", "mips64"], + "enum": [ + {"name": "arm", "description": "Specifies the processer architecture as arm."}, + {"name": "arm64", "description": "Specifies the processer architecture as arm64."}, + {"name": "x86-32", "description": "Specifies the processer architecture as x86-32."}, + {"name": "x86-64", "description": "Specifies the processer architecture as x86-64."}, + {"name": "mips", "description": "Specifies the processer architecture as mips."}, + {"name": "mips64", "description": "Specifies the processer architecture as mips64."} + ], "description": "The machine's processor architecture." }, { "id": "PlatformNaclArch", "description": "The native client architecture. This may be different from arch on some platforms.", "type": "string", - "enum": ["arm", "x86-32", "x86-64", "mips", "mips64"] + "enum": [ + {"name": "arm", "description": "Specifies the native client architecture as arm."}, + {"name": "x86-32", "description": "Specifies the native client architecture as x86-32."}, + {"name": "x86-64", "description": "Specifies the native client architecture as x86-64."}, + {"name": "mips", "description": "Specifies the native client architecture as mips."}, + {"name": "mips64", "description": "Specifies the native client architecture as mips64."} + ] }, { "id": "PlatformInfo", @@ -126,25 +136,44 @@ { "id": "RequestUpdateCheckStatus", "type": "string", - "enum": ["throttled", "no_update", "update_available"], + "enum": [ + {"name": "throttled", "description": "Specifies that the status check has been throttled. This can occur after repeated checks within a short amount of time."}, + {"name": "no_update", "description": "Specifies that there are no available updates to install."}, + {"name": "update_available", "description": "Specifies that there is an available update to install."} + ], "description": "Result of the update check." }, { "id": "OnInstalledReason", "type": "string", - "enum": ["install", "update", "chrome_update", "shared_module_update"], + "enum": [ + {"name": "install", "description": "Specifies the event reason as an installation."}, + {"name": "update", "description": "Specifies the event reason as an extension update."}, + {"name": "chrome_update", "description": "Specifies the event reason as a Chrome update."}, + {"name": "shared_module_update", "description": "Specifies the event reason as an update to a shared module."} + ], "description": "The reason that this event is being dispatched." }, { "id": "OnRestartRequiredReason", "type": "string", "description": "The reason that the event is being dispatched. 'app_update' is used when the restart is needed because the application is updated to a newer version. 'os_update' is used when the restart is needed because the browser/OS is updated to a newer version. 'periodic' is used when the system runs for more than the permitted uptime set in the enterprise policy.", - "enum": ["app_update", "os_update", "periodic"] + "enum": [ + {"name": "app_update", "description": "Specifies the event reason as an update to the app."}, + {"name": "os_update", "description": "Specifies the event reason as an update to the operating system."}, + {"name": "periodic", "description": "Specifies the event reason as a periodic restart of the app."} + ] }, { "id": "ContextType", "type": "string", - "enum": ["TAB", "POPUP", "BACKGROUND", "OFFSCREEN_DOCUMENT", "SIDE_PANEL"] + "enum": [ + {"name": "TAB", "description": "Specifies the context type as a tab"}, + {"name": "POPUP", "description": "Specifies the context type as an extension popup window"}, + {"name": "BACKGROUND", "description": "Specifies the context type as a service worker."}, + {"name": "OFFSCREEN_DOCUMENT", "description": "Specifies the context type as an offscreen document."}, + {"name": "SIDE_PANEL", "description": "Specifies the context type as a side panel."} + ] }, { "id": "ExtensionContext", @@ -248,7 +277,7 @@ "lastError": { "type": "object", "optional": true, - "description": "This will be defined during an API method callback if there was an error", + "description": "Populated with an error message if calling an API function fails; otherwise undefined. This is only defined within the scope of that function's callback. If an error is produced, but runtime.lastError is not accessed within the callback, a message is logged to the console listing the API function that produced the error. API functions that return promises do not set this property.", "properties": { "message": { "optional": true, @@ -297,7 +326,7 @@ }, { "name": "getManifest", - "description": "Returns details about the app or extension from the manifest. The object returned is a serialization of the full manifest file.", + "description": "Returns details about the app or extension from the manifest. The object returned is a serialization of the full manifest file.", "type": "function", "nocompile": true, "parameters": [], @@ -405,9 +434,9 @@ "name": "connect", "type": "function", "nocompile": true, - "description": "Attempts to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and web messaging. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via $(ref:tabs.connect).", + "description": "Attempts to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and web messaging. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via $(ref:tabs.connect).", "parameters": [ - {"type": "string", "name": "extensionId", "optional": true, "description": "The ID of the extension or app to connect to. If omitted, a connection will be attempted with your own extension. Required if sending messages from a web page for web messaging."}, + {"type": "string", "name": "extensionId", "optional": true, "description": "The ID of the extension or app to connect to. If omitted, a connection will be attempted with your own extension. Required if sending messages from a web page for web messaging."}, { "type": "object", "name": "connectInfo", @@ -427,7 +456,7 @@ "name": "connectNative", "type": "function", "nocompile": true, - "description": "Connects to a native application in the host machine. See Native Messaging for more information.", + "description": "Connects to a native application in the host machine. See Native Messaging for more information.", "parameters": [ { "type": "string", @@ -447,7 +476,7 @@ "allowAmbiguousOptionalArguments": true, "description": "Sends a single message to event listeners within your extension/app or a different extension/app. Similar to $(ref:runtime.connect) but only sends a single message, with an optional response. If sending to your extension, the $(ref:runtime.onMessage) event will be fired in every frame of your extension (except for the sender's frame), or $(ref:runtime.onMessageExternal), if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use $(ref:tabs.sendMessage).", "parameters": [ - {"type": "string", "name": "extensionId", "optional": true, "description": "The ID of the extension/app to send the message to. If omitted, the message will be sent to your own extension/app. Required if sending messages from a web page for web messaging."}, + {"type": "string", "name": "extensionId", "optional": true, "description": "The ID of the extension/app to send the message to. If omitted, the message will be sent to your own extension/app. Required if sending messages from a web page for web messaging."}, { "type": "any", "name": "message", "description": "The message to send. This message should be a JSON-ifiable object." }, { "type": "object", @@ -525,20 +554,18 @@ "name": "getPackageDirectoryEntry", "type": "function", "description": "Returns a DirectoryEntry for the package directory.", - "parameters": [ - { - "type": "function", - "name": "callback", - "parameters": [ - { - "name": "directoryEntry", - "type": "object", - "additionalProperties": { "type": "any" }, - "isInstanceOf": "DirectoryEntry" - } - ] - } - ] + "parameters": [], + "returns_async": { + "name": "callback", + "parameters": [ + { + "name": "directoryEntry", + "type": "object", + "additionalProperties": { "type": "any" }, + "isInstanceOf": "DirectoryEntry" + } + ] + } }, { "name": "getContexts", @@ -652,14 +679,13 @@ "name": "onConnectExternal", "type": "function", "nocompile": true, - "description": "Fired when a connection is made from another extension (by $(ref:runtime.connect)).", + "description": "Fired when a connection is made from another extension (by $(ref:runtime.connect)), or from an externally connectable web site.", "parameters": [ {"$ref": "Port", "name": "port"} ] }, { "name": "onUserScriptConnect", - "nodoc": true, "type": "function", "nocompile": true, "options": { "unmanaged": true }, @@ -715,7 +741,6 @@ }, { "name": "onUserScriptMessage", - "nodoc": true, "type": "function", "nocompile": true, "options": { "unmanaged": true }, diff --git a/idl/extensions/scripts_internal.idl b/idl/extensions/scripts_internal.idl new file mode 100644 index 0000000..010ff69 --- /dev/null +++ b/idl/extensions/scripts_internal.idl @@ -0,0 +1,69 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Internal namespace for representing content scripts. +namespace scriptsInternal { + // The source of the user script. This will also determine certain + // capabilities of the script (such as whether it can use globs, raw strings + // for code, etc). + enum Source { + DYNAMIC_CONTENT_SCRIPT, + DYNAMIC_USER_SCRIPT, + MANIFEST_CONTENT_SCRIPT + }; + + // The source of the script to inject. + dictionary ScriptSource { + // A string containing the JavaScript code to inject. Exactly one of + // file or code must be specified. + DOMString? code; + // The path of the JavaScript file to inject relative to the extension's + // root directory. Exactly one of file or code + // must be specified. + DOMString? file; + }; + + // Describes a serialized script, intended for storage and persistence across + // browser sessions. + // Note: Though it is called "UserScript", this is used for scripts through + // the scripting API (dynamic content scripts), content scripts in the + // manifest (static content scripts), and user scripts through the userScripts + // API. "UserScript" was chosen because it matches the correspodning + // extenisons::UserScript object (the runtime representation of this) and + // because "Script" is ambiguous (e.g. background script, general JS script, + // etc). + dictionary SerializedUserScript { + // Whether the script will inject into all frames, regardless if it is not + // the top-most frame in the tab. + boolean? allFrames; + // The list of CSS files to be injected into matching pages. Note that, + // today, we only expect these to contain files. It is represented as a + // ScriptSource for compatibility and consistency with `js`. + ScriptSource[]? css; + // Excludes pages that this user script would otherwise be injected into. + DOMString[]? excludeMatches; + // Specifies wildcard patterns for pages this user script will NOT be + // injected into. + DOMString[]? excludeGlobs; + // The ID of the script. + DOMString id; + // Specifies wildcard patterns for pages this user script will be injected + // into. + DOMString[]? includeGlobs; + // The list of sources of javascript to be injected into matching pages. + ScriptSource[]? js; + // Specifies which pages this user script will be injected into. + DOMString[] matches; + // Whether the script should inject into any frames where the URL belongs to + // a scheme that would never match a specified Match Pattern, including + // about:, data:, blob:, and filesystem: schemes. + boolean? matchOriginAsFallback; + // Specifies when JavaScript files are injected into the web page. + extensionTypes.RunAt? runAt; + // The "source" of the user script. + Source source; + // The JavaScript "world" to run the script in. + extensionTypes.ExecutionWorld world; + }; +}; \ No newline at end of file diff --git a/idl/extensions/serial.idl b/idl/extensions/serial.idl index aadc033..4f9f5c4 100644 --- a/idl/extensions/serial.idl +++ b/idl/extensions/serial.idl @@ -4,7 +4,6 @@ // Use the chrome.serial API to read from and write to a device // connected to a serial port. -[modernised_enums] namespace serial { dictionary DeviceInfo { @@ -263,82 +262,90 @@ namespace serial { // Returns information about available serial devices on the system. // The list is regenerated each time this method is called. // |callback| : Called with the list of DeviceInfo objects. - static void getDevices(GetDevicesCallback callback); + [supportsPromises] static void getDevices(GetDevicesCallback callback); // Connects to a given serial port. // |path| : The system path of the serial port to open. // |options| : Port configuration options. // |callback| : Called when the connection has been opened. - static void connect(DOMString path, - optional ConnectionOptions options, - ConnectCallback callback); + [supportsPromises] static void connect(DOMString path, + optional ConnectionOptions options, + ConnectCallback callback); // Update the option settings on an open serial port connection. // |connectionId| : The id of the opened connection. // |options| : Port configuration options. // |callback| : Called when the configuation has completed. - static void update(long connectionId, - ConnectionOptions options, - UpdateCallback callback); + [supportsPromises] static void update(long connectionId, + ConnectionOptions options, + UpdateCallback callback); // Disconnects from a serial port. // |connectionId| : The id of the opened connection. // |callback| : Called when the connection has been closed. - static void disconnect(long connectionId, DisconnectCallback callback); + [supportsPromises] static void disconnect(long connectionId, + DisconnectCallback callback); // Pauses or unpauses an open connection. // |connectionId| : The id of the opened connection. // |paused| : Flag to indicate whether to pause or unpause. // |callback| : Called when the connection has been successfully paused or // unpaused. - static void setPaused(long connectionId, - boolean paused, - SetPausedCallback callback); + [supportsPromises] static void setPaused(long connectionId, + boolean paused, + SetPausedCallback callback); // Retrieves the state of a given connection. // |connectionId| : The id of the opened connection. // |callback| : Called with connection state information when available. - static void getInfo(long connectionId, GetInfoCallback callback); + [supportsPromises] static void getInfo(long connectionId, + GetInfoCallback callback); // Retrieves the list of currently opened serial port connections owned by // the application. // |callback| : Called with the list of connections when available. - static void getConnections(GetConnectionsCallback callback); + [supportsPromises] static void getConnections( + GetConnectionsCallback callback); // Writes data to the given connection. // |connectionId| : The id of the connection. // |data| : The data to send. // |callback| : Called when the operation has completed. - static void send(long connectionId, - ArrayBuffer data, - SendCallback callback); + [supportsPromises] static void send(long connectionId, + ArrayBuffer data, + SendCallback callback); // Flushes all bytes in the given connection's input and output buffers. - static void flush(long connectionId, FlushCallback callback); + [supportsPromises] static void flush(long connectionId, + FlushCallback callback); // Retrieves the state of control signals on a given connection. // |connectionId| : The id of the connection. // |callback| : Called when the control signals are available. - static void getControlSignals(long connectionId, - GetControlSignalsCallback callback); + [supportsPromises] static void getControlSignals( + long connectionId, + GetControlSignalsCallback callback); // Sets the state of control signals on a given connection. // |connectionId| : The id of the connection. // |signals| : The set of signal changes to send to the device. // |callback| : Called once the control signals have been set. - static void setControlSignals(long connectionId, - HostControlSignals signals, - SetControlSignalsCallback callback); + [supportsPromises] static void setControlSignals( + long connectionId, + HostControlSignals signals, + SetControlSignalsCallback callback); // Suspends character transmission on a given connection and places the // transmission line in a break state until the clearBreak is called. // |connectionId| : The id of the connection. - static void setBreak(long connectionId, SetBreakCallback callback); + [supportsPromises] static void setBreak(long connectionId, + SetBreakCallback callback); // Restore character transmission on a given connection and place the // transmission line in a nonbreak state. // |connectionId| : The id of the connection. - static void clearBreak(long connectionId, ClearBreakCallback callback); + [supportsPromises] static void clearBreak(long connectionId, + ClearBreakCallback callback); }; interface Events { diff --git a/idl/extensions/socket.idl b/idl/extensions/socket.idl index abc2751..3f3c8d2 100644 --- a/idl/extensions/socket.idl +++ b/idl/extensions/socket.idl @@ -6,7 +6,6 @@ // network using TCP and UDP connections. Note: Starting with Chrome 33, // this API is deprecated in favor of the $(ref:sockets.udp), $(ref:sockets.tcp) and // $(ref:sockets.tcpServer) APIs. -[modernised_enums] namespace socket { enum SocketType { tcp, @@ -173,6 +172,8 @@ namespace socket { // |hostname| : The hostname or IP address of the remote machine. // |port| : The port of the remote machine. // |callback| : Called when the connection attempt is complete. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void connect(long socketId, DOMString hostname, long port, @@ -184,6 +185,8 @@ namespace socket { // |address| : The address of the local machine. // |port| : The port of the local machine. // |callback| : Called when the bind attempt is complete. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void bind(long socketId, DOMString address, long port, @@ -199,6 +202,8 @@ namespace socket { // |bufferSize| : The read buffer size. // |callback| : Delivers data that was available to be read without // blocking. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void read(long socketId, optional long bufferSize, ReadCallback callback); @@ -208,6 +213,8 @@ namespace socket { // |data| : The data to write. // |callback| : Called when the write operation completes without blocking // or an error occurs. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void write(long socketId, ArrayBuffer data, WriteCallback callback); @@ -216,6 +223,8 @@ namespace socket { // |socketId| : The socketId. // |bufferSize| : The receive buffer size. // |callback| : Returns result of the recvFrom operation. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void recvFrom(long socketId, optional long bufferSize, RecvFromCallback callback); @@ -227,6 +236,8 @@ namespace socket { // |port| : The port of the remote machine. // |callback| : Called when the send operation completes without blocking // or an error occurs. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void sendTo(long socketId, ArrayBuffer data, DOMString address, @@ -242,6 +253,8 @@ namespace socket { // |port| : The port of the local machine. // |backlog| : Length of the socket's listen queue. // |callback| : Called when listen operation completes. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void listen(long socketId, DOMString address, long port, @@ -255,6 +268,8 @@ namespace socket { // invoked immediately with an error as the resultCode. // |socketId| : The socketId. // |callback| : The callback is invoked when a new socket is accepted. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void accept(long socketId, AcceptCallback callback); @@ -264,6 +279,8 @@ namespace socket { // |delay| : Set the delay seconds between the last data packet received // and the first keepalive probe. Default is 0. // |callback| : Called when the setKeepAlive attempt is complete. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void setKeepAlive(long socketId, boolean enable, optional long delay, @@ -274,6 +291,8 @@ namespace socket { // |socketId| : The socketId. // |noDelay| : If true, disables Nagle's algorithm. // |callback| : Called when the setNoDelay attempt is complete. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void setNoDelay(long socketId, boolean noDelay, SetNoDelayCallback callback); @@ -295,6 +314,8 @@ namespace socket { // |address| : The group address to join. Domain names are not supported. // |callback| : Called when the join group operation is done with an // integer parameter indicating the platform-independent error code. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void joinGroup(long socketId, DOMString address, JoinGroupCallback callback); @@ -311,6 +332,8 @@ namespace socket { // |address| : The group address to leave. Domain names are not supported. // |callback| : Called when the leave group operation is done with an // integer parameter indicating the platform-independent error code. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void leaveGroup(long socketId, DOMString address, LeaveGroupCallback callback); @@ -321,6 +344,8 @@ namespace socket { // |socketId| : The socketId. // |ttl| : The time-to-live value. // |callback| : Called when the configuration operation is done. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void setMulticastTimeToLive( long socketId, long ttl, @@ -343,6 +368,8 @@ namespace socket { // |socketId| : The socketId. // |enabled| : Indicate whether to enable loopback mode. // |callback| : Called when the configuration operation is done. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void setMulticastLoopbackMode( long socketId, boolean enabled, @@ -351,6 +378,8 @@ namespace socket { // Get the multicast group addresses the socket is currently joined to. // |socketId| : The socketId. // |callback| : Called with an array of strings of the result. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void getJoinedGroups(long socketId, GetJoinedGroupsCallback callback); @@ -358,6 +387,8 @@ namespace socket { // |socketId| : The connected socket to use. // |options| : Constraints and parameters for the TLS connection. // |callback| : Called when the TLS connection attempt is complete. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void secure(long socketId, optional SecureOptions options, SecureCallback callback); diff --git a/idl/extensions/sockets_tcp.idl b/idl/extensions/sockets_tcp.idl index ca19f9c..9437ebc 100644 --- a/idl/extensions/sockets_tcp.idl +++ b/idl/extensions/sockets_tcp.idl @@ -5,7 +5,6 @@ // Use the chrome.sockets.tcp API to send and receive data over the // network using TCP connections. This API supersedes the TCP functionality // previously found in the chrome.socket API. -[modernised_enums] namespace sockets.tcp { // The socket properties specified in the create or // update function. Each property is optional. If a property @@ -197,6 +196,8 @@ namespace sockets.tcp { // |delay| : Set the delay seconds between the last data packet received // and the first keepalive probe. Default is 0. // |callback| : Called when the setKeepAlive attempt is complete. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void setKeepAlive(long socketId, boolean enable, optional long delay, @@ -207,6 +208,8 @@ namespace sockets.tcp { // |socketId| : The socket identifier. // |noDelay| : If true, disables Nagle's algorithm. // |callback| : Called when the setNoDelay attempt is complete. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void setNoDelay(long socketId, boolean noDelay, SetNoDelayCallback callback); @@ -223,6 +226,8 @@ namespace sockets.tcp { // |peerPort| : The port of the remote machine. // |dnsQueryType| : The address resolution preference. // |callback| : Called when the connect attempt is complete. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void connect(long socketId, DOMString peerAddress, long peerPort, @@ -239,6 +244,8 @@ namespace sockets.tcp { // |socketId| : The existing, connected socket to use. // |options| : Constraints and parameters for the TLS connection. // |callback| : Called when the connection attempt is complete. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void secure(long socketId, optional SecureOptions options, SecureCallback callback); @@ -247,6 +254,8 @@ namespace sockets.tcp { // |socketId| : The socket identifier. // |data| : The data to send. // |callback| : Called when the send operation completes. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void send(long socketId, ArrayBuffer data, SendCallback callback); diff --git a/idl/extensions/sockets_tcp_server.idl b/idl/extensions/sockets_tcp_server.idl index cbbde5d..5c3bf36 100644 --- a/idl/extensions/sockets_tcp_server.idl +++ b/idl/extensions/sockets_tcp_server.idl @@ -144,6 +144,8 @@ namespace sockets.tcpServer { // depends on the Operating System (SOMAXCONN), which ensures a reasonable // queue length for most applications. // |callback| : Called when listen operation completes. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void listen(long socketId, DOMString address, long port, diff --git a/idl/extensions/sockets_udp.idl b/idl/extensions/sockets_udp.idl index f4b021b..2ba62f4 100644 --- a/idl/extensions/sockets_udp.idl +++ b/idl/extensions/sockets_udp.idl @@ -5,7 +5,6 @@ // Use the chrome.sockets.udp API to send and receive data over the // network using UDP connections. This API supersedes the UDP functionality // previously found in the "socket" API. -[modernised_enums] namespace sockets.udp { // The socket properties specified in the create or // update function. Each property is optional. If a property @@ -200,6 +199,8 @@ namespace sockets.udp { // available network interfaces. // |port| : The port of the local machine. Use "0" to bind to a free port. // |callback| : Called when the bind operation completes. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void bind(long socketId, DOMString address, long port, @@ -213,6 +214,8 @@ namespace sockets.udp { // |port| : The port of the remote machine. // |dnsQueryType| : The address resolution preference. // |callback| : Called when the send operation completes. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void send(long socketId, ArrayBuffer data, DOMString address, @@ -244,6 +247,8 @@ namespace sockets.udp { // |socketId| : The socket ID. // |address| : The group address to join. Domain names are not supported. // |callback| : Called when the joinGroup operation completes. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void joinGroup(long socketId, DOMString address, JoinGroupCallback callback); @@ -260,6 +265,8 @@ namespace sockets.udp { // |socketId| : The socket ID. // |address| : The group address to leave. Domain names are not supported. // |callback| : Called when the leaveGroup operation completes. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void leaveGroup(long socketId, DOMString address, LeaveGroupCallback callback); @@ -271,6 +278,8 @@ namespace sockets.udp { // |socketId| : The socket ID. // |ttl| : The time-to-live value. // |callback| : Called when the configuration operation completes. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void setMulticastTimeToLive( long socketId, long ttl, @@ -293,6 +302,8 @@ namespace sockets.udp { // |socketId| : The socket ID. // |enabled| : Indicate whether to enable loopback mode. // |callback| : Called when the configuration operation completes. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void setMulticastLoopbackMode( long socketId, boolean enabled, @@ -309,6 +320,8 @@ namespace sockets.udp { // |socketId| : The socket ID. // |enabled| : true to enable broadcast packets, // false to disable them. + [doesNotSupportPromises= + "Sets error along with callback arguments crbug.com/1504372"] static void setBroadcast(long socketId, boolean enabled, SetBroadcastCallback callback); diff --git a/idl/extensions/storage.json b/idl/extensions/storage.json index 078e98a..8723ecc 100644 --- a/idl/extensions/storage.json +++ b/idl/extensions/storage.json @@ -7,14 +7,15 @@ "namespace": "storage", "description": "Use the chrome.storage API to store, retrieve, and track changes to user data.", "unprivileged": true, - "compiler_options": { - "modernised_enums": true - }, "types": [ { "id": "AccessLevel", "type": "string", - "enum": ["TRUSTED_CONTEXTS", "TRUSTED_AND_UNTRUSTED_CONTEXTS"], + "enum": [ + {"name": "TRUSTED_CONTEXTS", "description": "Specifies contexts originating from the extension itself."}, + {"name": "TRUSTED_AND_UNTRUSTED_CONTEXTS", "description": "Specifies contexts originating from outside the extension."} + // + ], "description": "The storage area's access level." }, { @@ -96,7 +97,7 @@ "parameters": [ { "name": "bytesInUse", - "type": "integer", + "type": "number", "description": "Amount of space being used in storage, in bytes." } ] diff --git a/idl/extensions/system_display.idl b/idl/extensions/system_display.idl index 99331d0..66cc3c0 100644 --- a/idl/extensions/system_display.idl +++ b/idl/extensions/system_display.idl @@ -3,7 +3,6 @@ // found in the LICENSE file. // Use the system.display API to query display metadata. -[modernised_enums] namespace system.display { dictionary Bounds { @@ -130,6 +129,14 @@ namespace system.display { long yearOfManufacture; }; + // An enum to tell if the display is detected and used by the + // system. The display is considered 'inactive', if it is not + // detected by the system (maybe disconnected, or considered + // disconnected due to sleep mode, etc). This state is used to keep + // existing display when the all displays are disconnected, for + // example. + enum ActiveState { active, inactive }; + dictionary DisplayUnitInfo { // The unique identifier of the display. DOMString id; @@ -160,6 +167,9 @@ namespace system.display { // True if this display is enabled. boolean isEnabled; + // Active if the display is detected and used by the system. + ActiveState activeState; + // True for all displays when in unified desktop mode. See documentation // for $(ref:enableUnifiedDesktop). boolean isUnified; @@ -283,14 +293,16 @@ namespace system.display { // Mirror mode, i.e. different ways of how a display is mirrored to other // displays. enum MirrorMode { - // Use the default mode (extended or unified desktop). + // Specifies the default mode (extended or unified desktop). off, - // The default source display will be mirrored to all other displays. + // Specifies that the default source display will be mirrored to all other + // displays. normal, - // The specified source display will be mirrored to the provided - // destination displays. All other connected displays will be extended. + // Specifies that the specified source display will be mirrored to the + // provided destination displays. All other connected displays will be + // extended. mixed }; diff --git a/idl/extensions/system_storage.idl b/idl/extensions/system_storage.idl index 5f29301..8195745 100644 --- a/idl/extensions/system_storage.idl +++ b/idl/extensions/system_storage.idl @@ -5,7 +5,6 @@ // Use the chrome.system.storage API to query storage device // information and be notified when a removable storage device is attached and // detached. -[modernised_enums] namespace system.storage { enum StorageUnitType { diff --git a/idl/extensions/test.json b/idl/extensions/test.json index 6901b97..58c3c3b 100644 --- a/idl/extensions/test.json +++ b/idl/extensions/test.json @@ -116,6 +116,14 @@ {"type": "string", "name": "message"} ] }, + { + "name": "openFileUrl", + "type": "function", + "description": "Open file: URLs for tests.", + "parameters": [ + {"type": "string", "name": "url"} + ] + }, { "name": "sendMessage", "type": "function", diff --git a/idl/extensions/types.json b/idl/extensions/types.json new file mode 100644 index 0000000..b43c29b --- /dev/null +++ b/idl/extensions/types.json @@ -0,0 +1,161 @@ +// Copyright 2012 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +[ + { + "namespace": "types", + "description": "The chrome.types API contains type declarations for Chrome.", + "types": [ + { + "id": "ChromeSettingScope", + "type": "string", + "enum": ["regular", "regular_only", "incognito_persistent", "incognito_session_only"], + "description": "The scope of the ChromeSetting. One of" + }, + { + "id": "LevelOfControl", + "type": "string", + "enum": ["not_controllable", "controlled_by_other_extensions", "controllable_by_this_extension", "controlled_by_this_extension"], + "description": "One of" + }, + { + "id": "ChromeSetting", + "type": "object", + "js_module": "ChromeSetting", + "customBindings": "ChromeSetting", + "description": "An interface that allows access to a Chrome browser setting. See $(ref:accessibilityFeatures) for an example.", + "functions": [ + { + "name": "get", + "type": "function", + "nocompile": true, + "description": "Gets the value of a setting.", + "parameters": [ + { + "name": "details", + "type": "object", + "description": "Which setting to consider.", + "properties": { + "incognito": { + "type": "boolean", + "optional": true, + "description": "Whether to return the value that applies to the incognito session (default false)." + } + } + } + ], + "returns_async": { + "name": "callback", + "parameters": [ + { + "name": "details", + "type": "object", + "description": "Details of the currently effective value.", + "properties": { + "value": { + "description": "The value of the setting.", + "type": "any" + }, + "levelOfControl": { + "$ref": "LevelOfControl", + "description": "The level of control of the setting." + }, + "incognitoSpecific": { + "description": "Whether the effective value is specific to the incognito session.
This property will only be present if the incognito property in the details parameter of get() was true.", + "type": "boolean", + "optional": true + } + } + } + ] + } + }, + { + "name": "set", + "type": "function", + "nocompile": true, + "description": "Sets the value of a setting.", + "parameters": [ + { + "name": "details", + "type": "object", + "description": "Which setting to change.", + "properties": { + "value": { + "description": "The value of the setting.
Note that every setting has a specific value type, which is described together with the setting. An extension should not set a value of a different type.", + "type": "any" + }, + "scope": { + "$ref": "ChromeSettingScope", + "optional": true, + "description": "Where to set the setting (default: regular)." + } + } + } + ], + "returns_async": { + "name": "callback", + "description": "Called at the completion of the set operation.", + "optional": true, + "parameters": [] + } + }, + { + "name": "clear", + "type": "function", + "nocompile": true, + "description": "Clears the setting, restoring any default value.", + "parameters": [ + { + "name": "details", + "type": "object", + "description": "Which setting to clear.", + "properties": { + "scope": { + "$ref": "ChromeSettingScope", + "optional": true, + "description": "Where to clear the setting (default: regular)." + } + } + } + ], + "returns_async": { + "name": "callback", + "description": "Called at the completion of the clear operation.", + "optional": true, + "parameters": [] + } + } + ], + "events": [ + { + "name": "onChange", + "description": "Fired after the setting changes.", + "parameters": [ + { + "type": "object", + "name": "details", + "properties": { + "value": { + "description": "The value of the setting after the change.", + "type": "any" + }, + "levelOfControl": { + "$ref": "LevelOfControl", + "description": "The level of control of the setting." + }, + "incognitoSpecific": { + "description": "Whether the value that has changed is specific to the incognito session.
This property will only be present if the user has enabled the extension in incognito mode.", + "type": "boolean", + "optional": true + } + } + } + ] + } + ] + } + ] + } +] \ No newline at end of file diff --git a/idl/extensions/usb.idl b/idl/extensions/usb.idl index 9ef518d..6ecc2cb 100644 --- a/idl/extensions/usb.idl +++ b/idl/extensions/usb.idl @@ -9,7 +9,6 @@ // Errors generated by this API are reported by setting // $(ref:runtime.lastError) and executing the function's regular callback. The // callback's regular parameters will be undefined in this case. -[modernised_enums] namespace usb { // Direction, Recipient, RequestType, and TransferType all map to their diff --git a/idl/extensions/user_scripts.idl b/idl/extensions/user_scripts.idl new file mode 100644 index 0000000..62a90aa --- /dev/null +++ b/idl/extensions/user_scripts.idl @@ -0,0 +1,144 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Use the userScripts API to execute user scripts in the User +// Scripts context. +namespace userScripts { + // The JavaScript world for a user script to execute within. + enum ExecutionWorld { + // Specifies the execution environment of the DOM, which is the execution + // environment shared with the host page's JavaScript. + MAIN, + // Specifies the execution enviroment that is specific to user scripts and + // is exempt from the page's CSP. + USER_SCRIPT + }; + + // The source of the script to inject. + dictionary ScriptSource { + // A string containing the JavaScript code to inject. Exactly one of + // file or code must be specified. + DOMString? code; + // The path of the JavaScript file to inject relative to the extension's + // root directory. Exactly one of file or code + // must be specified. + DOMString? file; + }; + + // Describes a user script to be injected into a web page registered through + // this API. The script is injected into a page if its URL matches any of + // "matches" or "include_globs" patterns, and the URL doesn't match + // "exclude_matches" and "exclude_globs" patterns. + dictionary RegisteredUserScript { + // If true, it will inject into all frames, even if the frame is not the + // top-most frame in the tab. Each frame is checked independently for URL + // requirements; it will not inject into child frames if the URL + // requirements are not met. Defaults to false, meaning that only the top + // frame is matched. + boolean? allFrames; + // Excludes pages that this user script would otherwise be injected into. + // See Match Patterns for more details on + // the syntax of these strings. + DOMString[]? excludeMatches; + // The ID of the user script specified in the API call. This property must + // not start with a '_' as it's reserved as a prefix for generated script + // IDs. + DOMString id; + // Specifies wildcard patterns for pages this user script will be injected + // into. + DOMString[]? includeGlobs; + // Specifies wildcard patterns for pages this user script will NOT be + // injected into. + DOMString[]? excludeGlobs; + // The list of ScriptSource objects defining sources of scripts to be + // injected into matching pages. + ScriptSource[] js; + // Specifies which pages this user script will be injected into. See + // Match Patterns for more details on the + // syntax of these strings. This property must be specified for + // ${ref:register}. + DOMString[]? matches; + // Specifies when JavaScript files are injected into the web page. The + // preferred and default value is document_idle. + extensionTypes.RunAt? runAt; + // The JavaScript execution environment to run the script in. The default is + // `USER_SCRIPT`. + ExecutionWorld? world; + }; + + // An object used to filter user scripts for ${ref:getScripts}. + dictionary UserScriptFilter { + // $(ref:getScripts) only returns scripts with the IDs specified in this + // list. + DOMString[]? ids; + }; + + // An object used to update the `USER_SCRIPT` world + // configuration. If a propertie is not specified, it will reset it to its + // default value. + dictionary WorldProperties{ + // Specifies the world csp. The default is the `ISOLATED` + // world csp. + DOMString? csp; + // Specifies whether messaging APIs are exposed. The default is + // false. + boolean? messaging; + }; + + callback RegisterCallback = void(); + + callback GetScriptsCallback = void(RegisteredUserScript[] scripts); + + callback UnregisterCallback = void(); + + callback UpdateCallback = void(); + + callback ConfigureWorldCallback = void(); + + interface Functions { + // Registers one or more user scripts for this extension. + // |scripts|: Contains a list of user scripts to be registered. + // |callback|: Called once scripts have been fully registered or if an error + // has ocurred. + [supportsPromises] static void register(RegisteredUserScript[] scripts, + optional RegisterCallback callback); + + // Returns all dynamically-registered user scripts for this extension. + // |filter|: If specified, this method returns only the user scripts that + // match it. + // |callback|: Called once scripts have been fully registered or if an error + // occurs. + [supportsPromises] static void getScripts( + optional UserScriptFilter filter, + GetScriptsCallback callback); + + // Unregisters all dynamically-registered user scripts for this extension. + // |filter|: If specified, this method unregisters only the user scripts + // that match it. + // |callback|: Called once scripts have been fully unregistered or if an + // error ocurs + [supportsPromises] static void unregister( + optional UserScriptFilter filter, + UnregisterCallback callback); + + // Updates one or more user scripts for this extension. + // |scripts|: Contains a list of user scripts to be updated. A property is + // only updated for the existing script if it is specified in this object. + // If there are errors during script parsing/file validation, or if the IDs + // specified do not correspond to a fully registered script, then no scripts + // are updated. + // |callback|: Called once scripts have been fully updated or if an error + // occurs. + [supportsPromises] static void update( + RegisteredUserScript[] scripts, + optional UpdateCallback callback); + + // Configures the `USER_SCRIPT` execution environment. + // |properties|: Contains the user script world configuration. + // |callback|: Called once world hase been configured. + [supportsPromises] static void configureWorld( + WorldProperties properties, + optional ConfigureWorldCallback callback); + }; +}; \ No newline at end of file diff --git a/idl/extensions/virtual_keyboard_private.json b/idl/extensions/virtual_keyboard_private.json index 9b59829..7d9e9c0 100644 --- a/idl/extensions/virtual_keyboard_private.json +++ b/idl/extensions/virtual_keyboard_private.json @@ -6,7 +6,6 @@ { "namespace": "virtualKeyboardPrivate", "compiler_options": { - "modernised_enums": true, "implemented_in": "extensions/browser/api/virtual_keyboard_private/virtual_keyboard_private_api.h" }, "platforms": ["chromeos"], diff --git a/idl/extensions/web_accessible_resources.idl b/idl/extensions/web_accessible_resources.idl index 8cca3a1..7f45226 100644 --- a/idl/extensions/web_accessible_resources.idl +++ b/idl/extensions/web_accessible_resources.idl @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Stub namepsace for the "web_accessible_resources" manifest key. +// Stub namespace for the "web_accessible_resources" manifest key. [generate_error_messages] namespace webAccessibleResources { dictionary WebAccessibleResource { // Relative paths within the extension package representing web accessible @@ -10,8 +10,8 @@ DOMString[] resources; // List of match - // patterns to which "resources" are accessible. These patterns should + // href="https://developer.chrome.com/docs/extensions/develop/concepts/match-patterns"> + // match patterns to which "resources" are accessible. These patterns should // have an effective path of "*". Each match will be checked against the // initiating origin. DOMString[]? matches; diff --git a/idl/extensions/web_accessible_resources_mv2.idl b/idl/extensions/web_accessible_resources_mv2.idl index bb5ba13..1ed7a15 100644 --- a/idl/extensions/web_accessible_resources_mv2.idl +++ b/idl/extensions/web_accessible_resources_mv2.idl @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Stub namepsace for the "web_accessible_resources" manifest key. +// Stub namespace for the "web_accessible_resources" manifest key. [generate_error_messages] namespace webAccessibleResourcesMv2 { dictionary ManifestKeys { // Relative paths within the extension package representing web accessible diff --git a/idl/extensions/web_request.json b/idl/extensions/web_request.json index 78923a7..2e8a260 100644 --- a/idl/extensions/web_request.json +++ b/idl/extensions/web_request.json @@ -6,9 +6,6 @@ { "namespace": "webRequest", "description": "Use the chrome.webRequest API to observe and analyze traffic and to intercept, block, or modify requests in-flight.", - "compiler_options": { - "modernised_enums": true - }, "properties": { "MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES": { "value": 20, @@ -19,52 +16,101 @@ { "id": "ResourceType", "type": "string", - "enum": ["main_frame", "sub_frame", "stylesheet", "script", "image", "font", "object", "xmlhttprequest", "ping", "csp_report", "media", "websocket", "webbundle", "other"] + "enum": [ + {"name": "main_frame", "description": "Specifies the resource as the main frame."}, + {"name": "sub_frame", "description": "Specifies the resource as a sub frame."}, + {"name": "stylesheet", "description": "Specifies the resource as a stylesheet."}, + {"name": "script", "description": "Specifies the resource as a script."}, + {"name": "image", "description": "Specifies the resource as an image."}, + {"name": "font", "description": "Specifies the resource as a font."}, + {"name": "object", "description": "Specifies the resource as an object."}, + {"name": "xmlhttprequest", + "description": "Specifies the resource as an XMLHttpRequest."}, + {"name": "ping", + "description": "Specifies the resource as a ping."}, + {"name": "csp_report", + "description": "Specifies the resource as a Content Security Policy (CSP) report."}, + {"name": "media", "description": "Specifies the resource as a media object."}, + {"name": "websocket", "description": "Specifies the resource as a WebSocket."}, + {"name": "webbundle", "description": "Specifies the resource as a WebBundle."}, + {"name": "other", "description": "Specifies the resource as a type not included in the listed types."} + ] }, { "id": "OnBeforeRequestOptions", "type": "string", - "enum": ["blocking", "requestBody", "extraHeaders"] + "enum": [ + {"name": "blocking", "description": "Specifies the request is blocked until the callback function returns."}, + {"name": "requestBody", "description": "Specifies that the request body should be included in the event."}, + {"name": "extraHeaders", "description": "Specifies that headers can violate Cross-Origin Resource Sharing (CORS)."} + ] }, { "id": "OnBeforeSendHeadersOptions", "type": "string", - "enum": ["requestHeaders", "blocking", "extraHeaders"] + "enum": [ + {"name": "requestHeaders", "description": "Specifies that the request header should be included in the event."}, + {"name": "blocking", "description": "Specifies the request is blocked until the callback function returns."}, + {"name": "extraHeaders", "description": "Specifies that headers can violate Cross-Origin Resource Sharing (CORS)."} + ] }, { "id": "OnSendHeadersOptions", "type": "string", - "enum": ["requestHeaders", "extraHeaders"] + "enum": [ + {"name": "requestHeaders", "description": "Specifies that the request header should be included in the event."}, + {"name": "extraHeaders", "description": "Specifies that headers can violate Cross-Origin Resource Sharing (CORS)."} + ] }, { "id": "OnHeadersReceivedOptions", "type": "string", - "enum": ["blocking", "responseHeaders", "extraHeaders"] + "enum": [ + {"name": "blocking", "description": "Specifies the request is blocked until the callback function returns."}, + {"name": "responseHeaders", "description": "Specifies that the response headers should be included in the event."}, + {"name": "extraHeaders", "description": "Specifies that headers can violate Cross-Origin Resource Sharing (CORS)."} + ] }, { "id": "OnAuthRequiredOptions", "type": "string", - "enum": ["responseHeaders", "blocking", "asyncBlocking", "extraHeaders"] + "enum": [ + {"name": "responseHeaders", "description": "Specifies that the response headers should be included in the event."}, + {"name": "blocking", "description": "Specifies the request is blocked until the callback function returns."}, + {"name": "asyncBlocking", "description": "Specifies that the callback function is handled asynchronously."}, + {"name": "extraHeaders", "description": "Specifies that headers can violate Cross-Origin Resource Sharing (CORS)."} + ] }, { "id": "OnResponseStartedOptions", "type": "string", - "enum": ["responseHeaders", "extraHeaders"] + "enum": [ + {"name": "responseHeaders", "description": "Specifies that the response headers should be included in the event."}, + {"name": "extraHeaders", "description": "Specifies that headers can violate Cross-Origin Resource Sharing (CORS)."} + ] }, { "id": "OnBeforeRedirectOptions", "type": "string", - "enum": ["responseHeaders", "extraHeaders"] + "enum": [ + {"name": "responseHeaders", "description": "Specifies that the response headers should be included in the event."}, + {"name": "extraHeaders", "description": "Specifies that headers can violate Cross-Origin Resource Sharing (CORS)."} + ] }, { "id": "OnCompletedOptions", "type": "string", - "enum": ["responseHeaders", "extraHeaders"] + "enum": [ + {"name": "responseHeaders", "description": "Specifies that the response headers should be included in the event."}, + {"name": "extraHeaders", "description": "Specifies that headers can violate Cross-Origin Resource Sharing (CORS)."} + ] }, { "id": "OnErrorOccurredOptions", "type": "string", - "enum": ["extraHeaders"] + "enum": [ + {"name": "extraHeaders", "description": "Specifies that headers can violate Cross-Origin Resource Sharing (CORS)."} + ] }, { "id": "RequestFilter", diff --git a/idl/extensions/web_view_internal.json b/idl/extensions/web_view_internal.json index a894018..6baa6d7 100644 --- a/idl/extensions/web_view_internal.json +++ b/idl/extensions/web_view_internal.json @@ -7,7 +7,6 @@ "namespace": "webViewInternal", "description": "none", "compiler_options": { - "modernised_enums": true, "implemented_in": "extensions/browser/api/guest_view/web_view/web_view_internal_api.h" }, "properties": { diff --git a/idl/extensions/webcam_private.idl b/idl/extensions/webcam_private.idl index e4bdfa5..f24f112 100644 --- a/idl/extensions/webcam_private.idl +++ b/idl/extensions/webcam_private.idl @@ -3,7 +3,6 @@ // found in the LICENSE file. // Webcam Private API. -[modernised_enums] namespace webcamPrivate { enum PanDirection { stop, right, left }; enum TiltDirection { stop, up, down }; diff --git a/lib/action.dart b/lib/action.dart index b8fabdd..c7ccf61 100644 --- a/lib/action.dart +++ b/lib/action.dart @@ -67,7 +67,7 @@ class ChromeAction { /// non-tab-specific badge text is returned. If /// [displayActionCountAsBadgeText](declarativeNetRequest#setExtensionActionOptions) /// is enabled, a placeholder text will be returned unless the - /// [declarativeNetRequestFeedback](declare_permissions#declarativeNetRequestFeedback) + /// [declarativeNetRequestFeedback](/docs/extensions/develop/concepts/declare-permissions#declarativeNetRequestFeedback) /// permission is present or tab-specific badge text was provided. Future getBadgeText(TabDetails details) async { var $res = await promiseToFuture( diff --git a/lib/alarms.dart b/lib/alarms.dart index f1a9cd1..541df55 100644 --- a/lib/alarms.dart +++ b/lib/alarms.dart @@ -27,12 +27,12 @@ class ChromeAlarms { /// replaced by this alarm. /// /// In order to reduce the load on the user's machine, Chrome limits alarms - /// to at most once every 1 minute but may delay them an arbitrary amount + /// to at most once every 30 seconds but may delay them an arbitrary amount /// more. That is, setting `delayInMinutes` or - /// `periodInMinutes` to less than `1` will not be + /// `periodInMinutes` to less than `0.5` will not be /// honored and will cause a warning. `when` can be set to less - /// than 1 minute after "now" without warning but won't actually cause the - /// alarm to fire for at least 1 minute. + /// than 30 seconds after "now" without warning but won't actually cause the + /// alarm to fire for at least 30 seconds. /// /// To help you debug your app or extension, when you've loaded it unpacked, /// there's no limit to how often the alarm can fire. diff --git a/lib/browser_action.dart b/lib/browser_action.dart index a6e7b3b..5d86e48 100644 --- a/lib/browser_action.dart +++ b/lib/browser_action.dart @@ -16,7 +16,7 @@ extension ChromeBrowserActionExtension on Chrome { /// Use browser actions to put icons in the main Google Chrome toolbar, to the /// right of the address bar. In addition to its [icon](browserAction#icon), a /// browser action can have a [tooltip](browserAction#tooltip), a - /// [badge](browserAction#badge), and a [popup](browserAction#popups). + /// [badge](browserAction#badge), and a [popup](browserAction#popup). ChromeBrowserAction get browserAction => _browserAction; } diff --git a/lib/certificate_provider.dart b/lib/certificate_provider.dart index 042d345..fbde10a 100644 --- a/lib/certificate_provider.dart +++ b/lib/certificate_provider.dart @@ -142,35 +142,40 @@ class ChromeCertificateProvider { /// Types of supported cryptographic signature algorithms. enum Algorithm { - /// RSASSA PKCS#1 v1.5 signature algorithm with the MD5-SHA-1 hashing. The - /// extension must not prepend a DigestInfo prefix but only add PKCS#1 - /// padding. This algorithm is deprecated and will never be requested by - /// Chrome as of version 109. + /// Specifies the RSASSA PKCS#1 v1.5 signature algorithm with the MD5-SHA-1 + /// hashing. The extension must not prepend a DigestInfo prefix but only + /// add PKCS#1 padding. This algorithm is deprecated and will never be + /// requested + /// by Chrome as of version 109. rsassaPkcs1V15Md5Sha1('RSASSA_PKCS1_v1_5_MD5_SHA1'), - /// RSASSA PKCS#1 v1.5 signature algorithm with the SHA-1 hash function. + /// Specifies the RSASSA PKCS#1 v1.5 signature algorithm + /// with the SHA-1 hash function. rsassaPkcs1V15Sha1('RSASSA_PKCS1_v1_5_SHA1'), - /// RSASSA PKCS#1 v1.5 signature algorithm with the SHA-256 hashing function. + /// Specifies the RSASSA PKCS#1 v1.5 signature algorithm + /// with the SHA-256 hashing function. rsassaPkcs1V15Sha256('RSASSA_PKCS1_v1_5_SHA256'), - /// RSASSA PKCS#1 v1.5 signature algorithm with the SHA-384 hashing function. + /// Specifies the RSASSA PKCS#1 v1.5 signature algorithm + /// with the SHA-384 hashing function. rsassaPkcs1V15Sha384('RSASSA_PKCS1_v1_5_SHA384'), - /// RSASSA PKCS#1 v1.5 signature algorithm with the SHA-512 hashing function. + /// Specifies the RSASSA PKCS#1 v1.5 signature algorithm + /// with the SHA-512 hashing function. rsassaPkcs1V15Sha512('RSASSA_PKCS1_v1_5_SHA512'), - /// Since Chrome 89. RSASSA PSS signature algorithm with the SHA-256 hashing + /// Specifies the RSASSA PSS signature algorithm with the SHA-256 hashing /// function, MGF1 mask generation function and the salt of the same size as /// the hash. rsassaPssSha256('RSASSA_PSS_SHA256'), - /// Since Chrome 89. RSASSA PSS signature algorithm with the SHA-384 hashing + /// Specifies the RSASSA PSS signature algorithm with the SHA-384 hashing /// function, MGF1 mask generation function and the salt of the same size as /// the hash. rsassaPssSha384('RSASSA_PSS_SHA384'), - /// Since Chrome 89. RSASSA PSS signature algorithm with the SHA-512 hashing + /// Specifies the RSASSA PSS signature algorithm with the SHA-512 hashing /// function, MGF1 mask generation function and the salt of the same size as /// the hash. rsassaPssSha512('RSASSA_PSS_SHA512'); @@ -186,8 +191,8 @@ enum Algorithm { /// Types of errors that the extension can report. enum Error { - /// General error that cannot be represented by other more specific error - /// codes. + /// General error that cannot be represented by other more specific + /// error codes. generalError('GENERAL_ERROR'); const Error(this.value); @@ -201,10 +206,19 @@ enum Error { /// Deprecated. Replaced by [Algorithm]. enum Hash { + /// Specifies the MD5 and SHA1 hashing algorithms. md5Sha1('MD5_SHA1'), + + /// Specifies the SHA1 hashing algorithm. sha1('SHA1'), + + /// Specifies the SHA256 hashing algorithm. sha256('SHA256'), + + /// Specifies the SHA384 hashing algorithm. sha384('SHA384'), + + /// Specifies the SHA512 hashing algorithm. sha512('SHA512'); const Hash(this.value); @@ -218,7 +232,10 @@ enum Hash { /// The type of code being requested by the extension with requestPin function. enum PinRequestType { + /// Specifies the requested code is a PIN. pin('PIN'), + + /// Specifies the requested code is a PUK. puk('PUK'); const PinRequestType(this.value); @@ -233,9 +250,16 @@ enum PinRequestType { /// The types of errors that can be presented to the user through the /// requestPin function. enum PinRequestErrorType { + /// Specifies the PIN is invalid. invalidPin('INVALID_PIN'), + + /// Specifies the PUK is invalid. invalidPuk('INVALID_PUK'), + + /// Specifies the maximum attempt number has been exceeded. maxAttemptsExceeded('MAX_ATTEMPTS_EXCEEDED'), + + /// Specifies that the error cannot be represented by the above types. unknownError('UNKNOWN_ERROR'); const PinRequestErrorType(this.value); diff --git a/lib/commands.dart b/lib/commands.dart index e9d4eda..016400d 100644 --- a/lib/commands.dart +++ b/lib/commands.dart @@ -25,7 +25,8 @@ class ChromeCommands { bool get isAvailable => $js.chrome.commandsNullable != null && alwaysTrue; /// Returns all the registered extension commands for this extension and their - /// shortcut (if active). + /// shortcut (if active). Before Chrome 110, this command did not return + /// `_execute_action`. /// [returns] Called to return the registered commands. Future> getAll() async { var $res = await promiseToFuture($js.chrome.commands.getAll()); diff --git a/lib/content_settings.dart b/lib/content_settings.dart index e0c7998..cb5df25 100644 --- a/lib/content_settings.dart +++ b/lib/content_settings.dart @@ -122,6 +122,20 @@ class ChromeContentSettings { ContentSetting get microphone => ContentSetting.fromJS($js.chrome.contentSettings.microphone); + /// Whether to allow sites to access the clipboard via advanced capabilities + /// of the Async Clipboard API. "Advanced" capabilities include anything + /// besides writing built-in formats after a user gesture, i.e. the ability to + /// read, the ability to write custom formats, and the ability to write + /// without a user gesture. One of + /// [allow]: Allow sites to use advanced clipboard capabilities, + /// [block]: Don't allow sites to use advanced clipboard capabilties, + /// [ask]: Ask when a site wants to use advanced clipboard capabilities. + /// Default is [ask]. + /// The primary URL is the URL of the document which requested clipboard + /// access. The secondary URL is not used. + ContentSetting get clipboard => + ContentSetting.fromJS($js.chrome.contentSettings.clipboard); + /// Whether to allow sites to access the camera. One of /// [allow]: Allow sites to access the camera, /// [block]: Don't allow sites to access the camera, @@ -184,6 +198,20 @@ enum AutoVerifyContentSetting { values.firstWhere((e) => e.value == value); } +enum ClipboardContentSetting { + allow('allow'), + block('block'), + ask('ask'); + + const ClipboardContentSetting(this.value); + + final String value; + + String get toJS => value; + static ClipboardContentSetting fromJS(String value) => + values.firstWhere((e) => e.value == value); +} + enum CookiesContentSetting { allow('allow'), block('block'), diff --git a/lib/context_menus.dart b/lib/context_menus.dart index c9b8f96..1e28cf6 100644 --- a/lib/context_menus.dart +++ b/lib/context_menus.dart @@ -386,9 +386,9 @@ class CreateProperties { /// Whether the item is visible in the menu. bool? visible, - /// A function that is called back when the menu item is clicked. Event - /// pages cannot use this; instead, they should register a listener for - /// [contextMenus.onClicked]. + /// A function that is called back when the menu item is clicked. This is + /// not available inside of a service worker; instead, they should register + /// a listener for [contextMenus.onClicked]. JSFunction? onclick, /// The ID of a parent menu item; this makes the item a child of a @@ -397,7 +397,7 @@ class CreateProperties { /// Restricts the item to apply only to documents or frames whose URL /// matches one of the given patterns. For details on pattern formats, see - /// [Match Patterns](match_patterns). + /// [Match Patterns](/docs/extensions/develop/concepts/match-patterns). List? documentUrlPatterns, /// Similar to `documentUrlPatterns`, filters based on the `src` attribute @@ -484,9 +484,9 @@ class CreateProperties { _wrapped.visible = v; } - /// A function that is called back when the menu item is clicked. Event pages - /// cannot use this; instead, they should register a listener for - /// [contextMenus.onClicked]. + /// A function that is called back when the menu item is clicked. This is not + /// available inside of a service worker; instead, they should register a + /// listener for [contextMenus.onClicked]. JSFunction? get onclick => _wrapped.onclick; set onclick(JSFunction? v) { @@ -512,7 +512,7 @@ class CreateProperties { /// Restricts the item to apply only to documents or frames whose URL matches /// one of the given patterns. For details on pattern formats, see [Match - /// Patterns](match_patterns). + /// Patterns](/docs/extensions/develop/concepts/match-patterns). List? get documentUrlPatterns => _wrapped.documentUrlPatterns?.toDart .cast() .map((e) => e) diff --git a/lib/cookies.dart b/lib/cookies.dart index 0ae432a..bb04a8b 100644 --- a/lib/cookies.dart +++ b/lib/cookies.dart @@ -32,9 +32,10 @@ class ChromeCookies { } /// Retrieves all cookies from a single cookie store that match the given - /// information. The cookies returned will be sorted, with those with the - /// longest path first. If multiple cookies have the same path length, those - /// with the earliest creation time will be first. + /// information. The cookies returned will be sorted, with those with the + /// longest path first. If multiple cookies have the same path length, those + /// with the earliest creation time will be first. This method only retrieves + /// cookies for domains that the extension has host permissions to. /// [details] Information to filter the cookies being retrieved. Future> getAll(GetAllDetails details) async { var $res = @@ -125,6 +126,27 @@ enum OnChangedCause { values.firstWhere((e) => e.value == value); } +class CookiePartitionKey { + CookiePartitionKey.fromJS(this._wrapped); + + CookiePartitionKey( + { + /// The top-level site the partitioned cookie is available in. + String? topLevelSite}) + : _wrapped = $js.CookiePartitionKey(topLevelSite: topLevelSite); + + final $js.CookiePartitionKey _wrapped; + + $js.CookiePartitionKey get toJS => _wrapped; + + /// The top-level site the partitioned cookie is available in. + String? get topLevelSite => _wrapped.topLevelSite; + + set topLevelSite(String? v) { + _wrapped.topLevelSite = v; + } +} + class Cookie { Cookie.fromJS(this._wrapped); @@ -168,6 +190,10 @@ class Cookie { /// The ID of the cookie store containing this cookie, as provided in /// getAllCookieStores(). required String storeId, + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + CookiePartitionKey? partitionKey, }) : _wrapped = $js.Cookie( name: name, value: value, @@ -180,6 +206,7 @@ class Cookie { session: session, expirationDate: expirationDate, storeId: storeId, + partitionKey: partitionKey?.toJS, ); final $js.Cookie _wrapped; @@ -269,6 +296,15 @@ class Cookie { set storeId(String v) { _wrapped.storeId = v; } + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + CookiePartitionKey? get partitionKey => + _wrapped.partitionKey?.let(CookiePartitionKey.fromJS); + + set partitionKey(CookiePartitionKey? v) { + _wrapped.partitionKey = v?.toJS; + } } class CookieStore { @@ -321,10 +357,15 @@ class CookieDetails { /// The ID of the cookie store in which to look for the cookie. By default, /// the current execution context's cookie store will be used. String? storeId, + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + CookiePartitionKey? partitionKey, }) : _wrapped = $js.CookieDetails( url: url, name: name, storeId: storeId, + partitionKey: partitionKey?.toJS, ); final $js.CookieDetails _wrapped; @@ -355,6 +396,15 @@ class CookieDetails { set storeId(String? v) { _wrapped.storeId = v; } + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + CookiePartitionKey? get partitionKey => + _wrapped.partitionKey?.let(CookiePartitionKey.fromJS); + + set partitionKey(CookiePartitionKey? v) { + _wrapped.partitionKey = v?.toJS; + } } class OnChangedChangeInfo { @@ -428,6 +478,10 @@ class GetAllDetails { /// The cookie store to retrieve cookies from. If omitted, the current /// execution context's cookie store will be used. String? storeId, + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + CookiePartitionKey? partitionKey, }) : _wrapped = $js.GetAllDetails( url: url, name: name, @@ -436,6 +490,7 @@ class GetAllDetails { secure: secure, session: session, storeId: storeId, + partitionKey: partitionKey?.toJS, ); final $js.GetAllDetails _wrapped; @@ -493,6 +548,15 @@ class GetAllDetails { set storeId(String? v) { _wrapped.storeId = v; } + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + CookiePartitionKey? get partitionKey => + _wrapped.partitionKey?.let(CookiePartitionKey.fromJS); + + set partitionKey(CookiePartitionKey? v) { + _wrapped.partitionKey = v?.toJS; + } } class SetDetails { @@ -536,6 +600,10 @@ class SetDetails { /// The ID of the cookie store in which to set the cookie. By default, the /// cookie is set in the current execution context's cookie store. String? storeId, + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + CookiePartitionKey? partitionKey, }) : _wrapped = $js.SetDetails( url: url, name: name, @@ -547,6 +615,7 @@ class SetDetails { sameSite: sameSite?.toJS, expirationDate: expirationDate, storeId: storeId, + partitionKey: partitionKey?.toJS, ); final $js.SetDetails _wrapped; @@ -629,6 +698,15 @@ class SetDetails { set storeId(String? v) { _wrapped.storeId = v; } + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + CookiePartitionKey? get partitionKey => + _wrapped.partitionKey?.let(CookiePartitionKey.fromJS); + + set partitionKey(CookiePartitionKey? v) { + _wrapped.partitionKey = v?.toJS; + } } class RemoveCallbackDetails { @@ -643,10 +721,15 @@ class RemoveCallbackDetails { /// The ID of the cookie store from which the cookie was removed. required String storeId, + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + CookiePartitionKey? partitionKey, }) : _wrapped = $js.RemoveCallbackDetails( url: url, name: name, storeId: storeId, + partitionKey: partitionKey?.toJS, ); final $js.RemoveCallbackDetails _wrapped; @@ -673,4 +756,13 @@ class RemoveCallbackDetails { set storeId(String v) { _wrapped.storeId = v; } + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + CookiePartitionKey? get partitionKey => + _wrapped.partitionKey?.let(CookiePartitionKey.fromJS); + + set partitionKey(CookiePartitionKey? v) { + _wrapped.partitionKey = v?.toJS; + } } diff --git a/lib/declarative_content.dart b/lib/declarative_content.dart index fcc5453..93b0315 100644 --- a/lib/declarative_content.dart +++ b/lib/declarative_content.dart @@ -111,7 +111,8 @@ class PageStateMatcher { List? css, /// Matches if the bookmarked state of the page is equal to the specified - /// value. Requres the [bookmarks permission](declare_permissions). + /// value. Requres the [bookmarks + /// permission](/docs/extensions/develop/concepts/declare-permissions). bool? isBookmarked, required PageStateMatcherInstanceType instanceType, }) : _wrapped = $js.PageStateMatcher( @@ -147,7 +148,8 @@ class PageStateMatcher { } /// Matches if the bookmarked state of the page is equal to the specified - /// value. Requres the [bookmarks permission](declare_permissions). + /// value. Requres the [bookmarks + /// permission](/docs/extensions/develop/concepts/declare-permissions). bool? get isBookmarked => _wrapped.isBookmarked; set isBookmarked(bool? v) { diff --git a/lib/declarative_net_request.dart b/lib/declarative_net_request.dart index 81968aa..5f8e3ca 100644 --- a/lib/declarative_net_request.dart +++ b/lib/declarative_net_request.dart @@ -212,15 +212,28 @@ class ChromeDeclarativeNetRequest { int get guaranteedMinimumStaticRules => $js.chrome.declarativeNetRequest.GUARANTEED_MINIMUM_STATIC_RULES; - /// The maximum number of dynamic rules that an extension can add. - int get maxNumberOfDynamicRules => - $js.chrome.declarativeNetRequest.MAX_NUMBER_OF_DYNAMIC_RULES; - /// The maximum number of combined dynamic and session scoped rules an /// extension can add. int get maxNumberOfDynamicAndSessionRules => $js.chrome.declarativeNetRequest.MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES; + /// The maximum number of dynamic rules that an extension can add. + int get maxNumberOfDynamicRules => + $js.chrome.declarativeNetRequest.MAX_NUMBER_OF_DYNAMIC_RULES; + + /// The maximum number of "unsafe" dynamic rules that an extension can add. + int get maxNumberOfUnsafeDynamicRules => + $js.chrome.declarativeNetRequest.MAX_NUMBER_OF_UNSAFE_DYNAMIC_RULES; + + /// The maximum number of session scoped rules that an extension can add. + int get maxNumberOfSessionRules => + $js.chrome.declarativeNetRequest.MAX_NUMBER_OF_SESSION_RULES; + + /// The maximum number of "unsafe" session scoped rules that an extension can + /// add. + int get maxNumberOfUnsafeSessionRules => + $js.chrome.declarativeNetRequest.MAX_NUMBER_OF_UNSAFE_SESSION_RULES; + /// Time interval within which `MAX_GETMATCHEDRULES_CALLS_PER_INTERVAL /// getMatchedRules` calls can be made, specified in minutes. /// Additional calls will fail immediately and set [runtime.lastError]. @@ -715,6 +728,57 @@ class Redirect { } } +class HeaderInfo { + HeaderInfo.fromJS(this._wrapped); + + HeaderInfo({ + /// The name of the header. + required String header, + + /// If specified, match this rule if the header's value contains at least + /// one + /// element in this list. + List? values, + + /// If specified, the rule is not matched if the header exists but its value + /// contains at least one element in this list. + List? excludedValues, + }) : _wrapped = $js.HeaderInfo( + header: header, + values: values?.toJSArray((e) => e), + excludedValues: excludedValues?.toJSArray((e) => e), + ); + + final $js.HeaderInfo _wrapped; + + $js.HeaderInfo get toJS => _wrapped; + + /// The name of the header. + String get header => _wrapped.header; + + set header(String v) { + _wrapped.header = v; + } + + /// If specified, match this rule if the header's value contains at least one + /// element in this list. + List? get values => + _wrapped.values?.toDart.cast().map((e) => e).toList(); + + set values(List? v) { + _wrapped.values = v?.toJSArray((e) => e); + } + + /// If specified, the rule is not matched if the header exists but its value + /// contains at least one element in this list. + List? get excludedValues => + _wrapped.excludedValues?.toDart.cast().map((e) => e).toList(); + + set excludedValues(List? v) { + _wrapped.excludedValues = v?.toJSArray((e) => e); + } +} + class RuleCondition { RuleCondition.fromJS(this._wrapped); @@ -771,7 +835,7 @@ class RuleCondition { String? regexFilter, /// Whether the `urlFilter` or `regexFilter` - /// (whichever is specified) is case sensitive. Default is true. + /// (whichever is specified) is case sensitive. Default is false. bool? isUrlFilterCaseSensitive, /// The rule will only match network requests originating from the list of @@ -887,6 +951,15 @@ class RuleCondition { /// [tabs.TAB_ID_NONE] excludes requests which don't originate from a /// tab. Only supported for session-scoped rules. List? excludedTabIds, + + /// Rule matches if the request matches any response header in this list (if + /// specified). + /// TODO(crbug,com/1141166): Add documentation once feature is complete. + List? responseHeaders, + + /// Rule does not match if the request has any of the specified headers. + /// TODO(crbug,com/1141166): Add documentation once feature is complete. + List? excludedResponseHeaders, }) : _wrapped = $js.RuleCondition( urlFilter: urlFilter, regexFilter: regexFilter, @@ -907,6 +980,8 @@ class RuleCondition { domainType: domainType?.toJS, tabIds: tabIds?.toJSArray((e) => e), excludedTabIds: excludedTabIds?.toJSArray((e) => e), + responseHeaders: responseHeaders?.toJSArray((e) => e.toJS), + excludedResponseHeaders: excludedResponseHeaders?.toJSArray((e) => e), ); final $js.RuleCondition _wrapped; @@ -970,7 +1045,7 @@ class RuleCondition { } /// Whether the `urlFilter` or `regexFilter` - /// (whichever is specified) is case sensitive. Default is true. + /// (whichever is specified) is case sensitive. Default is false. bool? get isUrlFilterCaseSensitive => _wrapped.isUrlFilterCaseSensitive; set isUrlFilterCaseSensitive(bool? v) { @@ -1169,6 +1244,30 @@ class RuleCondition { set excludedTabIds(List? v) { _wrapped.excludedTabIds = v?.toJSArray((e) => e); } + + /// Rule matches if the request matches any response header in this list (if + /// specified). + /// TODO(crbug,com/1141166): Add documentation once feature is complete. + List? get responseHeaders => _wrapped.responseHeaders?.toDart + .cast<$js.HeaderInfo>() + .map((e) => HeaderInfo.fromJS(e)) + .toList(); + + set responseHeaders(List? v) { + _wrapped.responseHeaders = v?.toJSArray((e) => e.toJS); + } + + /// Rule does not match if the request has any of the specified headers. + /// TODO(crbug,com/1141166): Add documentation once feature is complete. + List? get excludedResponseHeaders => + _wrapped.excludedResponseHeaders?.toDart + .cast() + .map((e) => e) + .toList(); + + set excludedResponseHeaders(List? v) { + _wrapped.excludedResponseHeaders = v?.toJSArray((e) => e); + } } class ModifyHeaderInfo { diff --git a/lib/document_scan.dart b/lib/document_scan.dart index 094646d..74b919a 100644 --- a/lib/document_scan.dart +++ b/lib/document_scan.dart @@ -3,6 +3,7 @@ library; import 'dart:js_util'; +import 'dart:typed_data'; import 'src/internal_helpers.dart'; import 'src/js/document_scan.dart' as $js; @@ -30,6 +31,336 @@ class ChromeDocumentScan { $js.chrome.documentScan.scan(options.toJS)); return ScanResults.fromJS($res); } + + /// Gets the list of available scanners. On success, the list will be + /// sent to the callback. + /// |filter| : `DeviceFilter` indicating which types of scanners + /// should be returned. + /// |callback| : Called with the result and list of scanners. + Future getScannerList(DeviceFilter filter) async { + var $res = await promiseToFuture<$js.GetScannerListResponse>( + $js.chrome.documentScan.getScannerList(filter.toJS)); + return GetScannerListResponse.fromJS($res); + } + + /// Opens a scanner for exclusive access. On success, the response containing + /// a scanner handle and configuration will be sent to the callback. + /// |scannerId| : Scanner id previously returned from `getScannerList` + /// indicating which scanner should be opened. + /// |callback| : Called with the result. + Future openScanner(String scannerId) async { + var $res = await promiseToFuture<$js.OpenScannerResponse>( + $js.chrome.documentScan.openScanner(scannerId)); + return OpenScannerResponse.fromJS($res); + } + + /// Gets the group names and member options from a scanner handle previously + /// opened by `openScanner`. + /// |scannerHandle| : Open scanner handle previously returned from + /// `openScanner`. + /// |callback| : Called with the result. + Future getOptionGroups(String scannerHandle) async { + var $res = await promiseToFuture<$js.GetOptionGroupsResponse>( + $js.chrome.documentScan.getOptionGroups(scannerHandle)); + return GetOptionGroupsResponse.fromJS($res); + } + + /// Closes a previously opened scanner handle. A response indicating the + /// outcome will be sent to the callback. Even if the response is not a + /// success, the supplied handle will become invalid and should not be used + /// for further operations. + /// |scannerHandle| : Open scanner handle previously returned from + /// `openScanner`. + /// |callback| : Called with the result. + Future closeScanner(String scannerHandle) async { + var $res = await promiseToFuture<$js.CloseScannerResponse>( + $js.chrome.documentScan.closeScanner(scannerHandle)); + return CloseScannerResponse.fromJS($res); + } + + /// Sends the list of new option values in `options` as a bundle + /// to be set on `scannerHandle`. Each option will be set by the + /// backend the order specified. Returns a backend response indicating the + /// result of each option setting and a new set of final option values after + /// all options have been updated. + /// |scannerHandle| : Open scanner handle previously returned from + /// `openScanner`. + /// |options| : A list of `OptionSetting`s that will be applied to + /// `scannerHandle`. + /// |callback| : Called with the result. + Future setOptions( + String scannerHandle, + List options, + ) async { + var $res = await promiseToFuture<$js.SetOptionsResponse>( + $js.chrome.documentScan.setOptions( + scannerHandle, + options.toJSArray((e) => e.toJS), + )); + return SetOptionsResponse.fromJS($res); + } + + /// Starts a scan using a previously opened scanner handle. A response + /// indicating the outcome will be sent to the callback. If successful, the + /// response will include a job handle that can be used in subsequent calls + /// to read scan data or cancel a scan. + /// |scannerHandle| : Open scanner handle previously returned from + /// `openScanner`. + /// |options| : `StartScanOptions` indicating what options are to + /// be used for the scan. `StartScanOptions.format` must match + /// one of the entries returned in the scanner's `ScannerInfo`. + /// |callback| : Called with the result. + Future startScan( + String scannerHandle, + StartScanOptions options, + ) async { + var $res = await promiseToFuture<$js.StartScanResponse>( + $js.chrome.documentScan.startScan( + scannerHandle, + options.toJS, + )); + return StartScanResponse.fromJS($res); + } + + /// Cancels a scan that was previously started using `startScan`. + /// The response is sent to the callback. + /// |job| : An active scan job previously returned from + /// `startScan`. + /// |callback| : Called with the result. + Future cancelScan(String job) async { + var $res = await promiseToFuture<$js.CancelScanResponse>( + $js.chrome.documentScan.cancelScan(job)); + return CancelScanResponse.fromJS($res); + } + + /// Reads the next chunk of available image data from an active job handle. + /// A response indicating the outcome will be sent to the callback. + /// + /// It is valid for a response to have result + /// `OperationResult.SUCCESS` with a zero-length + /// `data` member. This means the scanner is still working but + /// does not yet have additional data ready. The caller should wait a short + /// time and try again. + /// + /// When the scan job completes, the response will have the result + /// `OperationResult.EOF`. This response may contain a final + /// non-zero `data` member. + /// |job| : Active job handle previously returned from + /// `startScan`. + /// |callback| : Called with the result. + Future readScanData(String job) async { + var $res = await promiseToFuture<$js.ReadScanDataResponse>( + $js.chrome.documentScan.readScanData(job)); + return ReadScanDataResponse.fromJS($res); + } +} + +/// OperationResult is an enum that indicates the result of each operation +/// performed by the backend. It contains the same causes as SANE_Status plus +/// additional statuses that come from the IPC layers and image conversion +/// stages. +enum OperationResult { + /// An unknown or generic failure occurred. + unknown('UNKNOWN'), + + /// Operation succeeded. + success('SUCCESS'), + + /// The operation is not supported. + unsupported('UNSUPPORTED'), + + /// The operation was cancelled. + cancelled('CANCELLED'), + + /// The device is busy. + deviceBusy('DEVICE_BUSY'), + + /// Data or argument is invalid. + invalid('INVALID'), + + /// Value is the wrong type for the underlying option. + wrongType('WRONG_TYPE'), + + /// No more data is available. + eof('EOF'), + + /// The document feeder is jammed. + adfJammed('ADF_JAMMED'), + + /// The document feeder is empty. + adfEmpty('ADF_EMPTY'), + + /// The flatbed cover is open. + coverOpen('COVER_OPEN'), + + /// An error occurred while communicating with the device. + ioError('IO_ERROR'), + + /// The device requires authentication. + accessDenied('ACCESS_DENIED'), + + /// Not enough memory was available to complete the operation. + noMemory('NO_MEMORY'), + + /// The device was not reachable. + unreachable('UNREACHABLE'), + + /// The device was disconnected. + missing('MISSING'), + + /// An internal error occurred. + internalError('INTERNAL_ERROR'); + + const OperationResult(this.value); + + final String value; + + String get toJS => value; + static OperationResult fromJS(String value) => + values.firstWhere((e) => e.value == value); +} + +/// How the scanner is connected to the computer. +enum ConnectionType { + unspecified('UNSPECIFIED'), + usb('USB'), + network('NETWORK'); + + const ConnectionType(this.value); + + final String value; + + String get toJS => value; + static ConnectionType fromJS(String value) => + values.firstWhere((e) => e.value == value); +} + +/// The type of an option. This is the same set of types as SANE_Value_Type. +enum OptionType { + /// Unknown option type. `value` will be unset. + unknown('UNKNOWN'), + + /// true/false only. `value` will be a boolean. + bool('BOOL'), + + /// Signed 32-bit integer. `value` will be long or long[], + /// depending on whether the option takes more than one value. + int('INT'), + + /// Double in the range -32768-32767.9999 with a resolution of 1/65535. + /// `value` will be double or double[] depending on whether the + /// option takes more than one value. + fixed('FIXED'), + + /// A sequence of any bytes except NUL ('\0'). `value` will be a + /// DOMString. + string('STRING'), + + /// Hardware button or toggle. No value. + button('BUTTON'), + + /// Grouping option. No value. This is included for compatibility, but + /// will not normally be returned in `ScannerOption` values. Use + /// `getOptionGroups()` to retrieve the list of groups with their + /// member options. + group('GROUP'); + + const OptionType(this.value); + + final String value; + + String get toJS => value; + static OptionType fromJS(String value) => + values.firstWhere((e) => e.value == value); +} + +/// The unit of measurement for an option. This is the same set of units as +/// SANE_Unit. +enum OptionUnit { + /// Value is a unitless number, e.g. threshold. + unitless('UNITLESS'), + + /// Value is a number of pixels, e.g., scan dimensions. + pixel('PIXEL'), + + /// Value is the number of bits, e.g., color depth. + bit('BIT'), + + /// Value is measured in millimeters, e.g., scan dimensions. + mm('MM'), + + /// Value is measured in dots per inch, e.g., resolution. + dpi('DPI'), + + /// Value is a percent, e.g., brightness. + percent('PERCENT'), + + /// Value is measured in microseconds, e.g., exposure time. + microsecond('MICROSECOND'); + + const OptionUnit(this.value); + + final String value; + + String get toJS => value; + static OptionUnit fromJS(String value) => + values.firstWhere((e) => e.value == value); +} + +/// The type of constraint represented by an OptionConstraint. +enum ConstraintType { + /// Constraint represents a range of `OptionType.INT` values. + /// `min`, `max`, and `quant` will be + /// `long`, and `list` will be unset. + intRange('INT_RANGE'), + + /// Constraint represents a range of `OptionType.FIXED` values. + /// `min`, `max`, and `quant` will be + /// `double`, and `list` will be unset. + fixedRange('FIXED_RANGE'), + + /// Constraint represents a specific list of `OptionType.INT` + /// values. `list` will contain `long` values, and + /// the other fields will be unset. + intList('INT_LIST'), + + /// Constraint represents a specific list of `OptionType.FIXED` + /// values. `list` will contain `double` values, and + /// the other fields will be unset. + fixedList('FIXED_LIST'), + + /// Constraint represents a specific list of `OptionType.STRING` + /// values. `list` will contain `DOMString` values, + /// and the other fields will be unset. + stringList('STRING_LIST'); + + const ConstraintType(this.value); + + final String value; + + String get toJS => value; + static ConstraintType fromJS(String value) => + values.firstWhere((e) => e.value == value); +} + +/// How an option can be changed. +enum Configurability { + /// Option is read-only and cannot be changed. + notConfigurable('NOT_CONFIGURABLE'), + + /// Option can be set in software. + softwareConfigurable('SOFTWARE_CONFIGURABLE'), + + /// Option can be set by the user toggling/pushing a hardware button. + hardwareConfigurable('HARDWARE_CONFIGURABLE'); + + const Configurability(this.value); + + final String value; + + String get toJS => value; + static Configurability fromJS(String value) => + values.firstWhere((e) => e.value == value); } class ScanOptions { @@ -101,3 +432,1013 @@ class ScanResults { _wrapped.mimeType = v; } } + +class ScannerInfo { + ScannerInfo.fromJS(this._wrapped); + + ScannerInfo({ + /// For connecting with `openScanner`. + required String scannerId, + + /// Printable name for displaying in the UI. + required String name, + + /// Scanner manufacturer. + required String manufacturer, + + /// Scanner model if available, or a generic description. + required String model, + + /// For matching against other `ScannerInfo` entries that point + /// to the same physical device. + required String deviceUuid, + + /// How the scanner is connected to the computer. + required ConnectionType connectionType, + + /// If true, the scanner connection's transport cannot be intercepted by a + /// passive listener, such as TLS or USB. + required bool secure, + + /// MIME types that can be requested for returned scans. + required List imageFormats, + }) : _wrapped = $js.ScannerInfo( + scannerId: scannerId, + name: name, + manufacturer: manufacturer, + model: model, + deviceUuid: deviceUuid, + connectionType: connectionType.toJS, + secure: secure, + imageFormats: imageFormats.toJSArray((e) => e), + ); + + final $js.ScannerInfo _wrapped; + + $js.ScannerInfo get toJS => _wrapped; + + /// For connecting with `openScanner`. + String get scannerId => _wrapped.scannerId; + + set scannerId(String v) { + _wrapped.scannerId = v; + } + + /// Printable name for displaying in the UI. + String get name => _wrapped.name; + + set name(String v) { + _wrapped.name = v; + } + + /// Scanner manufacturer. + String get manufacturer => _wrapped.manufacturer; + + set manufacturer(String v) { + _wrapped.manufacturer = v; + } + + /// Scanner model if available, or a generic description. + String get model => _wrapped.model; + + set model(String v) { + _wrapped.model = v; + } + + /// For matching against other `ScannerInfo` entries that point + /// to the same physical device. + String get deviceUuid => _wrapped.deviceUuid; + + set deviceUuid(String v) { + _wrapped.deviceUuid = v; + } + + /// How the scanner is connected to the computer. + ConnectionType get connectionType => + ConnectionType.fromJS(_wrapped.connectionType); + + set connectionType(ConnectionType v) { + _wrapped.connectionType = v.toJS; + } + + /// If true, the scanner connection's transport cannot be intercepted by a + /// passive listener, such as TLS or USB. + bool get secure => _wrapped.secure; + + set secure(bool v) { + _wrapped.secure = v; + } + + /// MIME types that can be requested for returned scans. + List get imageFormats => + _wrapped.imageFormats.toDart.cast().map((e) => e).toList(); + + set imageFormats(List v) { + _wrapped.imageFormats = v.toJSArray((e) => e); + } +} + +class OptionConstraint { + OptionConstraint.fromJS(this._wrapped); + + OptionConstraint({ + required ConstraintType type, + Object? min, + Object? max, + Object? quant, + Object? list, + }) : _wrapped = $js.OptionConstraint( + type: type.toJS, + min: switch (min) { + int() => min.jsify()!, + double() => min.jsify()!, + null => null, + _ => throw UnsupportedError( + 'Received type: ${min.runtimeType}. Supported types are: int, double') + }, + max: switch (max) { + int() => max.jsify()!, + double() => max.jsify()!, + null => null, + _ => throw UnsupportedError( + 'Received type: ${max.runtimeType}. Supported types are: int, double') + }, + quant: switch (quant) { + int() => quant.jsify()!, + double() => quant.jsify()!, + null => null, + _ => throw UnsupportedError( + 'Received type: ${quant.runtimeType}. Supported types are: int, double') + }, + list: switch (list) { + List() => list.toJSArray((e) => e), + List() => list.toJSArray((e) => e), + List() => list.toJSArrayString(), + null => null, + _ => throw UnsupportedError( + 'Received type: ${list.runtimeType}. Supported types are: List, List, List') + }, + ); + + final $js.OptionConstraint _wrapped; + + $js.OptionConstraint get toJS => _wrapped; + + ConstraintType get type => ConstraintType.fromJS(_wrapped.type); + + set type(ConstraintType v) { + _wrapped.type = v.toJS; + } + + Object? get min => _wrapped.min?.when( + isInt: (v) => v, + isDouble: (v) => v, + ); + + set min(Object? v) { + _wrapped.min = switch (v) { + int() => v.jsify()!, + double() => v.jsify()!, + null => null, + _ => throw UnsupportedError( + 'Received type: ${v.runtimeType}. Supported types are: int, double') + }; + } + + Object? get max => _wrapped.max?.when( + isInt: (v) => v, + isDouble: (v) => v, + ); + + set max(Object? v) { + _wrapped.max = switch (v) { + int() => v.jsify()!, + double() => v.jsify()!, + null => null, + _ => throw UnsupportedError( + 'Received type: ${v.runtimeType}. Supported types are: int, double') + }; + } + + Object? get quant => _wrapped.quant?.when( + isInt: (v) => v, + isDouble: (v) => v, + ); + + set quant(Object? v) { + _wrapped.quant = switch (v) { + int() => v.jsify()!, + double() => v.jsify()!, + null => null, + _ => throw UnsupportedError( + 'Received type: ${v.runtimeType}. Supported types are: int, double') + }; + } + + Object? get list => _wrapped.list?.when( + isArray: (v) => v.toDart.cast().map((e) => e).toList(), + ); + + set list(Object? v) { + _wrapped.list = switch (v) { + List() => v.toJSArray((e) => e), + List() => v.toJSArray((e) => e), + List() => v.toJSArrayString(), + null => null, + _ => throw UnsupportedError( + 'Received type: ${v.runtimeType}. Supported types are: List, List, List') + }; + } +} + +class ScannerOption { + ScannerOption.fromJS(this._wrapped); + + ScannerOption({ + /// Option name using lowercase a-z, numbers, and dashes. + required String name, + + /// Printable one-line title. + required String title, + + /// Longer description of the option. + required String description, + + /// The type that `value` will contain and that is needed for + /// setting this option. + required OptionType type, + + /// Unit of measurement for this option. + required OptionUnit unit, + + /// Current value of the option if relevant. Note the type passed here must + /// match the type specified in `type`. + Object? value, + + /// Constraint on possible values. + OptionConstraint? constraint, + + /// Can be detected from software. + required bool isDetectable, + + /// Whether/how the option can be changed. + required Configurability configurability, + + /// Can be automatically set by the backend. + required bool isAutoSettable, + + /// Emulated by the backend if true. + required bool isEmulated, + + /// Option is active and can be set/retrieved. If false, the + /// `value` field will not be set. + required bool isActive, + + /// UI should not display this option by default. + required bool isAdvanced, + + /// Option is used for internal configuration and should never be displayed + /// in the UI. + required bool isInternal, + }) : _wrapped = $js.ScannerOption( + name: name, + title: title, + description: description, + type: type.toJS, + unit: unit.toJS, + value: switch (value) { + bool() => value.jsify()!, + double() => value.jsify()!, + List() => value.toJSArray((e) => e), + int() => value.jsify()!, + List() => value.toJSArray((e) => e), + String() => value.jsify()!, + null => null, + _ => throw UnsupportedError( + 'Received type: ${value.runtimeType}. Supported types are: bool, double, List, int, List, String') + }, + constraint: constraint?.toJS, + isDetectable: isDetectable, + configurability: configurability.toJS, + isAutoSettable: isAutoSettable, + isEmulated: isEmulated, + isActive: isActive, + isAdvanced: isAdvanced, + isInternal: isInternal, + ); + + final $js.ScannerOption _wrapped; + + $js.ScannerOption get toJS => _wrapped; + + /// Option name using lowercase a-z, numbers, and dashes. + String get name => _wrapped.name; + + set name(String v) { + _wrapped.name = v; + } + + /// Printable one-line title. + String get title => _wrapped.title; + + set title(String v) { + _wrapped.title = v; + } + + /// Longer description of the option. + String get description => _wrapped.description; + + set description(String v) { + _wrapped.description = v; + } + + /// The type that `value` will contain and that is needed for + /// setting this option. + OptionType get type => OptionType.fromJS(_wrapped.type); + + set type(OptionType v) { + _wrapped.type = v.toJS; + } + + /// Unit of measurement for this option. + OptionUnit get unit => OptionUnit.fromJS(_wrapped.unit); + + set unit(OptionUnit v) { + _wrapped.unit = v.toJS; + } + + /// Current value of the option if relevant. Note the type passed here must + /// match the type specified in `type`. + Object? get value => _wrapped.value?.when( + isBool: (v) => v, + isDouble: (v) => v, + isArray: (v) => v.toDart.cast().map((e) => e).toList(), + isInt: (v) => v, + isString: (v) => v, + ); + + set value(Object? v) { + _wrapped.value = switch (v) { + bool() => v.jsify()!, + double() => v.jsify()!, + List() => v.toJSArray((e) => e), + int() => v.jsify()!, + List() => v.toJSArray((e) => e), + String() => v.jsify()!, + null => null, + _ => throw UnsupportedError( + 'Received type: ${v.runtimeType}. Supported types are: bool, double, List, int, List, String') + }; + } + + /// Constraint on possible values. + OptionConstraint? get constraint => + _wrapped.constraint?.let(OptionConstraint.fromJS); + + set constraint(OptionConstraint? v) { + _wrapped.constraint = v?.toJS; + } + + /// Can be detected from software. + bool get isDetectable => _wrapped.isDetectable; + + set isDetectable(bool v) { + _wrapped.isDetectable = v; + } + + /// Whether/how the option can be changed. + Configurability get configurability => + Configurability.fromJS(_wrapped.configurability); + + set configurability(Configurability v) { + _wrapped.configurability = v.toJS; + } + + /// Can be automatically set by the backend. + bool get isAutoSettable => _wrapped.isAutoSettable; + + set isAutoSettable(bool v) { + _wrapped.isAutoSettable = v; + } + + /// Emulated by the backend if true. + bool get isEmulated => _wrapped.isEmulated; + + set isEmulated(bool v) { + _wrapped.isEmulated = v; + } + + /// Option is active and can be set/retrieved. If false, the + /// `value` field will not be set. + bool get isActive => _wrapped.isActive; + + set isActive(bool v) { + _wrapped.isActive = v; + } + + /// UI should not display this option by default. + bool get isAdvanced => _wrapped.isAdvanced; + + set isAdvanced(bool v) { + _wrapped.isAdvanced = v; + } + + /// Option is used for internal configuration and should never be displayed + /// in the UI. + bool get isInternal => _wrapped.isInternal; + + set isInternal(bool v) { + _wrapped.isInternal = v; + } +} + +class DeviceFilter { + DeviceFilter.fromJS(this._wrapped); + + DeviceFilter({ + /// Only return scanners that are directly attached to the computer. + bool? local, + + /// Only return scanners that use a secure transport, such as USB or TLS. + bool? secure, + }) : _wrapped = $js.DeviceFilter( + local: local, + secure: secure, + ); + + final $js.DeviceFilter _wrapped; + + $js.DeviceFilter get toJS => _wrapped; + + /// Only return scanners that are directly attached to the computer. + bool? get local => _wrapped.local; + + set local(bool? v) { + _wrapped.local = v; + } + + /// Only return scanners that use a secure transport, such as USB or TLS. + bool? get secure => _wrapped.secure; + + set secure(bool? v) { + _wrapped.secure = v; + } +} + +class OptionGroup { + OptionGroup.fromJS(this._wrapped); + + OptionGroup({ + /// Printable title, e.g. "Geometry options". + required String title, + + /// Names of contained options, in backend-provided order. + required List members, + }) : _wrapped = $js.OptionGroup( + title: title, + members: members.toJSArray((e) => e), + ); + + final $js.OptionGroup _wrapped; + + $js.OptionGroup get toJS => _wrapped; + + /// Printable title, e.g. "Geometry options". + String get title => _wrapped.title; + + set title(String v) { + _wrapped.title = v; + } + + /// Names of contained options, in backend-provided order. + List get members => + _wrapped.members.toDart.cast().map((e) => e).toList(); + + set members(List v) { + _wrapped.members = v.toJSArray((e) => e); + } +} + +class GetScannerListResponse { + GetScannerListResponse.fromJS(this._wrapped); + + GetScannerListResponse({ + /// The backend's enumeration result. Note that partial results could be + /// returned even if this indicates an error. + required OperationResult result, + + /// A possibly-empty list of scanners that match the provided + /// `DeviceFilter`. + required List scanners, + }) : _wrapped = $js.GetScannerListResponse( + result: result.toJS, + scanners: scanners.toJSArray((e) => e.toJS), + ); + + final $js.GetScannerListResponse _wrapped; + + $js.GetScannerListResponse get toJS => _wrapped; + + /// The backend's enumeration result. Note that partial results could be + /// returned even if this indicates an error. + OperationResult get result => OperationResult.fromJS(_wrapped.result); + + set result(OperationResult v) { + _wrapped.result = v.toJS; + } + + /// A possibly-empty list of scanners that match the provided + /// `DeviceFilter`. + List get scanners => _wrapped.scanners.toDart + .cast<$js.ScannerInfo>() + .map((e) => ScannerInfo.fromJS(e)) + .toList(); + + set scanners(List v) { + _wrapped.scanners = v.toJSArray((e) => e.toJS); + } +} + +class OpenScannerResponse { + OpenScannerResponse.fromJS(this._wrapped); + + OpenScannerResponse({ + /// Same scanner ID passed to `openScanner()`. + required String scannerId, + + /// Backend result of opening the scanner. + required OperationResult result, + + /// If `result` is `OperationResult.SUCCESS`, a handle + /// to the scanner that can be used for further operations. + String? scannerHandle, + + /// If `result` is `OperationResult.SUCCESS`, a + /// key-value mapping from option names to `ScannerOption`. + Map? options, + }) : _wrapped = $js.OpenScannerResponse( + scannerId: scannerId, + result: result.toJS, + scannerHandle: scannerHandle, + options: options?.jsify(), + ); + + final $js.OpenScannerResponse _wrapped; + + $js.OpenScannerResponse get toJS => _wrapped; + + /// Same scanner ID passed to `openScanner()`. + String get scannerId => _wrapped.scannerId; + + set scannerId(String v) { + _wrapped.scannerId = v; + } + + /// Backend result of opening the scanner. + OperationResult get result => OperationResult.fromJS(_wrapped.result); + + set result(OperationResult v) { + _wrapped.result = v.toJS; + } + + /// If `result` is `OperationResult.SUCCESS`, a handle + /// to the scanner that can be used for further operations. + String? get scannerHandle => _wrapped.scannerHandle; + + set scannerHandle(String? v) { + _wrapped.scannerHandle = v; + } + + /// If `result` is `OperationResult.SUCCESS`, a + /// key-value mapping from option names to `ScannerOption`. + Map? get options => _wrapped.options?.toDartMap(); + + set options(Map? v) { + _wrapped.options = v?.jsify(); + } +} + +class GetOptionGroupsResponse { + GetOptionGroupsResponse.fromJS(this._wrapped); + + GetOptionGroupsResponse({ + /// Same scanner handle passed to `getOptionGroups()`. + required String scannerHandle, + + /// The backend's result of getting the option groups. + required OperationResult result, + + /// If `result` is `OperationResult.SUCCESS`, a list of + /// option groups in the order supplied by the backend. + List? groups, + }) : _wrapped = $js.GetOptionGroupsResponse( + scannerHandle: scannerHandle, + result: result.toJS, + groups: groups?.toJSArray((e) => e.toJS), + ); + + final $js.GetOptionGroupsResponse _wrapped; + + $js.GetOptionGroupsResponse get toJS => _wrapped; + + /// Same scanner handle passed to `getOptionGroups()`. + String get scannerHandle => _wrapped.scannerHandle; + + set scannerHandle(String v) { + _wrapped.scannerHandle = v; + } + + /// The backend's result of getting the option groups. + OperationResult get result => OperationResult.fromJS(_wrapped.result); + + set result(OperationResult v) { + _wrapped.result = v.toJS; + } + + /// If `result` is `OperationResult.SUCCESS`, a list of + /// option groups in the order supplied by the backend. + List? get groups => _wrapped.groups?.toDart + .cast<$js.OptionGroup>() + .map((e) => OptionGroup.fromJS(e)) + .toList(); + + set groups(List? v) { + _wrapped.groups = v?.toJSArray((e) => e.toJS); + } +} + +class CloseScannerResponse { + CloseScannerResponse.fromJS(this._wrapped); + + CloseScannerResponse({ + /// Same scanner handle passed to `closeScanner()`. + required String scannerHandle, + + /// Backend result of closing the scanner. Even if this value is not + /// `OperationResult.SUCCESS`, the handle will be invalid and + /// should not be used for any further operations. + required OperationResult result, + }) : _wrapped = $js.CloseScannerResponse( + scannerHandle: scannerHandle, + result: result.toJS, + ); + + final $js.CloseScannerResponse _wrapped; + + $js.CloseScannerResponse get toJS => _wrapped; + + /// Same scanner handle passed to `closeScanner()`. + String get scannerHandle => _wrapped.scannerHandle; + + set scannerHandle(String v) { + _wrapped.scannerHandle = v; + } + + /// Backend result of closing the scanner. Even if this value is not + /// `OperationResult.SUCCESS`, the handle will be invalid and + /// should not be used for any further operations. + OperationResult get result => OperationResult.fromJS(_wrapped.result); + + set result(OperationResult v) { + _wrapped.result = v.toJS; + } +} + +class OptionSetting { + OptionSetting.fromJS(this._wrapped); + + OptionSetting({ + /// Name of the option to set. + required String name, + + /// Type of the option. The requested type must match the real type of the + /// underlying option. + required OptionType type, + + /// Value to set. Leave unset to request automatic setting for options that + /// have `autoSettable` enabled. The type supplied for + /// `value` must match `type`. + Object? value, + }) : _wrapped = $js.OptionSetting( + name: name, + type: type.toJS, + value: switch (value) { + bool() => value.jsify()!, + double() => value.jsify()!, + List() => value.toJSArray((e) => e), + int() => value.jsify()!, + List() => value.toJSArray((e) => e), + String() => value.jsify()!, + null => null, + _ => throw UnsupportedError( + 'Received type: ${value.runtimeType}. Supported types are: bool, double, List, int, List, String') + }, + ); + + final $js.OptionSetting _wrapped; + + $js.OptionSetting get toJS => _wrapped; + + /// Name of the option to set. + String get name => _wrapped.name; + + set name(String v) { + _wrapped.name = v; + } + + /// Type of the option. The requested type must match the real type of the + /// underlying option. + OptionType get type => OptionType.fromJS(_wrapped.type); + + set type(OptionType v) { + _wrapped.type = v.toJS; + } + + /// Value to set. Leave unset to request automatic setting for options that + /// have `autoSettable` enabled. The type supplied for + /// `value` must match `type`. + Object? get value => _wrapped.value?.when( + isBool: (v) => v, + isDouble: (v) => v, + isArray: (v) => v.toDart.cast().map((e) => e).toList(), + isInt: (v) => v, + isString: (v) => v, + ); + + set value(Object? v) { + _wrapped.value = switch (v) { + bool() => v.jsify()!, + double() => v.jsify()!, + List() => v.toJSArray((e) => e), + int() => v.jsify()!, + List() => v.toJSArray((e) => e), + String() => v.jsify()!, + null => null, + _ => throw UnsupportedError( + 'Received type: ${v.runtimeType}. Supported types are: bool, double, List, int, List, String') + }; + } +} + +class SetOptionResult { + SetOptionResult.fromJS(this._wrapped); + + SetOptionResult({ + /// Name of the option that was set. + required String name, + + /// Backend result of setting the option. + required OperationResult result, + }) : _wrapped = $js.SetOptionResult( + name: name, + result: result.toJS, + ); + + final $js.SetOptionResult _wrapped; + + $js.SetOptionResult get toJS => _wrapped; + + /// Name of the option that was set. + String get name => _wrapped.name; + + set name(String v) { + _wrapped.name = v; + } + + /// Backend result of setting the option. + OperationResult get result => OperationResult.fromJS(_wrapped.result); + + set result(OperationResult v) { + _wrapped.result = v.toJS; + } +} + +class SetOptionsResponse { + SetOptionsResponse.fromJS(this._wrapped); + + SetOptionsResponse({ + /// The same scanner handle passed to `setOptions()`. + required String scannerHandle, + + /// One result per passed-in `OptionSetting`. + required List results, + + /// Updated key-value mapping from option names to + /// `ScannerOption` containing the new configuration after + /// attempting to set all supplied options. This has the same structure as + /// the `options` field in `OpenScannerResponse`. + /// + /// This field will be set even if some options were not set successfully, + /// but will be unset if retrieving the updated configuration fails (e.g., + /// if the scanner is disconnected in the middle). + Map? options, + }) : _wrapped = $js.SetOptionsResponse( + scannerHandle: scannerHandle, + results: results.toJSArray((e) => e.toJS), + options: options?.jsify(), + ); + + final $js.SetOptionsResponse _wrapped; + + $js.SetOptionsResponse get toJS => _wrapped; + + /// The same scanner handle passed to `setOptions()`. + String get scannerHandle => _wrapped.scannerHandle; + + set scannerHandle(String v) { + _wrapped.scannerHandle = v; + } + + /// One result per passed-in `OptionSetting`. + List get results => _wrapped.results.toDart + .cast<$js.SetOptionResult>() + .map((e) => SetOptionResult.fromJS(e)) + .toList(); + + set results(List v) { + _wrapped.results = v.toJSArray((e) => e.toJS); + } + + /// Updated key-value mapping from option names to + /// `ScannerOption` containing the new configuration after + /// attempting to set all supplied options. This has the same structure as + /// the `options` field in `OpenScannerResponse`. + /// + /// This field will be set even if some options were not set successfully, + /// but will be unset if retrieving the updated configuration fails (e.g., + /// if the scanner is disconnected in the middle). + Map? get options => _wrapped.options?.toDartMap(); + + set options(Map? v) { + _wrapped.options = v?.jsify(); + } +} + +class StartScanOptions { + StartScanOptions.fromJS(this._wrapped); + + StartScanOptions( + { + /// MIME type to return scanned data in. + required String format}) + : _wrapped = $js.StartScanOptions(format: format); + + final $js.StartScanOptions _wrapped; + + $js.StartScanOptions get toJS => _wrapped; + + /// MIME type to return scanned data in. + String get format => _wrapped.format; + + set format(String v) { + _wrapped.format = v; + } +} + +class StartScanResponse { + StartScanResponse.fromJS(this._wrapped); + + StartScanResponse({ + /// The same scanner handle that was passed to `startScan()`. + required String scannerHandle, + + /// The backend's start scan result. + required OperationResult result, + + /// If `result` is `OperationResult.SUCCESS`, a handle + /// that can be used to read scan data or cancel the job. + String? job, + }) : _wrapped = $js.StartScanResponse( + scannerHandle: scannerHandle, + result: result.toJS, + job: job, + ); + + final $js.StartScanResponse _wrapped; + + $js.StartScanResponse get toJS => _wrapped; + + /// The same scanner handle that was passed to `startScan()`. + String get scannerHandle => _wrapped.scannerHandle; + + set scannerHandle(String v) { + _wrapped.scannerHandle = v; + } + + /// The backend's start scan result. + OperationResult get result => OperationResult.fromJS(_wrapped.result); + + set result(OperationResult v) { + _wrapped.result = v.toJS; + } + + /// If `result` is `OperationResult.SUCCESS`, a handle + /// that can be used to read scan data or cancel the job. + String? get job => _wrapped.job; + + set job(String? v) { + _wrapped.job = v; + } +} + +class CancelScanResponse { + CancelScanResponse.fromJS(this._wrapped); + + CancelScanResponse({ + /// The same job handle that was passed to `cancelScan()`. + required String job, + + /// The backend's cancel scan result. + required OperationResult result, + }) : _wrapped = $js.CancelScanResponse( + job: job, + result: result.toJS, + ); + + final $js.CancelScanResponse _wrapped; + + $js.CancelScanResponse get toJS => _wrapped; + + /// The same job handle that was passed to `cancelScan()`. + String get job => _wrapped.job; + + set job(String v) { + _wrapped.job = v; + } + + /// The backend's cancel scan result. + OperationResult get result => OperationResult.fromJS(_wrapped.result); + + set result(OperationResult v) { + _wrapped.result = v.toJS; + } +} + +class ReadScanDataResponse { + ReadScanDataResponse.fromJS(this._wrapped); + + ReadScanDataResponse({ + /// Same job handle passed to `readScanData()`. + required String job, + + /// The backend result of reading data. If this is + /// `OperationResult.SUCCESS`, `data` will contain the + /// next (possibly zero-length) chunk of image data that was ready for + /// reading. If this is `OperationResult.EOF`, `data` + /// will contain the final chunk of image data. + required OperationResult result, + + /// If result is `OperationResult.SUCCESS`, the next chunk of + /// scanned image data. + ByteBuffer? data, + + /// If result is `OperationResult.SUCCESS`, an estimate of how + /// much of the total scan data has been delivered so far, in the range + /// 0-100. + int? estimatedCompletion, + }) : _wrapped = $js.ReadScanDataResponse( + job: job, + result: result.toJS, + data: data?.toJS, + estimatedCompletion: estimatedCompletion, + ); + + final $js.ReadScanDataResponse _wrapped; + + $js.ReadScanDataResponse get toJS => _wrapped; + + /// Same job handle passed to `readScanData()`. + String get job => _wrapped.job; + + set job(String v) { + _wrapped.job = v; + } + + /// The backend result of reading data. If this is + /// `OperationResult.SUCCESS`, `data` will contain the + /// next (possibly zero-length) chunk of image data that was ready for + /// reading. If this is `OperationResult.EOF`, `data` + /// will contain the final chunk of image data. + OperationResult get result => OperationResult.fromJS(_wrapped.result); + + set result(OperationResult v) { + _wrapped.result = v.toJS; + } + + /// If result is `OperationResult.SUCCESS`, the next chunk of + /// scanned image data. + ByteBuffer? get data => _wrapped.data?.toDart; + + set data(ByteBuffer? v) { + _wrapped.data = v?.toJS; + } + + /// If result is `OperationResult.SUCCESS`, an estimate of how + /// much of the total scan data has been delivered so far, in the range + /// 0-100. + int? get estimatedCompletion => _wrapped.estimatedCompletion; + + set estimatedCompletion(int? v) { + _wrapped.estimatedCompletion = v; + } +} diff --git a/lib/downloads.dart b/lib/downloads.dart index 18ae408..c4ab3d4 100644 --- a/lib/downloads.dart +++ b/lib/downloads.dart @@ -103,11 +103,12 @@ class ChromeDownloads { return $res; } - /// Open the downloaded file now if the [DownloadItem] is complete; - /// otherwise returns an error through [runtime.lastError]. Requires the - /// `"downloads.open"` permission in addition to the - /// `"downloads"` permission. An [onChanged] event will fire - /// when the item is opened for the first time. + /// Opens the downloaded file now if the [DownloadItem] is complete; + /// otherwise returns an error through [runtime.lastError]. This method + /// requires the `"downloads.open"` permission in addition to the + /// `"downloads"` permission. An [onChanged] event fires + /// when the item is opened for the first time. This method can only be called + /// in response to a user gesture. /// |downloadId|: The identifier for the downloaded file. void open(int downloadId) { $js.chrome.downloads.open(downloadId); @@ -160,6 +161,7 @@ class ChromeDownloads { /// one other extension has disabled it will return an error through /// [runtime.lastError]. Requires the `"downloads.shelf"` /// permission in addition to the `"downloads"` permission. + @Deprecated(r'Use $(ref:setUiOptions) instead.') void setShelfEnabled(bool enabled) { $js.chrome.downloads.setShelfEnabled(enabled); } @@ -345,6 +347,7 @@ enum DangerType { accepted('accepted'), allowlistedByPolicy('allowlistedByPolicy'), asyncScanning('asyncScanning'), + asyncLocalPasswordScanning('asyncLocalPasswordScanning'), passwordProtected('passwordProtected'), blockedTooLarge('blockedTooLarge'), sensitiveContentWarning('sensitiveContentWarning'), @@ -353,7 +356,8 @@ enum DangerType { deepScannedFailed('deepScannedFailed'), deepScannedSafe('deepScannedSafe'), deepScannedOpenedDangerous('deepScannedOpenedDangerous'), - promptForScaning('promptForScaning'), + promptForScanning('promptForScanning'), + promptForLocalPasswordScanning('promptForLocalPasswordScanning'), accountCompromise('accountCompromise'); const DangerType(this.value); diff --git a/lib/extension_types.dart b/lib/extension_types.dart index 82909dd..b72a455 100644 --- a/lib/extension_types.dart +++ b/lib/extension_types.dart @@ -98,11 +98,13 @@ enum DocumentLifecycle { } /// The JavaScript world for a script to execute within. Can either be an -/// isolated world, unique to this extension, or the main world of the DOM which -/// is shared with the page's JavaScript. +/// isolated world unique to this extension, the main world of the DOM which is +/// shared with the page's JavaScript, or a user scripts world that is only +/// available for scripts registered with the User Scripts API. enum ExecutionWorld { isolated('ISOLATED'), - main('MAIN'); + main('MAIN'), + userScript('USER_SCRIPT'); const ExecutionWorld(this.value); diff --git a/lib/file_system_provider.dart b/lib/file_system_provider.dart index 3af0c27..9b3d669 100644 --- a/lib/file_system_provider.dart +++ b/lib/file_system_provider.dart @@ -72,7 +72,7 @@ class ChromeFileSystemProvider { /// Notifies about changes in the watched directory at /// `observedPath` in `recursive` mode. If the file - /// system is mounted with `supportsNofityTag`, then + /// system is mounted with `supportsNotifyTag`, then /// `tag` must be provided, and all changes since the last /// notification always reported, even if the system was shutdown. The last /// tag can be obtained with [getAll]. @@ -664,6 +664,39 @@ typedef FileDataCallback = void Function( bool, ); +class CloudIdentifier { + CloudIdentifier.fromJS(this._wrapped); + + CloudIdentifier({ + /// Identifier for the cloud storage provider (e.g. 'drive.google.com'). + required String providerName, + + /// The provider's identifier for the given file/directory. + required String id, + }) : _wrapped = $js.CloudIdentifier( + providerName: providerName, + id: id, + ); + + final $js.CloudIdentifier _wrapped; + + $js.CloudIdentifier get toJS => _wrapped; + + /// Identifier for the cloud storage provider (e.g. 'drive.google.com'). + String get providerName => _wrapped.providerName; + + set providerName(String v) { + _wrapped.providerName = v; + } + + /// The provider's identifier for the given file/directory. + String get id => _wrapped.id; + + set id(String v) { + _wrapped.id = v; + } +} + class EntryMetadata { EntryMetadata.fromJS(this._wrapped); @@ -693,6 +726,13 @@ class EntryMetadata { /// 32 KB in size. Optional, but can be provided only when explicitly /// requested by the [onGetMetadataRequested] event. String? thumbnail, + + /// Cloud storage representation of this entry. Must be provided if + /// requested + /// in `options` and the file is backed by cloud storage. For + /// local files not backed by cloud storage, it should be undefined when + /// requested. + CloudIdentifier? cloudIdentifier, }) : _wrapped = $js.EntryMetadata( isDirectory: isDirectory, name: name, @@ -700,6 +740,7 @@ class EntryMetadata { modificationTime: modificationTime, mimeType: mimeType, thumbnail: thumbnail, + cloudIdentifier: cloudIdentifier?.toJS, ); final $js.EntryMetadata _wrapped; @@ -754,6 +795,17 @@ class EntryMetadata { set thumbnail(String? v) { _wrapped.thumbnail = v; } + + /// Cloud storage representation of this entry. Must be provided if requested + /// in `options` and the file is backed by cloud storage. For + /// local files not backed by cloud storage, it should be undefined when + /// requested. + CloudIdentifier? get cloudIdentifier => + _wrapped.cloudIdentifier?.let(CloudIdentifier.fromJS); + + set cloudIdentifier(CloudIdentifier? v) { + _wrapped.cloudIdentifier = v?.toJS; + } } class Watcher { @@ -1117,8 +1169,12 @@ class GetMetadataRequestedOptions { /// Set to `true` if `mimeType` value is requested. required bool mimeType, - /// Set to `true` if the thumbnail is requested. + /// Set to `true` if `thumbnail` value is requested. required bool thumbnail, + + /// Set to `true` if `cloudIdentifier` value is + /// requested. + required bool cloudIdentifier, }) : _wrapped = $js.GetMetadataRequestedOptions( fileSystemId: fileSystemId, requestId: requestId, @@ -1129,6 +1185,7 @@ class GetMetadataRequestedOptions { modificationTime: modificationTime, mimeType: mimeType, thumbnail: thumbnail, + cloudIdentifier: cloudIdentifier, ); final $js.GetMetadataRequestedOptions _wrapped; @@ -1192,12 +1249,20 @@ class GetMetadataRequestedOptions { _wrapped.mimeType = v; } - /// Set to `true` if the thumbnail is requested. + /// Set to `true` if `thumbnail` value is requested. bool get thumbnail => _wrapped.thumbnail; set thumbnail(bool v) { _wrapped.thumbnail = v; } + + /// Set to `true` if `cloudIdentifier` value is + /// requested. + bool get cloudIdentifier => _wrapped.cloudIdentifier; + + set cloudIdentifier(bool v) { + _wrapped.cloudIdentifier = v; + } } class GetActionsRequestedOptions { @@ -1274,7 +1339,7 @@ class ReadDirectoryRequestedOptions { /// Set to `true` if `mimeType` value is requested. required bool mimeType, - /// Set to `true` if the thumbnail is requested. + /// Set to `true` if `thumbnail` value is requested. required bool thumbnail, }) : _wrapped = $js.ReadDirectoryRequestedOptions( fileSystemId: fileSystemId, @@ -1349,7 +1414,7 @@ class ReadDirectoryRequestedOptions { _wrapped.mimeType = v; } - /// Set to `true` if the thumbnail is requested. + /// Set to `true` if `thumbnail` value is requested. bool get thumbnail => _wrapped.thumbnail; set thumbnail(bool v) { diff --git a/lib/history.dart b/lib/history.dart index 3afc1fc..51f754b 100644 --- a/lib/history.dart +++ b/lib/history.dart @@ -14,7 +14,7 @@ extension ChromeHistoryExtension on Chrome { /// Use the `chrome.history` API to interact with the browser's record of /// visited pages. You can add, remove, and query for URLs in the browser's /// history. To override the history page with your own version, see [Override - /// Pages](override). + /// Pages](develop/ui/override-chrome-pages). ChromeHistory get history => _history; } diff --git a/lib/i18n.dart b/lib/i18n.dart index 1d34e02..415062d 100644 --- a/lib/i18n.dart +++ b/lib/i18n.dart @@ -35,7 +35,7 @@ class ChromeI18n { /// or the _substitutions_ array has more than 9 elements - this method /// returns `undefined`. /// [messageName] The name of the message, as specified in the `messages.json` file. + /// href='how-to/ui/localization-message-formats'>`messages.json` file. /// [substitutions] Up to 9 substitution strings, if the message requires /// any. /// [returns] Message localized for current locale. diff --git a/lib/identity.dart b/lib/identity.dart index 3fda82c..5c5bb9f 100644 --- a/lib/identity.dart +++ b/lib/identity.dart @@ -35,7 +35,7 @@ class ChromeIdentity { /// Gets an OAuth2 access token using the client ID and scopes /// specified in the `oauth2` + /// href="/docs/apps/app_identity#update_manifest">`oauth2` /// section of manifest.json. /// /// The Identity API caches access tokens in memory, so it's ok to @@ -159,10 +159,10 @@ class ChromeIdentity { } enum AccountStatus { - /// Sync is enabled for the primary account. + /// Specifies that Sync is enabled for the primary account. sync('SYNC'), - /// Any primary account, if exists. + /// Specifies the existence of a primary account, if any. any('ANY'); const AccountStatus(this.value); diff --git a/lib/login_state.dart b/lib/login_state.dart index 2a9ac37..d512e07 100644 --- a/lib/login_state.dart +++ b/lib/login_state.dart @@ -45,10 +45,10 @@ class ChromeLoginState { } enum ProfileType { - /// The extension is in the signin profile. + /// Specifies that the extension is in the signin profile. signinProfile('SIGNIN_PROFILE'), - /// The extension is in the user profile. + /// Specifies that the extension is in the user profile. userProfile('USER_PROFILE'); const ProfileType(this.value); @@ -61,22 +61,22 @@ enum ProfileType { } enum SessionState { - /// The session state is unknown. + /// Specifies that the session state is unknown. unknown('UNKNOWN'), - /// The user is in the out-of-box-experience screen. + /// Specifies that the user is in the out-of-box-experience screen. inOobeScreen('IN_OOBE_SCREEN'), - /// The user is in the login screen. + /// Specifies that the user is in the login screen. inLoginScreen('IN_LOGIN_SCREEN'), - /// The user is in the session. + /// Specifies that the user is in the session. inSession('IN_SESSION'), - /// The user is in the lock screen. + /// Specifies that the user is in the lock screen. inLockScreen('IN_LOCK_SCREEN'), - /// The device is in RMA mode, finalizing repairs. + /// Specifies that the device is in RMA mode, finalizing repairs. inRmaScreen('IN_RMA_SCREEN'); const SessionState(this.value); diff --git a/lib/management.dart b/lib/management.dart index 3673619..24043aa 100644 --- a/lib/management.dart +++ b/lib/management.dart @@ -13,7 +13,8 @@ final _management = ChromeManagement._(); extension ChromeManagementExtension on Chrome { /// The `chrome.management` API provides ways to manage the list of /// extensions/apps that are installed and running. It is particularly useful - /// for extensions that [override](override) the built-in New Tab page. + /// for extensions that [override](develop/ui/override-chrome-pages) the + /// built-in New Tab page. ChromeManagement get management => _management; } @@ -49,8 +50,9 @@ class ChromeManagement { return ExtensionInfo.fromJS($res); } - /// Returns a list of [permission warnings](permission_warnings) for the given - /// extension id. + /// Returns a list of [permission + /// warnings](develop/concepts/permission-warnings) for the given extension + /// id. /// [id] The ID of an already installed extension. Future> getPermissionWarningsById(String id) async { var $res = await promiseToFuture( @@ -58,9 +60,10 @@ class ChromeManagement { return $res.toDart.cast().map((e) => e).toList(); } - /// Returns a list of [permission warnings](permission_warnings) for the given - /// extension manifest string. Note: This function can be used without - /// requesting the 'management' permission in the manifest. + /// Returns a list of [permission + /// warnings](develop/concepts/permission-warnings) for the given extension + /// manifest string. Note: This function can be used without requesting the + /// 'management' permission in the manifest. /// [manifestStr] Extension manifest JSON string. Future> getPermissionWarningsByManifest( String manifestStr) async { @@ -156,23 +159,6 @@ class ChromeManagement { return ExtensionInfo.fromJS($res); } - /// Checks if the replacement android app can be installed. Errors generated - /// by this API are reported by setting [runtime.lastError] and executing the - /// function's regular callback. - Future canInstallReplacementAndroidApp() async { - var $res = await promiseToFuture( - $js.chrome.management.canInstallReplacementAndroidApp()); - return $res; - } - - /// Prompts the user to install the replacement Android app from the manifest. - /// Errors generated by this API are reported by setting [runtime.lastError] - /// and executing the function's regular callback. - Future installReplacementAndroidApp() async { - await promiseToFuture( - $js.chrome.management.installReplacementAndroidApp()); - } - /// Launches the replacement_web_app specified in the manifest. Prompts the /// user to install if not already installed. Future installReplacementWebApp() async { @@ -331,11 +317,12 @@ class ExtensionInfo { /// The description of this extension, app, or theme. required String description, - /// The [version](manifest/version) of this extension, app, or theme. + /// The [version](reference/manifest/version) of this extension, app, or + /// theme. required String version, - /// The [version name](manifest/version#version_name) of this extension, - /// app, or theme if the manifest specified one. + /// The [version name](reference/manifest/version#version_name) of this + /// extension, app, or theme if the manifest specified one. String? versionName, /// Whether this extension can be disabled or uninstalled by the user. @@ -376,7 +363,8 @@ class ExtensionInfo { /// declared in the manifest, and the actual image at that url may be larger /// or smaller than what was declared, so you might consider using explicit /// width and height attributes on img tags referencing these images. See - /// the [manifest documentation on icons](manifest/icons) for more details. + /// the [manifest documentation on icons](reference/manifest/icons) for more + /// details. List? icons, /// Returns a list of API based permissions. @@ -451,15 +439,16 @@ class ExtensionInfo { _wrapped.description = v; } - /// The [version](manifest/version) of this extension, app, or theme. + /// The [version](reference/manifest/version) of this extension, app, or + /// theme. String get version => _wrapped.version; set version(String v) { _wrapped.version = v; } - /// The [version name](manifest/version#version_name) of this extension, app, - /// or theme if the manifest specified one. + /// The [version name](reference/manifest/version#version_name) of this + /// extension, app, or theme if the manifest specified one. String? get versionName => _wrapped.versionName; set versionName(String? v) { @@ -549,7 +538,7 @@ class ExtensionInfo { /// in the manifest, and the actual image at that url may be larger or smaller /// than what was declared, so you might consider using explicit width and /// height attributes on img tags referencing these images. See the [manifest - /// documentation on icons](manifest/icons) for more details. + /// documentation on icons](reference/manifest/icons) for more details. List? get icons => _wrapped.icons?.toDart .cast<$js.IconInfo>() .map((e) => IconInfo.fromJS(e)) diff --git a/lib/notifications.dart b/lib/notifications.dart index f9b9ccf..e76e382 100644 --- a/lib/notifications.dart +++ b/lib/notifications.dart @@ -141,17 +141,19 @@ class ChromeNotifications { } enum TemplateType { - /// icon, title, message, expandedMessage, up to two buttons + /// Contains an icon, title, message, expandedMessage, and up to two + /// buttons. basic('basic'), - /// icon, title, message, expandedMessage, image, up to two buttons + /// Contains an icon, title, message, expandedMessage, image, and up + /// to two buttons. image('image'), - /// icon, title, message, items, up to two buttons. Users on Mac OS X only - /// see the first item. + /// Contains an icon, title, message, items, and up to two buttons. + /// Users on Mac OS X only see the first item. list('list'), - /// icon, title, message, progress, up to two buttons + /// Contains an icon, title, message, progress, and up to two buttons. progress('progress'); const TemplateType(this.value); @@ -164,11 +166,12 @@ enum TemplateType { } enum PermissionLevel { - /// User has elected to show notifications from the app or extension. - /// This is the default at install time. + /// Specifies that the user has elected to show notifications + /// from the app or extension. This is the default at install time. granted('granted'), - /// User has elected not to show notifications from the app or extension. + /// Specifies that the user has elected not to show notifications + /// from the app or extension. denied('denied'); const PermissionLevel(this.value); diff --git a/lib/offscreen.dart b/lib/offscreen.dart index 2a64853..6234878 100644 --- a/lib/offscreen.dart +++ b/lib/offscreen.dart @@ -52,48 +52,67 @@ enum Reason { /// A reason used for testing purposes only. testing('TESTING'), - /// The offscreen document is responsible for playing audio. + /// Specifies that the offscreen document is responsible for playing audio. audioPlayback('AUDIO_PLAYBACK'), - /// The offscreen document needs to embed and script an iframe in order to - /// modify the iframe's content. + /// Specifies that the offscreen document needs to embed and script an + /// iframe in order to modify the iframe's content. iframeScripting('IFRAME_SCRIPTING'), - /// The offscreen document needs to embed an iframe and scrape its DOM to - /// extract information. + /// Specifies that the offscreen document needs to embed an iframe and + /// scrape its DOM to extract information. domScraping('DOM_SCRAPING'), - /// The offscreen document needs to interact with Blob objects (including - /// `URL.createObjectURL()`). + /// Specifies that the offscreen document needs to interact with Blob + /// objects (including `URL.createObjectURL()`). blobs('BLOBS'), - /// The offscreen document needs to use the `DOMParser` API. + /// Specifies that the offscreen document needs to use the + /// WebRTC + /// APIs. webRtc('WEB_RTC'), - /// The offscreen document needs to interact with the clipboard APIs - /// (e.g. `Navigator.clipboard`). + /// Specifies that the offscreen document needs to interact with the + /// navigator.geolocation + /// Specifies that the offscreen document needs to use + /// navigator.getBattery. + batteryStatus('BATTERY_STATUS'), + + /// Specifies that the offscreen document needs to use + /// window.matchMedia. + matchMedia('MATCH_MEDIA'), + + /// Specifies that the offscreen document needs to use + /// navigator.geolocation. geolocation('GEOLOCATION'); const Reason(this.value); diff --git a/lib/permissions.dart b/lib/permissions.dart index 42c35e0..f651d95 100644 --- a/lib/permissions.dart +++ b/lib/permissions.dart @@ -12,9 +12,9 @@ final _permissions = ChromePermissions._(); extension ChromePermissionsExtension on Chrome { /// Use the `chrome.permissions` API to request [declared optional - /// permissions](permissions#manifest) at run time rather than install time, - /// so users understand why the permissions are needed and grant only those - /// that are necessary. + /// permissions](/docs/extensions/mv3/declare_permissions/) at run time rather + /// than install time, so users understand why the permissions are needed and + /// grant only those that are necessary. ChromePermissions get permissions => _permissions; } diff --git a/lib/power.dart b/lib/power.dart index 320f413..6918fb5 100644 --- a/lib/power.dart +++ b/lib/power.dart @@ -43,10 +43,10 @@ class ChromePower { } enum Level { - /// Prevent the system from sleeping in response to user inactivity. + /// Prevents the system from sleeping in response to user inactivity. system('system'), - /// Prevent the display from being turned off or dimmed or the system + /// Prevents the display from being turned off or dimmed, or the system /// from sleeping in response to user inactivity. display('display'); diff --git a/lib/printer_provider.dart b/lib/printer_provider.dart index 6273178..ec62e30 100644 --- a/lib/printer_provider.dart +++ b/lib/printer_provider.dart @@ -104,19 +104,19 @@ class ChromePrinterProvider { /// Error codes returned in response to [onPrintRequested] event. enum PrintError { - /// Operation completed successfully. + /// Specifies that the operation was completed successfully. ok('OK'), - /// General failure. + /// Specifies that a general failure occured. failed('FAILED'), - /// Print ticket is invalid. For example, ticket is inconsistent with - /// capabilities or extension is not able to handle all settings from the - /// ticket. + /// Specifies that the print ticket is invalid. For example, the ticket is + /// inconsistent with some capabilities, or the extension is not able to + /// handle all settings from the ticket. invalidTicket('INVALID_TICKET'), - /// Document is invalid. For example, data may be corrupted or the format is - /// incompatible with the extension. + /// Specifies that the document is invalid. For example, data may be + /// corrupted or the format is incompatible with the extension. invalidData('INVALID_DATA'); const PrintError(this.value); @@ -196,6 +196,12 @@ class PrintJob { /// Print ticket in /// /// CJT format. + /// required Map ticket, /// The document content type. Supported formats are @@ -234,6 +240,12 @@ class PrintJob { /// Print ticket in /// /// CJT format. + /// Map get ticket => _wrapped.ticket.toDartMap(); set ticket(Map v) { diff --git a/lib/printing.dart b/lib/printing.dart index 36f4ad1..2de47e4 100644 --- a/lib/printing.dart +++ b/lib/printing.dart @@ -22,9 +22,12 @@ class ChromePrinting { bool get isAvailable => $js.chrome.printingNullable != null && alwaysTrue; - /// Submits the job for print. - /// If the extension is not listed in PrintingAPIExtensionsAllowlist policy, - /// the user will be prompted to accept the print job. + /// Submits the job for printing. If the extension is not listed in + /// the + /// `PrintingAPIExtensionsAllowlist` policy, + /// the user is prompted to accept the print job.
+ /// Before Chrome 120, this function did not return a promise. Future submitJob(SubmitJobRequest request) async { var $res = await promiseToFuture<$js.SubmitJobResponse>( $js.chrome.printing.submitJob(request.toJS)); @@ -194,9 +197,12 @@ class SubmitJobRequest { SubmitJobRequest({ /// The print job to be submitted. - /// The only supported content type is "application/pdf", and the CJT ticket - /// shouldn't include FitToPageTicketItem, PageRangeTicketItem, - /// ReverseOrderTicketItem and VendorTicketItem fields since they are + /// The only supported content type is "application/pdf", and the + /// [Cloud Job + /// Ticket](https://developers.google.com/cloud-print/docs/cdd#cjt) + /// shouldn't include `FitToPageTicketItem`, + /// `PageRangeTicketItem`, `ReverseOrderTicketItem` + /// and `VendorTicketItem` fields since they are /// irrelevant for native printing. All other fields must be present. required PrintJob job, @@ -213,9 +219,11 @@ class SubmitJobRequest { $js.SubmitJobRequest get toJS => _wrapped; /// The print job to be submitted. - /// The only supported content type is "application/pdf", and the CJT ticket - /// shouldn't include FitToPageTicketItem, PageRangeTicketItem, - /// ReverseOrderTicketItem and VendorTicketItem fields since they are + /// The only supported content type is "application/pdf", and the + /// [Cloud Job Ticket](https://developers.google.com/cloud-print/docs/cdd#cjt) + /// shouldn't include `FitToPageTicketItem`, + /// `PageRangeTicketItem`, `ReverseOrderTicketItem` + /// and `VendorTicketItem` fields since they are /// irrelevant for native printing. All other fields must be present. PrintJob get job => PrintJob.fromJS(_wrapped.job); diff --git a/lib/printing_metrics.dart b/lib/printing_metrics.dart index 42b3113..ef4e291 100644 --- a/lib/printing_metrics.dart +++ b/lib/printing_metrics.dart @@ -44,14 +44,18 @@ class ChromePrintingMetrics { /// The source of the print job. enum PrintJobSource { - /// The job was created from the Print Preview page initiated by the user. + /// Specifies that the job was created from the Print Preview page + /// initiated by the user. printPreview('PRINT_PREVIEW'), - /// The job was created from an Android App. + /// Specifies that the job was created from an Android App. androidApp('ANDROID_APP'), - /// The job was created by extension via Chrome API. - extension('EXTENSION'); + /// Specifies that the job was created by extension via Chrome API. + extension('EXTENSION'), + + /// Specifies that the job was created by an Isolated Web App via API. + isolatedWebApp('ISOLATED_WEB_APP'); const PrintJobSource(this.value); @@ -62,15 +66,15 @@ enum PrintJobSource { values.firstWhere((e) => e.value == value); } -/// The final status of the print job. +/// Specifies the final status of the print job. enum PrintJobStatus { - /// Print job was interrupted due to some error. + /// Specifies that the print job was interrupted due to some error. failed('FAILED'), - /// Print job was canceled by the user or via API. + /// Specifies that the print job was canceled by the user or via API. canceled('CANCELED'), - /// Print job was printed without any errors. + /// Specifies that the print job was printed without any errors. printed('PRINTED'); const PrintJobStatus(this.value); @@ -84,10 +88,10 @@ enum PrintJobStatus { /// The source of the printer. enum PrinterSource { - /// Printer was added by user. + /// Specifies that the printer was added by user. user('USER'), - /// Printer was added via policy. + /// Specifies that the printer was added via policy. policy('POLICY'); const PrinterSource(this.value); @@ -100,10 +104,10 @@ enum PrinterSource { } enum ColorMode { - /// Black and white mode was used. + /// Specifies that black and white mode was used. blackAndWhite('BLACK_AND_WHITE'), - /// Color mode was used. + /// Specifies that color mode was used. color('COLOR'); const ColorMode(this.value); @@ -116,13 +120,13 @@ enum ColorMode { } enum DuplexMode { - /// One-sided printing was used. + /// Specifies that one-sided printing was used. oneSided('ONE_SIDED'), - /// Two-sided printing was used, flipping on long edge. + /// Specifies that two-sided printing was used, flipping on long edge. twoSidedLongEdge('TWO_SIDED_LONG_EDGE'), - /// Two-sided printing was used, flipping on short edge. + /// Specifies that two-sided printing was used, flipping on short edge. twoSidedShortEdge('TWO_SIDED_SHORT_EDGE'); const DuplexMode(this.value); diff --git a/lib/privacy.dart b/lib/privacy.dart index e06aa24..a026c5f 100644 --- a/lib/privacy.dart +++ b/lib/privacy.dart @@ -273,12 +273,6 @@ class PrivacyWebsites { /// `true`. required ChromeSetting thirdPartyCookiesAllowed, - /// If enabled, the experimental [Privacy - /// Sandbox](https://www.chromium.org/Home/chromium-privacy/privacy-sandbox) - /// features are active. The value of this preference is of type boolean, - /// and the default value is `true`. - required ChromeSetting privacySandboxEnabled, - /// If disabled, the [Topics /// API](https://developer.chrome.com/en/docs/privacy-sandbox/topics/) is /// deactivated. The value of this preference is of type boolean, and the @@ -325,9 +319,16 @@ class PrivacyWebsites { /// unique ID to plugins in order to run protected content. The value of /// this preference is of type boolean, and the default value is `true`. ChromeSetting? protectedContentEnabled, + + /// If disabled, [Related Website + /// Sets](https://developer.chrome.com/docs/privacy-sandbox/related-website-sets/) + /// is deactivated. The value of this preference is of type boolean, and the + /// default value is `true`. Extensions may only disable this API by setting + /// the value to `false`. If you try setting this API to `true`, it will + /// throw an error. + required ChromeSetting relatedWebsiteSetsEnabled, }) : _wrapped = $js.PrivacyWebsites( thirdPartyCookiesAllowed: thirdPartyCookiesAllowed.toJS, - privacySandboxEnabled: privacySandboxEnabled.toJS, topicsEnabled: topicsEnabled.toJS, fledgeEnabled: fledgeEnabled.toJS, adMeasurementEnabled: adMeasurementEnabled.toJS, @@ -335,6 +336,7 @@ class PrivacyWebsites { referrersEnabled: referrersEnabled.toJS, doNotTrackEnabled: doNotTrackEnabled.toJS, protectedContentEnabled: protectedContentEnabled?.toJS, + relatedWebsiteSetsEnabled: relatedWebsiteSetsEnabled.toJS, ); final $js.PrivacyWebsites _wrapped; @@ -351,17 +353,6 @@ class PrivacyWebsites { _wrapped.thirdPartyCookiesAllowed = v.toJS; } - /// If enabled, the experimental [Privacy - /// Sandbox](https://www.chromium.org/Home/chromium-privacy/privacy-sandbox) - /// features are active. The value of this preference is of type boolean, and - /// the default value is `true`. - ChromeSetting get privacySandboxEnabled => - ChromeSetting.fromJS(_wrapped.privacySandboxEnabled); - - set privacySandboxEnabled(ChromeSetting v) { - _wrapped.privacySandboxEnabled = v.toJS; - } - /// If disabled, the [Topics /// API](https://developer.chrome.com/en/docs/privacy-sandbox/topics/) is /// deactivated. The value of this preference is of type boolean, and the @@ -443,4 +434,17 @@ class PrivacyWebsites { set protectedContentEnabled(ChromeSetting? v) { _wrapped.protectedContentEnabled = v?.toJS; } + + /// If disabled, [Related Website + /// Sets](https://developer.chrome.com/docs/privacy-sandbox/related-website-sets/) + /// is deactivated. The value of this preference is of type boolean, and the + /// default value is `true`. Extensions may only disable this API by setting + /// the value to `false`. If you try setting this API to `true`, it will throw + /// an error. + ChromeSetting get relatedWebsiteSetsEnabled => + ChromeSetting.fromJS(_wrapped.relatedWebsiteSetsEnabled); + + set relatedWebsiteSetsEnabled(ChromeSetting v) { + _wrapped.relatedWebsiteSetsEnabled = v.toJS; + } } diff --git a/lib/proxy.dart b/lib/proxy.dart index b77ee0b..5f2fd5c 100644 --- a/lib/proxy.dart +++ b/lib/proxy.dart @@ -13,7 +13,8 @@ final _proxy = ChromeProxy._(); extension ChromeProxyExtension on Chrome { /// Use the `chrome.proxy` API to manage Chrome's proxy settings. This API /// relies on the [ChromeSetting prototype of the type - /// API](types#ChromeSetting) for getting and setting the proxy configuration. + /// API](reference/api/types#type-ChromeSetting) for getting and setting the + /// proxy configuration. ChromeProxy get proxy => _proxy; } diff --git a/lib/runtime.dart b/lib/runtime.dart index f3a5000..23637e1 100644 --- a/lib/runtime.dart +++ b/lib/runtime.dart @@ -12,7 +12,7 @@ export 'src/chrome.dart' show chrome; final _runtime = ChromeRuntime._(); extension ChromeRuntimeExtension on Chrome { - /// Use the `chrome.runtime` API to retrieve the background page, return + /// Use the `chrome.runtime` API to retrieve the service worker, return /// details about the manifest, and listen for and respond to events in the /// app or extension lifecycle. You can also use this API to convert the /// relative path of URLs to fully-qualified URLs. @@ -49,7 +49,8 @@ class ChromeRuntime { } /// Returns details about the app or extension from the manifest. The object - /// returned is a serialization of the full [manifest file](manifest.html). + /// returned is a serialization of the full [manifest + /// file](reference/manifest). /// [returns] The manifest details. Map getManifest() { return $js.chrome.runtime.getManifest().toDartMap(); @@ -127,14 +128,14 @@ class ChromeRuntime { /// Attempts to connect listeners within an extension/app (such as the /// background page), or other extensions/apps. This is useful for content /// scripts connecting to their extension processes, inter-app/extension - /// communication, and [web messaging](manifest/externally_connectable.html). - /// Note that this does not connect to any listeners in a content script. - /// Extensions may connect to content scripts embedded in tabs via - /// [tabs.connect]. + /// communication, and [web + /// messaging](/docs/extensions/manifest/externally_connectable). Note that + /// this does not connect to any listeners in a content script. Extensions may + /// connect to content scripts embedded in tabs via [tabs.connect]. /// [extensionId] The ID of the extension or app to connect to. If omitted, /// a connection will be attempted with your own extension. Required if /// sending messages from a web page for [web - /// messaging](manifest/externally_connectable.html). + /// messaging](/docs/extensions/reference/manifest/externally-connectable). /// [returns] Port through which messages can be sent and received. The /// port's $(ref:Port onDisconnect) event is fired if the extension/app does /// not exist. @@ -149,7 +150,7 @@ class ChromeRuntime { } /// Connects to a native application in the host machine. See [Native - /// Messaging](nativeMessaging) for more information. + /// Messaging](develop/concepts/native-messaging) for more information. /// [application] The name of the registered application to connect to. /// [returns] Port through which messages can be sent and received with the /// application @@ -168,7 +169,7 @@ class ChromeRuntime { /// [extensionId] The ID of the extension/app to send the message to. If /// omitted, the message will be sent to your own extension/app. Required if /// sending messages from a web page for [web - /// messaging](manifest/externally_connectable.html). + /// messaging](/docs/extensions/manifest/externally_connectable). /// [message] The message to send. This message should be a JSON-ifiable /// object. Future sendMessage( @@ -208,14 +209,10 @@ class ChromeRuntime { } /// Returns a DirectoryEntry for the package directory. - Future getPackageDirectoryEntry() { - var $completer = Completer(); - $js.chrome.runtime.getPackageDirectoryEntry((JSObject directoryEntry) { - if (checkRuntimeLastError($completer)) { - $completer.complete(directoryEntry); - } - }.toJS); - return $completer.future; + Future getPackageDirectoryEntry() async { + var $res = await promiseToFuture( + $js.chrome.runtime.getPackageDirectoryEntry()); + return $res; } /// Fetches information about active contexts associated with this extension @@ -232,7 +229,12 @@ class ChromeRuntime { .toList(); } - /// This will be defined during an API method callback if there was an error + /// Populated with an error message if calling an API function fails; + /// otherwise undefined. This is only defined within the scope of that + /// function's callback. If an error is produced, but `runtime.lastError` is + /// not accessed within the callback, a message is logged to the console + /// listing the API function that produced the error. API functions that + /// return promises do not set this property. RuntimeLastError? get lastError => $js.chrome.runtime.lastError?.let(RuntimeLastError.fromJS); @@ -303,7 +305,7 @@ class ChromeRuntime { }); /// Fired when a connection is made from another extension (by - /// [runtime.connect]). + /// [runtime.connect]), or from an externally connectable web site. EventStream get onConnectExternal => $js.chrome.runtime.onConnectExternal.asStream(($c) => ($js.Port port) { return $c(Port.fromJS(port)); @@ -381,12 +383,25 @@ class ChromeRuntime { /// The operating system Chrome is running on. enum PlatformOs { + /// Specifies the MacOS operating system. mac('mac'), + + /// Specifies the Windows operating system. win('win'), + + /// Specifies the Android operating system. android('android'), + + /// Specifies the Chrome operating system. cros('cros'), + + /// Specifies the Linux operating system. linux('linux'), + + /// Specifies the OpenBSD operating system. openbsd('openbsd'), + + /// Specifies the Fuchsia operating system. fuchsia('fuchsia'); const PlatformOs(this.value); @@ -400,11 +415,22 @@ enum PlatformOs { /// The machine's processor architecture. enum PlatformArch { + /// Specifies the processer architecture as arm. arm('arm'), + + /// Specifies the processer architecture as arm64. arm64('arm64'), + + /// Specifies the processer architecture as x86-32. x8632('x86-32'), + + /// Specifies the processer architecture as x86-64. x8664('x86-64'), + + /// Specifies the processer architecture as mips. mips('mips'), + + /// Specifies the processer architecture as mips64. mips64('mips64'); const PlatformArch(this.value); @@ -419,10 +445,19 @@ enum PlatformArch { /// The native client architecture. This may be different from arch on some /// platforms. enum PlatformNaclArch { + /// Specifies the native client architecture as arm. arm('arm'), + + /// Specifies the native client architecture as x86-32. x8632('x86-32'), + + /// Specifies the native client architecture as x86-64. x8664('x86-64'), + + /// Specifies the native client architecture as mips. mips('mips'), + + /// Specifies the native client architecture as mips64. mips64('mips64'); const PlatformNaclArch(this.value); @@ -436,8 +471,14 @@ enum PlatformNaclArch { /// Result of the update check. enum RequestUpdateCheckStatus { + /// Specifies that the status check has been throttled. This can occur after + /// repeated checks within a short amount of time. throttled('throttled'), + + /// Specifies that there are no available updates to install. noUpdate('no_update'), + + /// Specifies that there is an available update to install. updateAvailable('update_available'); const RequestUpdateCheckStatus(this.value); @@ -451,9 +492,16 @@ enum RequestUpdateCheckStatus { /// The reason that this event is being dispatched. enum OnInstalledReason { + /// Specifies the event reason as an installation. install('install'), + + /// Specifies the event reason as an extension update. update('update'), + + /// Specifies the event reason as a Chrome update. chromeUpdate('chrome_update'), + + /// Specifies the event reason as an update to a shared module. sharedModuleUpdate('shared_module_update'); const OnInstalledReason(this.value); @@ -471,8 +519,13 @@ enum OnInstalledReason { /// updated to a newer version. 'periodic' is used when the system runs for more /// than the permitted uptime set in the enterprise policy. enum OnRestartRequiredReason { + /// Specifies the event reason as an update to the app. appUpdate('app_update'), + + /// Specifies the event reason as an update to the operating system. osUpdate('os_update'), + + /// Specifies the event reason as a periodic restart of the app. periodic('periodic'); const OnRestartRequiredReason(this.value); @@ -485,10 +538,19 @@ enum OnRestartRequiredReason { } enum ContextType { + /// Specifies the context type as a tab tab('TAB'), + + /// Specifies the context type as an extension popup window popup('POPUP'), + + /// Specifies the context type as a service worker. background('BACKGROUND'), + + /// Specifies the context type as an offscreen document. offscreenDocument('OFFSCREEN_DOCUMENT'), + + /// Specifies the context type as a side panel. sidePanel('SIDE_PANEL'); const ContextType(this.value); diff --git a/lib/scripting.dart b/lib/scripting.dart index ddbc6b4..cc34063 100644 --- a/lib/scripting.dart +++ b/lib/scripting.dart @@ -136,10 +136,12 @@ enum StyleOrigin { /// The JavaScript world for a script to execute within. enum ExecutionWorld { - /// The isolated world, unique to this extension. + /// Specifies the isolated world, which is the execution environment unique + /// to this extension. isolated('ISOLATED'), - /// The main world of the DOM, shared with the page's JavaScript. + /// Specifies the main world of the DOM, which is the execution environment + /// shared with the host page's JavaScript. main('MAIN'); const ExecutionWorld(this.value); @@ -229,11 +231,11 @@ class ScriptInjection { /// A JavaScript function to inject. This function will be serialized, and /// then deserialized for injection. This means that any bound parameters /// and execution context will be lost. - /// Exactly one of `files` and `func` must be + /// Exactly one of `files` or `func` must be /// specified. JSAny? func, - /// The arguments to curry into a provided function. This is only valid if + /// The arguments to pass to the provided function. This is only valid if /// the `func` parameter is specified. These arguments must be /// JSON-serializable. List? args, @@ -247,7 +249,7 @@ class ScriptInjection { /// The path of the JS or CSS files to inject, relative to the extension's /// root directory. - /// Exactly one of `files` and `func` must be + /// Exactly one of `files` or `func` must be /// specified. List? files, @@ -280,7 +282,7 @@ class ScriptInjection { /// A JavaScript function to inject. This function will be serialized, and /// then deserialized for injection. This means that any bound parameters /// and execution context will be lost. - /// Exactly one of `files` and `func` must be + /// Exactly one of `files` or `func` must be /// specified. JSAny? get func => _wrapped.func; @@ -288,7 +290,7 @@ class ScriptInjection { _wrapped.func = v; } - /// The arguments to curry into a provided function. This is only valid if + /// The arguments to pass to the provided function. This is only valid if /// the `func` parameter is specified. These arguments must be /// JSON-serializable. List? get args => @@ -311,7 +313,7 @@ class ScriptInjection { /// The path of the JS or CSS files to inject, relative to the extension's /// root directory. - /// Exactly one of `files` and `func` must be + /// Exactly one of `files` or `func` must be /// specified. List? get files => _wrapped.files?.toDart.cast().map((e) => e).toList(); @@ -465,15 +467,15 @@ class RegisteredContentScript { required String id, /// Specifies which pages this content script will be injected into. See - /// [Match Patterns](match_patterns) for more details on the - /// syntax of these strings. Must be specified for + /// [Match Patterns](develop/concepts/match-patterns) for more + /// details on the syntax of these strings. Must be specified for /// [registerContentScripts]. List? matches, /// Excludes pages that this content script would otherwise be injected /// into. - /// See [Match Patterns](match_patterns) for more details on the - /// syntax of these strings. + /// See [Match Patterns](develop/concepts/match-patterns) for + /// more details on the syntax of these strings. List? excludeMatches, /// The list of CSS files to be injected into matching pages. These are @@ -492,8 +494,13 @@ class RegisteredContentScript { /// frame is matched. bool? allFrames, - /// TODO(devlin): Add documentation once the implementation is complete. See - /// crbug.com/55084. + /// Indicates whether the script can be injected into frames where the URL + /// contains an unsupported scheme; specifically: about:, data:, blob:, or + /// filesystem:. In these cases, the URL's origin is checked to determine if + /// the script should be injected. If the origin is `null` (as is the case + /// for data: URLs) then the used origin is either the frame that created + /// the current frame or the frame that initiated the navigation to this + /// frame. Note that this may not be the parent frame. bool? matchOriginAsFallback, /// Specifies when JavaScript files are injected into the web page. The @@ -533,8 +540,8 @@ class RegisteredContentScript { } /// Specifies which pages this content script will be injected into. See - /// [Match Patterns](match_patterns) for more details on the - /// syntax of these strings. Must be specified for + /// [Match Patterns](develop/concepts/match-patterns) for more + /// details on the syntax of these strings. Must be specified for /// [registerContentScripts]. List? get matches => _wrapped.matches?.toDart.cast().map((e) => e).toList(); @@ -544,8 +551,8 @@ class RegisteredContentScript { } /// Excludes pages that this content script would otherwise be injected into. - /// See [Match Patterns](match_patterns) for more details on the - /// syntax of these strings. + /// See [Match Patterns](develop/concepts/match-patterns) for + /// more details on the syntax of these strings. List? get excludeMatches => _wrapped.excludeMatches?.toDart.cast().map((e) => e).toList(); @@ -583,8 +590,13 @@ class RegisteredContentScript { _wrapped.allFrames = v; } - /// TODO(devlin): Add documentation once the implementation is complete. See - /// crbug.com/55084. + /// Indicates whether the script can be injected into frames where the URL + /// contains an unsupported scheme; specifically: about:, data:, blob:, or + /// filesystem:. In these cases, the URL's origin is checked to determine if + /// the script should be injected. If the origin is `null` (as is the case + /// for data: URLs) then the used origin is either the frame that created + /// the current frame or the frame that initiated the navigation to this + /// frame. Note that this may not be the parent frame. bool? get matchOriginAsFallback => _wrapped.matchOriginAsFallback; set matchOriginAsFallback(bool? v) { diff --git a/lib/search.dart b/lib/search.dart index e864fd8..dfd82a3 100644 --- a/lib/search.dart +++ b/lib/search.dart @@ -29,13 +29,14 @@ class ChromeSearch { } enum Disposition { - /// Display results in the calling tab or the tab from the active browser. + /// Specifies that the search results display in the calling tab or the tab + /// from the active browser. currentTab('CURRENT_TAB'), - /// Display search results in a new tab. + /// Specifies that the search results display in a new tab. newTab('NEW_TAB'), - /// Display search results in a new window. + /// Specifies that the search results display in a new window. newWindow('NEW_WINDOW'); const Disposition(this.value); diff --git a/lib/side_panel.dart b/lib/side_panel.dart index a53e64f..568fbfc 100644 --- a/lib/side_panel.dart +++ b/lib/side_panel.dart @@ -216,7 +216,7 @@ class OpenOptions { /// the extension has a global (non-tab-specific) side panel or /// `tabId` is also specified. This will override any /// currently-active global side panel the user has open in the given - /// window. At least one of this and `tabId` must be provided. + /// window. At least one of this or `tabId` must be provided. int? windowId, /// The tab in which to open the side panel. If the corresponding tab has @@ -225,7 +225,7 @@ class OpenOptions { /// the specified tab and any other tabs without a currently-open tab- /// specific panel. This will override any currently-active side panel /// (global or tab-specific) in the corresponding tab. At least one of this - /// and `windowId` must be provided. + /// or `windowId` must be provided. int? tabId, }) : _wrapped = $js.OpenOptions( windowId: windowId, @@ -240,7 +240,7 @@ class OpenOptions { /// the extension has a global (non-tab-specific) side panel or /// `tabId` is also specified. This will override any /// currently-active global side panel the user has open in the given - /// window. At least one of this and `tabId` must be provided. + /// window. At least one of this or `tabId` must be provided. int? get windowId => _wrapped.windowId; set windowId(int? v) { @@ -253,7 +253,7 @@ class OpenOptions { /// the specified tab and any other tabs without a currently-open tab- /// specific panel. This will override any currently-active side panel /// (global or tab-specific) in the corresponding tab. At least one of this - /// and `windowId` must be provided. + /// or `windowId` must be provided. int? get tabId => _wrapped.tabId; set tabId(int? v) { diff --git a/lib/src/internal_helpers.dart b/lib/src/internal_helpers.dart index c07e957..f596f0c 100644 --- a/lib/src/internal_helpers.dart +++ b/lib/src/internal_helpers.dart @@ -46,6 +46,8 @@ extension JSAnyExtension on JSAny { extension JSChoiceExtension on T { Object when({ int Function(int)? isInt, + double Function(double)? isDouble, + bool Function(bool)? isBool, String Function(String)? isString, List Function(JSArray)? isArray, Map Function(JSAny)? isMap, @@ -57,6 +59,12 @@ extension JSChoiceExtension on T { if (isInt != null && (this is num || instanceOfString(this, 'Number'))) { return isInt(this as int); } + if (isDouble != null && (this is num || instanceOfString(this, 'Number'))) { + return isDouble(this as double); + } + if (isBool != null && (this is bool || instanceOfString(this, 'Boolean'))) { + return isBool(this as bool); + } if (isString != null && (this is String || instanceOfString(this, 'String'))) { return isString(this as String); diff --git a/lib/src/js/accessibility_features.dart b/lib/src/js/accessibility_features.dart index 9b554bd..3f4c47a 100644 --- a/lib/src/js/accessibility_features.dart +++ b/lib/src/js/accessibility_features.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -30,11 +31,7 @@ extension JSChromeJSAccessibilityFeaturesExtension on JSChrome { } } -@JS() -@staticInterop -class JSAccessibilityFeatures {} - -extension JSAccessibilityFeaturesExtension on JSAccessibilityFeatures { +extension type JSAccessibilityFeatures._(JSObject _) { /// *ChromeOS only.* /// /// Spoken feedback (text-to-speech). The value indicates whether the feature diff --git a/lib/src/js/action.dart b/lib/src/js/action.dart index 39e6636..d04902c 100644 --- a/lib/src/js/action.dart +++ b/lib/src/js/action.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSActionExtension on JSChrome { } } -@JS() -@staticInterop -class JSAction {} - -extension JSActionExtension on JSAction { +extension type JSAction._(JSObject _) { /// Sets the title of the action. This shows up in the tooltip. external JSPromise setTitle(SetTitleDetails details); @@ -55,7 +52,7 @@ extension JSActionExtension on JSAction { /// non-tab-specific badge text is returned. If /// [displayActionCountAsBadgeText](declarativeNetRequest#setExtensionActionOptions) /// is enabled, a placeholder text will be returned unless the - /// [declarativeNetRequestFeedback](declare_permissions#declarativeNetRequestFeedback) + /// [declarativeNetRequestFeedback](/docs/extensions/develop/concepts/declare-permissions#declarativeNetRequestFeedback) /// permission is present or tab-specific badge text was provided. external JSPromise getBadgeText(TabDetails details); @@ -105,64 +102,42 @@ extension JSActionExtension on JSAction { /// action has a popup. external Event get onClicked; } - -@JS() -@staticInterop -@anonymous -class TabDetails { +extension type TabDetails._(JSObject _) implements JSObject { external factory TabDetails( { /// The ID of the tab to query state for. If no tab is specified, the /// non-tab-specific state is returned. int? tabId}); -} -extension TabDetailsExtension on TabDetails { /// The ID of the tab to query state for. If no tab is specified, the /// non-tab-specific state is returned. external int? tabId; } - -@JS() -@staticInterop -@anonymous -class UserSettings { +extension type UserSettings._(JSObject _) implements JSObject { external factory UserSettings( { /// Whether the extension's action icon is visible on browser windows' /// top-level toolbar (i.e., whether the extension has been 'pinned' by the /// user). bool isOnToolbar}); -} -extension UserSettingsExtension on UserSettings { /// Whether the extension's action icon is visible on browser windows' /// top-level toolbar (i.e., whether the extension has been 'pinned' by the /// user). external bool isOnToolbar; } - -@JS() -@staticInterop -@anonymous -class OpenPopupOptions { +extension type OpenPopupOptions._(JSObject _) implements JSObject { external factory OpenPopupOptions( { /// The id of the window to open the action popup in. Defaults to the /// currently-active window if unspecified. int? windowId}); -} -extension OpenPopupOptionsExtension on OpenPopupOptions { /// The id of the window to open the action popup in. Defaults to the /// currently-active window if unspecified. external int? windowId; } - -@JS() -@staticInterop -@anonymous -class SetTitleDetails { +extension type SetTitleDetails._(JSObject _) implements JSObject { external factory SetTitleDetails({ /// The string the action should display when moused over. String title, @@ -171,9 +146,7 @@ class SetTitleDetails { /// resets when the tab is closed. int? tabId, }); -} -extension SetTitleDetailsExtension on SetTitleDetails { /// The string the action should display when moused over. external String title; @@ -181,11 +154,7 @@ extension SetTitleDetailsExtension on SetTitleDetails { /// resets when the tab is closed. external int? tabId; } - -@JS() -@staticInterop -@anonymous -class SetIconDetails { +extension type SetIconDetails._(JSObject _) implements JSObject { external factory SetIconDetails({ /// Either an ImageData object or a dictionary {size -> ImageData} /// representing icon to be set. If the icon is specified as a dictionary, the @@ -210,9 +179,7 @@ class SetIconDetails { /// resets when the tab is closed. int? tabId, }); -} -extension SetIconDetailsExtension on SetIconDetails { /// Either an ImageData object or a dictionary {size -> ImageData} /// representing icon to be set. If the icon is specified as a dictionary, the /// actual image to be used is chosen depending on screen's pixel density. If @@ -236,11 +203,7 @@ extension SetIconDetailsExtension on SetIconDetails { /// resets when the tab is closed. external int? tabId; } - -@JS() -@staticInterop -@anonymous -class SetPopupDetails { +extension type SetPopupDetails._(JSObject _) implements JSObject { external factory SetPopupDetails({ /// Limits the change to when a particular tab is selected. Automatically /// resets when the tab is closed. @@ -250,9 +213,7 @@ class SetPopupDetails { /// string (`''`), no popup is shown. String popup, }); -} -extension SetPopupDetailsExtension on SetPopupDetails { /// Limits the change to when a particular tab is selected. Automatically /// resets when the tab is closed. external int? tabId; @@ -261,11 +222,7 @@ extension SetPopupDetailsExtension on SetPopupDetails { /// string (`''`), no popup is shown. external String popup; } - -@JS() -@staticInterop -@anonymous -class SetBadgeTextDetails { +extension type SetBadgeTextDetails._(JSObject _) implements JSObject { external factory SetBadgeTextDetails({ /// Any number of characters can be passed, but only about four can fit in the /// space. If an empty string (`''`) is passed, the badge text is cleared. If @@ -277,9 +234,7 @@ class SetBadgeTextDetails { /// resets when the tab is closed. int? tabId, }); -} -extension SetBadgeTextDetailsExtension on SetBadgeTextDetails { /// Any number of characters can be passed, but only about four can fit in the /// space. If an empty string (`''`) is passed, the badge text is cleared. If /// `tabId` is specified and `text` is null, the text for the specified tab is @@ -290,11 +245,8 @@ extension SetBadgeTextDetailsExtension on SetBadgeTextDetails { /// resets when the tab is closed. external int? tabId; } - -@JS() -@staticInterop -@anonymous -class SetBadgeBackgroundColorDetails { +extension type SetBadgeBackgroundColorDetails._(JSObject _) + implements JSObject { external factory SetBadgeBackgroundColorDetails({ /// An array of four integers in the range [0,255] that make up the RGBA color /// of the badge. For example, opaque red is `[255, 0, 0, 255]`. Can also be a @@ -305,10 +257,7 @@ class SetBadgeBackgroundColorDetails { /// resets when the tab is closed. int? tabId, }); -} -extension SetBadgeBackgroundColorDetailsExtension - on SetBadgeBackgroundColorDetails { /// An array of four integers in the range [0,255] that make up the RGBA color /// of the badge. For example, opaque red is `[255, 0, 0, 255]`. Can also be a /// string with a CSS value, with opaque red being `#FF0000` or `#F00`. @@ -318,11 +267,7 @@ extension SetBadgeBackgroundColorDetailsExtension /// resets when the tab is closed. external int? tabId; } - -@JS() -@staticInterop -@anonymous -class SetBadgeTextColorDetails { +extension type SetBadgeTextColorDetails._(JSObject _) implements JSObject { external factory SetBadgeTextColorDetails({ /// An array of four integers in the range [0,255] that make up the RGBA color /// of the badge. For example, opaque red is `[255, 0, 0, 255]`. Can also be a @@ -337,9 +282,7 @@ class SetBadgeTextColorDetails { /// resets when the tab is closed. int? tabId, }); -} -extension SetBadgeTextColorDetailsExtension on SetBadgeTextColorDetails { /// An array of four integers in the range [0,255] that make up the RGBA color /// of the badge. For example, opaque red is `[255, 0, 0, 255]`. Can also be a /// string with a CSS value, with opaque red being `#FF0000` or `#F00`. Not diff --git a/lib/src/js/alarms.dart b/lib/src/js/alarms.dart index 20f2998..264b304 100644 --- a/lib/src/js/alarms.dart +++ b/lib/src/js/alarms.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,23 +24,19 @@ extension JSChromeJSAlarmsExtension on JSChrome { } } -@JS() -@staticInterop -class JSAlarms {} - -extension JSAlarmsExtension on JSAlarms { +extension type JSAlarms._(JSObject _) { /// Creates an alarm. Near the time(s) specified by [alarmInfo], /// the `onAlarm` event is fired. If there is another alarm with /// the same name (or no name if none is specified), it will be cancelled and /// replaced by this alarm. /// /// In order to reduce the load on the user's machine, Chrome limits alarms - /// to at most once every 1 minute but may delay them an arbitrary amount + /// to at most once every 30 seconds but may delay them an arbitrary amount /// more. That is, setting `delayInMinutes` or - /// `periodInMinutes` to less than `1` will not be + /// `periodInMinutes` to less than `0.5` will not be /// honored and will cause a warning. `when` can be set to less - /// than 1 minute after "now" without warning but won't actually cause the - /// alarm to fire for at least 1 minute. + /// than 30 seconds after "now" without warning but won't actually cause the + /// alarm to fire for at least 30 seconds. /// /// To help you debug your app or extension, when you've loaded it unpacked, /// there's no limit to how often the alarm can fire. @@ -77,11 +74,7 @@ extension JSAlarmsExtension on JSAlarms { /// |alarm|: The alarm that has elapsed. external Event get onAlarm; } - -@JS() -@staticInterop -@anonymous -class Alarm { +extension type Alarm._(JSObject _) implements JSObject { external factory Alarm({ /// Name of this alarm. String name, @@ -95,9 +88,7 @@ class Alarm { /// [periodInMinutes] minutes. double? periodInMinutes, }); -} -extension AlarmExtension on Alarm { /// Name of this alarm. external String name; @@ -110,11 +101,7 @@ extension AlarmExtension on Alarm { /// [periodInMinutes] minutes. external double? periodInMinutes; } - -@JS() -@staticInterop -@anonymous -class AlarmCreateInfo { +extension type AlarmCreateInfo._(JSObject _) implements JSObject { external factory AlarmCreateInfo({ /// Time at which the alarm should fire, in milliseconds past the epoch /// (e.g. `Date.now() + n`). @@ -133,9 +120,7 @@ class AlarmCreateInfo { /// double? periodInMinutes, }); -} -extension AlarmCreateInfoExtension on AlarmCreateInfo { /// Time at which the alarm should fire, in milliseconds past the epoch /// (e.g. `Date.now() + n`). external double? when; diff --git a/lib/src/js/audio.dart b/lib/src/js/audio.dart index 4cca81c..ebce6b1 100644 --- a/lib/src/js/audio.dart +++ b/lib/src/js/audio.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -25,11 +26,7 @@ extension JSChromeJSAudioExtension on JSChrome { } } -@JS() -@staticInterop -class JSAudio {} - -extension JSAudioExtension on JSAudio { +extension type JSAudio._(JSObject _) { /// Gets a list of audio devices filtered based on |filter|. /// |filter|: Device properties by which to filter the list of returned /// audio devices. If the filter is not set or set to `{}`, @@ -85,11 +82,7 @@ typedef StreamType = String; /// Available audio device types. typedef DeviceType = String; - -@JS() -@staticInterop -@anonymous -class AudioDeviceInfo { +extension type AudioDeviceInfo._(JSObject _) implements JSObject { external factory AudioDeviceInfo({ /// The unique identifier of the audio device. String id, @@ -115,9 +108,7 @@ class AudioDeviceInfo { /// The stable/persisted device id string when available. String? stableDeviceId, }); -} -extension AudioDeviceInfoExtension on AudioDeviceInfo { /// The unique identifier of the audio device. external String id; @@ -142,11 +133,7 @@ extension AudioDeviceInfoExtension on AudioDeviceInfo { /// The stable/persisted device id string when available. external String? stableDeviceId; } - -@JS() -@staticInterop -@anonymous -class DeviceFilter { +extension type DeviceFilter._(JSObject _) implements JSObject { external factory DeviceFilter({ /// If set, only audio devices whose stream type is included in this list /// will satisfy the filter. @@ -156,9 +143,7 @@ class DeviceFilter { /// satisfy the filter. bool? isActive, }); -} -extension DeviceFilterExtension on DeviceFilter { /// If set, only audio devices whose stream type is included in this list /// will satisfy the filter. external JSArray? streamTypes; @@ -167,11 +152,7 @@ extension DeviceFilterExtension on DeviceFilter { /// satisfy the filter. external bool? isActive; } - -@JS() -@staticInterop -@anonymous -class DeviceProperties { +extension type DeviceProperties._(JSObject _) implements JSObject { external factory DeviceProperties( { /// @@ -181,9 +162,7 @@ class DeviceProperties { /// If used with audio input device, represents audio device gain. /// If used with audio output device, represents audio device volume. int? level}); -} -extension DevicePropertiesExtension on DeviceProperties { /// /// The audio device's desired sound level. Defaults to the device's /// current sound level. @@ -192,11 +171,7 @@ extension DevicePropertiesExtension on DeviceProperties { /// If used with audio output device, represents audio device volume. external int? level; } - -@JS() -@staticInterop -@anonymous -class DeviceIdLists { +extension type DeviceIdLists._(JSObject _) implements JSObject { external factory DeviceIdLists({ /// List of input devices specified by their ID. /// To indicate input devices should be unaffected, leave this property @@ -208,9 +183,7 @@ class DeviceIdLists { /// unset. JSArray? output, }); -} -extension DeviceIdListsExtension on DeviceIdLists { /// List of input devices specified by their ID. /// To indicate input devices should be unaffected, leave this property /// unset. @@ -221,11 +194,7 @@ extension DeviceIdListsExtension on DeviceIdLists { /// unset. external JSArray? output; } - -@JS() -@staticInterop -@anonymous -class MuteChangedEvent { +extension type MuteChangedEvent._(JSObject _) implements JSObject { external factory MuteChangedEvent({ /// The type of the stream for which the mute value changed. The updated mute /// value applies to all devices with this stream type. @@ -234,9 +203,7 @@ class MuteChangedEvent { /// Whether or not the stream is now muted. bool isMuted, }); -} -extension MuteChangedEventExtension on MuteChangedEvent { /// The type of the stream for which the mute value changed. The updated mute /// value applies to all devices with this stream type. external StreamType streamType; @@ -244,11 +211,7 @@ extension MuteChangedEventExtension on MuteChangedEvent { /// Whether or not the stream is now muted. external bool isMuted; } - -@JS() -@staticInterop -@anonymous -class LevelChangedEvent { +extension type LevelChangedEvent._(JSObject _) implements JSObject { external factory LevelChangedEvent({ /// ID of device whose sound level has changed. String deviceId, @@ -256,9 +219,7 @@ class LevelChangedEvent { /// The device's new sound level. int level, }); -} -extension LevelChangedEventExtension on LevelChangedEvent { /// ID of device whose sound level has changed. external String deviceId; diff --git a/lib/src/js/bookmarks.dart b/lib/src/js/bookmarks.dart index da8d511..f2a72dc 100644 --- a/lib/src/js/bookmarks.dart +++ b/lib/src/js/bookmarks.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,11 +25,7 @@ extension JSChromeJSBookmarksExtension on JSChrome { } } -@JS() -@staticInterop -class JSBookmarks {} - -extension JSBookmarksExtension on JSBookmarks { +extension type JSBookmarks._(JSObject _) { /// Retrieves the specified BookmarkTreeNode(s). external JSPromise get( @@ -124,11 +121,7 @@ extension JSBookmarksExtension on JSBookmarks { /// indicates that this node was configured by the system administrator. Omitted /// if the node can be modified by the user and the extension (default). typedef BookmarkTreeNodeUnmodifiable = String; - -@JS() -@staticInterop -@anonymous -class BookmarkTreeNode { +extension type BookmarkTreeNode._(JSObject _) implements JSObject { external factory BookmarkTreeNode({ /// The unique identifier for the node. IDs are unique within the current /// profile, and they remain valid even after the browser is restarted. @@ -167,9 +160,7 @@ class BookmarkTreeNode { /// An ordered list of children of this node. JSArray? children, }); -} -extension BookmarkTreeNodeExtension on BookmarkTreeNode { /// The unique identifier for the node. IDs are unique within the current /// profile, and they remain valid even after the browser is restarted. external String id; @@ -207,11 +198,7 @@ extension BookmarkTreeNodeExtension on BookmarkTreeNode { /// An ordered list of children of this node. external JSArray? children; } - -@JS() -@staticInterop -@anonymous -class CreateDetails { +extension type CreateDetails._(JSObject _) implements JSObject { external factory CreateDetails({ /// Defaults to the Other Bookmarks folder. String? parentId, @@ -219,9 +206,7 @@ class CreateDetails { String? title, String? url, }); -} -extension CreateDetailsExtension on CreateDetails { /// Defaults to the Other Bookmarks folder. external String? parentId; @@ -231,55 +216,37 @@ extension CreateDetailsExtension on CreateDetails { external String? url; } - -@JS() -@staticInterop -@anonymous -class OnRemovedRemoveInfo { +extension type OnRemovedRemoveInfo._(JSObject _) implements JSObject { external factory OnRemovedRemoveInfo({ String parentId, int index, BookmarkTreeNode node, }); -} -extension OnRemovedRemoveInfoExtension on OnRemovedRemoveInfo { external String parentId; external int index; external BookmarkTreeNode node; } - -@JS() -@staticInterop -@anonymous -class OnChangedChangeInfo { +extension type OnChangedChangeInfo._(JSObject _) implements JSObject { external factory OnChangedChangeInfo({ String title, String? url, }); -} -extension OnChangedChangeInfoExtension on OnChangedChangeInfo { external String title; external String? url; } - -@JS() -@staticInterop -@anonymous -class OnMovedMoveInfo { +extension type OnMovedMoveInfo._(JSObject _) implements JSObject { external factory OnMovedMoveInfo({ String parentId, int index, String oldParentId, int oldIndex, }); -} -extension OnMovedMoveInfoExtension on OnMovedMoveInfo { external String parentId; external int index; @@ -288,23 +255,13 @@ extension OnMovedMoveInfoExtension on OnMovedMoveInfo { external int oldIndex; } - -@JS() -@staticInterop -@anonymous -class OnChildrenReorderedReorderInfo { +extension type OnChildrenReorderedReorderInfo._(JSObject _) + implements JSObject { external factory OnChildrenReorderedReorderInfo({JSArray childIds}); -} -extension OnChildrenReorderedReorderInfoExtension - on OnChildrenReorderedReorderInfo { external JSArray childIds; } - -@JS() -@staticInterop -@anonymous -class SearchQuery { +extension type SearchQuery._(JSObject _) implements JSObject { external factory SearchQuery({ /// A string of words and quoted phrases that are matched against bookmark /// URLs and titles. @@ -316,9 +273,7 @@ class SearchQuery { /// The title of the bookmark; matches verbatim. String? title, }); -} -extension SearchQueryExtension on SearchQuery { /// A string of words and quoted phrases that are matched against bookmark /// URLs and titles. external String? query; @@ -329,34 +284,22 @@ extension SearchQueryExtension on SearchQuery { /// The title of the bookmark; matches verbatim. external String? title; } - -@JS() -@staticInterop -@anonymous -class MoveDestination { +extension type MoveDestination._(JSObject _) implements JSObject { external factory MoveDestination({ String? parentId, int? index, }); -} -extension MoveDestinationExtension on MoveDestination { external String? parentId; external int? index; } - -@JS() -@staticInterop -@anonymous -class UpdateChanges { +extension type UpdateChanges._(JSObject _) implements JSObject { external factory UpdateChanges({ String? title, String? url, }); -} -extension UpdateChangesExtension on UpdateChanges { external String? title; external String? url; diff --git a/lib/src/js/browser_action.dart b/lib/src/js/browser_action.dart index 74a1f50..93154f8 100644 --- a/lib/src/js/browser_action.dart +++ b/lib/src/js/browser_action.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -15,7 +16,7 @@ extension JSChromeJSBrowserActionExtension on JSChrome { /// Use browser actions to put icons in the main Google Chrome toolbar, to the /// right of the address bar. In addition to its [icon](browserAction#icon), a /// browser action can have a [tooltip](browserAction#tooltip), a - /// [badge](browserAction#badge), and a [popup](browserAction#popups). + /// [badge](browserAction#badge), and a [popup](browserAction#popup). JSBrowserAction get browserAction { var browserActionNullable = this.browserActionNullable; if (browserActionNullable == null) { @@ -25,11 +26,7 @@ extension JSChromeJSBrowserActionExtension on JSChrome { } } -@JS() -@staticInterop -class JSBrowserAction {} - -extension JSBrowserActionExtension on JSBrowserAction { +extension type JSBrowserAction._(JSObject _) { /// Sets the title of the browser action. This title appears in the tooltip. external JSPromise setTitle(SetTitleDetails details); @@ -90,28 +87,18 @@ typedef ColorArray = JSArray; /// Pixel data for an image. Must be an ImageData object; for example, from a /// `canvas` element. typedef ImageDataType = JSObject; - -@JS() -@staticInterop -@anonymous -class TabDetails { +extension type TabDetails._(JSObject _) implements JSObject { external factory TabDetails( { /// The ID of the tab to query state for. If no tab is specified, the /// non-tab-specific state is returned. int? tabId}); -} -extension TabDetailsExtension on TabDetails { /// The ID of the tab to query state for. If no tab is specified, the /// non-tab-specific state is returned. external int? tabId; } - -@JS() -@staticInterop -@anonymous -class SetTitleDetails { +extension type SetTitleDetails._(JSObject _) implements JSObject { external factory SetTitleDetails({ /// The string the browser action should display when moused over. String title, @@ -120,9 +107,7 @@ class SetTitleDetails { /// resets when the tab is closed. int? tabId, }); -} -extension SetTitleDetailsExtension on SetTitleDetails { /// The string the browser action should display when moused over. external String title; @@ -130,11 +115,7 @@ extension SetTitleDetailsExtension on SetTitleDetails { /// resets when the tab is closed. external int? tabId; } - -@JS() -@staticInterop -@anonymous -class SetIconDetails { +extension type SetIconDetails._(JSObject _) implements JSObject { external factory SetIconDetails({ /// Either an ImageData object or a dictionary {size -> ImageData} /// representing an icon to be set. If the icon is specified as a dictionary, @@ -159,9 +140,7 @@ class SetIconDetails { /// resets when the tab is closed. int? tabId, }); -} -extension SetIconDetailsExtension on SetIconDetails { /// Either an ImageData object or a dictionary {size -> ImageData} /// representing an icon to be set. If the icon is specified as a dictionary, /// the image used is chosen depending on the screen's pixel density. If the @@ -185,11 +164,7 @@ extension SetIconDetailsExtension on SetIconDetails { /// resets when the tab is closed. external int? tabId; } - -@JS() -@staticInterop -@anonymous -class SetPopupDetails { +extension type SetPopupDetails._(JSObject _) implements JSObject { external factory SetPopupDetails({ /// Limits the change to when a particular tab is selected. Automatically /// resets when the tab is closed. @@ -199,9 +174,7 @@ class SetPopupDetails { /// string (`''`), no popup is shown. String popup, }); -} -extension SetPopupDetailsExtension on SetPopupDetails { /// Limits the change to when a particular tab is selected. Automatically /// resets when the tab is closed. external int? tabId; @@ -210,11 +183,7 @@ extension SetPopupDetailsExtension on SetPopupDetails { /// string (`''`), no popup is shown. external String popup; } - -@JS() -@staticInterop -@anonymous -class SetBadgeTextDetails { +extension type SetBadgeTextDetails._(JSObject _) implements JSObject { external factory SetBadgeTextDetails({ /// Any number of characters can be passed, but only about four can fit into /// the space. If an empty string (`''`) is passed, the badge text is cleared. @@ -226,9 +195,7 @@ class SetBadgeTextDetails { /// resets when the tab is closed. int? tabId, }); -} -extension SetBadgeTextDetailsExtension on SetBadgeTextDetails { /// Any number of characters can be passed, but only about four can fit into /// the space. If an empty string (`''`) is passed, the badge text is cleared. /// If `tabId` is specified and `text` is null, the text for the specified @@ -239,11 +206,8 @@ extension SetBadgeTextDetailsExtension on SetBadgeTextDetails { /// resets when the tab is closed. external int? tabId; } - -@JS() -@staticInterop -@anonymous -class SetBadgeBackgroundColorDetails { +extension type SetBadgeBackgroundColorDetails._(JSObject _) + implements JSObject { external factory SetBadgeBackgroundColorDetails({ /// An array of four integers in the range 0-255 that make up the RGBA color /// of the badge. Can also be a string with a CSS hex color value; for @@ -254,10 +218,7 @@ class SetBadgeBackgroundColorDetails { /// resets when the tab is closed. int? tabId, }); -} -extension SetBadgeBackgroundColorDetailsExtension - on SetBadgeBackgroundColorDetails { /// An array of four integers in the range 0-255 that make up the RGBA color /// of the badge. Can also be a string with a CSS hex color value; for /// example, `#FF0000` or `#F00` (red). Renders colors at full opacity. diff --git a/lib/src/js/browsing_data.dart b/lib/src/js/browsing_data.dart index 21ec5d8..8d0a83b 100644 --- a/lib/src/js/browsing_data.dart +++ b/lib/src/js/browsing_data.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSBrowsingDataExtension on JSChrome { } } -@JS() -@staticInterop -class JSBrowsingData {} - -extension JSBrowsingDataExtension on JSBrowsingData { +extension type JSBrowsingData._(JSObject _) { /// Reports which types of data are currently selected in the 'Clear browsing /// data' settings UI. Note: some of the data types included in this API are /// not available in the settings UI, and some UI settings control more than @@ -88,11 +85,7 @@ extension JSBrowsingDataExtension on JSBrowsingData { /// Clears websites' WebSQL data. external JSPromise removeWebSQL(RemovalOptions options); } - -@JS() -@staticInterop -@anonymous -class RemovalOptions { +extension type RemovalOptions._(JSObject _) implements JSObject { external factory RemovalOptions({ /// Remove data accumulated on or after this date, represented in milliseconds /// since the epoch (accessible via the `getTime` method of the JavaScript @@ -116,9 +109,7 @@ class RemovalOptions { /// and cache. Cookies are excluded for the whole registrable domain. JSArray? excludeOrigins, }); -} -extension RemovalOptionsExtension on RemovalOptions { /// Remove data accumulated on or after this date, represented in milliseconds /// since the epoch (accessible via the `getTime` method of the JavaScript /// `Date` object). If absent, defaults to 0 (which would remove all browsing @@ -141,11 +132,7 @@ extension RemovalOptionsExtension on RemovalOptions { /// and cache. Cookies are excluded for the whole registrable domain. external JSArray? excludeOrigins; } - -@JS() -@staticInterop -@anonymous -class DataTypeSet { +extension type DataTypeSet._(JSObject _) implements JSObject { external factory DataTypeSet({ /// Websites' appcaches. bool? appcache, @@ -192,9 +179,7 @@ class DataTypeSet { /// Websites' WebSQL data. bool? webSQL, }); -} -extension DataTypeSetExtension on DataTypeSet { /// Websites' appcaches. external bool? appcache; @@ -240,11 +225,7 @@ extension DataTypeSetExtension on DataTypeSet { /// Websites' WebSQL data. external bool? webSQL; } - -@JS() -@staticInterop -@anonymous -class SettingsCallbackResult { +extension type SettingsCallbackResult._(JSObject _) implements JSObject { external factory SettingsCallbackResult({ RemovalOptions options, @@ -258,9 +239,7 @@ class SettingsCallbackResult { /// if not. DataTypeSet dataRemovalPermitted, }); -} -extension SettingsCallbackResultExtension on SettingsCallbackResult { external RemovalOptions options; /// All of the types will be present in the result, with values of `true` if @@ -273,11 +252,7 @@ extension SettingsCallbackResultExtension on SettingsCallbackResult { /// if not. external DataTypeSet dataRemovalPermitted; } - -@JS() -@staticInterop -@anonymous -class RemovalOptionsOriginTypes { +extension type RemovalOptionsOriginTypes._(JSObject _) implements JSObject { external factory RemovalOptionsOriginTypes({ /// Normal websites. bool? unprotectedWeb, @@ -289,9 +264,7 @@ class RemovalOptionsOriginTypes { /// careful!). bool? extension, }); -} -extension RemovalOptionsOriginTypesExtension on RemovalOptionsOriginTypes { /// Normal websites. external bool? unprotectedWeb; diff --git a/lib/src/js/certificate_provider.dart b/lib/src/js/certificate_provider.dart index db41f47..f8111e9 100644 --- a/lib/src/js/certificate_provider.dart +++ b/lib/src/js/certificate_provider.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSCertificateProviderExtension on JSChrome { } } -@JS() -@staticInterop -class JSCertificateProvider {} - -extension JSCertificateProviderExtension on JSCertificateProvider { +extension type JSCertificateProvider._(JSObject _) { /// Requests the PIN from the user. Only one ongoing request at a time is /// allowed. The requests issued while another flow is ongoing are rejected. /// It's the extension's responsibility to try again later if another flow is @@ -127,11 +124,7 @@ typedef CertificatesCallback = JSFunction; /// padding. If an error occurred, this callback should be called without /// signature. typedef SignCallback = JSFunction; - -@JS() -@staticInterop -@anonymous -class ClientCertificateInfo { +extension type ClientCertificateInfo._(JSObject _) implements JSObject { external factory ClientCertificateInfo({ /// The array must contain the DER encoding of the X.509 client certificate /// as its first element. @@ -142,9 +135,7 @@ class ClientCertificateInfo { /// asked for signatures using one of these algorithms. JSArray supportedAlgorithms, }); -} -extension ClientCertificateInfoExtension on ClientCertificateInfo { /// The array must contain the DER encoding of the X.509 client certificate /// as its first element. /// This must include exactly one certificate. @@ -154,11 +145,7 @@ extension ClientCertificateInfoExtension on ClientCertificateInfo { /// asked for signatures using one of these algorithms. external JSArray supportedAlgorithms; } - -@JS() -@staticInterop -@anonymous -class SetCertificatesDetails { +extension type SetCertificatesDetails._(JSObject _) implements JSObject { external factory SetCertificatesDetails({ /// When called in response to [onCertificatesUpdateRequested], should /// contain the received `certificatesRequestId` value. Otherwise, @@ -172,9 +159,7 @@ class SetCertificatesDetails { /// List of currently available client certificates. JSArray clientCertificates, }); -} -extension SetCertificatesDetailsExtension on SetCertificatesDetails { /// When called in response to [onCertificatesUpdateRequested], should /// contain the received `certificatesRequestId` value. Otherwise, /// should be unset. @@ -187,26 +172,16 @@ extension SetCertificatesDetailsExtension on SetCertificatesDetails { /// List of currently available client certificates. external JSArray clientCertificates; } - -@JS() -@staticInterop -@anonymous -class CertificatesUpdateRequest { +extension type CertificatesUpdateRequest._(JSObject _) implements JSObject { external factory CertificatesUpdateRequest( { /// Request identifier to be passed to [setCertificates]. int certificatesRequestId}); -} -extension CertificatesUpdateRequestExtension on CertificatesUpdateRequest { /// Request identifier to be passed to [setCertificates]. external int certificatesRequestId; } - -@JS() -@staticInterop -@anonymous -class SignatureRequest { +extension type SignatureRequest._(JSObject _) implements JSObject { external factory SignatureRequest({ /// Request identifier to be passed to [reportSignature]. int signRequestId, @@ -221,9 +196,7 @@ class SignatureRequest { /// `input` using the associated private key. JSArrayBuffer certificate, }); -} -extension SignatureRequestExtension on SignatureRequest { /// Request identifier to be passed to [reportSignature]. external int signRequestId; @@ -237,11 +210,7 @@ extension SignatureRequestExtension on SignatureRequest { /// `input` using the associated private key. external JSArrayBuffer certificate; } - -@JS() -@staticInterop -@anonymous -class ReportSignatureDetails { +extension type ReportSignatureDetails._(JSObject _) implements JSObject { external factory ReportSignatureDetails({ /// Request identifier that was received via the [onSignatureRequested] /// event. @@ -253,9 +222,7 @@ class ReportSignatureDetails { /// The signature, if successfully generated. JSArrayBuffer? signature, }); -} -extension ReportSignatureDetailsExtension on ReportSignatureDetails { /// Request identifier that was received via the [onSignatureRequested] /// event. external int signRequestId; @@ -266,11 +233,7 @@ extension ReportSignatureDetailsExtension on ReportSignatureDetails { /// The signature, if successfully generated. external JSArrayBuffer? signature; } - -@JS() -@staticInterop -@anonymous -class CertificateInfo { +extension type CertificateInfo._(JSObject _) implements JSObject { external factory CertificateInfo({ /// Must be the DER encoding of a X.509 certificate. Currently, only /// certificates of RSA keys are supported. @@ -281,9 +244,7 @@ class CertificateInfo { /// hash algorithms. This should be in order of decreasing hash preference. JSArray supportedHashes, }); -} -extension CertificateInfoExtension on CertificateInfo { /// Must be the DER encoding of a X.509 certificate. Currently, only /// certificates of RSA keys are supported. external JSArrayBuffer certificate; @@ -293,11 +254,7 @@ extension CertificateInfoExtension on CertificateInfo { /// hash algorithms. This should be in order of decreasing hash preference. external JSArray supportedHashes; } - -@JS() -@staticInterop -@anonymous -class SignRequest { +extension type SignRequest._(JSObject _) implements JSObject { external factory SignRequest({ /// The unique ID to be used by the extension should it need to call a method /// that requires it, e.g. requestPin. @@ -313,9 +270,7 @@ class SignRequest { /// `digest` using the associated private key. JSArrayBuffer certificate, }); -} -extension SignRequestExtension on SignRequest { /// The unique ID to be used by the extension should it need to call a method /// that requires it, e.g. requestPin. external int signRequestId; @@ -330,11 +285,7 @@ extension SignRequestExtension on SignRequest { /// `digest` using the associated private key. external JSArrayBuffer certificate; } - -@JS() -@staticInterop -@anonymous -class RequestPinDetails { +extension type RequestPinDetails._(JSObject _) implements JSObject { external factory RequestPinDetails({ /// The ID given by Chrome in SignRequest. int signRequestId, @@ -353,9 +304,7 @@ class RequestPinDetails { /// exceeded. int? attemptsLeft, }); -} -extension RequestPinDetailsExtension on RequestPinDetails { /// The ID given by Chrome in SignRequest. external int signRequestId; @@ -373,11 +322,7 @@ extension RequestPinDetailsExtension on RequestPinDetails { /// exceeded. external int? attemptsLeft; } - -@JS() -@staticInterop -@anonymous -class StopPinRequestDetails { +extension type StopPinRequestDetails._(JSObject _) implements JSObject { external factory StopPinRequestDetails({ /// The ID given by Chrome in SignRequest. int signRequestId, @@ -387,9 +332,7 @@ class StopPinRequestDetails { /// e.g. MAX_ATTEMPTS_EXCEEDED. PinRequestErrorType? errorType, }); -} -extension StopPinRequestDetailsExtension on StopPinRequestDetails { /// The ID given by Chrome in SignRequest. external int signRequestId; @@ -398,19 +341,13 @@ extension StopPinRequestDetailsExtension on StopPinRequestDetails { /// e.g. MAX_ATTEMPTS_EXCEEDED. external PinRequestErrorType? errorType; } - -@JS() -@staticInterop -@anonymous -class PinResponseDetails { +extension type PinResponseDetails._(JSObject _) implements JSObject { external factory PinResponseDetails( { /// The code provided by the user. Empty if user closed the dialog or some /// other error occurred. String? userInput}); -} -extension PinResponseDetailsExtension on PinResponseDetails { /// The code provided by the user. Empty if user closed the dialog or some /// other error occurred. external String? userInput; diff --git a/lib/src/js/commands.dart b/lib/src/js/commands.dart index a8641b5..0609a1a 100644 --- a/lib/src/js/commands.dart +++ b/lib/src/js/commands.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,23 +25,16 @@ extension JSChromeJSCommandsExtension on JSChrome { } } -@JS() -@staticInterop -class JSCommands {} - -extension JSCommandsExtension on JSCommands { +extension type JSCommands._(JSObject _) { /// Returns all the registered extension commands for this extension and their - /// shortcut (if active). + /// shortcut (if active). Before Chrome 110, this command did not return + /// `_execute_action`. external JSPromise getAll(); /// Fired when a registered command is activated using a keyboard shortcut. external Event get onCommand; } - -@JS() -@staticInterop -@anonymous -class Command { +extension type Command._(JSObject _) implements JSObject { external factory Command({ /// The name of the Extension Command String? name, @@ -51,9 +45,7 @@ class Command { /// The shortcut active for this command, or blank if not active. String? shortcut, }); -} -extension CommandExtension on Command { /// The name of the Extension Command external String? name; diff --git a/lib/src/js/content_settings.dart b/lib/src/js/content_settings.dart index 19426f2..f7a97b9 100644 --- a/lib/src/js/content_settings.dart +++ b/lib/src/js/content_settings.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -25,11 +26,7 @@ extension JSChromeJSContentSettingsExtension on JSChrome { } } -@JS() -@staticInterop -class JSContentSettings {} - -extension JSContentSettingsExtension on JSContentSettings { +extension type JSContentSettings._(JSObject _) { /// Whether to allow sites to use the [Private State Tokens /// API](https://developer.chrome.com/docs/privacy-sandbox/trust-tokens/). One /// of @@ -117,6 +114,19 @@ extension JSContentSettingsExtension on JSContentSettings { /// NOTE: The 'allow' setting is not valid if both patterns are ''. external ContentSetting get microphone; + /// Whether to allow sites to access the clipboard via advanced capabilities + /// of the Async Clipboard API. "Advanced" capabilities include anything + /// besides writing built-in formats after a user gesture, i.e. the ability to + /// read, the ability to write custom formats, and the ability to write + /// without a user gesture. One of + /// [allow]: Allow sites to use advanced clipboard capabilities, + /// [block]: Don't allow sites to use advanced clipboard capabilties, + /// [ask]: Ask when a site wants to use advanced clipboard capabilities. + /// Default is [ask]. + /// The primary URL is the URL of the document which requested clipboard + /// access. The secondary URL is not used. + external ContentSetting get clipboard; + /// Whether to allow sites to access the camera. One of /// [allow]: Allow sites to access the camera, /// [block]: Don't allow sites to access the camera, @@ -154,6 +164,8 @@ typedef Scope = String; typedef AutoVerifyContentSetting = String; +typedef ClipboardContentSetting = String; + typedef CookiesContentSetting = String; typedef ImagesContentSetting = String; @@ -179,11 +191,7 @@ typedef CameraContentSetting = String; typedef PpapiBrokerContentSetting = String; typedef MultipleAutomaticDownloadsContentSetting = String; - -@JS() -@staticInterop -@anonymous -class ResourceIdentifier { +extension type ResourceIdentifier._(JSObject _) implements JSObject { external factory ResourceIdentifier({ /// The resource identifier for the given content type. String id, @@ -191,24 +199,16 @@ class ResourceIdentifier { /// A human readable description of the resource. String? description, }); -} -extension ResourceIdentifierExtension on ResourceIdentifier { /// The resource identifier for the given content type. external String id; /// A human readable description of the resource. external String? description; } - -@JS() -@staticInterop -@anonymous -class ContentSetting { +extension type ContentSetting._(JSObject _) implements JSObject { external factory ContentSetting(); -} -extension ContentSettingExtension on ContentSetting { /// Clear all content setting rules set by this extension. external JSPromise clear(ClearDetails details); @@ -220,43 +220,27 @@ extension ContentSettingExtension on ContentSetting { external JSPromise getResourceIdentifiers(); } - -@JS() -@staticInterop -@anonymous -class ClearDetails { +extension type ClearDetails._(JSObject _) implements JSObject { external factory ClearDetails( { /// Where to clear the setting (default: regular). Scope? scope}); -} -extension ClearDetailsExtension on ClearDetails { /// Where to clear the setting (default: regular). external Scope? scope; } - -@JS() -@staticInterop -@anonymous -class GetCallbackDetails { +extension type GetCallbackDetails._(JSObject _) implements JSObject { external factory GetCallbackDetails( { /// The content setting. See the description of the individual ContentSetting /// objects for the possible values. JSAny setting}); -} -extension GetCallbackDetailsExtension on GetCallbackDetails { /// The content setting. See the description of the individual ContentSetting /// objects for the possible values. external JSAny setting; } - -@JS() -@staticInterop -@anonymous -class GetDetails { +extension type GetDetails._(JSObject _) implements JSObject { external factory GetDetails({ /// The primary URL for which the content setting should be retrieved. Note /// that the meaning of a primary URL depends on the content type. @@ -275,9 +259,7 @@ class GetDetails { /// false) bool? incognito, }); -} -extension GetDetailsExtension on GetDetails { /// The primary URL for which the content setting should be retrieved. Note /// that the meaning of a primary URL depends on the content type. external String primaryUrl; @@ -295,11 +277,7 @@ extension GetDetailsExtension on GetDetails { /// false) external bool? incognito; } - -@JS() -@staticInterop -@anonymous -class SetDetails { +extension type SetDetails._(JSObject _) implements JSObject { external factory SetDetails({ /// The pattern for the primary URL. For details on the format of a pattern, /// see [Content Setting Patterns](contentSettings#patterns). @@ -320,9 +298,7 @@ class SetDetails { /// Where to set the setting (default: regular). Scope? scope, }); -} -extension SetDetailsExtension on SetDetails { /// The pattern for the primary URL. For details on the format of a pattern, /// see [Content Setting Patterns](contentSettings#patterns). external String primaryPattern; diff --git a/lib/src/js/context_menus.dart b/lib/src/js/context_menus.dart index 533c5c4..edc840d 100644 --- a/lib/src/js/context_menus.dart +++ b/lib/src/js/context_menus.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,11 +25,7 @@ extension JSChromeJSContextMenusExtension on JSChrome { } } -@JS() -@staticInterop -class JSContextMenus {} - -extension JSContextMenusExtension on JSContextMenus { +extension type JSContextMenus._(JSObject _) { /// Creates a new context menu item. If an error occurs during creation, it /// may not be detected until the creation callback fires; details will be in /// [runtime.lastError]. @@ -87,11 +84,7 @@ typedef ContextType = String; /// The type of menu item. typedef ItemType = String; - -@JS() -@staticInterop -@anonymous -class OnClickData { +extension type OnClickData._(JSObject _) implements JSObject { external factory OnClickData({ /// The ID of the menu item that was clicked. JSAny menuItemId, @@ -137,9 +130,7 @@ class OnClickData { /// clicked. bool? checked, }); -} -extension OnClickDataExtension on OnClickData { /// The ID of the menu item that was clicked. external JSAny menuItemId; @@ -184,11 +175,7 @@ extension OnClickDataExtension on OnClickData { /// clicked. external bool? checked; } - -@JS() -@staticInterop -@anonymous -class CreateProperties { +extension type CreateProperties._(JSObject _) implements JSObject { external factory CreateProperties({ /// The type of menu item. Defaults to `normal`. ItemType? type, @@ -215,9 +202,9 @@ class CreateProperties { /// Whether the item is visible in the menu. bool? visible, - /// A function that is called back when the menu item is clicked. Event pages - /// cannot use this; instead, they should register a listener for - /// [contextMenus.onClicked]. + /// A function that is called back when the menu item is clicked. This is not + /// available inside of a service worker; instead, they should register a + /// listener for [contextMenus.onClicked]. JSFunction? onclick, /// The ID of a parent menu item; this makes the item a child of a previously @@ -226,7 +213,7 @@ class CreateProperties { /// Restricts the item to apply only to documents or frames whose URL matches /// one of the given patterns. For details on pattern formats, see [Match - /// Patterns](match_patterns). + /// Patterns](/docs/extensions/develop/concepts/match-patterns). JSArray? documentUrlPatterns, /// Similar to `documentUrlPatterns`, filters based on the `src` attribute of @@ -236,9 +223,7 @@ class CreateProperties { /// Whether this context menu item is enabled or disabled. Defaults to `true`. bool? enabled, }); -} -extension CreatePropertiesExtension on CreateProperties { /// The type of menu item. Defaults to `normal`. external ItemType? type; @@ -264,9 +249,9 @@ extension CreatePropertiesExtension on CreateProperties { /// Whether the item is visible in the menu. external bool? visible; - /// A function that is called back when the menu item is clicked. Event pages - /// cannot use this; instead, they should register a listener for - /// [contextMenus.onClicked]. + /// A function that is called back when the menu item is clicked. This is not + /// available inside of a service worker; instead, they should register a + /// listener for [contextMenus.onClicked]. external JSFunction? onclick; /// The ID of a parent menu item; this makes the item a child of a previously @@ -275,7 +260,7 @@ extension CreatePropertiesExtension on CreateProperties { /// Restricts the item to apply only to documents or frames whose URL matches /// one of the given patterns. For details on pattern formats, see [Match - /// Patterns](match_patterns). + /// Patterns](/docs/extensions/develop/concepts/match-patterns). external JSArray? documentUrlPatterns; /// Similar to `documentUrlPatterns`, filters based on the `src` attribute of @@ -285,11 +270,7 @@ extension CreatePropertiesExtension on CreateProperties { /// Whether this context menu item is enabled or disabled. Defaults to `true`. external bool? enabled; } - -@JS() -@staticInterop -@anonymous -class UpdateProperties { +extension type UpdateProperties._(JSObject _) implements JSObject { external factory UpdateProperties({ ItemType? type, String? title, @@ -307,9 +288,7 @@ class UpdateProperties { JSArray? targetUrlPatterns, bool? enabled, }); -} -extension UpdatePropertiesExtension on UpdateProperties { external ItemType? type; external String? title; diff --git a/lib/src/js/cookies.dart b/lib/src/js/cookies.dart index b4b1774..a5d3471 100644 --- a/lib/src/js/cookies.dart +++ b/lib/src/js/cookies.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSCookiesExtension on JSChrome { } } -@JS() -@staticInterop -class JSCookies {} - -extension JSCookiesExtension on JSCookies { +extension type JSCookies._(JSObject _) { /// Retrieves information about a single cookie. If more than one cookie of /// the same name exists for the given URL, the one with the longest path will /// be returned. For cookies with the same path length, the cookie with the @@ -35,9 +32,10 @@ extension JSCookiesExtension on JSCookies { external JSPromise get(CookieDetails details); /// Retrieves all cookies from a single cookie store that match the given - /// information. The cookies returned will be sorted, with those with the - /// longest path first. If multiple cookies have the same path length, those - /// with the earliest creation time will be first. + /// information. The cookies returned will be sorted, with those with the + /// longest path first. If multiple cookies have the same path length, those + /// with the earliest creation time will be first. This method only retrieves + /// cookies for domains that the extension has host permissions to. external JSPromise getAll( /// Information to filter the cookies being retrieved. @@ -82,11 +80,16 @@ typedef SameSiteStatus = String; /// call that overwrote it, "cause" will be "overwrite". Plan your response /// accordingly. typedef OnChangedCause = String; - -@JS() -@staticInterop -@anonymous -class Cookie { +extension type CookiePartitionKey._(JSObject _) implements JSObject { + external factory CookiePartitionKey( + { + /// The top-level site the partitioned cookie is available in. + String? topLevelSite}); + + /// The top-level site the partitioned cookie is available in. + external String? topLevelSite; +} +extension type Cookie._(JSObject _) implements JSObject { external factory Cookie({ /// The name of the cookie. String name, @@ -127,10 +130,12 @@ class Cookie { /// The ID of the cookie store containing this cookie, as provided in /// getAllCookieStores(). String storeId, + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + CookiePartitionKey? partitionKey, }); -} -extension CookieExtension on Cookie { /// The name of the cookie. external String name; @@ -170,12 +175,12 @@ extension CookieExtension on Cookie { /// The ID of the cookie store containing this cookie, as provided in /// getAllCookieStores(). external String storeId; -} -@JS() -@staticInterop -@anonymous -class CookieStore { + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + external CookiePartitionKey? partitionKey; +} +extension type CookieStore._(JSObject _) implements JSObject { external factory CookieStore({ /// The unique identifier for the cookie store. String id, @@ -183,20 +188,14 @@ class CookieStore { /// Identifiers of all the browser tabs that share this cookie store. JSArray tabIds, }); -} -extension CookieStoreExtension on CookieStore { /// The unique identifier for the cookie store. external String id; /// Identifiers of all the browser tabs that share this cookie store. external JSArray tabIds; } - -@JS() -@staticInterop -@anonymous -class CookieDetails { +extension type CookieDetails._(JSObject _) implements JSObject { external factory CookieDetails({ /// The URL with which the cookie to access is associated. This argument may /// be a full URL, in which case any data following the URL path (e.g. the @@ -210,10 +209,12 @@ class CookieDetails { /// The ID of the cookie store in which to look for the cookie. By default, /// the current execution context's cookie store will be used. String? storeId, + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + CookiePartitionKey? partitionKey, }); -} -extension CookieDetailsExtension on CookieDetails { /// The URL with which the cookie to access is associated. This argument may /// be a full URL, in which case any data following the URL path (e.g. the /// query string) is simply ignored. If host permissions for this URL are not @@ -226,12 +227,12 @@ extension CookieDetailsExtension on CookieDetails { /// The ID of the cookie store in which to look for the cookie. By default, /// the current execution context's cookie store will be used. external String? storeId; -} -@JS() -@staticInterop -@anonymous -class OnChangedChangeInfo { + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + external CookiePartitionKey? partitionKey; +} +extension type OnChangedChangeInfo._(JSObject _) implements JSObject { external factory OnChangedChangeInfo({ /// True if a cookie was removed. bool removed, @@ -242,9 +243,7 @@ class OnChangedChangeInfo { /// The underlying reason behind the cookie's change. OnChangedCause cause, }); -} -extension OnChangedChangeInfoExtension on OnChangedChangeInfo { /// True if a cookie was removed. external bool removed; @@ -254,11 +253,7 @@ extension OnChangedChangeInfoExtension on OnChangedChangeInfo { /// The underlying reason behind the cookie's change. external OnChangedCause cause; } - -@JS() -@staticInterop -@anonymous -class GetAllDetails { +extension type GetAllDetails._(JSObject _) implements JSObject { external factory GetAllDetails({ /// Restricts the retrieved cookies to those that would match the given URL. String? url, @@ -283,10 +278,12 @@ class GetAllDetails { /// The cookie store to retrieve cookies from. If omitted, the current /// execution context's cookie store will be used. String? storeId, + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + CookiePartitionKey? partitionKey, }); -} -extension GetAllDetailsExtension on GetAllDetails { /// Restricts the retrieved cookies to those that would match the given URL. external String? url; @@ -310,12 +307,12 @@ extension GetAllDetailsExtension on GetAllDetails { /// The cookie store to retrieve cookies from. If omitted, the current /// execution context's cookie store will be used. external String? storeId; -} -@JS() -@staticInterop -@anonymous -class SetDetails { + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + external CookiePartitionKey? partitionKey; +} +extension type SetDetails._(JSObject _) implements JSObject { external factory SetDetails({ /// The request-URI to associate with the setting of the cookie. This value /// can affect the default domain and path values of the created cookie. If @@ -353,10 +350,12 @@ class SetDetails { /// The ID of the cookie store in which to set the cookie. By default, the /// cookie is set in the current execution context's cookie store. String? storeId, + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + CookiePartitionKey? partitionKey, }); -} -extension SetDetailsExtension on SetDetails { /// The request-URI to associate with the setting of the cookie. This value /// can affect the default domain and path values of the created cookie. If /// host permissions for this URL are not specified in the manifest file, the @@ -393,12 +392,12 @@ extension SetDetailsExtension on SetDetails { /// The ID of the cookie store in which to set the cookie. By default, the /// cookie is set in the current execution context's cookie store. external String? storeId; -} -@JS() -@staticInterop -@anonymous -class RemoveCallbackDetails { + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + external CookiePartitionKey? partitionKey; +} +extension type RemoveCallbackDetails._(JSObject _) implements JSObject { external factory RemoveCallbackDetails({ /// The URL associated with the cookie that's been removed. String url, @@ -408,10 +407,12 @@ class RemoveCallbackDetails { /// The ID of the cookie store from which the cookie was removed. String storeId, + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + CookiePartitionKey? partitionKey, }); -} -extension RemoveCallbackDetailsExtension on RemoveCallbackDetails { /// The URL associated with the cookie that's been removed. external String url; @@ -420,4 +421,8 @@ extension RemoveCallbackDetailsExtension on RemoveCallbackDetails { /// The ID of the cookie store from which the cookie was removed. external String storeId; + + /// The partition key for reading or modifying cookies with the Partitioned + /// attribute. + external CookiePartitionKey? partitionKey; } diff --git a/lib/src/js/debugger.dart b/lib/src/js/debugger.dart index 937a8d8..84b6448 100644 --- a/lib/src/js/debugger.dart +++ b/lib/src/js/debugger.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -28,11 +29,7 @@ extension JSChromeJSDebuggerExtension on JSChrome { } } -@JS() -@staticInterop -class JSDebugger {} - -extension JSDebuggerExtension on JSDebugger { +extension type JSDebugger._(JSObject _) { /// Attaches debugger to the given target. external JSPromise attach( /// Debugging target to which you want to attach. @@ -83,11 +80,7 @@ typedef TargetInfoType = String; /// Connection termination reason. typedef DetachReason = String; - -@JS() -@staticInterop -@anonymous -class Debuggee { +extension type Debuggee._(JSObject _) implements JSObject { external factory Debuggee({ /// The id of the tab which you intend to debug. int? tabId, @@ -100,9 +93,7 @@ class Debuggee { /// The opaque id of the debug target. String? targetId, }); -} -extension DebuggeeExtension on Debuggee { /// The id of the tab which you intend to debug. external int? tabId; @@ -114,11 +105,7 @@ extension DebuggeeExtension on Debuggee { /// The opaque id of the debug target. external String? targetId; } - -@JS() -@staticInterop -@anonymous -class TargetInfo { +extension type TargetInfo._(JSObject _) implements JSObject { external factory TargetInfo({ /// Target type. TargetInfoType type, @@ -144,9 +131,7 @@ class TargetInfo { /// Target favicon URL. String? faviconUrl, }); -} -extension TargetInfoExtension on TargetInfo { /// Target type. external TargetInfoType type; diff --git a/lib/src/js/declarative_content.dart b/lib/src/js/declarative_content.dart index fbf60bf..bfeb7cf 100644 --- a/lib/src/js/declarative_content.dart +++ b/lib/src/js/declarative_content.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -25,11 +26,7 @@ extension JSChromeJSDeclarativeContentExtension on JSChrome { } } -@JS() -@staticInterop -class JSDeclarativeContent {} - -extension JSDeclarativeContentExtension on JSDeclarativeContent { +extension type JSDeclarativeContent._(JSObject _) { external Event get onPageChanged; } @@ -46,11 +43,7 @@ typedef RequestContentScriptInstanceType = String; /// See https://developer.mozilla.org/en-US/docs/Web/API/ImageData. typedef ImageDataType = JSObject; - -@JS() -@staticInterop -@anonymous -class PageStateMatcher { +extension type PageStateMatcher._(JSObject _) implements JSObject { external factory PageStateMatcher({ /// Matches if the conditions of the `UrlFilter` are fulfilled for the /// top-level URL of the page. @@ -65,13 +58,12 @@ class PageStateMatcher { JSArray? css, /// Matches if the bookmarked state of the page is equal to the specified - /// value. Requres the [bookmarks permission](declare_permissions). + /// value. Requres the [bookmarks + /// permission](/docs/extensions/develop/concepts/declare-permissions). bool? isBookmarked, PageStateMatcherInstanceType instanceType, }); -} -extension PageStateMatcherExtension on PageStateMatcher { /// Matches if the conditions of the `UrlFilter` are fulfilled for the /// top-level URL of the page. external UrlFilter? pageUrl; @@ -85,38 +77,23 @@ extension PageStateMatcherExtension on PageStateMatcher { external JSArray? css; /// Matches if the bookmarked state of the page is equal to the specified - /// value. Requres the [bookmarks permission](declare_permissions). + /// value. Requres the [bookmarks + /// permission](/docs/extensions/develop/concepts/declare-permissions). external bool? isBookmarked; external PageStateMatcherInstanceType instanceType; } - -@JS() -@staticInterop -@anonymous -class ShowPageAction { +extension type ShowPageAction._(JSObject _) implements JSObject { external factory ShowPageAction({ShowPageActionInstanceType instanceType}); -} -extension ShowPageActionExtension on ShowPageAction { external ShowPageActionInstanceType instanceType; } - -@JS() -@staticInterop -@anonymous -class ShowAction { +extension type ShowAction._(JSObject _) implements JSObject { external factory ShowAction({ShowActionInstanceType instanceType}); -} -extension ShowActionExtension on ShowAction { external ShowActionInstanceType instanceType; } - -@JS() -@staticInterop -@anonymous -class SetIcon { +extension type SetIcon._(JSObject _) implements JSObject { external factory SetIcon({ SetIconInstanceType instanceType, @@ -130,9 +107,7 @@ class SetIcon { /// {'16': foo}`. JSAny? imageData, }); -} -extension SetIconExtension on SetIcon { external SetIconInstanceType instanceType; /// Either an `ImageData` object or a dictionary {size -> ImageData} @@ -145,11 +120,7 @@ extension SetIconExtension on SetIcon { /// {'16': foo}`. external JSAny? imageData; } - -@JS() -@staticInterop -@anonymous -class RequestContentScript { +extension type RequestContentScript._(JSObject _) implements JSObject { external factory RequestContentScript({ /// Names of CSS files to be injected as a part of the content script. JSArray? css, @@ -166,9 +137,7 @@ class RequestContentScript { bool? matchAboutBlank, RequestContentScriptInstanceType instanceType, }); -} -extension RequestContentScriptExtension on RequestContentScript { /// Names of CSS files to be injected as a part of the content script. external JSArray? css; diff --git a/lib/src/js/declarative_net_request.dart b/lib/src/js/declarative_net_request.dart index 6be25d4..dfb55b8 100644 --- a/lib/src/js/declarative_net_request.dart +++ b/lib/src/js/declarative_net_request.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -27,11 +28,7 @@ extension JSChromeJSDeclarativeNetRequestExtension on JSChrome { } } -@JS() -@staticInterop -class JSDeclarativeNetRequest {} - -extension JSDeclarativeNetRequestExtension on JSDeclarativeNetRequest { +extension type JSDeclarativeNetRequest._(JSObject _) { /// Modifies the current set of dynamic rules for the extension. /// The rules with IDs listed in `options.removeRuleIds` are first /// removed, and then the rules given in `options.addRules` are @@ -172,13 +169,23 @@ extension JSDeclarativeNetRequestExtension on JSDeclarativeNetRequest { /// the [global static rule limit](#global-static-rule-limit). external int get GUARANTEED_MINIMUM_STATIC_RULES; - /// The maximum number of dynamic rules that an extension can add. - external int get MAX_NUMBER_OF_DYNAMIC_RULES; - /// The maximum number of combined dynamic and session scoped rules an /// extension can add. external int get MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES; + /// The maximum number of dynamic rules that an extension can add. + external int get MAX_NUMBER_OF_DYNAMIC_RULES; + + /// The maximum number of "unsafe" dynamic rules that an extension can add. + external int get MAX_NUMBER_OF_UNSAFE_DYNAMIC_RULES; + + /// The maximum number of session scoped rules that an extension can add. + external int get MAX_NUMBER_OF_SESSION_RULES; + + /// The maximum number of "unsafe" session scoped rules that an extension can + /// add. + external int get MAX_NUMBER_OF_UNSAFE_SESSION_RULES; + /// Time interval within which `MAX_GETMATCHEDRULES_CALLS_PER_INTERVAL /// getMatchedRules` calls can be made, specified in minutes. /// Additional calls will fail immediately and set [runtime.lastError]. @@ -229,11 +236,7 @@ typedef RuleActionType = String; /// Describes the reason why a given regular expression isn't supported. typedef UnsupportedRegexReason = String; - -@JS() -@staticInterop -@anonymous -class Ruleset { +extension type Ruleset._(JSObject _) implements JSObject { external factory Ruleset({ /// A non-empty string uniquely identifying the ruleset. IDs beginning with /// '_' are reserved for internal use. @@ -245,9 +248,7 @@ class Ruleset { /// Whether the ruleset is enabled by default. bool enabled, }); -} -extension RulesetExtension on Ruleset { /// A non-empty string uniquely identifying the ruleset. IDs beginning with /// '_' are reserved for internal use. external String id; @@ -258,11 +259,7 @@ extension RulesetExtension on Ruleset { /// Whether the ruleset is enabled by default. external bool enabled; } - -@JS() -@staticInterop -@anonymous -class QueryKeyValue { +extension type QueryKeyValue._(JSObject _) implements JSObject { external factory QueryKeyValue({ String key, String value, @@ -271,9 +268,7 @@ class QueryKeyValue { /// Otherwise, the key is also added if it's missing. Defaults to false. bool? replaceOnly, }); -} -extension QueryKeyValueExtension on QueryKeyValue { external String key; external String value; @@ -282,11 +277,7 @@ extension QueryKeyValueExtension on QueryKeyValue { /// Otherwise, the key is also added if it's missing. Defaults to false. external bool? replaceOnly; } - -@JS() -@staticInterop -@anonymous -class QueryTransform { +extension type QueryTransform._(JSObject _) implements JSObject { external factory QueryTransform({ /// The list of query keys to be removed. JSArray? removeParams, @@ -294,20 +285,14 @@ class QueryTransform { /// The list of query key-value pairs to be added or replaced. JSArray? addOrReplaceParams, }); -} -extension QueryTransformExtension on QueryTransform { /// The list of query keys to be removed. external JSArray? removeParams; /// The list of query key-value pairs to be added or replaced. external JSArray? addOrReplaceParams; } - -@JS() -@staticInterop -@anonymous -class URLTransform { +extension type URLTransform._(JSObject _) implements JSObject { external factory URLTransform({ /// The new scheme for the request. Allowed values are "http", "https", /// "ftp" and "chrome-extension". @@ -339,9 +324,7 @@ class URLTransform { /// The new password for the request. String? password, }); -} -extension URLTransformExtension on URLTransform { /// The new scheme for the request. Allowed values are "http", "https", /// "ftp" and "chrome-extension". external String? scheme; @@ -372,11 +355,7 @@ extension URLTransformExtension on URLTransform { /// The new password for the request. external String? password; } - -@JS() -@staticInterop -@anonymous -class Redirect { +extension type Redirect._(JSObject _) implements JSObject { external factory Redirect({ /// Path relative to the extension directory. Should start with '/'. String? extensionPath, @@ -394,9 +373,7 @@ class Redirect { /// corresponding capture groups. \0 refers to the entire matching text. String? regexSubstitution, }); -} -extension RedirectExtension on Redirect { /// Path relative to the extension directory. Should start with '/'. external String? extensionPath; @@ -413,11 +390,32 @@ extension RedirectExtension on Redirect { /// corresponding capture groups. \0 refers to the entire matching text. external String? regexSubstitution; } +extension type HeaderInfo._(JSObject _) implements JSObject { + external factory HeaderInfo({ + /// The name of the header. + String header, -@JS() -@staticInterop -@anonymous -class RuleCondition { + /// If specified, match this rule if the header's value contains at least one + /// element in this list. + JSArray? values, + + /// If specified, the rule is not matched if the header exists but its value + /// contains at least one element in this list. + JSArray? excludedValues, + }); + + /// The name of the header. + external String header; + + /// If specified, match this rule if the header's value contains at least one + /// element in this list. + external JSArray? values; + + /// If specified, the rule is not matched if the header exists but its value + /// contains at least one element in this list. + external JSArray? excludedValues; +} +extension type RuleCondition._(JSObject _) implements JSObject { external factory RuleCondition({ /// The pattern which is matched against the network request url. /// Supported constructs: @@ -468,7 +466,7 @@ class RuleCondition { String? regexFilter, /// Whether the `urlFilter` or `regexFilter` - /// (whichever is specified) is case sensitive. Default is true. + /// (whichever is specified) is case sensitive. Default is false. bool? isUrlFilterCaseSensitive, /// The rule will only match network requests originating from the list of @@ -583,10 +581,17 @@ class RuleCondition { /// [tabs.TAB_ID_NONE] excludes requests which don't originate from a /// tab. Only supported for session-scoped rules. JSArray? excludedTabIds, + + /// Rule matches if the request matches any response header in this list (if + /// specified). + /// TODO(crbug,com/1141166): Add documentation once feature is complete. + JSArray? responseHeaders, + + /// Rule does not match if the request has any of the specified headers. + /// TODO(crbug,com/1141166): Add documentation once feature is complete. + JSArray? excludedResponseHeaders, }); -} -extension RuleConditionExtension on RuleCondition { /// The pattern which is matched against the network request url. /// Supported constructs: /// @@ -636,7 +641,7 @@ extension RuleConditionExtension on RuleCondition { external String? regexFilter; /// Whether the `urlFilter` or `regexFilter` - /// (whichever is specified) is case sensitive. Default is true. + /// (whichever is specified) is case sensitive. Default is false. external bool? isUrlFilterCaseSensitive; /// The rule will only match network requests originating from the list of @@ -751,12 +756,17 @@ extension RuleConditionExtension on RuleCondition { /// [tabs.TAB_ID_NONE] excludes requests which don't originate from a /// tab. Only supported for session-scoped rules. external JSArray? excludedTabIds; -} -@JS() -@staticInterop -@anonymous -class ModifyHeaderInfo { + /// Rule matches if the request matches any response header in this list (if + /// specified). + /// TODO(crbug,com/1141166): Add documentation once feature is complete. + external JSArray? responseHeaders; + + /// Rule does not match if the request has any of the specified headers. + /// TODO(crbug,com/1141166): Add documentation once feature is complete. + external JSArray? excludedResponseHeaders; +} +extension type ModifyHeaderInfo._(JSObject _) implements JSObject { external factory ModifyHeaderInfo({ /// The name of the header to be modified. String header, @@ -768,9 +778,7 @@ class ModifyHeaderInfo { /// and `set` operations. String? value, }); -} -extension ModifyHeaderInfoExtension on ModifyHeaderInfo { /// The name of the header to be modified. external String header; @@ -781,11 +789,7 @@ extension ModifyHeaderInfoExtension on ModifyHeaderInfo { /// and `set` operations. external String? value; } - -@JS() -@staticInterop -@anonymous -class RuleAction { +extension type RuleAction._(JSObject _) implements JSObject { external factory RuleAction({ /// The type of action to perform. RuleActionType type, @@ -802,9 +806,7 @@ class RuleAction { /// RuleActionType is "modifyHeaders". JSArray? responseHeaders, }); -} -extension RuleActionExtension on RuleAction { /// The type of action to perform. external RuleActionType type; @@ -820,11 +822,7 @@ extension RuleActionExtension on RuleAction { /// RuleActionType is "modifyHeaders". external JSArray? responseHeaders; } - -@JS() -@staticInterop -@anonymous -class Rule { +extension type Rule._(JSObject _) implements JSObject { external factory Rule({ /// An id which uniquely identifies a rule. Mandatory and should be >= 1. int id, @@ -838,9 +836,7 @@ class Rule { /// The action to take if this rule is matched. RuleAction action, }); -} -extension RuleExtension on Rule { /// An id which uniquely identifies a rule. Mandatory and should be >= 1. external int id; @@ -853,11 +849,7 @@ extension RuleExtension on Rule { /// The action to take if this rule is matched. external RuleAction action; } - -@JS() -@staticInterop -@anonymous -class MatchedRule { +extension type MatchedRule._(JSObject _) implements JSObject { external factory MatchedRule({ /// A matching rule's ID. int ruleId, @@ -867,9 +859,7 @@ class MatchedRule { /// [DYNAMIC_RULESET_ID]. String rulesetId, }); -} -extension MatchedRuleExtension on MatchedRule { /// A matching rule's ID. external int ruleId; @@ -878,26 +868,16 @@ extension MatchedRuleExtension on MatchedRule { /// [DYNAMIC_RULESET_ID]. external String rulesetId; } - -@JS() -@staticInterop -@anonymous -class GetRulesFilter { +extension type GetRulesFilter._(JSObject _) implements JSObject { external factory GetRulesFilter( { /// If specified, only rules with matching IDs are included. JSArray? ruleIds}); -} -extension GetRulesFilterExtension on GetRulesFilter { /// If specified, only rules with matching IDs are included. external JSArray? ruleIds; } - -@JS() -@staticInterop -@anonymous -class MatchedRuleInfo { +extension type MatchedRuleInfo._(JSObject _) implements JSObject { external factory MatchedRuleInfo({ MatchedRule rule, @@ -910,9 +890,7 @@ class MatchedRuleInfo { /// still active. Else -1. int tabId, }); -} -extension MatchedRuleInfoExtension on MatchedRuleInfo { external MatchedRule rule; /// The time the rule was matched. Timestamps will correspond to the @@ -924,11 +902,7 @@ extension MatchedRuleInfoExtension on MatchedRuleInfo { /// still active. Else -1. external int tabId; } - -@JS() -@staticInterop -@anonymous -class MatchedRulesFilter { +extension type MatchedRulesFilter._(JSObject _) implements JSObject { external factory MatchedRulesFilter({ /// If specified, only matches rules for the given tab. Matches rules not /// associated with any active tab if set to -1. @@ -937,9 +911,7 @@ class MatchedRulesFilter { /// If specified, only matches rules after the given timestamp. double? minTimeStamp, }); -} -extension MatchedRulesFilterExtension on MatchedRulesFilter { /// If specified, only matches rules for the given tab. Matches rules not /// associated with any active tab if set to -1. external int? tabId; @@ -947,26 +919,16 @@ extension MatchedRulesFilterExtension on MatchedRulesFilter { /// If specified, only matches rules after the given timestamp. external double? minTimeStamp; } - -@JS() -@staticInterop -@anonymous -class RulesMatchedDetails { +extension type RulesMatchedDetails._(JSObject _) implements JSObject { external factory RulesMatchedDetails( { /// Rules matching the given filter. JSArray rulesMatchedInfo}); -} -extension RulesMatchedDetailsExtension on RulesMatchedDetails { /// Rules matching the given filter. external JSArray rulesMatchedInfo; } - -@JS() -@staticInterop -@anonymous -class RequestDetails { +extension type RequestDetails._(JSObject _) implements JSObject { external factory RequestDetails({ /// The ID of the request. Request IDs are unique within a browser session. String requestId, @@ -1015,9 +977,7 @@ class RequestDetails { /// The resource type of the request. ResourceType type, }); -} -extension RequestDetailsExtension on RequestDetails { /// The ID of the request. Request IDs are unique within a browser session. external String requestId; @@ -1065,11 +1025,7 @@ extension RequestDetailsExtension on RequestDetails { /// The resource type of the request. external ResourceType type; } - -@JS() -@staticInterop -@anonymous -class TestMatchRequestDetails { +extension type TestMatchRequestDetails._(JSObject _) implements JSObject { external factory TestMatchRequestDetails({ /// The URL of the hypothetical request. String url, @@ -1089,9 +1045,7 @@ class TestMatchRequestDetails { /// the request isn't related to a tab. int? tabId, }); -} -extension TestMatchRequestDetailsExtension on TestMatchRequestDetails { /// The URL of the hypothetical request. external String url; @@ -1110,52 +1064,30 @@ extension TestMatchRequestDetailsExtension on TestMatchRequestDetails { /// the request isn't related to a tab. external int? tabId; } - -@JS() -@staticInterop -@anonymous -class MatchedRuleInfoDebug { +extension type MatchedRuleInfoDebug._(JSObject _) implements JSObject { external factory MatchedRuleInfoDebug({ MatchedRule rule, /// Details about the request for which the rule was matched. RequestDetails request, }); -} -extension MatchedRuleInfoDebugExtension on MatchedRuleInfoDebug { external MatchedRule rule; /// Details about the request for which the rule was matched. external RequestDetails request; } - -@JS() -@staticInterop -@anonymous -class DNRInfo { +extension type DNRInfo._(JSObject _) implements JSObject { external factory DNRInfo({JSArray rule_resources}); -} -extension DNRInfoExtension on DNRInfo { external JSArray rule_resources; } - -@JS() -@staticInterop -@anonymous -class ManifestKeys { +extension type ManifestKeys._(JSObject _) implements JSObject { external factory ManifestKeys({DNRInfo declarative_net_request}); -} -extension ManifestKeysExtension on ManifestKeys { external DNRInfo declarative_net_request; } - -@JS() -@staticInterop -@anonymous -class RegexOptions { +extension type RegexOptions._(JSObject _) implements JSObject { external factory RegexOptions({ /// The regular expresson to check. String regex, @@ -1169,9 +1101,7 @@ class RegexOptions { /// `regexSubstition` action. The default is false. bool? requireCapturing, }); -} -extension RegexOptionsExtension on RegexOptions { /// The regular expresson to check. external String regex; @@ -1184,11 +1114,7 @@ extension RegexOptionsExtension on RegexOptions { /// `regexSubstition` action. The default is false. external bool? requireCapturing; } - -@JS() -@staticInterop -@anonymous -class IsRegexSupportedResult { +extension type IsRegexSupportedResult._(JSObject _) implements JSObject { external factory IsRegexSupportedResult({ bool isSupported, @@ -1196,35 +1122,23 @@ class IsRegexSupportedResult { /// provided if `isSupported` is false. UnsupportedRegexReason? reason, }); -} -extension IsRegexSupportedResultExtension on IsRegexSupportedResult { external bool isSupported; /// Specifies the reason why the regular expression is not supported. Only /// provided if `isSupported` is false. external UnsupportedRegexReason? reason; } - -@JS() -@staticInterop -@anonymous -class TestMatchOutcomeResult { +extension type TestMatchOutcomeResult._(JSObject _) implements JSObject { external factory TestMatchOutcomeResult( { /// The rules (if any) that match the hypothetical request. JSArray matchedRules}); -} -extension TestMatchOutcomeResultExtension on TestMatchOutcomeResult { /// The rules (if any) that match the hypothetical request. external JSArray matchedRules; } - -@JS() -@staticInterop -@anonymous -class UpdateRuleOptions { +extension type UpdateRuleOptions._(JSObject _) implements JSObject { external factory UpdateRuleOptions({ /// IDs of the rules to remove. Any invalid IDs will be ignored. JSArray? removeRuleIds, @@ -1232,20 +1146,14 @@ class UpdateRuleOptions { /// Rules to add. JSArray? addRules, }); -} -extension UpdateRuleOptionsExtension on UpdateRuleOptions { /// IDs of the rules to remove. Any invalid IDs will be ignored. external JSArray? removeRuleIds; /// Rules to add. external JSArray? addRules; } - -@JS() -@staticInterop -@anonymous -class UpdateRulesetOptions { +extension type UpdateRulesetOptions._(JSObject _) implements JSObject { external factory UpdateRulesetOptions({ /// The set of ids corresponding to a static [Ruleset] that should be /// disabled. @@ -1255,9 +1163,7 @@ class UpdateRulesetOptions { /// enabled. JSArray? enableRulesetIds, }); -} -extension UpdateRulesetOptionsExtension on UpdateRulesetOptions { /// The set of ids corresponding to a static [Ruleset] that should be /// disabled. external JSArray? disableRulesetIds; @@ -1266,11 +1172,7 @@ extension UpdateRulesetOptionsExtension on UpdateRulesetOptions { /// enabled. external JSArray? enableRulesetIds; } - -@JS() -@staticInterop -@anonymous -class UpdateStaticRulesOptions { +extension type UpdateStaticRulesOptions._(JSObject _) implements JSObject { external factory UpdateStaticRulesOptions({ /// The id corresponding to a static [Ruleset]. String rulesetId, @@ -1281,9 +1183,7 @@ class UpdateStaticRulesOptions { /// Set of ids corresponding to rules in the [Ruleset] to enable. JSArray? enableRuleIds, }); -} -extension UpdateStaticRulesOptionsExtension on UpdateStaticRulesOptions { /// The id corresponding to a static [Ruleset]. external String rulesetId; @@ -1293,26 +1193,16 @@ extension UpdateStaticRulesOptionsExtension on UpdateStaticRulesOptions { /// Set of ids corresponding to rules in the [Ruleset] to enable. external JSArray? enableRuleIds; } - -@JS() -@staticInterop -@anonymous -class GetDisabledRuleIdsOptions { +extension type GetDisabledRuleIdsOptions._(JSObject _) implements JSObject { external factory GetDisabledRuleIdsOptions( { /// The id corresponding to a static [Ruleset]. String rulesetId}); -} -extension GetDisabledRuleIdsOptionsExtension on GetDisabledRuleIdsOptions { /// The id corresponding to a static [Ruleset]. external String rulesetId; } - -@JS() -@staticInterop -@anonymous -class TabActionCountUpdate { +extension type TabActionCountUpdate._(JSObject _) implements JSObject { external factory TabActionCountUpdate({ /// The tab for which to update the action count. int tabId, @@ -1321,9 +1211,7 @@ class TabActionCountUpdate { /// decrement the count. int increment, }); -} -extension TabActionCountUpdateExtension on TabActionCountUpdate { /// The tab for which to update the action count. external int tabId; @@ -1331,11 +1219,7 @@ extension TabActionCountUpdateExtension on TabActionCountUpdate { /// decrement the count. external int increment; } - -@JS() -@staticInterop -@anonymous -class ExtensionActionOptions { +extension type ExtensionActionOptions._(JSObject _) implements JSObject { external factory ExtensionActionOptions({ /// Whether to automatically display the action count for a page as the /// extension's badge text. This preference is persisted across sessions. @@ -1344,9 +1228,7 @@ class ExtensionActionOptions { /// Details of how the tab's action count should be adjusted. TabActionCountUpdate? tabUpdate, }); -} -extension ExtensionActionOptionsExtension on ExtensionActionOptions { /// Whether to automatically display the action count for a page as the /// extension's badge text. This preference is persisted across sessions. external bool? displayActionCountAsBadgeText; diff --git a/lib/src/js/desktop_capture.dart b/lib/src/js/desktop_capture.dart index 074a85b..7ff6e29 100644 --- a/lib/src/js/desktop_capture.dart +++ b/lib/src/js/desktop_capture.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,11 +25,7 @@ extension JSChromeJSDesktopCaptureExtension on JSChrome { } } -@JS() -@staticInterop -class JSDesktopCapture {} - -extension JSDesktopCaptureExtension on JSDesktopCapture { +extension type JSDesktopCapture._(JSObject _) { /// Shows desktop media picker UI with the specified set of sources. external int chooseDesktopMedia( /// Set of sources that should be shown to the user. The sources order in @@ -68,11 +65,7 @@ typedef SystemAudioPreferenceEnum = String; /// Mirrors /// [SelfCapturePreferenceEnum](https://w3c.github.io/mediacapture-screen-share/#dom-selfcapturepreferenceenum). typedef SelfCapturePreferenceEnum = String; - -@JS() -@staticInterop -@anonymous -class ChooseDesktopMediaOptions { +extension type ChooseDesktopMediaOptions._(JSObject _) implements JSObject { external factory ChooseDesktopMediaOptions({ /// Mirrors /// [systemAudio](https://w3c.github.io/mediacapture-screen-share/#dom-displaymediastreamconstraints-systemaudio). @@ -87,9 +80,7 @@ class ChooseDesktopMediaOptions { /// the appropriate warnings, as it does when getDisplayMedia() is invoked. bool? suppressLocalAudioPlaybackIntended, }); -} -extension ChooseDesktopMediaOptionsExtension on ChooseDesktopMediaOptions { /// Mirrors /// [systemAudio](https://w3c.github.io/mediacapture-screen-share/#dom-displaymediastreamconstraints-systemaudio). external SystemAudioPreferenceEnum? systemAudio; diff --git a/lib/src/js/devtools_inspected_window.dart b/lib/src/js/devtools_inspected_window.dart index e4dbb95..a04daf7 100644 --- a/lib/src/js/devtools_inspected_window.dart +++ b/lib/src/js/devtools_inspected_window.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -27,11 +28,7 @@ extension JSChromeJSDevtoolsInspectedWindowExtension on JSChromeDevtools { } } -@JS() -@staticInterop -class JSDevtoolsInspectedWindow {} - -extension JSDevtoolsInspectedWindowExtension on JSDevtoolsInspectedWindow { +extension type JSDevtoolsInspectedWindow._(JSObject _) { /// Evaluates a JavaScript expression in the context of the main frame of the /// inspected page. The expression must evaluate to a JSON-compliant object, /// otherwise an exception is thrown. The eval function can report either a @@ -73,18 +70,12 @@ extension JSDevtoolsInspectedWindowExtension on JSDevtoolsInspectedWindow { /// API. external int get tabId; } - -@JS() -@staticInterop -@anonymous -class Resource { +extension type Resource._(JSObject _) implements JSObject { external factory Resource( { /// The URL of the resource. String url}); -} -extension ResourceExtension on Resource { /// The URL of the resource. external String url; @@ -109,11 +100,7 @@ extension ResourceExtension on Resource { JSFunction? callback, ); } - -@JS() -@staticInterop -@anonymous -class EvalExceptionInfo { +extension type EvalExceptionInfo._(JSObject _) implements JSObject { external factory EvalExceptionInfo({ /// Set if the error occurred on the DevTools side before the expression is /// evaluated. @@ -139,9 +126,7 @@ class EvalExceptionInfo { /// Set if the evaluated code produces an unhandled exception. String value, }); -} -extension EvalExceptionInfoExtension on EvalExceptionInfo { /// Set if the error occurred on the DevTools side before the expression is /// evaluated. external bool isError; @@ -166,11 +151,7 @@ extension EvalExceptionInfoExtension on EvalExceptionInfo { /// Set if the evaluated code produces an unhandled exception. external String value; } - -@JS() -@staticInterop -@anonymous -class EvalOptions { +extension type EvalOptions._(JSObject _) implements JSObject { external factory EvalOptions({ /// If specified, the expression is evaluated on the iframe whose URL matches /// the one specified. By default, the expression is evaluated in the top @@ -189,9 +170,7 @@ class EvalOptions { /// overrides the 'true' setting on useContentScriptContext. String? scriptExecutionContext, }); -} -extension EvalOptionsExtension on EvalOptions { /// If specified, the expression is evaluated on the iframe whose URL matches /// the one specified. By default, the expression is evaluated in the top /// frame of the inspected page. @@ -209,11 +188,7 @@ extension EvalOptionsExtension on EvalOptions { /// overrides the 'true' setting on useContentScriptContext. external String? scriptExecutionContext; } - -@JS() -@staticInterop -@anonymous -class ReloadOptions { +extension type ReloadOptions._(JSObject _) implements JSObject { external factory ReloadOptions({ /// When true, the loader will bypass the cache for all inspected page /// resources loaded before the `load` event is fired. The effect is similar @@ -233,9 +208,7 @@ class ReloadOptions { /// the user presses Ctrl+R. String? injectedScript, }); -} -extension ReloadOptionsExtension on ReloadOptions { /// When true, the loader will bypass the cache for all inspected page /// resources loaded before the `load` event is fired. The effect is similar /// to pressing Ctrl+Shift+R in the inspected window or within the Developer diff --git a/lib/src/js/devtools_network.dart b/lib/src/js/devtools_network.dart index c320522..1602ad9 100644 --- a/lib/src/js/devtools_network.dart +++ b/lib/src/js/devtools_network.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -25,11 +26,7 @@ extension JSChromeJSDevtoolsNetworkExtension on JSChromeDevtools { } } -@JS() -@staticInterop -class JSDevtoolsNetwork {} - -extension JSDevtoolsNetworkExtension on JSDevtoolsNetwork { +extension type JSDevtoolsNetwork._(JSObject _) { /// Returns HAR log that contains all known network requests. external void getHAR( @@ -43,15 +40,9 @@ extension JSDevtoolsNetworkExtension on JSDevtoolsNetwork { /// Fired when the inspected window navigates to a new page. external Event get onNavigated; } - -@JS() -@staticInterop -@anonymous -class Request { +extension type Request._(JSObject _) implements JSObject { external factory Request(); -} -extension RequestExtension on Request { /// Returns content of the response body. external void getContent( diff --git a/lib/src/js/devtools_panels.dart b/lib/src/js/devtools_panels.dart index bd55a27..23c3756 100644 --- a/lib/src/js/devtools_panels.dart +++ b/lib/src/js/devtools_panels.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -26,11 +27,7 @@ extension JSChromeJSDevtoolsPanelsExtension on JSChromeDevtools { } } -@JS() -@staticInterop -class JSDevtoolsPanels {} - -extension JSDevtoolsPanelsExtension on JSDevtoolsPanels { +extension type JSDevtoolsPanels._(JSObject _) { /// Creates an extension panel. external void create( /// Title that is displayed next to the extension icon in the Developer @@ -83,15 +80,9 @@ extension JSDevtoolsPanelsExtension on JSDevtoolsPanels { /// values: `default` (the default) and `dark`. external String get themeName; } - -@JS() -@staticInterop -@anonymous -class ElementsPanel { +extension type ElementsPanel._(JSObject _) implements JSObject { external factory ElementsPanel(); -} -extension ElementsPanelExtension on ElementsPanel { /// Creates a pane within panel's sidebar. external void createSidebarPane( /// Text that is displayed in sidebar caption. @@ -104,15 +95,9 @@ extension ElementsPanelExtension on ElementsPanel { /// Fired when an object is selected in the panel. external Event get onSelectionChanged; } - -@JS() -@staticInterop -@anonymous -class SourcesPanel { +extension type SourcesPanel._(JSObject _) implements JSObject { external factory SourcesPanel(); -} -extension SourcesPanelExtension on SourcesPanel { /// Creates a pane within panel's sidebar. external void createSidebarPane( /// Text that is displayed in sidebar caption. @@ -125,15 +110,9 @@ extension SourcesPanelExtension on SourcesPanel { /// Fired when an object is selected in the panel. external Event get onSelectionChanged; } - -@JS() -@staticInterop -@anonymous -class ExtensionPanel { +extension type ExtensionPanel._(JSObject _) implements JSObject { external factory ExtensionPanel(); -} -extension ExtensionPanelExtension on ExtensionPanel { /// Appends a button to the status bar of the panel. external Button createStatusBarButton( /// Path to the icon of the button. The file should contain a 64x24-pixel @@ -158,15 +137,9 @@ extension ExtensionPanelExtension on ExtensionPanel { /// Fired when the user switches away from the panel. external Event get onHidden; } - -@JS() -@staticInterop -@anonymous -class ExtensionSidebarPane { +extension type ExtensionSidebarPane._(JSObject _) implements JSObject { external factory ExtensionSidebarPane(); -} -extension ExtensionSidebarPaneExtension on ExtensionSidebarPane { /// Sets the height of the sidebar. external void setHeight( @@ -216,15 +189,9 @@ extension ExtensionSidebarPaneExtension on ExtensionSidebarPane { /// switching away from the panel that hosts the sidebar pane. external Event get onHidden; } - -@JS() -@staticInterop -@anonymous -class Button { +extension type Button._(JSObject _) implements JSObject { external factory Button(); -} -extension ButtonExtension on Button { /// Updates the attributes of the button. If some of the arguments are omitted /// or `null`, the corresponding attributes are not updated. external void update( diff --git a/lib/src/js/devtools_recorder.dart b/lib/src/js/devtools_recorder.dart index 0cf7bda..4e835c1 100644 --- a/lib/src/js/devtools_recorder.dart +++ b/lib/src/js/devtools_recorder.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -25,11 +26,7 @@ extension JSChromeJSDevtoolsRecorderExtension on JSChromeDevtools { } } -@JS() -@staticInterop -class JSDevtoolsRecorder {} - -extension JSDevtoolsRecorderExtension on JSDevtoolsRecorder { +extension type JSDevtoolsRecorder._(JSObject _) { /// Registers a Recorder extension plugin. external void registerRecorderExtensionPlugin( /// An instance implementing the RecorderExtensionPlugin interface. @@ -53,15 +50,9 @@ extension JSDevtoolsRecorderExtension on JSDevtoolsRecorder { String pagePath, ); } - -@JS() -@staticInterop -@anonymous -class RecorderExtensionPlugin { +extension type RecorderExtensionPlugin._(JSObject _) implements JSObject { external factory RecorderExtensionPlugin(); -} -extension RecorderExtensionPluginExtension on RecorderExtensionPlugin { /// Converts a recording from the Recorder panel format into a string. external void stringify( @@ -88,15 +79,9 @@ extension RecorderExtensionPluginExtension on RecorderExtensionPlugin { /// recording schema. JSAny recording); } - -@JS() -@staticInterop -@anonymous -class RecorderView { +extension type RecorderView._(JSObject _) implements JSObject { external factory RecorderView(); -} -extension RecorderViewExtension on RecorderView { /// Indicates that the extension wants to show this view in the Recorder /// panel. external void show(); diff --git a/lib/src/js/document_scan.dart b/lib/src/js/document_scan.dart index cd12b48..43a4d7c 100644 --- a/lib/src/js/document_scan.dart +++ b/lib/src/js/document_scan.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,22 +24,120 @@ extension JSChromeJSDocumentScanExtension on JSChrome { } } -@JS() -@staticInterop -class JSDocumentScan {} - -extension JSDocumentScanExtension on JSDocumentScan { +extension type JSDocumentScan._(JSObject _) { /// Performs a document scan. On success, the PNG data will be /// sent to the callback. /// |options| : Object containing scan parameters. /// |callback| : Called with the result and data from the scan. external JSPromise scan(ScanOptions options); + + /// Gets the list of available scanners. On success, the list will be + /// sent to the callback. + /// |filter| : `DeviceFilter` indicating which types of scanners + /// should be returned. + /// |callback| : Called with the result and list of scanners. + external JSPromise getScannerList(DeviceFilter filter); + + /// Opens a scanner for exclusive access. On success, the response containing + /// a scanner handle and configuration will be sent to the callback. + /// |scannerId| : Scanner id previously returned from `getScannerList` + /// indicating which scanner should be opened. + /// |callback| : Called with the result. + external JSPromise openScanner(String scannerId); + + /// Gets the group names and member options from a scanner handle previously + /// opened by `openScanner`. + /// |scannerHandle| : Open scanner handle previously returned from + /// `openScanner`. + /// |callback| : Called with the result. + external JSPromise getOptionGroups(String scannerHandle); + + /// Closes a previously opened scanner handle. A response indicating the + /// outcome will be sent to the callback. Even if the response is not a + /// success, the supplied handle will become invalid and should not be used + /// for further operations. + /// |scannerHandle| : Open scanner handle previously returned from + /// `openScanner`. + /// |callback| : Called with the result. + external JSPromise closeScanner(String scannerHandle); + + /// Sends the list of new option values in `options` as a bundle + /// to be set on `scannerHandle`. Each option will be set by the + /// backend the order specified. Returns a backend response indicating the + /// result of each option setting and a new set of final option values after + /// all options have been updated. + /// |scannerHandle| : Open scanner handle previously returned from + /// `openScanner`. + /// |options| : A list of `OptionSetting`s that will be applied to + /// `scannerHandle`. + /// |callback| : Called with the result. + external JSPromise setOptions( + String scannerHandle, + JSArray options, + ); + + /// Starts a scan using a previously opened scanner handle. A response + /// indicating the outcome will be sent to the callback. If successful, the + /// response will include a job handle that can be used in subsequent calls + /// to read scan data or cancel a scan. + /// |scannerHandle| : Open scanner handle previously returned from + /// `openScanner`. + /// |options| : `StartScanOptions` indicating what options are to + /// be used for the scan. `StartScanOptions.format` must match + /// one of the entries returned in the scanner's `ScannerInfo`. + /// |callback| : Called with the result. + external JSPromise startScan( + String scannerHandle, + StartScanOptions options, + ); + + /// Cancels a scan that was previously started using `startScan`. + /// The response is sent to the callback. + /// |job| : An active scan job previously returned from + /// `startScan`. + /// |callback| : Called with the result. + external JSPromise cancelScan(String job); + + /// Reads the next chunk of available image data from an active job handle. + /// A response indicating the outcome will be sent to the callback. + /// + /// It is valid for a response to have result + /// `OperationResult.SUCCESS` with a zero-length + /// `data` member. This means the scanner is still working but + /// does not yet have additional data ready. The caller should wait a short + /// time and try again. + /// + /// When the scan job completes, the response will have the result + /// `OperationResult.EOF`. This response may contain a final + /// non-zero `data` member. + /// |job| : Active job handle previously returned from + /// `startScan`. + /// |callback| : Called with the result. + external JSPromise readScanData(String job); } -@JS() -@staticInterop -@anonymous -class ScanOptions { +/// OperationResult is an enum that indicates the result of each operation +/// performed by the backend. It contains the same causes as SANE_Status plus +/// additional statuses that come from the IPC layers and image conversion +/// stages. +typedef OperationResult = String; + +/// How the scanner is connected to the computer. +typedef ConnectionType = String; + +/// The type of an option. This is the same set of types as SANE_Value_Type. +typedef OptionType = String; + +/// The unit of measurement for an option. This is the same set of units as +/// SANE_Unit. +typedef OptionUnit = String; + +/// The type of constraint represented by an OptionConstraint. +typedef ConstraintType = String; + +/// How an option can be changed. +typedef Configurability = String; +extension type ScanOptions._(JSObject _) implements JSObject { external factory ScanOptions({ /// The MIME types that are accepted by the caller. JSArray? mimeTypes, @@ -46,20 +145,14 @@ class ScanOptions { /// The number of scanned images allowed (defaults to 1). int? maxImages, }); -} -extension ScanOptionsExtension on ScanOptions { /// The MIME types that are accepted by the caller. external JSArray? mimeTypes; /// The number of scanned images allowed (defaults to 1). external int? maxImages; } - -@JS() -@staticInterop -@anonymous -class ScanResults { +extension type ScanResults._(JSObject _) implements JSObject { external factory ScanResults({ /// The data image URLs in a form that can be passed as the "src" value to /// an image tag. @@ -68,9 +161,7 @@ class ScanResults { /// The MIME type of `dataUrls`. String mimeType, }); -} -extension ScanResultsExtension on ScanResults { /// The data image URLs in a form that can be passed as the "src" value to /// an image tag. external JSArray dataUrls; @@ -78,3 +169,459 @@ extension ScanResultsExtension on ScanResults { /// The MIME type of `dataUrls`. external String mimeType; } +extension type ScannerInfo._(JSObject _) implements JSObject { + external factory ScannerInfo({ + /// For connecting with `openScanner`. + String scannerId, + + /// Printable name for displaying in the UI. + String name, + + /// Scanner manufacturer. + String manufacturer, + + /// Scanner model if available, or a generic description. + String model, + + /// For matching against other `ScannerInfo` entries that point + /// to the same physical device. + String deviceUuid, + + /// How the scanner is connected to the computer. + ConnectionType connectionType, + + /// If true, the scanner connection's transport cannot be intercepted by a + /// passive listener, such as TLS or USB. + bool secure, + + /// MIME types that can be requested for returned scans. + JSArray imageFormats, + }); + + /// For connecting with `openScanner`. + external String scannerId; + + /// Printable name for displaying in the UI. + external String name; + + /// Scanner manufacturer. + external String manufacturer; + + /// Scanner model if available, or a generic description. + external String model; + + /// For matching against other `ScannerInfo` entries that point + /// to the same physical device. + external String deviceUuid; + + /// How the scanner is connected to the computer. + external ConnectionType connectionType; + + /// If true, the scanner connection's transport cannot be intercepted by a + /// passive listener, such as TLS or USB. + external bool secure; + + /// MIME types that can be requested for returned scans. + external JSArray imageFormats; +} +extension type OptionConstraint._(JSObject _) implements JSObject { + external factory OptionConstraint({ + ConstraintType type, + JSAny? min, + JSAny? max, + JSAny? quant, + JSAny? list, + }); + + external ConstraintType type; + + external JSAny? min; + + external JSAny? max; + + external JSAny? quant; + + external JSAny? list; +} +extension type ScannerOption._(JSObject _) implements JSObject { + external factory ScannerOption({ + /// Option name using lowercase a-z, numbers, and dashes. + String name, + + /// Printable one-line title. + String title, + + /// Longer description of the option. + String description, + + /// The type that `value` will contain and that is needed for + /// setting this option. + OptionType type, + + /// Unit of measurement for this option. + OptionUnit unit, + + /// Current value of the option if relevant. Note the type passed here must + /// match the type specified in `type`. + JSAny? value, + + /// Constraint on possible values. + OptionConstraint? constraint, + + /// Can be detected from software. + bool isDetectable, + + /// Whether/how the option can be changed. + Configurability configurability, + + /// Can be automatically set by the backend. + bool isAutoSettable, + + /// Emulated by the backend if true. + bool isEmulated, + + /// Option is active and can be set/retrieved. If false, the + /// `value` field will not be set. + bool isActive, + + /// UI should not display this option by default. + bool isAdvanced, + + /// Option is used for internal configuration and should never be displayed + /// in the UI. + bool isInternal, + }); + + /// Option name using lowercase a-z, numbers, and dashes. + external String name; + + /// Printable one-line title. + external String title; + + /// Longer description of the option. + external String description; + + /// The type that `value` will contain and that is needed for + /// setting this option. + external OptionType type; + + /// Unit of measurement for this option. + external OptionUnit unit; + + /// Current value of the option if relevant. Note the type passed here must + /// match the type specified in `type`. + external JSAny? value; + + /// Constraint on possible values. + external OptionConstraint? constraint; + + /// Can be detected from software. + external bool isDetectable; + + /// Whether/how the option can be changed. + external Configurability configurability; + + /// Can be automatically set by the backend. + external bool isAutoSettable; + + /// Emulated by the backend if true. + external bool isEmulated; + + /// Option is active and can be set/retrieved. If false, the + /// `value` field will not be set. + external bool isActive; + + /// UI should not display this option by default. + external bool isAdvanced; + + /// Option is used for internal configuration and should never be displayed + /// in the UI. + external bool isInternal; +} +extension type DeviceFilter._(JSObject _) implements JSObject { + external factory DeviceFilter({ + /// Only return scanners that are directly attached to the computer. + bool? local, + + /// Only return scanners that use a secure transport, such as USB or TLS. + bool? secure, + }); + + /// Only return scanners that are directly attached to the computer. + external bool? local; + + /// Only return scanners that use a secure transport, such as USB or TLS. + external bool? secure; +} +extension type OptionGroup._(JSObject _) implements JSObject { + external factory OptionGroup({ + /// Printable title, e.g. "Geometry options". + String title, + + /// Names of contained options, in backend-provided order. + JSArray members, + }); + + /// Printable title, e.g. "Geometry options". + external String title; + + /// Names of contained options, in backend-provided order. + external JSArray members; +} +extension type GetScannerListResponse._(JSObject _) implements JSObject { + external factory GetScannerListResponse({ + /// The backend's enumeration result. Note that partial results could be + /// returned even if this indicates an error. + OperationResult result, + + /// A possibly-empty list of scanners that match the provided + /// `DeviceFilter`. + JSArray scanners, + }); + + /// The backend's enumeration result. Note that partial results could be + /// returned even if this indicates an error. + external OperationResult result; + + /// A possibly-empty list of scanners that match the provided + /// `DeviceFilter`. + external JSArray scanners; +} +extension type OpenScannerResponse._(JSObject _) implements JSObject { + external factory OpenScannerResponse({ + /// Same scanner ID passed to `openScanner()`. + String scannerId, + + /// Backend result of opening the scanner. + OperationResult result, + + /// If `result` is `OperationResult.SUCCESS`, a handle + /// to the scanner that can be used for further operations. + String? scannerHandle, + + /// If `result` is `OperationResult.SUCCESS`, a + /// key-value mapping from option names to `ScannerOption`. + JSAny? options, + }); + + /// Same scanner ID passed to `openScanner()`. + external String scannerId; + + /// Backend result of opening the scanner. + external OperationResult result; + + /// If `result` is `OperationResult.SUCCESS`, a handle + /// to the scanner that can be used for further operations. + external String? scannerHandle; + + /// If `result` is `OperationResult.SUCCESS`, a + /// key-value mapping from option names to `ScannerOption`. + external JSAny? options; +} +extension type GetOptionGroupsResponse._(JSObject _) implements JSObject { + external factory GetOptionGroupsResponse({ + /// Same scanner handle passed to `getOptionGroups()`. + String scannerHandle, + + /// The backend's result of getting the option groups. + OperationResult result, + + /// If `result` is `OperationResult.SUCCESS`, a list of + /// option groups in the order supplied by the backend. + JSArray? groups, + }); + + /// Same scanner handle passed to `getOptionGroups()`. + external String scannerHandle; + + /// The backend's result of getting the option groups. + external OperationResult result; + + /// If `result` is `OperationResult.SUCCESS`, a list of + /// option groups in the order supplied by the backend. + external JSArray? groups; +} +extension type CloseScannerResponse._(JSObject _) implements JSObject { + external factory CloseScannerResponse({ + /// Same scanner handle passed to `closeScanner()`. + String scannerHandle, + + /// Backend result of closing the scanner. Even if this value is not + /// `OperationResult.SUCCESS`, the handle will be invalid and + /// should not be used for any further operations. + OperationResult result, + }); + + /// Same scanner handle passed to `closeScanner()`. + external String scannerHandle; + + /// Backend result of closing the scanner. Even if this value is not + /// `OperationResult.SUCCESS`, the handle will be invalid and + /// should not be used for any further operations. + external OperationResult result; +} +extension type OptionSetting._(JSObject _) implements JSObject { + external factory OptionSetting({ + /// Name of the option to set. + String name, + + /// Type of the option. The requested type must match the real type of the + /// underlying option. + OptionType type, + + /// Value to set. Leave unset to request automatic setting for options that + /// have `autoSettable` enabled. The type supplied for + /// `value` must match `type`. + JSAny? value, + }); + + /// Name of the option to set. + external String name; + + /// Type of the option. The requested type must match the real type of the + /// underlying option. + external OptionType type; + + /// Value to set. Leave unset to request automatic setting for options that + /// have `autoSettable` enabled. The type supplied for + /// `value` must match `type`. + external JSAny? value; +} +extension type SetOptionResult._(JSObject _) implements JSObject { + external factory SetOptionResult({ + /// Name of the option that was set. + String name, + + /// Backend result of setting the option. + OperationResult result, + }); + + /// Name of the option that was set. + external String name; + + /// Backend result of setting the option. + external OperationResult result; +} +extension type SetOptionsResponse._(JSObject _) implements JSObject { + external factory SetOptionsResponse({ + /// The same scanner handle passed to `setOptions()`. + String scannerHandle, + + /// One result per passed-in `OptionSetting`. + JSArray results, + + /// Updated key-value mapping from option names to + /// `ScannerOption` containing the new configuration after + /// attempting to set all supplied options. This has the same structure as + /// the `options` field in `OpenScannerResponse`. + /// + /// This field will be set even if some options were not set successfully, + /// but will be unset if retrieving the updated configuration fails (e.g., + /// if the scanner is disconnected in the middle). + JSAny? options, + }); + + /// The same scanner handle passed to `setOptions()`. + external String scannerHandle; + + /// One result per passed-in `OptionSetting`. + external JSArray results; + + /// Updated key-value mapping from option names to + /// `ScannerOption` containing the new configuration after + /// attempting to set all supplied options. This has the same structure as + /// the `options` field in `OpenScannerResponse`. + /// + /// This field will be set even if some options were not set successfully, + /// but will be unset if retrieving the updated configuration fails (e.g., + /// if the scanner is disconnected in the middle). + external JSAny? options; +} +extension type StartScanOptions._(JSObject _) implements JSObject { + external factory StartScanOptions( + { + /// MIME type to return scanned data in. + String format}); + + /// MIME type to return scanned data in. + external String format; +} +extension type StartScanResponse._(JSObject _) implements JSObject { + external factory StartScanResponse({ + /// The same scanner handle that was passed to `startScan()`. + String scannerHandle, + + /// The backend's start scan result. + OperationResult result, + + /// If `result` is `OperationResult.SUCCESS`, a handle + /// that can be used to read scan data or cancel the job. + String? job, + }); + + /// The same scanner handle that was passed to `startScan()`. + external String scannerHandle; + + /// The backend's start scan result. + external OperationResult result; + + /// If `result` is `OperationResult.SUCCESS`, a handle + /// that can be used to read scan data or cancel the job. + external String? job; +} +extension type CancelScanResponse._(JSObject _) implements JSObject { + external factory CancelScanResponse({ + /// The same job handle that was passed to `cancelScan()`. + String job, + + /// The backend's cancel scan result. + OperationResult result, + }); + + /// The same job handle that was passed to `cancelScan()`. + external String job; + + /// The backend's cancel scan result. + external OperationResult result; +} +extension type ReadScanDataResponse._(JSObject _) implements JSObject { + external factory ReadScanDataResponse({ + /// Same job handle passed to `readScanData()`. + String job, + + /// The backend result of reading data. If this is + /// `OperationResult.SUCCESS`, `data` will contain the + /// next (possibly zero-length) chunk of image data that was ready for + /// reading. If this is `OperationResult.EOF`, `data` + /// will contain the final chunk of image data. + OperationResult result, + + /// If result is `OperationResult.SUCCESS`, the next chunk of + /// scanned image data. + JSArrayBuffer? data, + + /// If result is `OperationResult.SUCCESS`, an estimate of how + /// much of the total scan data has been delivered so far, in the range + /// 0-100. + int? estimatedCompletion, + }); + + /// Same job handle passed to `readScanData()`. + external String job; + + /// The backend result of reading data. If this is + /// `OperationResult.SUCCESS`, `data` will contain the + /// next (possibly zero-length) chunk of image data that was ready for + /// reading. If this is `OperationResult.EOF`, `data` + /// will contain the final chunk of image data. + external OperationResult result; + + /// If result is `OperationResult.SUCCESS`, the next chunk of + /// scanned image data. + external JSArrayBuffer? data; + + /// If result is `OperationResult.SUCCESS`, an estimate of how + /// much of the total scan data has been delivered so far, in the range + /// 0-100. + external int? estimatedCompletion; +} diff --git a/lib/src/js/dom.dart b/lib/src/js/dom.dart index 9a0ae91..fd034e2 100644 --- a/lib/src/js/dom.dart +++ b/lib/src/js/dom.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -22,11 +23,7 @@ extension JSChromeJSDomExtension on JSChrome { } } -@JS() -@staticInterop -class JSDom {} - -extension JSDomExtension on JSDom { +extension type JSDom._(JSObject _) { /// Gets the open shadow root or the closed shadow root hosted by the /// specified element. If the element doesn't attach the shadow root, it will /// return null. diff --git a/lib/src/js/downloads.dart b/lib/src/js/downloads.dart index 971c390..2e6515a 100644 --- a/lib/src/js/downloads.dart +++ b/lib/src/js/downloads.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSDownloadsExtension on JSChrome { } } -@JS() -@staticInterop -class JSDownloads {} - -extension JSDownloadsExtension on JSDownloads { +extension type JSDownloads._(JSObject _) { /// Download a URL. If the URL uses the HTTP[S] protocol, then the request /// will include all cookies currently set for its hostname. If both /// `filename` and `saveAs` are specified, then the @@ -87,11 +84,12 @@ extension JSDownloadsExtension on JSDownloads { GetFileIconOptions? options, ); - /// Open the downloaded file now if the [DownloadItem] is complete; - /// otherwise returns an error through [runtime.lastError]. Requires the - /// `"downloads.open"` permission in addition to the - /// `"downloads"` permission. An [onChanged] event will fire - /// when the item is opened for the first time. + /// Opens the downloaded file now if the [DownloadItem] is complete; + /// otherwise returns an error through [runtime.lastError]. This method + /// requires the `"downloads.open"` permission in addition to the + /// `"downloads"` permission. An [onChanged] event fires + /// when the item is opened for the first time. This method can only be called + /// in response to a user gesture. /// |downloadId|: The identifier for the downloaded file. external void open(int downloadId); @@ -130,6 +128,7 @@ extension JSDownloadsExtension on JSDownloads { /// one other extension has disabled it will return an error through /// [runtime.lastError]. Requires the `"downloads.shelf"` /// permission in addition to the `"downloads"` permission. + @Deprecated(r'Use $(ref:setUiOptions) instead.') external void setShelfEnabled(bool enabled); /// Change the download UI of every window associated with the current @@ -229,11 +228,7 @@ typedef DangerType = String; typedef State = String; typedef SuggestFilenameCallback = JSFunction; - -@JS() -@staticInterop -@anonymous -class HeaderNameValuePair { +extension type HeaderNameValuePair._(JSObject _) implements JSObject { external factory HeaderNameValuePair({ /// Name of the HTTP header. String name, @@ -241,20 +236,14 @@ class HeaderNameValuePair { /// Value of the HTTP header. String value, }); -} -extension HeaderNameValuePairExtension on HeaderNameValuePair { /// Name of the HTTP header. external String name; /// Value of the HTTP header. external String value; } - -@JS() -@staticInterop -@anonymous -class FilenameSuggestion { +extension type FilenameSuggestion._(JSObject _) implements JSObject { external factory FilenameSuggestion({ /// The [DownloadItem]'s new target [DownloadItem.filename], as a path /// relative to the user's default Downloads directory, possibly containing @@ -267,9 +256,7 @@ class FilenameSuggestion { /// The action to take if `filename` already exists. FilenameConflictAction? conflictAction, }); -} -extension FilenameSuggestionExtension on FilenameSuggestion { /// The [DownloadItem]'s new target [DownloadItem.filename], as a path /// relative to the user's default Downloads directory, possibly containing /// subdirectories. Absolute paths, empty paths, and paths containing @@ -281,11 +268,7 @@ extension FilenameSuggestionExtension on FilenameSuggestion { /// The action to take if `filename` already exists. external FilenameConflictAction? conflictAction; } - -@JS() -@staticInterop -@anonymous -class DownloadOptions { +extension type DownloadOptions._(JSObject _) implements JSObject { external factory DownloadOptions({ /// The URL to download. String url, @@ -316,9 +299,7 @@ class DownloadOptions { /// Post body. String? body, }); -} -extension DownloadOptionsExtension on DownloadOptions { /// The URL to download. external String url; @@ -348,11 +329,7 @@ extension DownloadOptionsExtension on DownloadOptions { /// Post body. external String? body; } - -@JS() -@staticInterop -@anonymous -class DownloadItem { +extension type DownloadItem._(JSObject _) implements JSObject { external factory DownloadItem({ /// An identifier that is persistent across browser sessions. int id, @@ -451,9 +428,7 @@ class DownloadItem { /// changes its name or if the user changes their locale. String? byExtensionName, }); -} -extension DownloadItemExtension on DownloadItem { /// An identifier that is persistent across browser sessions. external int id; @@ -551,11 +526,7 @@ extension DownloadItemExtension on DownloadItem { /// changes its name or if the user changes their locale. external String? byExtensionName; } - -@JS() -@staticInterop -@anonymous -class DownloadQuery { +extension type DownloadQuery._(JSObject _) implements JSObject { external factory DownloadQuery({ /// This array of search terms limits results to [DownloadItem] whose /// `filename` or `url` or `finalUrl` @@ -662,9 +633,7 @@ class DownloadQuery { /// Whether the downloaded file exists; bool? exists, }); -} -extension DownloadQueryExtension on DownloadQuery { /// This array of search terms limits results to [DownloadItem] whose /// `filename` or `url` or `finalUrl` /// contain all of the search terms that do not begin with a dash '-' and @@ -770,59 +739,37 @@ extension DownloadQueryExtension on DownloadQuery { /// Whether the downloaded file exists; external bool? exists; } - -@JS() -@staticInterop -@anonymous -class StringDelta { +extension type StringDelta._(JSObject _) implements JSObject { external factory StringDelta({ String? previous, String? current, }); -} -extension StringDeltaExtension on StringDelta { external String? previous; external String? current; } - -@JS() -@staticInterop -@anonymous -class DoubleDelta { +extension type DoubleDelta._(JSObject _) implements JSObject { external factory DoubleDelta({ double? previous, double? current, }); -} -extension DoubleDeltaExtension on DoubleDelta { external double? previous; external double? current; } - -@JS() -@staticInterop -@anonymous -class BooleanDelta { +extension type BooleanDelta._(JSObject _) implements JSObject { external factory BooleanDelta({ bool? previous, bool? current, }); -} -extension BooleanDeltaExtension on BooleanDelta { external bool? previous; external bool? current; } - -@JS() -@staticInterop -@anonymous -class DownloadDelta { +extension type DownloadDelta._(JSObject _) implements JSObject { external factory DownloadDelta({ /// The `id` of the [DownloadItem] /// that changed. @@ -870,9 +817,7 @@ class DownloadDelta { /// The change in `exists`, if any. BooleanDelta? exists, }); -} -extension DownloadDeltaExtension on DownloadDelta { /// The `id` of the [DownloadItem] /// that changed. external int id; @@ -919,11 +864,7 @@ extension DownloadDeltaExtension on DownloadDelta { /// The change in `exists`, if any. external BooleanDelta? exists; } - -@JS() -@staticInterop -@anonymous -class GetFileIconOptions { +extension type GetFileIconOptions._(JSObject _) implements JSObject { external factory GetFileIconOptions( { /// The size of the returned icon. The icon will be square with dimensions @@ -931,27 +872,19 @@ class GetFileIconOptions { /// pixels. The only supported sizes are 16 and 32. It is an error to specify /// any other size. int? size}); -} -extension GetFileIconOptionsExtension on GetFileIconOptions { /// The size of the returned icon. The icon will be square with dimensions /// size * size pixels. The default and largest size for the icon is 32x32 /// pixels. The only supported sizes are 16 and 32. It is an error to specify /// any other size. external int? size; } - -@JS() -@staticInterop -@anonymous -class UiOptions { +extension type UiOptions._(JSObject _) implements JSObject { external factory UiOptions( { /// Enable or disable the download UI. bool enabled}); -} -extension UiOptionsExtension on UiOptions { /// Enable or disable the download UI. external bool enabled; } diff --git a/lib/src/js/enterprise_device_attributes.dart b/lib/src/js/enterprise_device_attributes.dart index 329c601..0e6bff6 100644 --- a/lib/src/js/enterprise_device_attributes.dart +++ b/lib/src/js/enterprise_device_attributes.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -28,12 +29,7 @@ extension JSChromeJSEnterpriseDeviceAttributesExtension on JSChromeEnterprise { } } -@JS() -@staticInterop -class JSEnterpriseDeviceAttributes {} - -extension JSEnterpriseDeviceAttributesExtension - on JSEnterpriseDeviceAttributes { +extension type JSEnterpriseDeviceAttributes._(JSObject _) { /// Fetches the value of /// [the device identifier of the directory /// API](https://developers.google.com/admin-sdk/directory/v1/guides/manage-chrome-devices), diff --git a/lib/src/js/enterprise_hardware_platform.dart b/lib/src/js/enterprise_hardware_platform.dart index a1fdcab..fe4e143 100644 --- a/lib/src/js/enterprise_hardware_platform.dart +++ b/lib/src/js/enterprise_hardware_platform.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -27,29 +28,18 @@ extension JSChromeJSEnterpriseHardwarePlatformExtension on JSChromeEnterprise { } } -@JS() -@staticInterop -class JSEnterpriseHardwarePlatform {} - -extension JSEnterpriseHardwarePlatformExtension - on JSEnterpriseHardwarePlatform { +extension type JSEnterpriseHardwarePlatform._(JSObject _) { /// Obtains the manufacturer and model for the hardware platform and, if /// the extension is authorized, returns it via |callback|. /// |callback|: Called with the hardware platform info. external JSPromise getHardwarePlatformInfo(); } - -@JS() -@staticInterop -@anonymous -class HardwarePlatformInfo { +extension type HardwarePlatformInfo._(JSObject _) implements JSObject { external factory HardwarePlatformInfo({ String model, String manufacturer, }); -} -extension HardwarePlatformInfoExtension on HardwarePlatformInfo { external String model; external String manufacturer; diff --git a/lib/src/js/enterprise_networking_attributes.dart b/lib/src/js/enterprise_networking_attributes.dart index 1c9957b..9a5f95d 100644 --- a/lib/src/js/enterprise_networking_attributes.dart +++ b/lib/src/js/enterprise_networking_attributes.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -29,12 +30,7 @@ extension JSChromeJSEnterpriseNetworkingAttributesExtension } } -@JS() -@staticInterop -class JSEnterpriseNetworkingAttributes {} - -extension JSEnterpriseNetworkingAttributesExtension - on JSEnterpriseNetworkingAttributes { +extension type JSEnterpriseNetworkingAttributes._(JSObject _) { /// Retrieves the network details of the device's default network. /// If the user is not affiliated or the device is not connected to a /// network, [runtime.lastError] will be set with a failure reason. @@ -42,11 +38,7 @@ extension JSEnterpriseNetworkingAttributesExtension /// [NetworkDetails]. external JSPromise getNetworkDetails(); } - -@JS() -@staticInterop -@anonymous -class NetworkDetails { +extension type NetworkDetails._(JSObject _) implements JSObject { external factory NetworkDetails({ /// The device's MAC address. String macAddress, @@ -57,9 +49,7 @@ class NetworkDetails { /// The device's local IPv6 address (undefined if not configured). String? ipv6, }); -} -extension NetworkDetailsExtension on NetworkDetails { /// The device's MAC address. external String macAddress; diff --git a/lib/src/js/enterprise_platform_keys.dart b/lib/src/js/enterprise_platform_keys.dart index 75ab2f2..09be2a3 100644 --- a/lib/src/js/enterprise_platform_keys.dart +++ b/lib/src/js/enterprise_platform_keys.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -29,11 +30,7 @@ extension JSChromeJSEnterprisePlatformKeysExtension on JSChromeEnterprise { } } -@JS() -@staticInterop -class JSEnterprisePlatformKeys {} - -extension JSEnterprisePlatformKeysExtension on JSEnterprisePlatformKeys { +extension type JSEnterprisePlatformKeys._(JSObject _) { /// Returns the available Tokens. In a regular user's session the list will /// always contain the user's token with `id` `"user"`. /// If a system-wide TPM token is available, the returned list will also @@ -187,11 +184,7 @@ typedef Scope = String; /// Type of key to generate. typedef Algorithm = String; - -@JS() -@staticInterop -@anonymous -class Token { +extension type Token._(JSObject _) implements JSObject { external factory Token({ /// Uniquely identifies this `Token`. /// Static IDs are `"user"` and `"system"`, @@ -231,9 +224,7 @@ class Token { /// interface. JSObject softwareBackedSubtleCrypto, }); -} -extension TokenExtension on Token { /// Uniquely identifies this `Token`. /// Static IDs are `"user"` and `"system"`, /// referring to the platform's user-specific and the system-wide hardware @@ -272,26 +263,16 @@ extension TokenExtension on Token { /// interface. external JSObject softwareBackedSubtleCrypto; } - -@JS() -@staticInterop -@anonymous -class RegisterKeyOptions { +extension type RegisterKeyOptions._(JSObject _) implements JSObject { external factory RegisterKeyOptions( { /// Which algorithm the registered key should use. Algorithm algorithm}); -} -extension RegisterKeyOptionsExtension on RegisterKeyOptions { /// Which algorithm the registered key should use. external Algorithm algorithm; } - -@JS() -@staticInterop -@anonymous -class ChallengeKeyOptions { +extension type ChallengeKeyOptions._(JSObject _) implements JSObject { external factory ChallengeKeyOptions({ /// A challenge as emitted by the Verified Access Web API. JSArrayBuffer challenge, @@ -306,9 +287,7 @@ class ChallengeKeyOptions { /// Which Enterprise Key to challenge. Scope scope, }); -} -extension ChallengeKeyOptionsExtension on ChallengeKeyOptions { /// A challenge as emitted by the Verified Access Web API. external JSArrayBuffer challenge; diff --git a/lib/src/js/events.dart b/lib/src/js/events.dart index d8833ed..84b4919 100644 --- a/lib/src/js/events.dart +++ b/lib/src/js/events.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,16 +24,8 @@ extension JSChromeJSEventsExtension on JSChrome { } } -@JS() -@staticInterop -class JSEvents {} - -extension JSEventsExtension on JSEvents {} - -@JS() -@staticInterop -@anonymous -class Rule { +extension type JSEvents._(JSObject _) {} +extension type Rule._(JSObject _) implements JSObject { external factory Rule({ /// Optional identifier that allows referencing this rule. String? id, @@ -50,9 +43,7 @@ class Rule { /// Optional priority of this rule. Defaults to 100. int? priority, }); -} -extension RuleExtension on Rule { /// Optional identifier that allows referencing this rule. external String? id; @@ -69,15 +60,9 @@ extension RuleExtension on Rule { /// Optional priority of this rule. Defaults to 100. external int? priority; } - -@JS() -@staticInterop -@anonymous -class Event { +extension type Event._(JSObject _) implements JSObject { external factory Event(); -} -extension EventExtension on Event { /// Registers an event listener _callback_ to an event. external void addListener( @@ -149,11 +134,7 @@ extension EventExtension on Event { JSFunction? callback, ); } - -@JS() -@staticInterop -@anonymous -class UrlFilter { +extension type UrlFilter._(JSObject _) implements JSObject { external factory UrlFilter({ /// Matches if the host name of the URL contains a specified string. To test /// whether a host name component has a prefix 'foo', use hostContains: @@ -239,9 +220,7 @@ class UrlFilter { /// 80, 443 and in the range 1000-1200. JSArray? ports, }); -} -extension UrlFilterExtension on UrlFilter { /// Matches if the host name of the URL contains a specified string. To test /// whether a host name component has a prefix 'foo', use hostContains: /// '.foo'. This matches 'www.foobar.com' and 'foo.com', because an implicit diff --git a/lib/src/js/extension.dart b/lib/src/js/extension.dart index b9fc7fe..23765ed 100644 --- a/lib/src/js/extension.dart +++ b/lib/src/js/extension.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -25,11 +26,7 @@ extension JSChromeJSExtensionExtension on JSChrome { } } -@JS() -@staticInterop -class JSExtension {} - -extension JSExtensionExtension on JSExtension { +extension type JSExtension._(JSObject _) { /// Sends a single request to other listeners within the extension. Similar to /// [runtime.connect], but only sends a single request with an optional /// response. The [extension.onRequest] event is fired in each page of the @@ -102,11 +99,7 @@ extension JSExtensionExtension on JSExtension { /// The type of extension view. typedef ViewType = String; - -@JS() -@staticInterop -@anonymous -class GetViewsFetchProperties { +extension type GetViewsFetchProperties._(JSObject _) implements JSObject { external factory GetViewsFetchProperties({ /// The type of view to get. If omitted, returns all views (including /// background pages and tabs). @@ -119,9 +112,7 @@ class GetViewsFetchProperties { /// views. int? tabId, }); -} -extension GetViewsFetchPropertiesExtension on GetViewsFetchProperties { /// The type of view to get. If omitted, returns all views (including /// background pages and tabs). external ViewType? type; @@ -133,18 +124,12 @@ extension GetViewsFetchPropertiesExtension on GetViewsFetchProperties { /// views. external int? tabId; } - -@JS() -@staticInterop -@anonymous -class ExtensionLastError { +extension type ExtensionLastError._(JSObject _) implements JSObject { external factory ExtensionLastError( { /// Description of the error that has taken place. String message}); -} -extension ExtensionLastErrorExtension on ExtensionLastError { /// Description of the error that has taken place. external String message; } diff --git a/lib/src/js/extension_types.dart b/lib/src/js/extension_types.dart index 1766121..517cddd 100644 --- a/lib/src/js/extension_types.dart +++ b/lib/src/js/extension_types.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSExtensionTypesExtension on JSChrome { } } -@JS() -@staticInterop -class JSExtensionTypes {} - -extension JSExtensionTypesExtension on JSExtensionTypes {} +extension type JSExtensionTypes._(JSObject _) {} /// The format of an image. typedef ImageFormat = String; @@ -46,14 +43,11 @@ typedef FrameType = String; typedef DocumentLifecycle = String; /// The JavaScript world for a script to execute within. Can either be an -/// isolated world, unique to this extension, or the main world of the DOM which -/// is shared with the page's JavaScript. +/// isolated world unique to this extension, the main world of the DOM which is +/// shared with the page's JavaScript, or a user scripts world that is only +/// available for scripts registered with the User Scripts API. typedef ExecutionWorld = String; - -@JS() -@staticInterop -@anonymous -class ImageDetails { +extension type ImageDetails._(JSObject _) implements JSObject { external factory ImageDetails({ /// The format of the resulting image. Default is `"jpeg"`. ImageFormat? format, @@ -64,9 +58,7 @@ class ImageDetails { /// needed to store it will decrease. int? quality, }); -} -extension ImageDetailsExtension on ImageDetails { /// The format of the resulting image. Default is `"jpeg"`. external ImageFormat? format; @@ -76,11 +68,7 @@ extension ImageDetailsExtension on ImageDetails { /// needed to store it will decrease. external int? quality; } - -@JS() -@staticInterop -@anonymous -class InjectDetails { +extension type InjectDetails._(JSObject _) implements JSObject { external factory InjectDetails({ /// JavaScript or CSS code to inject. /// @@ -118,9 +106,7 @@ class InjectDetails { /// Defaults to `"author"`. CSSOrigin? cssOrigin, }); -} -extension InjectDetailsExtension on InjectDetails { /// JavaScript or CSS code to inject. /// /// **Warning:** @@ -157,11 +143,7 @@ extension InjectDetailsExtension on InjectDetails { /// Defaults to `"author"`. external CSSOrigin? cssOrigin; } - -@JS() -@staticInterop -@anonymous -class DeleteInjectionDetails { +extension type DeleteInjectionDetails._(JSObject _) implements JSObject { external factory DeleteInjectionDetails({ /// CSS code to remove. String? code, @@ -188,9 +170,7 @@ class DeleteInjectionDetails { /// CSS to remove. Defaults to `"author"`. CSSOrigin? cssOrigin, }); -} -extension DeleteInjectionDetailsExtension on DeleteInjectionDetails { /// CSS code to remove. external String? code; diff --git a/lib/src/js/file_browser_handler.dart b/lib/src/js/file_browser_handler.dart index 31a3db8..ddad7a6 100644 --- a/lib/src/js/file_browser_handler.dart +++ b/lib/src/js/file_browser_handler.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,19 +25,12 @@ extension JSChromeJSFileBrowserHandlerExtension on JSChrome { } } -@JS() -@staticInterop -class JSFileBrowserHandler {} - -extension JSFileBrowserHandlerExtension on JSFileBrowserHandler { +extension type JSFileBrowserHandler._(JSObject _) { /// Fired when file system action is executed from ChromeOS file browser. external Event get onExecute; } - -@JS() -@staticInterop -@anonymous -class FileHandlerExecuteEventDetails { +extension type FileHandlerExecuteEventDetails._(JSObject _) + implements JSObject { external factory FileHandlerExecuteEventDetails({ /// Array of Entry instances representing files that are targets of this /// action (selected in ChromeOS file browser). @@ -46,10 +40,7 @@ class FileHandlerExecuteEventDetails { /// browser session. int? tab_id, }); -} -extension FileHandlerExecuteEventDetailsExtension - on FileHandlerExecuteEventDetails { /// Array of Entry instances representing files that are targets of this /// action (selected in ChromeOS file browser). external JSArray entries; diff --git a/lib/src/js/file_system_provider.dart b/lib/src/js/file_system_provider.dart index d1ba5f6..769fd22 100644 --- a/lib/src/js/file_system_provider.dart +++ b/lib/src/js/file_system_provider.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSFileSystemProviderExtension on JSChrome { } } -@JS() -@staticInterop -class JSFileSystemProvider {} - -extension JSFileSystemProviderExtension on JSFileSystemProvider { +extension type JSFileSystemProvider._(JSObject _) { /// Mounts a file system with the given `fileSystemId` and /// `displayName`. `displayName` will be shown in the /// left panel of the Files app. `displayName` can contain any @@ -60,7 +57,7 @@ extension JSFileSystemProviderExtension on JSFileSystemProvider { /// Notifies about changes in the watched directory at /// `observedPath` in `recursive` mode. If the file - /// system is mounted with `supportsNofityTag`, then + /// system is mounted with `supportsNotifyTag`, then /// `tag` must be provided, and all changes since the last /// notification always reported, even if the system was shutdown. The last /// tag can be obtained with [getAll]. @@ -242,11 +239,22 @@ typedef EntriesCallback = JSFunction; /// has to be called again with additional entries. If no more data is /// available, then `hasMore` must be set to false. typedef FileDataCallback = JSFunction; +extension type CloudIdentifier._(JSObject _) implements JSObject { + external factory CloudIdentifier({ + /// Identifier for the cloud storage provider (e.g. 'drive.google.com'). + String providerName, -@JS() -@staticInterop -@anonymous -class EntryMetadata { + /// The provider's identifier for the given file/directory. + String id, + }); + + /// Identifier for the cloud storage provider (e.g. 'drive.google.com'). + external String providerName; + + /// The provider's identifier for the given file/directory. + external String id; +} +extension type EntryMetadata._(JSObject _) implements JSObject { external factory EntryMetadata({ /// True if it is a directory. Must be provided if requested in /// `options`. @@ -272,10 +280,14 @@ class EntryMetadata { /// 32 KB in size. Optional, but can be provided only when explicitly /// requested by the [onGetMetadataRequested] event. String? thumbnail, + + /// Cloud storage representation of this entry. Must be provided if requested + /// in `options` and the file is backed by cloud storage. For + /// local files not backed by cloud storage, it should be undefined when + /// requested. + CloudIdentifier? cloudIdentifier, }); -} -extension EntryMetadataExtension on EntryMetadata { /// True if it is a directory. Must be provided if requested in /// `options`. external bool? isDirectory; @@ -300,12 +312,14 @@ extension EntryMetadataExtension on EntryMetadata { /// 32 KB in size. Optional, but can be provided only when explicitly /// requested by the [onGetMetadataRequested] event. external String? thumbnail; -} -@JS() -@staticInterop -@anonymous -class Watcher { + /// Cloud storage representation of this entry. Must be provided if requested + /// in `options` and the file is backed by cloud storage. For + /// local files not backed by cloud storage, it should be undefined when + /// requested. + external CloudIdentifier? cloudIdentifier; +} +extension type Watcher._(JSObject _) implements JSObject { external factory Watcher({ /// The path of the entry being observed. String entryPath, @@ -317,9 +331,7 @@ class Watcher { /// Tag used by the last notification for the watcher. String? lastTag, }); -} -extension WatcherExtension on Watcher { /// The path of the entry being observed. external String entryPath; @@ -330,11 +342,7 @@ extension WatcherExtension on Watcher { /// Tag used by the last notification for the watcher. external String? lastTag; } - -@JS() -@staticInterop -@anonymous -class OpenedFile { +extension type OpenedFile._(JSObject _) implements JSObject { external factory OpenedFile({ /// A request ID to be be used by consecutive read/write and close requests. int openRequestId, @@ -345,9 +353,7 @@ class OpenedFile { /// Whether the file was opened for reading or writing. OpenFileMode mode, }); -} -extension OpenedFileExtension on OpenedFile { /// A request ID to be be used by consecutive read/write and close requests. external int openRequestId; @@ -357,11 +363,7 @@ extension OpenedFileExtension on OpenedFile { /// Whether the file was opened for reading or writing. external OpenFileMode mode; } - -@JS() -@staticInterop -@anonymous -class FileSystemInfo { +extension type FileSystemInfo._(JSObject _) implements JSObject { external factory FileSystemInfo({ /// The identifier of the file system. String fileSystemId, @@ -387,9 +389,7 @@ class FileSystemInfo { /// List of watchers. JSArray watchers, }); -} -extension FileSystemInfoExtension on FileSystemInfo { /// The identifier of the file system. external String fileSystemId; @@ -414,11 +414,7 @@ extension FileSystemInfoExtension on FileSystemInfo { /// List of watchers. external JSArray watchers; } - -@JS() -@staticInterop -@anonymous -class MountOptions { +extension type MountOptions._(JSObject _) implements JSObject { external factory MountOptions({ /// The string indentifier of the file system. Must be unique per each /// extension. @@ -443,9 +439,7 @@ class MountOptions { /// session. True by default. bool? persistent, }); -} -extension MountOptionsExtension on MountOptions { /// The string indentifier of the file system. Must be unique per each /// extension. external String fileSystemId; @@ -469,26 +463,16 @@ extension MountOptionsExtension on MountOptions { /// session. True by default. external bool? persistent; } - -@JS() -@staticInterop -@anonymous -class UnmountOptions { +extension type UnmountOptions._(JSObject _) implements JSObject { external factory UnmountOptions( { /// The identifier of the file system to be unmounted. String fileSystemId}); -} -extension UnmountOptionsExtension on UnmountOptions { /// The identifier of the file system to be unmounted. external String fileSystemId; } - -@JS() -@staticInterop -@anonymous -class UnmountRequestedOptions { +extension type UnmountRequestedOptions._(JSObject _) implements JSObject { external factory UnmountRequestedOptions({ /// The identifier of the file system to be unmounted. String fileSystemId, @@ -496,20 +480,14 @@ class UnmountRequestedOptions { /// The unique identifier of this request. int requestId, }); -} -extension UnmountRequestedOptionsExtension on UnmountRequestedOptions { /// The identifier of the file system to be unmounted. external String fileSystemId; /// The unique identifier of this request. external int requestId; } - -@JS() -@staticInterop -@anonymous -class GetMetadataRequestedOptions { +extension type GetMetadataRequestedOptions._(JSObject _) implements JSObject { external factory GetMetadataRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -536,12 +514,14 @@ class GetMetadataRequestedOptions { /// Set to `true` if `mimeType` value is requested. bool mimeType, - /// Set to `true` if the thumbnail is requested. + /// Set to `true` if `thumbnail` value is requested. bool thumbnail, + + /// Set to `true` if `cloudIdentifier` value is + /// requested. + bool cloudIdentifier, }); -} -extension GetMetadataRequestedOptionsExtension on GetMetadataRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -567,14 +547,14 @@ extension GetMetadataRequestedOptionsExtension on GetMetadataRequestedOptions { /// Set to `true` if `mimeType` value is requested. external bool mimeType; - /// Set to `true` if the thumbnail is requested. + /// Set to `true` if `thumbnail` value is requested. external bool thumbnail; -} -@JS() -@staticInterop -@anonymous -class GetActionsRequestedOptions { + /// Set to `true` if `cloudIdentifier` value is + /// requested. + external bool cloudIdentifier; +} +extension type GetActionsRequestedOptions._(JSObject _) implements JSObject { external factory GetActionsRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -585,9 +565,7 @@ class GetActionsRequestedOptions { /// List of paths of entries for the list of actions. JSArray entryPaths, }); -} -extension GetActionsRequestedOptionsExtension on GetActionsRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -597,11 +575,7 @@ extension GetActionsRequestedOptionsExtension on GetActionsRequestedOptions { /// List of paths of entries for the list of actions. external JSArray entryPaths; } - -@JS() -@staticInterop -@anonymous -class ReadDirectoryRequestedOptions { +extension type ReadDirectoryRequestedOptions._(JSObject _) implements JSObject { external factory ReadDirectoryRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -628,13 +602,10 @@ class ReadDirectoryRequestedOptions { /// Set to `true` if `mimeType` value is requested. bool mimeType, - /// Set to `true` if the thumbnail is requested. + /// Set to `true` if `thumbnail` value is requested. bool thumbnail, }); -} -extension ReadDirectoryRequestedOptionsExtension - on ReadDirectoryRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -660,14 +631,10 @@ extension ReadDirectoryRequestedOptionsExtension /// Set to `true` if `mimeType` value is requested. external bool mimeType; - /// Set to `true` if the thumbnail is requested. + /// Set to `true` if `thumbnail` value is requested. external bool thumbnail; } - -@JS() -@staticInterop -@anonymous -class OpenFileRequestedOptions { +extension type OpenFileRequestedOptions._(JSObject _) implements JSObject { external factory OpenFileRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -682,9 +649,7 @@ class OpenFileRequestedOptions { /// Whether the file will be used for reading or writing. OpenFileMode mode, }); -} -extension OpenFileRequestedOptionsExtension on OpenFileRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -698,11 +663,7 @@ extension OpenFileRequestedOptionsExtension on OpenFileRequestedOptions { /// Whether the file will be used for reading or writing. external OpenFileMode mode; } - -@JS() -@staticInterop -@anonymous -class CloseFileRequestedOptions { +extension type CloseFileRequestedOptions._(JSObject _) implements JSObject { external factory CloseFileRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -713,9 +674,7 @@ class CloseFileRequestedOptions { /// A request ID used to open the file. int openRequestId, }); -} -extension CloseFileRequestedOptionsExtension on CloseFileRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -725,11 +684,7 @@ extension CloseFileRequestedOptionsExtension on CloseFileRequestedOptions { /// A request ID used to open the file. external int openRequestId; } - -@JS() -@staticInterop -@anonymous -class ReadFileRequestedOptions { +extension type ReadFileRequestedOptions._(JSObject _) implements JSObject { external factory ReadFileRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -746,9 +701,7 @@ class ReadFileRequestedOptions { /// Number of bytes to be returned. double length, }); -} -extension ReadFileRequestedOptionsExtension on ReadFileRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -764,11 +717,8 @@ extension ReadFileRequestedOptionsExtension on ReadFileRequestedOptions { /// Number of bytes to be returned. external double length; } - -@JS() -@staticInterop -@anonymous -class CreateDirectoryRequestedOptions { +extension type CreateDirectoryRequestedOptions._(JSObject _) + implements JSObject { external factory CreateDirectoryRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -782,10 +732,7 @@ class CreateDirectoryRequestedOptions { /// Whether the operation is recursive (for directories only). bool recursive, }); -} -extension CreateDirectoryRequestedOptionsExtension - on CreateDirectoryRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -798,11 +745,7 @@ extension CreateDirectoryRequestedOptionsExtension /// Whether the operation is recursive (for directories only). external bool recursive; } - -@JS() -@staticInterop -@anonymous -class DeleteEntryRequestedOptions { +extension type DeleteEntryRequestedOptions._(JSObject _) implements JSObject { external factory DeleteEntryRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -816,9 +759,7 @@ class DeleteEntryRequestedOptions { /// Whether the operation is recursive (for directories only). bool recursive, }); -} -extension DeleteEntryRequestedOptionsExtension on DeleteEntryRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -831,11 +772,7 @@ extension DeleteEntryRequestedOptionsExtension on DeleteEntryRequestedOptions { /// Whether the operation is recursive (for directories only). external bool recursive; } - -@JS() -@staticInterop -@anonymous -class CreateFileRequestedOptions { +extension type CreateFileRequestedOptions._(JSObject _) implements JSObject { external factory CreateFileRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -846,9 +783,7 @@ class CreateFileRequestedOptions { /// The path of the file to be created. String filePath, }); -} -extension CreateFileRequestedOptionsExtension on CreateFileRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -858,11 +793,7 @@ extension CreateFileRequestedOptionsExtension on CreateFileRequestedOptions { /// The path of the file to be created. external String filePath; } - -@JS() -@staticInterop -@anonymous -class CopyEntryRequestedOptions { +extension type CopyEntryRequestedOptions._(JSObject _) implements JSObject { external factory CopyEntryRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -876,9 +807,7 @@ class CopyEntryRequestedOptions { /// The destination path for the copy operation. String targetPath, }); -} -extension CopyEntryRequestedOptionsExtension on CopyEntryRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -891,11 +820,7 @@ extension CopyEntryRequestedOptionsExtension on CopyEntryRequestedOptions { /// The destination path for the copy operation. external String targetPath; } - -@JS() -@staticInterop -@anonymous -class MoveEntryRequestedOptions { +extension type MoveEntryRequestedOptions._(JSObject _) implements JSObject { external factory MoveEntryRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -909,9 +834,7 @@ class MoveEntryRequestedOptions { /// The destination path for the copy operation. String targetPath, }); -} -extension MoveEntryRequestedOptionsExtension on MoveEntryRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -924,11 +847,7 @@ extension MoveEntryRequestedOptionsExtension on MoveEntryRequestedOptions { /// The destination path for the copy operation. external String targetPath; } - -@JS() -@staticInterop -@anonymous -class TruncateRequestedOptions { +extension type TruncateRequestedOptions._(JSObject _) implements JSObject { external factory TruncateRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -942,9 +861,7 @@ class TruncateRequestedOptions { /// Number of bytes to be retained after the operation completes. double length, }); -} -extension TruncateRequestedOptionsExtension on TruncateRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -957,11 +874,7 @@ extension TruncateRequestedOptionsExtension on TruncateRequestedOptions { /// Number of bytes to be retained after the operation completes. external double length; } - -@JS() -@staticInterop -@anonymous -class WriteFileRequestedOptions { +extension type WriteFileRequestedOptions._(JSObject _) implements JSObject { external factory WriteFileRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -978,9 +891,7 @@ class WriteFileRequestedOptions { /// Buffer of bytes to be written to the file. JSArrayBuffer data, }); -} -extension WriteFileRequestedOptionsExtension on WriteFileRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -996,11 +907,7 @@ extension WriteFileRequestedOptionsExtension on WriteFileRequestedOptions { /// Buffer of bytes to be written to the file. external JSArrayBuffer data; } - -@JS() -@staticInterop -@anonymous -class AbortRequestedOptions { +extension type AbortRequestedOptions._(JSObject _) implements JSObject { external factory AbortRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -1011,9 +918,7 @@ class AbortRequestedOptions { /// An ID of the request to be aborted. int operationRequestId, }); -} -extension AbortRequestedOptionsExtension on AbortRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -1023,11 +928,7 @@ extension AbortRequestedOptionsExtension on AbortRequestedOptions { /// An ID of the request to be aborted. external int operationRequestId; } - -@JS() -@staticInterop -@anonymous -class AddWatcherRequestedOptions { +extension type AddWatcherRequestedOptions._(JSObject _) implements JSObject { external factory AddWatcherRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -1042,9 +943,7 @@ class AddWatcherRequestedOptions { /// true for directories only. bool recursive, }); -} -extension AddWatcherRequestedOptionsExtension on AddWatcherRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -1058,11 +957,7 @@ extension AddWatcherRequestedOptionsExtension on AddWatcherRequestedOptions { /// true for directories only. external bool recursive; } - -@JS() -@staticInterop -@anonymous -class RemoveWatcherRequestedOptions { +extension type RemoveWatcherRequestedOptions._(JSObject _) implements JSObject { external factory RemoveWatcherRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -1076,10 +971,7 @@ class RemoveWatcherRequestedOptions { /// Mode of the watcher. bool recursive, }); -} -extension RemoveWatcherRequestedOptionsExtension - on RemoveWatcherRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -1092,11 +984,7 @@ extension RemoveWatcherRequestedOptionsExtension /// Mode of the watcher. external bool recursive; } - -@JS() -@staticInterop -@anonymous -class Action { +extension type Action._(JSObject _) implements JSObject { external factory Action({ /// The identifier of the action. Any string or [CommonActionId] for /// common actions. @@ -1105,9 +993,7 @@ class Action { /// The title of the action. It may be ignored for common actions. String? title, }); -} -extension ActionExtension on Action { /// The identifier of the action. Any string or [CommonActionId] for /// common actions. external String id; @@ -1115,11 +1001,7 @@ extension ActionExtension on Action { /// The title of the action. It may be ignored for common actions. external String? title; } - -@JS() -@staticInterop -@anonymous -class ExecuteActionRequestedOptions { +extension type ExecuteActionRequestedOptions._(JSObject _) implements JSObject { external factory ExecuteActionRequestedOptions({ /// The identifier of the file system related to this operation. String fileSystemId, @@ -1133,10 +1015,7 @@ class ExecuteActionRequestedOptions { /// The identifier of the action to be executed. String actionId, }); -} -extension ExecuteActionRequestedOptionsExtension - on ExecuteActionRequestedOptions { /// The identifier of the file system related to this operation. external String fileSystemId; @@ -1149,11 +1028,7 @@ extension ExecuteActionRequestedOptionsExtension /// The identifier of the action to be executed. external String actionId; } - -@JS() -@staticInterop -@anonymous -class Change { +extension type Change._(JSObject _) implements JSObject { external factory Change({ /// The path of the changed entry. String entryPath, @@ -1161,20 +1036,14 @@ class Change { /// The type of the change which happened to the entry. ChangeType changeType, }); -} -extension ChangeExtension on Change { /// The path of the changed entry. external String entryPath; /// The type of the change which happened to the entry. external ChangeType changeType; } - -@JS() -@staticInterop -@anonymous -class NotifyOptions { +extension type NotifyOptions._(JSObject _) implements JSObject { external factory NotifyOptions({ /// The identifier of the file system related to this change. String fileSystemId, @@ -1200,9 +1069,7 @@ class NotifyOptions { /// when the system was shutdown. String? tag, }); -} -extension NotifyOptionsExtension on NotifyOptions { /// The identifier of the file system related to this change. external String fileSystemId; @@ -1227,11 +1094,7 @@ extension NotifyOptionsExtension on NotifyOptions { /// when the system was shutdown. external String? tag; } - -@JS() -@staticInterop -@anonymous -class ConfigureRequestedOptions { +extension type ConfigureRequestedOptions._(JSObject _) implements JSObject { external factory ConfigureRequestedOptions({ /// The identifier of the file system to be configured. String fileSystemId, @@ -1239,9 +1102,7 @@ class ConfigureRequestedOptions { /// The unique identifier of this request. int requestId, }); -} -extension ConfigureRequestedOptionsExtension on ConfigureRequestedOptions { /// The identifier of the file system to be configured. external String fileSystemId; diff --git a/lib/src/js/font_settings.dart b/lib/src/js/font_settings.dart index b4d13b1..cfb37b8 100644 --- a/lib/src/js/font_settings.dart +++ b/lib/src/js/font_settings.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -22,11 +23,7 @@ extension JSChromeJSFontSettingsExtension on JSChrome { } } -@JS() -@staticInterop -class JSFontSettings {} - -extension JSFontSettingsExtension on JSFontSettings { +extension type JSFontSettings._(JSObject _) { /// Clears the font set by this extension, if any. external JSPromise clearFont(ClearFontDetails details); @@ -112,11 +109,7 @@ typedef GenericFamily = String; /// [controllable_by_this_extension]: can be controlled by this extension /// [controlled_by_this_extension]: controlled by this extension typedef LevelOfControl = String; - -@JS() -@staticInterop -@anonymous -class FontName { +extension type FontName._(JSObject _) implements JSObject { external factory FontName({ /// The font ID. String fontId, @@ -124,20 +117,14 @@ class FontName { /// The display name of the font. String displayName, }); -} -extension FontNameExtension on FontName { /// The font ID. external String fontId; /// The display name of the font. external String displayName; } - -@JS() -@staticInterop -@anonymous -class OnFontChangedDetails { +extension type OnFontChangedDetails._(JSObject _) implements JSObject { external factory OnFontChangedDetails({ /// The font ID. See the description in `getFont`. String fontId, @@ -151,9 +138,7 @@ class OnFontChangedDetails { /// The level of control this extension has over the setting. LevelOfControl levelOfControl, }); -} -extension OnFontChangedDetailsExtension on OnFontChangedDetails { /// The font ID. See the description in `getFont`. external String fontId; @@ -166,11 +151,8 @@ extension OnFontChangedDetailsExtension on OnFontChangedDetails { /// The level of control this extension has over the setting. external LevelOfControl levelOfControl; } - -@JS() -@staticInterop -@anonymous -class OnDefaultFontSizeChangedDetails { +extension type OnDefaultFontSizeChangedDetails._(JSObject _) + implements JSObject { external factory OnDefaultFontSizeChangedDetails({ /// The font size in pixels. int pixelSize, @@ -178,21 +160,15 @@ class OnDefaultFontSizeChangedDetails { /// The level of control this extension has over the setting. LevelOfControl levelOfControl, }); -} -extension OnDefaultFontSizeChangedDetailsExtension - on OnDefaultFontSizeChangedDetails { /// The font size in pixels. external int pixelSize; /// The level of control this extension has over the setting. external LevelOfControl levelOfControl; } - -@JS() -@staticInterop -@anonymous -class OnDefaultFixedFontSizeChangedDetails { +extension type OnDefaultFixedFontSizeChangedDetails._(JSObject _) + implements JSObject { external factory OnDefaultFixedFontSizeChangedDetails({ /// The font size in pixels. int pixelSize, @@ -200,21 +176,15 @@ class OnDefaultFixedFontSizeChangedDetails { /// The level of control this extension has over the setting. LevelOfControl levelOfControl, }); -} -extension OnDefaultFixedFontSizeChangedDetailsExtension - on OnDefaultFixedFontSizeChangedDetails { /// The font size in pixels. external int pixelSize; /// The level of control this extension has over the setting. external LevelOfControl levelOfControl; } - -@JS() -@staticInterop -@anonymous -class OnMinimumFontSizeChangedDetails { +extension type OnMinimumFontSizeChangedDetails._(JSObject _) + implements JSObject { external factory OnMinimumFontSizeChangedDetails({ /// The font size in pixels. int pixelSize, @@ -222,21 +192,14 @@ class OnMinimumFontSizeChangedDetails { /// The level of control this extension has over the setting. LevelOfControl levelOfControl, }); -} -extension OnMinimumFontSizeChangedDetailsExtension - on OnMinimumFontSizeChangedDetails { /// The font size in pixels. external int pixelSize; /// The level of control this extension has over the setting. external LevelOfControl levelOfControl; } - -@JS() -@staticInterop -@anonymous -class ClearFontDetails { +extension type ClearFontDetails._(JSObject _) implements JSObject { external factory ClearFontDetails({ /// The script for which the font should be cleared. If omitted, the global /// script font setting is cleared. @@ -245,9 +208,7 @@ class ClearFontDetails { /// The generic font family for which the font should be cleared. GenericFamily genericFamily, }); -} -extension ClearFontDetailsExtension on ClearFontDetails { /// The script for which the font should be cleared. If omitted, the global /// script font setting is cleared. external ScriptCode? script; @@ -255,11 +216,7 @@ extension ClearFontDetailsExtension on ClearFontDetails { /// The generic font family for which the font should be cleared. external GenericFamily genericFamily; } - -@JS() -@staticInterop -@anonymous -class GetFontCallbackDetails { +extension type GetFontCallbackDetails._(JSObject _) implements JSObject { external factory GetFontCallbackDetails({ /// The font ID. Rather than the literal font ID preference value, this may be /// the ID of the font that the system resolves the preference value to. So, @@ -271,9 +228,7 @@ class GetFontCallbackDetails { /// The level of control this extension has over the setting. LevelOfControl levelOfControl, }); -} -extension GetFontCallbackDetailsExtension on GetFontCallbackDetails { /// The font ID. Rather than the literal font ID preference value, this may be /// the ID of the font that the system resolves the preference value to. So, /// [fontId] can differ from the font passed to `setFont`, if, for example, @@ -284,11 +239,7 @@ extension GetFontCallbackDetailsExtension on GetFontCallbackDetails { /// The level of control this extension has over the setting. external LevelOfControl levelOfControl; } - -@JS() -@staticInterop -@anonymous -class GetFontDetails { +extension type GetFontDetails._(JSObject _) implements JSObject { external factory GetFontDetails({ /// The script for which the font should be retrieved. If omitted, the font /// setting for the global script (script code "Zyyy") is retrieved. @@ -297,9 +248,7 @@ class GetFontDetails { /// The generic font family for which the font should be retrieved. GenericFamily genericFamily, }); -} -extension GetFontDetailsExtension on GetFontDetails { /// The script for which the font should be retrieved. If omitted, the font /// setting for the global script (script code "Zyyy") is retrieved. external ScriptCode? script; @@ -307,11 +256,7 @@ extension GetFontDetailsExtension on GetFontDetails { /// The generic font family for which the font should be retrieved. external GenericFamily genericFamily; } - -@JS() -@staticInterop -@anonymous -class SetFontDetails { +extension type SetFontDetails._(JSObject _) implements JSObject { external factory SetFontDetails({ /// The script code which the font should be set. If omitted, the font setting /// for the global script (script code "Zyyy") is set. @@ -324,9 +269,7 @@ class SetFontDetails { /// setting. String fontId, }); -} -extension SetFontDetailsExtension on SetFontDetails { /// The script code which the font should be set. If omitted, the font setting /// for the global script (script code "Zyyy") is set. external ScriptCode? script; @@ -338,20 +281,11 @@ extension SetFontDetailsExtension on SetFontDetails { /// setting. external String fontId; } - -@JS() -@staticInterop -@anonymous -class ClearDefaultFontSizeDetails { +extension type ClearDefaultFontSizeDetails._(JSObject _) implements JSObject { external factory ClearDefaultFontSizeDetails(); } - -extension ClearDefaultFontSizeDetailsExtension on ClearDefaultFontSizeDetails {} - -@JS() -@staticInterop -@anonymous -class GetDefaultFontSizeCallbackDetails { +extension type GetDefaultFontSizeCallbackDetails._(JSObject _) + implements JSObject { external factory GetDefaultFontSizeCallbackDetails({ /// The font size in pixels. int pixelSize, @@ -359,55 +293,31 @@ class GetDefaultFontSizeCallbackDetails { /// The level of control this extension has over the setting. LevelOfControl levelOfControl, }); -} -extension GetDefaultFontSizeCallbackDetailsExtension - on GetDefaultFontSizeCallbackDetails { /// The font size in pixels. external int pixelSize; /// The level of control this extension has over the setting. external LevelOfControl levelOfControl; } - -@JS() -@staticInterop -@anonymous -class GetDefaultFontSizeDetails { +extension type GetDefaultFontSizeDetails._(JSObject _) implements JSObject { external factory GetDefaultFontSizeDetails(); } - -extension GetDefaultFontSizeDetailsExtension on GetDefaultFontSizeDetails {} - -@JS() -@staticInterop -@anonymous -class SetDefaultFontSizeDetails { +extension type SetDefaultFontSizeDetails._(JSObject _) implements JSObject { external factory SetDefaultFontSizeDetails( { /// The font size in pixels. int pixelSize}); -} -extension SetDefaultFontSizeDetailsExtension on SetDefaultFontSizeDetails { /// The font size in pixels. external int pixelSize; } - -@JS() -@staticInterop -@anonymous -class ClearDefaultFixedFontSizeDetails { +extension type ClearDefaultFixedFontSizeDetails._(JSObject _) + implements JSObject { external factory ClearDefaultFixedFontSizeDetails(); } - -extension ClearDefaultFixedFontSizeDetailsExtension - on ClearDefaultFixedFontSizeDetails {} - -@JS() -@staticInterop -@anonymous -class GetDefaultFixedFontSizeCallbackDetails { +extension type GetDefaultFixedFontSizeCallbackDetails._(JSObject _) + implements JSObject { external factory GetDefaultFixedFontSizeCallbackDetails({ /// The font size in pixels. int pixelSize, @@ -415,56 +325,32 @@ class GetDefaultFixedFontSizeCallbackDetails { /// The level of control this extension has over the setting. LevelOfControl levelOfControl, }); -} -extension GetDefaultFixedFontSizeCallbackDetailsExtension - on GetDefaultFixedFontSizeCallbackDetails { /// The font size in pixels. external int pixelSize; /// The level of control this extension has over the setting. external LevelOfControl levelOfControl; } - -@JS() -@staticInterop -@anonymous -class GetDefaultFixedFontSizeDetails { +extension type GetDefaultFixedFontSizeDetails._(JSObject _) + implements JSObject { external factory GetDefaultFixedFontSizeDetails(); } - -extension GetDefaultFixedFontSizeDetailsExtension - on GetDefaultFixedFontSizeDetails {} - -@JS() -@staticInterop -@anonymous -class SetDefaultFixedFontSizeDetails { +extension type SetDefaultFixedFontSizeDetails._(JSObject _) + implements JSObject { external factory SetDefaultFixedFontSizeDetails( { /// The font size in pixels. int pixelSize}); -} -extension SetDefaultFixedFontSizeDetailsExtension - on SetDefaultFixedFontSizeDetails { /// The font size in pixels. external int pixelSize; } - -@JS() -@staticInterop -@anonymous -class ClearMinimumFontSizeDetails { +extension type ClearMinimumFontSizeDetails._(JSObject _) implements JSObject { external factory ClearMinimumFontSizeDetails(); } - -extension ClearMinimumFontSizeDetailsExtension on ClearMinimumFontSizeDetails {} - -@JS() -@staticInterop -@anonymous -class GetMinimumFontSizeCallbackDetails { +extension type GetMinimumFontSizeCallbackDetails._(JSObject _) + implements JSObject { external factory GetMinimumFontSizeCallbackDetails({ /// The font size in pixels. int pixelSize, @@ -472,37 +358,22 @@ class GetMinimumFontSizeCallbackDetails { /// The level of control this extension has over the setting. LevelOfControl levelOfControl, }); -} -extension GetMinimumFontSizeCallbackDetailsExtension - on GetMinimumFontSizeCallbackDetails { /// The font size in pixels. external int pixelSize; /// The level of control this extension has over the setting. external LevelOfControl levelOfControl; } - -@JS() -@staticInterop -@anonymous -class GetMinimumFontSizeDetails { +extension type GetMinimumFontSizeDetails._(JSObject _) implements JSObject { external factory GetMinimumFontSizeDetails(); } - -extension GetMinimumFontSizeDetailsExtension on GetMinimumFontSizeDetails {} - -@JS() -@staticInterop -@anonymous -class SetMinimumFontSizeDetails { +extension type SetMinimumFontSizeDetails._(JSObject _) implements JSObject { external factory SetMinimumFontSizeDetails( { /// The font size in pixels. int pixelSize}); -} -extension SetMinimumFontSizeDetailsExtension on SetMinimumFontSizeDetails { /// The font size in pixels. external int pixelSize; } diff --git a/lib/src/js/gcm.dart b/lib/src/js/gcm.dart index 8bf2f54..872e09c 100644 --- a/lib/src/js/gcm.dart +++ b/lib/src/js/gcm.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,11 +25,7 @@ extension JSChromeJSGcmExtension on JSChrome { } } -@JS() -@staticInterop -class JSGcm {} - -extension JSGcmExtension on JSGcm { +extension type JSGcm._(JSObject _) { /// Registers the application with FCM. The registration ID will be returned /// by the `callback`. If `register` is called again with the same list of /// `senderIds`, the same registration ID will be returned. @@ -63,11 +60,7 @@ extension JSGcmExtension on JSGcm { /// The maximum size (in bytes) of all key/value pairs in a message. external int get MAX_MESSAGE_SIZE; } - -@JS() -@staticInterop -@anonymous -class OnMessageMessage { +extension type OnMessageMessage._(JSObject _) implements JSObject { external factory OnMessageMessage({ /// The message data. JSAny data, @@ -80,9 +73,7 @@ class OnMessageMessage { /// and collapsible messages for details. String? collapseKey, }); -} -extension OnMessageMessageExtension on OnMessageMessage { /// The message data. external JSAny data; @@ -94,11 +85,7 @@ extension OnMessageMessageExtension on OnMessageMessage { /// and collapsible messages for details. external String? collapseKey; } - -@JS() -@staticInterop -@anonymous -class OnSendErrorError { +extension type OnSendErrorError._(JSObject _) implements JSObject { external factory OnSendErrorError({ /// The error message describing the problem. String errorMessage, @@ -110,9 +97,7 @@ class OnSendErrorError { /// Additional details related to the error, when available. JSAny details, }); -} -extension OnSendErrorErrorExtension on OnSendErrorError { /// The error message describing the problem. external String errorMessage; @@ -123,11 +108,7 @@ extension OnSendErrorErrorExtension on OnSendErrorError { /// Additional details related to the error, when available. external JSAny details; } - -@JS() -@staticInterop -@anonymous -class SendMessage { +extension type SendMessage._(JSObject _) implements JSObject { external factory SendMessage({ /// The ID of the server to send the message to as assigned by [Google API /// Console](https://console.cloud.google.com/apis/dashboard). @@ -151,9 +132,7 @@ class SendMessage { /// Sum of all key/value pairs should not exceed [gcm.MAX_MESSAGE_SIZE]. JSAny data, }); -} -extension SendMessageExtension on SendMessage { /// The ID of the server to send the message to as assigned by [Google API /// Console](https://console.cloud.google.com/apis/dashboard). external String destinationId; diff --git a/lib/src/js/history.dart b/lib/src/js/history.dart index 95ee888..499ff37 100644 --- a/lib/src/js/history.dart +++ b/lib/src/js/history.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -15,7 +16,7 @@ extension JSChromeJSHistoryExtension on JSChrome { /// Use the `chrome.history` API to interact with the browser's record of /// visited pages. You can add, remove, and query for URLs in the browser's /// history. To override the history page with your own version, see [Override - /// Pages](override). + /// Pages](develop/ui/override-chrome-pages). JSHistory get history { var historyNullable = this.historyNullable; if (historyNullable == null) { @@ -25,11 +26,7 @@ extension JSChromeJSHistoryExtension on JSChrome { } } -@JS() -@staticInterop -class JSHistory {} - -extension JSHistoryExtension on JSHistory { +extension type JSHistory._(JSObject _) { /// Searches the history for the last visit time of each page matching the /// query. external JSPromise search(SearchQuery query); @@ -63,11 +60,7 @@ extension JSHistoryExtension on JSHistory { /// The [transition type](#transition_types) for this visit from its referrer. typedef TransitionType = String; - -@JS() -@staticInterop -@anonymous -class HistoryItem { +extension type HistoryItem._(JSObject _) implements JSObject { external factory HistoryItem({ /// The unique identifier for the item. String id, @@ -89,9 +82,7 @@ class HistoryItem { /// address. int? typedCount, }); -} -extension HistoryItemExtension on HistoryItem { /// The unique identifier for the item. external String id; @@ -112,11 +103,7 @@ extension HistoryItemExtension on HistoryItem { /// address. external int? typedCount; } - -@JS() -@staticInterop -@anonymous -class VisitItem { +extension type VisitItem._(JSObject _) implements JSObject { external factory VisitItem({ /// The unique identifier for the corresponding [history.HistoryItem]. String id, @@ -137,9 +124,7 @@ class VisitItem { /// different device. bool isLocal, }); -} -extension VisitItemExtension on VisitItem { /// The unique identifier for the corresponding [history.HistoryItem]. external String id; @@ -159,46 +144,30 @@ extension VisitItemExtension on VisitItem { /// different device. external bool isLocal; } - -@JS() -@staticInterop -@anonymous -class UrlDetails { +extension type UrlDetails._(JSObject _) implements JSObject { external factory UrlDetails( { /// The URL for the operation. It must be in the format as returned from a /// call to history.search. String url}); -} -extension UrlDetailsExtension on UrlDetails { /// The URL for the operation. It must be in the format as returned from a /// call to history.search. external String url; } - -@JS() -@staticInterop -@anonymous -class OnVisitRemovedRemoved { +extension type OnVisitRemovedRemoved._(JSObject _) implements JSObject { external factory OnVisitRemovedRemoved({ /// True if all history was removed. If true, then urls will be empty. bool allHistory, JSArray? urls, }); -} -extension OnVisitRemovedRemovedExtension on OnVisitRemovedRemoved { /// True if all history was removed. If true, then urls will be empty. external bool allHistory; external JSArray? urls; } - -@JS() -@staticInterop -@anonymous -class SearchQuery { +extension type SearchQuery._(JSObject _) implements JSObject { external factory SearchQuery({ /// A free-text query to the history service. Leave empty to retrieve all /// pages. @@ -216,9 +185,7 @@ class SearchQuery { /// The maximum number of results to retrieve. Defaults to 100. int? maxResults, }); -} -extension SearchQueryExtension on SearchQuery { /// A free-text query to the history service. Leave empty to retrieve all /// pages. external String text; @@ -235,11 +202,7 @@ extension SearchQueryExtension on SearchQuery { /// The maximum number of results to retrieve. Defaults to 100. external int? maxResults; } - -@JS() -@staticInterop -@anonymous -class DeleteRangeRange { +extension type DeleteRangeRange._(JSObject _) implements JSObject { external factory DeleteRangeRange({ /// Items added to history after this date, represented in milliseconds since /// the epoch. @@ -249,9 +212,7 @@ class DeleteRangeRange { /// the epoch. double endTime, }); -} -extension DeleteRangeRangeExtension on DeleteRangeRange { /// Items added to history after this date, represented in milliseconds since /// the epoch. external double startTime; diff --git a/lib/src/js/i18n.dart b/lib/src/js/i18n.dart index 528cf7e..da51772 100644 --- a/lib/src/js/i18n.dart +++ b/lib/src/js/i18n.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSI18nExtension on JSChrome { } } -@JS() -@staticInterop -class JSI18n {} - -extension JSI18nExtension on JSI18n { +extension type JSI18n._(JSObject _) { /// Gets the accept-languages of the browser. This is different from the /// locale used by the browser; to get the locale, use [i18n.getUILanguage]. external JSPromise getAcceptLanguages(); @@ -39,7 +36,7 @@ extension JSI18nExtension on JSI18n { /// returns `undefined`. external String getMessage( /// The name of the message, as specified in the `messages.json` file. + /// href='how-to/ui/localization-message-formats'>`messages.json` file. String messageName, /// Up to 9 substitution strings, if the message requires any. @@ -64,11 +61,7 @@ extension JSI18nExtension on JSI18n { /// For an unknown language, `und` will be returned, which means that /// [percentage] of the text is unknown to CLD typedef LanguageCode = String; - -@JS() -@staticInterop -@anonymous -class GetMessageOptions { +extension type GetMessageOptions._(JSObject _) implements JSObject { external factory GetMessageOptions( { /// Escape `<` in translation to `&lt;`. This applies only to the message @@ -76,20 +69,14 @@ class GetMessageOptions { /// translation is used in an HTML context. Closure Templates used with /// Closure Compiler generate this automatically. bool? escapeLt}); -} -extension GetMessageOptionsExtension on GetMessageOptions { /// Escape `<` in translation to `&lt;`. This applies only to the message /// itself, not to the placeholders. Developers might want to use this if the /// translation is used in an HTML context. Closure Templates used with /// Closure Compiler generate this automatically. external bool? escapeLt; } - -@JS() -@staticInterop -@anonymous -class DetectLanguageCallbackResult { +extension type DetectLanguageCallbackResult._(JSObject _) implements JSObject { external factory DetectLanguageCallbackResult({ /// CLD detected language reliability bool isReliable, @@ -97,31 +84,22 @@ class DetectLanguageCallbackResult { /// array of detectedLanguage JSArray languages, }); -} -extension DetectLanguageCallbackResultExtension - on DetectLanguageCallbackResult { /// CLD detected language reliability external bool isReliable; /// array of detectedLanguage external JSArray languages; } - -@JS() -@staticInterop -@anonymous -class DetectLanguageCallbackResultLanguages { +extension type DetectLanguageCallbackResultLanguages._(JSObject _) + implements JSObject { external factory DetectLanguageCallbackResultLanguages({ LanguageCode language, /// The percentage of the detected language int percentage, }); -} -extension DetectLanguageCallbackResultLanguagesExtension - on DetectLanguageCallbackResultLanguages { external LanguageCode language; /// The percentage of the detected language diff --git a/lib/src/js/identity.dart b/lib/src/js/identity.dart index 24e937c..7891ec9 100644 --- a/lib/src/js/identity.dart +++ b/lib/src/js/identity.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -22,11 +23,7 @@ extension JSChromeJSIdentityExtension on JSChrome { } } -@JS() -@staticInterop -class JSIdentity {} - -extension JSIdentityExtension on JSIdentity { +extension type JSIdentity._(JSObject _) { /// Retrieves a list of AccountInfo objects describing the accounts /// present on the profile. /// @@ -35,7 +32,7 @@ extension JSIdentityExtension on JSIdentity { /// Gets an OAuth2 access token using the client ID and scopes /// specified in the `oauth2` + /// href="/docs/apps/app_identity#update_manifest">`oauth2` /// section of manifest.json. /// /// The Identity API caches access tokens in memory, so it's ok to @@ -131,47 +128,31 @@ extension JSIdentityExtension on JSIdentity { } typedef AccountStatus = String; - -@JS() -@staticInterop -@anonymous -class AccountInfo { +extension type AccountInfo._(JSObject _) implements JSObject { external factory AccountInfo( { /// A unique identifier for the account. This ID will not change /// for the lifetime of the account. String id}); -} -extension AccountInfoExtension on AccountInfo { /// A unique identifier for the account. This ID will not change /// for the lifetime of the account. external String id; } - -@JS() -@staticInterop -@anonymous -class ProfileDetails { +extension type ProfileDetails._(JSObject _) implements JSObject { external factory ProfileDetails( { /// A status of the primary account signed into a profile whose /// `ProfileUserInfo` should be returned. Defaults to /// `SYNC` account status. AccountStatus? accountStatus}); -} -extension ProfileDetailsExtension on ProfileDetails { /// A status of the primary account signed into a profile whose /// `ProfileUserInfo` should be returned. Defaults to /// `SYNC` account status. external AccountStatus? accountStatus; } - -@JS() -@staticInterop -@anonymous -class ProfileUserInfo { +extension type ProfileUserInfo._(JSObject _) implements JSObject { external factory ProfileUserInfo({ /// An email address for the user account signed into the current /// profile. Empty if the user is not signed in or the @@ -185,9 +166,7 @@ class ProfileUserInfo { /// manifest permission is not specified. String id, }); -} -extension ProfileUserInfoExtension on ProfileUserInfo { /// An email address for the user account signed into the current /// profile. Empty if the user is not signed in or the /// `identity.email` manifest permission is not @@ -200,11 +179,7 @@ extension ProfileUserInfoExtension on ProfileUserInfo { /// manifest permission is not specified. external String id; } - -@JS() -@staticInterop -@anonymous -class TokenDetails { +extension type TokenDetails._(JSObject _) implements JSObject { external factory TokenDetails({ /// Fetching a token may require the user to sign-in to Chrome, or /// approve the application's requested scopes. If the interactive @@ -230,9 +205,7 @@ class TokenDetails { /// requested permissions are granted or denied individually. bool? enableGranularPermissions, }); -} -extension TokenDetailsExtension on TokenDetails { /// Fetching a token may require the user to sign-in to Chrome, or /// approve the application's requested scopes. If the interactive /// flag is `true`, `getAuthToken` will @@ -257,26 +230,16 @@ extension TokenDetailsExtension on TokenDetails { /// requested permissions are granted or denied individually. external bool? enableGranularPermissions; } - -@JS() -@staticInterop -@anonymous -class InvalidTokenDetails { +extension type InvalidTokenDetails._(JSObject _) implements JSObject { external factory InvalidTokenDetails( { /// The specific token that should be removed from the cache. String token}); -} -extension InvalidTokenDetailsExtension on InvalidTokenDetails { /// The specific token that should be removed from the cache. external String token; } - -@JS() -@staticInterop -@anonymous -class WebAuthFlowDetails { +extension type WebAuthFlowDetails._(JSObject _) implements JSObject { external factory WebAuthFlowDetails({ /// The URL that initiates the auth flow. String url, @@ -317,9 +280,7 @@ class WebAuthFlowDetails { /// `false`. int? timeoutMsForNonInteractive, }); -} -extension WebAuthFlowDetailsExtension on WebAuthFlowDetails { /// The URL that initiates the auth flow. external String url; @@ -359,11 +320,7 @@ extension WebAuthFlowDetailsExtension on WebAuthFlowDetails { /// `false`. external int? timeoutMsForNonInteractive; } - -@JS() -@staticInterop -@anonymous -class GetAuthTokenResult { +extension type GetAuthTokenResult._(JSObject _) implements JSObject { external factory GetAuthTokenResult({ /// The specific token associated with the request. String? token, @@ -371,9 +328,7 @@ class GetAuthTokenResult { /// A list of OAuth2 scopes granted to the extension. JSArray? grantedScopes, }); -} -extension GetAuthTokenResultExtension on GetAuthTokenResult { /// The specific token associated with the request. external String? token; diff --git a/lib/src/js/idle.dart b/lib/src/js/idle.dart index f4f9bf2..27cdc58 100644 --- a/lib/src/js/idle.dart +++ b/lib/src/js/idle.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -22,11 +23,7 @@ extension JSChromeJSIdleExtension on JSChrome { } } -@JS() -@staticInterop -class JSIdle {} - -extension JSIdleExtension on JSIdle { +extension type JSIdle._(JSObject _) { /// Returns "locked" if the system is locked, "idle" if the user has not /// generated any input for a specified number of seconds, or "active" /// otherwise. diff --git a/lib/src/js/input_ime.dart b/lib/src/js/input_ime.dart index 9c770ed..3666ad3 100644 --- a/lib/src/js/input_ime.dart +++ b/lib/src/js/input_ime.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -26,11 +27,7 @@ extension JSChromeJSInputImeExtension on JSChromeInput { } } -@JS() -@staticInterop -class JSInputIme {} - -extension JSInputImeExtension on JSInputIme { +extension type JSInputIme._(JSObject _) { /// Set the current composition. If this extension does not own the active /// IME, this fails. external JSPromise setComposition(SetCompositionParameters parameters); @@ -171,11 +168,7 @@ typedef AssistiveWindowType = String; /// ID of buttons in assistive window. typedef AssistiveWindowButton = String; - -@JS() -@staticInterop -@anonymous -class KeyboardEvent { +extension type KeyboardEvent._(JSObject _) implements JSObject { external factory KeyboardEvent({ /// One of keyup or keydown. KeyboardEventType type, @@ -214,9 +207,7 @@ class KeyboardEvent { /// Whether or not the CAPS_LOCK is enabled. bool? capsLock, }); -} -extension KeyboardEventExtension on KeyboardEvent { /// One of keyup or keydown. external KeyboardEventType type; @@ -254,11 +245,7 @@ extension KeyboardEventExtension on KeyboardEvent { /// Whether or not the CAPS_LOCK is enabled. external bool? capsLock; } - -@JS() -@staticInterop -@anonymous -class InputContext { +extension type InputContext._(JSObject _) implements JSObject { external factory InputContext({ /// This is used to specify targets of text field operations. This ID becomes /// invalid as soon as onBlur is called. @@ -283,9 +270,7 @@ class InputContext { /// suggestions for the user. bool shouldDoLearning, }); -} -extension InputContextExtension on InputContext { /// This is used to specify targets of text field operations. This ID becomes /// invalid as soon as onBlur is called. external int contextID; @@ -309,11 +294,7 @@ extension InputContextExtension on InputContext { /// suggestions for the user. external bool shouldDoLearning; } - -@JS() -@staticInterop -@anonymous -class MenuItem { +extension type MenuItem._(JSObject _) implements JSObject { external factory MenuItem({ /// String that will be passed to callbacks referencing this MenuItem. String id, @@ -333,9 +314,7 @@ class MenuItem { /// Indicates this item is enabled. bool? enabled, }); -} -extension MenuItemExtension on MenuItem { /// String that will be passed to callbacks referencing this MenuItem. external String id; @@ -354,11 +333,7 @@ extension MenuItemExtension on MenuItem { /// Indicates this item is enabled. external bool? enabled; } - -@JS() -@staticInterop -@anonymous -class AssistiveWindowProperties { +extension type AssistiveWindowProperties._(JSObject _) implements JSObject { external factory AssistiveWindowProperties({ AssistiveWindowType type, @@ -368,9 +343,7 @@ class AssistiveWindowProperties { /// Strings for ChromeVox to announce. String? announceString, }); -} -extension AssistiveWindowPropertiesExtension on AssistiveWindowProperties { external AssistiveWindowType type; /// Sets true to show AssistiveWindow, sets false to hide. @@ -379,11 +352,7 @@ extension AssistiveWindowPropertiesExtension on AssistiveWindowProperties { /// Strings for ChromeVox to announce. external String? announceString; } - -@JS() -@staticInterop -@anonymous -class MenuParameters { +extension type MenuParameters._(JSObject _) implements JSObject { external factory MenuParameters({ /// ID of the engine to use. String engineID, @@ -392,9 +361,7 @@ class MenuParameters { /// the array. JSArray items, }); -} -extension MenuParametersExtension on MenuParameters { /// ID of the engine to use. external String engineID; @@ -402,11 +369,8 @@ extension MenuParametersExtension on MenuParameters { /// the array. external JSArray items; } - -@JS() -@staticInterop -@anonymous -class OnSurroundingTextChangedSurroundingInfo { +extension type OnSurroundingTextChangedSurroundingInfo._(JSObject _) + implements JSObject { external factory OnSurroundingTextChangedSurroundingInfo({ /// The text around the cursor. This is only a subset of all text in the input /// field. @@ -425,10 +389,7 @@ class OnSurroundingTextChangedSurroundingInfo { /// character of `text`. int offset, }); -} -extension OnSurroundingTextChangedSurroundingInfoExtension - on OnSurroundingTextChangedSurroundingInfo { /// The text around the cursor. This is only a subset of all text in the input /// field. external String text; @@ -446,11 +407,8 @@ extension OnSurroundingTextChangedSurroundingInfoExtension /// character of `text`. external int offset; } - -@JS() -@staticInterop -@anonymous -class OnAssistiveWindowButtonClickedDetails { +extension type OnAssistiveWindowButtonClickedDetails._(JSObject _) + implements JSObject { external factory OnAssistiveWindowButtonClickedDetails({ /// The ID of the button clicked. AssistiveWindowButton buttonID, @@ -458,21 +416,14 @@ class OnAssistiveWindowButtonClickedDetails { /// The type of the assistive window. AssistiveWindowType windowType, }); -} -extension OnAssistiveWindowButtonClickedDetailsExtension - on OnAssistiveWindowButtonClickedDetails { /// The ID of the button clicked. external AssistiveWindowButton buttonID; /// The type of the assistive window. external AssistiveWindowType windowType; } - -@JS() -@staticInterop -@anonymous -class SetCompositionParameters { +extension type SetCompositionParameters._(JSObject _) implements JSObject { external factory SetCompositionParameters({ /// ID of the context where the composition text will be set int contextID, @@ -492,9 +443,7 @@ class SetCompositionParameters { /// List of segments and their associated types. JSArray? segments, }); -} -extension SetCompositionParametersExtension on SetCompositionParameters { /// ID of the context where the composition text will be set external int contextID; @@ -513,26 +462,16 @@ extension SetCompositionParametersExtension on SetCompositionParameters { /// List of segments and their associated types. external JSArray? segments; } - -@JS() -@staticInterop -@anonymous -class ClearCompositionParameters { +extension type ClearCompositionParameters._(JSObject _) implements JSObject { external factory ClearCompositionParameters( { /// ID of the context where the composition will be cleared int contextID}); -} -extension ClearCompositionParametersExtension on ClearCompositionParameters { /// ID of the context where the composition will be cleared external int contextID; } - -@JS() -@staticInterop -@anonymous -class CommitTextParameters { +extension type CommitTextParameters._(JSObject _) implements JSObject { external factory CommitTextParameters({ /// ID of the context where the text will be committed int contextID, @@ -540,20 +479,14 @@ class CommitTextParameters { /// The text to commit String text, }); -} -extension CommitTextParametersExtension on CommitTextParameters { /// ID of the context where the text will be committed external int contextID; /// The text to commit external String text; } - -@JS() -@staticInterop -@anonymous -class SendKeyEventsParameters { +extension type SendKeyEventsParameters._(JSObject _) implements JSObject { external factory SendKeyEventsParameters({ /// ID of the context where the key events will be sent, or zero to send key /// events to non-input field. @@ -562,9 +495,7 @@ class SendKeyEventsParameters { /// Data on the key event. JSArray keyData, }); -} -extension SendKeyEventsParametersExtension on SendKeyEventsParameters { /// ID of the context where the key events will be sent, or zero to send key /// events to non-input field. external int contextID; @@ -572,30 +503,20 @@ extension SendKeyEventsParametersExtension on SendKeyEventsParameters { /// Data on the key event. external JSArray keyData; } - -@JS() -@staticInterop -@anonymous -class SetCandidateWindowPropertiesParameters { +extension type SetCandidateWindowPropertiesParameters._(JSObject _) + implements JSObject { external factory SetCandidateWindowPropertiesParameters({ /// ID of the engine to set properties on. String engineID, SetCandidateWindowPropertiesParametersProperties properties, }); -} -extension SetCandidateWindowPropertiesParametersExtension - on SetCandidateWindowPropertiesParameters { /// ID of the engine to set properties on. external String engineID; external SetCandidateWindowPropertiesParametersProperties properties; } - -@JS() -@staticInterop -@anonymous -class SetCandidatesParameters { +extension type SetCandidatesParameters._(JSObject _) implements JSObject { external factory SetCandidatesParameters({ /// ID of the context that owns the candidate window. int contextID, @@ -603,20 +524,14 @@ class SetCandidatesParameters { /// List of candidates to show in the candidate window JSArray candidates, }); -} -extension SetCandidatesParametersExtension on SetCandidatesParameters { /// ID of the context that owns the candidate window. external int contextID; /// List of candidates to show in the candidate window external JSArray candidates; } - -@JS() -@staticInterop -@anonymous -class SetCursorPositionParameters { +extension type SetCursorPositionParameters._(JSObject _) implements JSObject { external factory SetCursorPositionParameters({ /// ID of the context that owns the candidate window. int contextID, @@ -624,20 +539,15 @@ class SetCursorPositionParameters { /// ID of the candidate to select. int candidateID, }); -} -extension SetCursorPositionParametersExtension on SetCursorPositionParameters { /// ID of the context that owns the candidate window. external int contextID; /// ID of the candidate to select. external int candidateID; } - -@JS() -@staticInterop -@anonymous -class SetAssistiveWindowPropertiesParameters { +extension type SetAssistiveWindowPropertiesParameters._(JSObject _) + implements JSObject { external factory SetAssistiveWindowPropertiesParameters({ /// ID of the context owning the assistive window. int contextID, @@ -645,21 +555,15 @@ class SetAssistiveWindowPropertiesParameters { /// Properties of the assistive window. AssistiveWindowProperties properties, }); -} -extension SetAssistiveWindowPropertiesParametersExtension - on SetAssistiveWindowPropertiesParameters { /// ID of the context owning the assistive window. external int contextID; /// Properties of the assistive window. external AssistiveWindowProperties properties; } - -@JS() -@staticInterop -@anonymous -class SetAssistiveWindowButtonHighlightedParameters { +extension type SetAssistiveWindowButtonHighlightedParameters._(JSObject _) + implements JSObject { external factory SetAssistiveWindowButtonHighlightedParameters({ /// ID of the context owning the assistive window. int contextID, @@ -676,10 +580,7 @@ class SetAssistiveWindowButtonHighlightedParameters { /// Whether the button should be highlighted. bool highlighted, }); -} -extension SetAssistiveWindowButtonHighlightedParametersExtension - on SetAssistiveWindowButtonHighlightedParameters { /// ID of the context owning the assistive window. external int contextID; @@ -695,11 +596,8 @@ extension SetAssistiveWindowButtonHighlightedParametersExtension /// Whether the button should be highlighted. external bool highlighted; } - -@JS() -@staticInterop -@anonymous -class DeleteSurroundingTextParameters { +extension type DeleteSurroundingTextParameters._(JSObject _) + implements JSObject { external factory DeleteSurroundingTextParameters({ /// ID of the engine receiving the event. String engineID, @@ -714,10 +612,7 @@ class DeleteSurroundingTextParameters { /// The number of characters to be deleted int length, }); -} -extension DeleteSurroundingTextParametersExtension - on DeleteSurroundingTextParameters { /// ID of the engine receiving the event. external String engineID; @@ -731,11 +626,8 @@ extension DeleteSurroundingTextParametersExtension /// The number of characters to be deleted external int length; } - -@JS() -@staticInterop -@anonymous -class SetCompositionParametersSegments { +extension type SetCompositionParametersSegments._(JSObject _) + implements JSObject { external factory SetCompositionParametersSegments({ /// Index of the character to start this segment at int start, @@ -746,10 +638,7 @@ class SetCompositionParametersSegments { /// The type of the underline to modify this segment. UnderlineStyle style, }); -} -extension SetCompositionParametersSegmentsExtension - on SetCompositionParametersSegments { /// Index of the character to start this segment at external int start; @@ -759,11 +648,8 @@ extension SetCompositionParametersSegmentsExtension /// The type of the underline to modify this segment. external UnderlineStyle style; } - -@JS() -@staticInterop -@anonymous -class SetCandidateWindowPropertiesParametersProperties { +extension type SetCandidateWindowPropertiesParametersProperties._(JSObject _) + implements JSObject { external factory SetCandidateWindowPropertiesParametersProperties({ /// True to show the Candidate window, false to hide it. bool? visible, @@ -793,10 +679,7 @@ class SetCandidateWindowPropertiesParametersProperties { /// Where to display the candidate window. WindowPosition? windowPosition, }); -} -extension SetCandidateWindowPropertiesParametersPropertiesExtension - on SetCandidateWindowPropertiesParametersProperties { /// True to show the Candidate window, false to hide it. external bool? visible; @@ -825,11 +708,8 @@ extension SetCandidateWindowPropertiesParametersPropertiesExtension /// Where to display the candidate window. external WindowPosition? windowPosition; } - -@JS() -@staticInterop -@anonymous -class SetCandidatesParametersCandidates { +extension type SetCandidatesParametersCandidates._(JSObject _) + implements JSObject { external factory SetCandidatesParametersCandidates({ /// The candidate String candidate, @@ -850,10 +730,7 @@ class SetCandidatesParametersCandidates { /// The usage or detail description of word. SetCandidatesParametersCandidatesUsage? usage, }); -} -extension SetCandidatesParametersCandidatesExtension - on SetCandidatesParametersCandidates { /// The candidate external String candidate; @@ -873,11 +750,8 @@ extension SetCandidatesParametersCandidatesExtension /// The usage or detail description of word. external SetCandidatesParametersCandidatesUsage? usage; } - -@JS() -@staticInterop -@anonymous -class SetCandidatesParametersCandidatesUsage { +extension type SetCandidatesParametersCandidatesUsage._(JSObject _) + implements JSObject { external factory SetCandidatesParametersCandidatesUsage({ /// The title string of details description. String title, @@ -885,10 +759,7 @@ class SetCandidatesParametersCandidatesUsage { /// The body string of detail description. String body, }); -} -extension SetCandidatesParametersCandidatesUsageExtension - on SetCandidatesParametersCandidatesUsage { /// The title string of details description. external String title; diff --git a/lib/src/js/instance_id.dart b/lib/src/js/instance_id.dart index 685d57a..207b399 100644 --- a/lib/src/js/instance_id.dart +++ b/lib/src/js/instance_id.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -22,11 +23,7 @@ extension JSChromeJSInstanceIdExtension on JSChrome { } } -@JS() -@staticInterop -class JSInstanceId {} - -extension JSInstanceIdExtension on JSInstanceId { +extension type JSInstanceId._(JSObject _) { /// Retrieves an identifier for the app instance. The instance ID will be /// returned by the `callback`. The same ID will be returned as long as the /// application identity has not been revoked or expired. @@ -56,11 +53,7 @@ extension JSInstanceIdExtension on JSInstanceId { /// Fired when all the granted tokens need to be refreshed. external Event get onTokenRefresh; } - -@JS() -@staticInterop -@anonymous -class GetTokenParams { +extension type GetTokenParams._(JSObject _) implements JSObject { external factory GetTokenParams({ /// Identifies the entity that is authorized to access resources associated /// with this Instance ID. It can be a project ID from [Google developer @@ -75,9 +68,7 @@ class GetTokenParams { /// associated with the token and may be used in processing the request. JSAny? options, }); -} -extension GetTokenParamsExtension on GetTokenParams { /// Identifies the entity that is authorized to access resources associated /// with this Instance ID. It can be a project ID from [Google developer /// console](https://code.google.com/apis/console). @@ -91,11 +82,7 @@ extension GetTokenParamsExtension on GetTokenParams { /// associated with the token and may be used in processing the request. external JSAny? options; } - -@JS() -@staticInterop -@anonymous -class DeleteTokenParams { +extension type DeleteTokenParams._(JSObject _) implements JSObject { external factory DeleteTokenParams({ /// The authorized entity that is used to obtain the token. String authorizedEntity, @@ -103,9 +90,7 @@ class DeleteTokenParams { /// The scope that is used to obtain the token. String scope, }); -} -extension DeleteTokenParamsExtension on DeleteTokenParams { /// The authorized entity that is used to obtain the token. external String authorizedEntity; diff --git a/lib/src/js/login_state.dart b/lib/src/js/login_state.dart index 9f17d10..56e4958 100644 --- a/lib/src/js/login_state.dart +++ b/lib/src/js/login_state.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSLoginStateExtension on JSChrome { } } -@JS() -@staticInterop -class JSLoginState {} - -extension JSLoginStateExtension on JSLoginState { +extension type JSLoginState._(JSObject _) { /// Gets the type of the profile the extension is in. external JSPromise getProfileType(); diff --git a/lib/src/js/management.dart b/lib/src/js/management.dart index eb91895..2c1f402 100644 --- a/lib/src/js/management.dart +++ b/lib/src/js/management.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -14,7 +15,8 @@ extension JSChromeJSManagementExtension on JSChrome { /// The `chrome.management` API provides ways to manage the list of /// extensions/apps that are installed and running. It is particularly useful - /// for extensions that [override](override) the built-in New Tab page. + /// for extensions that [override](develop/ui/override-chrome-pages) the + /// built-in New Tab page. JSManagement get management { var managementNullable = this.managementNullable; if (managementNullable == null) { @@ -24,11 +26,7 @@ extension JSChromeJSManagementExtension on JSChrome { } } -@JS() -@staticInterop -class JSManagement {} - -extension JSManagementExtension on JSManagement { +extension type JSManagement._(JSObject _) { /// Returns a list of information about installed extensions and apps. external JSPromise getAll(); @@ -44,16 +42,18 @@ extension JSManagementExtension on JSManagement { /// manifest. external JSPromise getSelf(); - /// Returns a list of [permission warnings](permission_warnings) for the given - /// extension id. + /// Returns a list of [permission + /// warnings](develop/concepts/permission-warnings) for the given extension + /// id. external JSPromise getPermissionWarningsById( /// The ID of an already installed extension. String id); - /// Returns a list of [permission warnings](permission_warnings) for the given - /// extension manifest string. Note: This function can be used without - /// requesting the 'management' permission in the manifest. + /// Returns a list of [permission + /// warnings](develop/concepts/permission-warnings) for the given extension + /// manifest string. Note: This function can be used without requesting the + /// 'management' permission in the manifest. external JSPromise getPermissionWarningsByManifest( /// Extension manifest JSON string. @@ -122,16 +122,6 @@ extension JSManagementExtension on JSManagement { String title, ); - /// Checks if the replacement android app can be installed. Errors generated - /// by this API are reported by setting [runtime.lastError] and executing the - /// function's regular callback. - external JSPromise canInstallReplacementAndroidApp(); - - /// Prompts the user to install the replacement Android app from the manifest. - /// Errors generated by this API are reported by setting [runtime.lastError] - /// and executing the function's regular callback. - external JSPromise installReplacementAndroidApp(); - /// Launches the replacement_web_app specified in the manifest. Prompts the /// user to install if not already installed. external JSPromise installReplacementWebApp(); @@ -165,11 +155,7 @@ typedef ExtensionType = String; /// [sideload]: The extension was installed by other software on the machine, /// [other]: The extension was installed by other means. typedef ExtensionInstallType = String; - -@JS() -@staticInterop -@anonymous -class IconInfo { +extension type IconInfo._(JSObject _) implements JSObject { external factory IconInfo({ /// A number representing the width and height of the icon. Likely values /// include (but are not limited to) 128, 48, 24, and 16. @@ -180,9 +166,7 @@ class IconInfo { /// `?grayscale=true` to the URL. String url, }); -} -extension IconInfoExtension on IconInfo { /// A number representing the width and height of the icon. Likely values /// include (but are not limited to) 128, 48, 24, and 16. external int size; @@ -192,11 +176,7 @@ extension IconInfoExtension on IconInfo { /// `?grayscale=true` to the URL. external String url; } - -@JS() -@staticInterop -@anonymous -class ExtensionInfo { +extension type ExtensionInfo._(JSObject _) implements JSObject { external factory ExtensionInfo({ /// The extension's unique identifier. String id, @@ -210,11 +190,12 @@ class ExtensionInfo { /// The description of this extension, app, or theme. String description, - /// The [version](manifest/version) of this extension, app, or theme. + /// The [version](reference/manifest/version) of this extension, app, or + /// theme. String version, - /// The [version name](manifest/version#version_name) of this extension, app, - /// or theme if the manifest specified one. + /// The [version name](reference/manifest/version#version_name) of this + /// extension, app, or theme if the manifest specified one. String? versionName, /// Whether this extension can be disabled or uninstalled by the user. @@ -255,7 +236,7 @@ class ExtensionInfo { /// in the manifest, and the actual image at that url may be larger or smaller /// than what was declared, so you might consider using explicit width and /// height attributes on img tags referencing these images. See the [manifest - /// documentation on icons](manifest/icons) for more details. + /// documentation on icons](reference/manifest/icons) for more details. JSArray? icons, /// Returns a list of API based permissions. @@ -273,9 +254,7 @@ class ExtensionInfo { /// The currently available launch types (only present for apps). JSArray? availableLaunchTypes, }); -} -extension ExtensionInfoExtension on ExtensionInfo { /// The extension's unique identifier. external String id; @@ -288,11 +267,12 @@ extension ExtensionInfoExtension on ExtensionInfo { /// The description of this extension, app, or theme. external String description; - /// The [version](manifest/version) of this extension, app, or theme. + /// The [version](reference/manifest/version) of this extension, app, or + /// theme. external String version; - /// The [version name](manifest/version#version_name) of this extension, app, - /// or theme if the manifest specified one. + /// The [version name](reference/manifest/version#version_name) of this + /// extension, app, or theme if the manifest specified one. external String? versionName; /// Whether this extension can be disabled or uninstalled by the user. @@ -333,7 +313,7 @@ extension ExtensionInfoExtension on ExtensionInfo { /// in the manifest, and the actual image at that url may be larger or smaller /// than what was declared, so you might consider using explicit width and /// height attributes on img tags referencing these images. See the [manifest - /// documentation on icons](manifest/icons) for more details. + /// documentation on icons](reference/manifest/icons) for more details. external JSArray? icons; /// Returns a list of API based permissions. @@ -351,20 +331,14 @@ extension ExtensionInfoExtension on ExtensionInfo { /// The currently available launch types (only present for apps). external JSArray? availableLaunchTypes; } - -@JS() -@staticInterop -@anonymous -class UninstallOptions { +extension type UninstallOptions._(JSObject _) implements JSObject { external factory UninstallOptions( { /// Whether or not a confirm-uninstall dialog should prompt the user. Defaults /// to false for self uninstalls. If an extension uninstalls another /// extension, this parameter is ignored and the dialog is always shown. bool? showConfirmDialog}); -} -extension UninstallOptionsExtension on UninstallOptions { /// Whether or not a confirm-uninstall dialog should prompt the user. Defaults /// to false for self uninstalls. If an extension uninstalls another /// extension, this parameter is ignored and the dialog is always shown. diff --git a/lib/src/js/notifications.dart b/lib/src/js/notifications.dart index 303e805..321f96a 100644 --- a/lib/src/js/notifications.dart +++ b/lib/src/js/notifications.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSNotificationsExtension on JSChrome { } } -@JS() -@staticInterop -class JSNotifications {} - -extension JSNotificationsExtension on JSNotifications { +extension type JSNotifications._(JSObject _) { /// Creates and displays a notification. /// |notificationId|: Identifier of the notification. If not set or empty, an /// ID will automatically be generated. If it matches an existing @@ -97,11 +94,7 @@ extension JSNotificationsExtension on JSNotifications { typedef TemplateType = String; typedef PermissionLevel = String; - -@JS() -@staticInterop -@anonymous -class NotificationItem { +extension type NotificationItem._(JSObject _) implements JSObject { external factory NotificationItem({ /// Title of one item of a list notification. String title, @@ -109,58 +102,40 @@ class NotificationItem { /// Additional details about this item. String message, }); -} -extension NotificationItemExtension on NotificationItem { /// Title of one item of a list notification. external String title; /// Additional details about this item. external String message; } - -@JS() -@staticInterop -@anonymous -class NotificationBitmap { +extension type NotificationBitmap._(JSObject _) implements JSObject { external factory NotificationBitmap({ int width, int height, JSArrayBuffer? data, }); -} -extension NotificationBitmapExtension on NotificationBitmap { external int width; external int height; external JSArrayBuffer? data; } - -@JS() -@staticInterop -@anonymous -class NotificationButton { +extension type NotificationButton._(JSObject _) implements JSObject { external factory NotificationButton({ String title, String? iconUrl, NotificationBitmap? iconBitmap, }); -} -extension NotificationButtonExtension on NotificationButton { external String title; external String? iconUrl; external NotificationBitmap? iconBitmap; } - -@JS() -@staticInterop -@anonymous -class NotificationOptions { +extension type NotificationOptions._(JSObject _) implements JSObject { external factory NotificationOptions({ /// Which type of notification to display. /// _Required for [notifications.create]_ method. @@ -232,9 +207,7 @@ class NotificationOptions { /// notification is being shown. This defaults to false. bool? silent, }); -} -extension NotificationOptionsExtension on NotificationOptions { /// Which type of notification to display. /// _Required for [notifications.create]_ method. external TemplateType? type; diff --git a/lib/src/js/offscreen.dart b/lib/src/js/offscreen.dart index ef6ccad..6f8a30f 100644 --- a/lib/src/js/offscreen.dart +++ b/lib/src/js/offscreen.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -22,11 +23,7 @@ extension JSChromeJSOffscreenExtension on JSChrome { } } -@JS() -@staticInterop -class JSOffscreen {} - -extension JSOffscreenExtension on JSOffscreen { +extension type JSOffscreen._(JSObject _) { /// Creates a new offscreen document for the extension. /// |parameters|: The parameters describing the offscreen document to create. /// |callback|: Invoked when the offscreen document is created and has @@ -48,11 +45,7 @@ extension JSOffscreenExtension on JSOffscreen { } typedef Reason = String; - -@JS() -@staticInterop -@anonymous -class CreateParameters { +extension type CreateParameters._(JSObject _) implements JSObject { external factory CreateParameters({ /// The reason(s) the extension is creating the offscreen document. JSArray reasons, @@ -65,9 +58,7 @@ class CreateParameters { /// user. String justification, }); -} -extension CreateParametersExtension on CreateParameters { /// The reason(s) the extension is creating the offscreen document. external JSArray reasons; diff --git a/lib/src/js/omnibox.dart b/lib/src/js/omnibox.dart index abeb468..7ca8166 100644 --- a/lib/src/js/omnibox.dart +++ b/lib/src/js/omnibox.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSOmniboxExtension on JSChrome { } } -@JS() -@staticInterop -class JSOmnibox {} - -extension JSOmniboxExtension on JSOmnibox { +extension type JSOmnibox._(JSObject _) { /// A callback passed to the onInputChanged event used for sending suggestions /// back to the browser. external void sendSuggestions( @@ -71,11 +68,7 @@ typedef DescriptionStyleType = String; /// navigate to a certain URL, a disposition of 'newForegroundTab' means the /// navigation should take place in a new selected tab. typedef OnInputEnteredDisposition = String; - -@JS() -@staticInterop -@anonymous -class MatchClassification { +extension type MatchClassification._(JSObject _) implements JSObject { external factory MatchClassification({ int offset, @@ -83,9 +76,7 @@ class MatchClassification { DescriptionStyleType type, int? length, }); -} -extension MatchClassificationExtension on MatchClassification { external int offset; /// The style type @@ -93,11 +84,7 @@ extension MatchClassificationExtension on MatchClassification { external int? length; } - -@JS() -@staticInterop -@anonymous -class SuggestResult { +extension type SuggestResult._(JSObject _) implements JSObject { external factory SuggestResult({ /// The text that is put into the URL bar, and that is sent to the extension /// when the user chooses this entry. @@ -119,9 +106,7 @@ class SuggestResult { /// extension. JSArray? descriptionStyles, }); -} -extension SuggestResultExtension on SuggestResult { /// The text that is put into the URL bar, and that is sent to the extension /// when the user chooses this entry. external String content; @@ -142,11 +127,7 @@ extension SuggestResultExtension on SuggestResult { /// extension. external JSArray? descriptionStyles; } - -@JS() -@staticInterop -@anonymous -class DefaultSuggestResult { +extension type DefaultSuggestResult._(JSObject _) implements JSObject { external factory DefaultSuggestResult({ /// The text that is displayed in the URL dropdown. Can contain XML-style /// markup for styling. The supported tags are 'url' (for a literal URL), @@ -159,9 +140,7 @@ class DefaultSuggestResult { /// extension. JSArray? descriptionStyles, }); -} -extension DefaultSuggestResultExtension on DefaultSuggestResult { /// The text that is displayed in the URL dropdown. Can contain XML-style /// markup for styling. The supported tags are 'url' (for a literal URL), /// 'match' (for highlighting text that matched what the user's query), and diff --git a/lib/src/js/page_action.dart b/lib/src/js/page_action.dart index 54780fd..adb5535 100644 --- a/lib/src/js/page_action.dart +++ b/lib/src/js/page_action.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -25,11 +26,7 @@ extension JSChromeJSPageActionExtension on JSChrome { } } -@JS() -@staticInterop -class JSPageAction {} - -extension JSPageActionExtension on JSPageAction { +extension type JSPageAction._(JSObject _) { /// Shows the page action. The page action is shown whenever the tab is /// selected. external JSPromise show( @@ -72,28 +69,18 @@ extension JSPageActionExtension on JSPageAction { /// Pixel data for an image. Must be an ImageData object (for example, from a /// `canvas` element). typedef ImageDataType = JSObject; - -@JS() -@staticInterop -@anonymous -class TabDetails { +extension type TabDetails._(JSObject _) implements JSObject { external factory TabDetails( { /// The ID of the tab to query state for. If no tab is specified, the /// non-tab-specific state is returned. int? tabId}); -} -extension TabDetailsExtension on TabDetails { /// The ID of the tab to query state for. If no tab is specified, the /// non-tab-specific state is returned. external int? tabId; } - -@JS() -@staticInterop -@anonymous -class SetTitleDetails { +extension type SetTitleDetails._(JSObject _) implements JSObject { external factory SetTitleDetails({ /// The id of the tab for which you want to modify the page action. int tabId, @@ -101,20 +88,14 @@ class SetTitleDetails { /// The tooltip string. String title, }); -} -extension SetTitleDetailsExtension on SetTitleDetails { /// The id of the tab for which you want to modify the page action. external int tabId; /// The tooltip string. external String title; } - -@JS() -@staticInterop -@anonymous -class SetIconDetails { +extension type SetIconDetails._(JSObject _) implements JSObject { external factory SetIconDetails({ /// The id of the tab for which you want to modify the page action. int tabId, @@ -141,9 +122,7 @@ class SetIconDetails { /// **Deprecated.** This argument is ignored. int? iconIndex, }); -} -extension SetIconDetailsExtension on SetIconDetails { /// The id of the tab for which you want to modify the page action. external int tabId; @@ -169,11 +148,7 @@ extension SetIconDetailsExtension on SetIconDetails { /// **Deprecated.** This argument is ignored. external int? iconIndex; } - -@JS() -@staticInterop -@anonymous -class SetPopupDetails { +extension type SetPopupDetails._(JSObject _) implements JSObject { external factory SetPopupDetails({ /// The id of the tab for which you want to modify the page action. int tabId, @@ -182,9 +157,7 @@ class SetPopupDetails { /// string (`''`), no popup is shown. String popup, }); -} -extension SetPopupDetailsExtension on SetPopupDetails { /// The id of the tab for which you want to modify the page action. external int tabId; diff --git a/lib/src/js/page_capture.dart b/lib/src/js/page_capture.dart index 0c4c78e..f44d4ee 100644 --- a/lib/src/js/page_capture.dart +++ b/lib/src/js/page_capture.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -22,26 +23,16 @@ extension JSChromeJSPageCaptureExtension on JSChrome { } } -@JS() -@staticInterop -class JSPageCapture {} - -extension JSPageCaptureExtension on JSPageCapture { +extension type JSPageCapture._(JSObject _) { /// Saves the content of the tab with given id as MHTML. external JSPromise saveAsMHTML(SaveAsMhtmlDetails details); } - -@JS() -@staticInterop -@anonymous -class SaveAsMhtmlDetails { +extension type SaveAsMhtmlDetails._(JSObject _) implements JSObject { external factory SaveAsMhtmlDetails( { /// The id of the tab to save as MHTML. int tabId}); -} -extension SaveAsMhtmlDetailsExtension on SaveAsMhtmlDetails { /// The id of the tab to save as MHTML. external int tabId; } diff --git a/lib/src/js/permissions.dart b/lib/src/js/permissions.dart index c69fa9d..07701fc 100644 --- a/lib/src/js/permissions.dart +++ b/lib/src/js/permissions.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -13,9 +14,9 @@ extension JSChromeJSPermissionsExtension on JSChrome { external JSPermissions? get permissionsNullable; /// Use the `chrome.permissions` API to request [declared optional - /// permissions](permissions#manifest) at run time rather than install time, - /// so users understand why the permissions are needed and grant only those - /// that are necessary. + /// permissions](/docs/extensions/mv3/declare_permissions/) at run time rather + /// than install time, so users understand why the permissions are needed and + /// grant only those that are necessary. JSPermissions get permissions { var permissionsNullable = this.permissionsNullable; if (permissionsNullable == null) { @@ -25,11 +26,7 @@ extension JSChromeJSPermissionsExtension on JSChrome { } } -@JS() -@staticInterop -class JSPermissions {} - -extension JSPermissionsExtension on JSPermissions { +extension type JSPermissions._(JSObject _) { /// Gets the extension's current set of permissions. external JSPromise getAll(); @@ -56,11 +53,7 @@ extension JSPermissionsExtension on JSPermissions { /// Fired when access to permissions has been removed from the extension. external Event get onRemoved; } - -@JS() -@staticInterop -@anonymous -class Permissions { +extension type Permissions._(JSObject _) implements JSObject { external factory Permissions({ /// List of named permissions (does not include hosts or origins). JSArray? permissions, @@ -70,9 +63,7 @@ class Permissions { /// associated with [Content Scripts](content_scripts). JSArray? origins, }); -} -extension PermissionsExtension on Permissions { /// List of named permissions (does not include hosts or origins). external JSArray? permissions; diff --git a/lib/src/js/platform_keys.dart b/lib/src/js/platform_keys.dart index b31beb3..00829e9 100644 --- a/lib/src/js/platform_keys.dart +++ b/lib/src/js/platform_keys.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -27,11 +28,7 @@ extension JSChromeJSPlatformKeysExtension on JSChrome { } } -@JS() -@staticInterop -class JSPlatformKeys {} - -extension JSPlatformKeysExtension on JSPlatformKeys { +extension type JSPlatformKeys._(JSObject _) { /// This method filters from a list of client certificates the ones that /// are known to the platform, match `request` and for which the /// extension has permission to access the certificate and its private key. @@ -116,11 +113,7 @@ extension JSPlatformKeysExtension on JSPlatformKeys { } typedef ClientCertificateType = String; - -@JS() -@staticInterop -@anonymous -class Match { +extension type Match._(JSObject _) implements JSObject { external factory Match({ /// The DER encoding of a X.509 certificate. JSArrayBuffer certificate, @@ -133,9 +126,7 @@ class Match { /// function are not included. JSAny keyAlgorithm, }); -} -extension MatchExtension on Match { /// The DER encoding of a X.509 certificate. external JSArrayBuffer certificate; @@ -147,11 +138,7 @@ extension MatchExtension on Match { /// function are not included. external JSAny keyAlgorithm; } - -@JS() -@staticInterop -@anonymous -class ClientCertificateRequest { +extension type ClientCertificateRequest._(JSObject _) implements JSObject { external factory ClientCertificateRequest({ /// This field is a list of the types of certificates requested, sorted in /// order of the server's preference. Only certificates of a type contained @@ -163,9 +150,7 @@ class ClientCertificateRequest { /// server. Each entry must be a DER-encoded X.509 DistinguishedName. JSArray certificateAuthorities, }); -} -extension ClientCertificateRequestExtension on ClientCertificateRequest { /// This field is a list of the types of certificates requested, sorted in /// order of the server's preference. Only certificates of a type contained /// in this list will be retrieved. If `certificateTypes` is the @@ -176,11 +161,7 @@ extension ClientCertificateRequestExtension on ClientCertificateRequest { /// server. Each entry must be a DER-encoded X.509 DistinguishedName. external JSArray certificateAuthorities; } - -@JS() -@staticInterop -@anonymous -class SelectDetails { +extension type SelectDetails._(JSObject _) implements JSObject { external factory SelectDetails({ /// Only certificates that match this request will be returned. ClientCertificateRequest request, @@ -199,9 +180,7 @@ class SelectDetails { /// extension has been granted access to (automatically or manually). bool interactive, }); -} -extension SelectDetailsExtension on SelectDetails { /// Only certificates that match this request will be returned. external ClientCertificateRequest request; @@ -219,11 +198,7 @@ extension SelectDetailsExtension on SelectDetails { /// extension has been granted access to (automatically or manually). external bool interactive; } - -@JS() -@staticInterop -@anonymous -class VerificationDetails { +extension type VerificationDetails._(JSObject _) implements JSObject { external factory VerificationDetails({ /// Each chain entry must be the DER encoding of a X.509 certificate, the /// first entry must be the server certificate and each entry must certify @@ -234,9 +209,7 @@ class VerificationDetails { /// that presented the `serverCertificateChain`. String hostname, }); -} -extension VerificationDetailsExtension on VerificationDetails { /// Each chain entry must be the DER encoding of a X.509 certificate, the /// first entry must be the server certificate and each entry must certify /// the entry preceding it. @@ -246,11 +219,7 @@ extension VerificationDetailsExtension on VerificationDetails { /// that presented the `serverCertificateChain`. external String hostname; } - -@JS() -@staticInterop -@anonymous -class VerificationResult { +extension type VerificationResult._(JSObject _) implements JSObject { external factory VerificationResult({ /// The result of the trust verification: true if trust for the given /// verification details could be established and false if trust is rejected @@ -266,9 +235,7 @@ class VerificationResult { /// compatible. JSArray debug_errors, }); -} -extension VerificationResultExtension on VerificationResult { /// The result of the trust verification: true if trust for the given /// verification details could be established and false if trust is rejected /// for any reason. diff --git a/lib/src/js/power.dart b/lib/src/js/power.dart index 2ab8468..60bd01b 100644 --- a/lib/src/js/power.dart +++ b/lib/src/js/power.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSPowerExtension on JSChrome { } } -@JS() -@staticInterop -class JSPower {} - -extension JSPowerExtension on JSPower { +extension type JSPower._(JSObject _) { /// Requests that power management be temporarily disabled. |level| /// describes the degree to which power management should be disabled. /// If a request previously made by the same app is still active, it diff --git a/lib/src/js/printer_provider.dart b/lib/src/js/printer_provider.dart index 5ccfdef..930066b 100644 --- a/lib/src/js/printer_provider.dart +++ b/lib/src/js/printer_provider.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,11 +25,7 @@ extension JSChromeJSPrinterProviderExtension on JSChrome { } } -@JS() -@staticInterop -class JSPrinterProvider {} - -extension JSPrinterProviderExtension on JSPrinterProvider { +extension type JSPrinterProvider._(JSObject _) { /// Event fired when print manager requests printers provided by extensions. /// |resultCallback|: Callback to return printer list. Every listener must /// call callback exactly once. @@ -74,11 +71,7 @@ typedef PrinterInfoCallback = JSFunction; typedef CapabilitiesCallback = JSFunction; typedef PrintCallback = JSFunction; - -@JS() -@staticInterop -@anonymous -class PrinterInfo { +extension type PrinterInfo._(JSObject _) implements JSObject { external factory PrinterInfo({ /// Unique printer ID. String id, @@ -89,9 +82,7 @@ class PrinterInfo { /// Printer's human readable description. String? description, }); -} -extension PrinterInfoExtension on PrinterInfo { /// Unique printer ID. external String id; @@ -101,11 +92,7 @@ extension PrinterInfoExtension on PrinterInfo { /// Printer's human readable description. external String? description; } - -@JS() -@staticInterop -@anonymous -class PrintJob { +extension type PrintJob._(JSObject _) implements JSObject { external factory PrintJob({ /// ID of the printer which should handle the job. String printerId, @@ -116,6 +103,12 @@ class PrintJob { /// Print ticket in /// /// CJT format. + /// JSAny ticket, /// The document content type. Supported formats are @@ -126,9 +119,7 @@ class PrintJob { /// |contentType|. JSObject document, }); -} -extension PrintJobExtension on PrintJob { /// ID of the printer which should handle the job. external String printerId; @@ -138,6 +129,12 @@ extension PrintJobExtension on PrintJob { /// Print ticket in /// /// CJT format. + /// external JSAny ticket; /// The document content type. Supported formats are diff --git a/lib/src/js/printing.dart b/lib/src/js/printing.dart index 2617baa..d0e3a48 100644 --- a/lib/src/js/printing.dart +++ b/lib/src/js/printing.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,14 +25,13 @@ extension JSChromeJSPrintingExtension on JSChrome { } } -@JS() -@staticInterop -class JSPrinting {} - -extension JSPrintingExtension on JSPrinting { - /// Submits the job for print. - /// If the extension is not listed in PrintingAPIExtensionsAllowlist policy, - /// the user will be prompted to accept the print job. +extension type JSPrinting._(JSObject _) { + /// Submits the job for printing. If the extension is not listed in + /// the + /// `PrintingAPIExtensionsAllowlist` policy, + /// the user is prompted to accept the print job.
+ /// Before Chrome 120, this function did not return a promise. external JSPromise submitJob(SubmitJobRequest request); /// Cancels previously submitted job. @@ -74,16 +74,14 @@ typedef PrinterStatus = String; /// Status of the print job. typedef JobStatus = String; - -@JS() -@staticInterop -@anonymous -class SubmitJobRequest { +extension type SubmitJobRequest._(JSObject _) implements JSObject { external factory SubmitJobRequest({ /// The print job to be submitted. - /// The only supported content type is "application/pdf", and the CJT ticket - /// shouldn't include FitToPageTicketItem, PageRangeTicketItem, - /// ReverseOrderTicketItem and VendorTicketItem fields since they are + /// The only supported content type is "application/pdf", and the + /// [Cloud Job Ticket](https://developers.google.com/cloud-print/docs/cdd#cjt) + /// shouldn't include `FitToPageTicketItem`, + /// `PageRangeTicketItem`, `ReverseOrderTicketItem` + /// and `VendorTicketItem` fields since they are /// irrelevant for native printing. All other fields must be present. PrintJob job, @@ -91,13 +89,13 @@ class SubmitJobRequest { /// shouldn't be populated by the extension. String? documentBlobUuid, }); -} -extension SubmitJobRequestExtension on SubmitJobRequest { /// The print job to be submitted. - /// The only supported content type is "application/pdf", and the CJT ticket - /// shouldn't include FitToPageTicketItem, PageRangeTicketItem, - /// ReverseOrderTicketItem and VendorTicketItem fields since they are + /// The only supported content type is "application/pdf", and the + /// [Cloud Job Ticket](https://developers.google.com/cloud-print/docs/cdd#cjt) + /// shouldn't include `FitToPageTicketItem`, + /// `PageRangeTicketItem`, `ReverseOrderTicketItem` + /// and `VendorTicketItem` fields since they are /// irrelevant for native printing. All other fields must be present. external PrintJob job; @@ -105,11 +103,7 @@ extension SubmitJobRequestExtension on SubmitJobRequest { /// shouldn't be populated by the extension. external String? documentBlobUuid; } - -@JS() -@staticInterop -@anonymous -class SubmitJobResponse { +extension type SubmitJobResponse._(JSObject _) implements JSObject { external factory SubmitJobResponse({ /// The status of the request. SubmitJobStatus status, @@ -118,9 +112,7 @@ class SubmitJobResponse { /// jobs on the device. If status is not OK, jobId will be null. String? jobId, }); -} -extension SubmitJobResponseExtension on SubmitJobResponse { /// The status of the request. external SubmitJobStatus status; @@ -128,11 +120,7 @@ extension SubmitJobResponseExtension on SubmitJobResponse { /// jobs on the device. If status is not OK, jobId will be null. external String? jobId; } - -@JS() -@staticInterop -@anonymous -class Printer { +extension type Printer._(JSObject _) implements JSObject { external factory Printer({ /// The printer's identifier; guaranteed to be unique among printers on the /// device. @@ -164,9 +152,7 @@ class Printer { /// recently. This value is guaranteed to be unique amongst printers. int? recentlyUsedRank, }); -} -extension PrinterExtension on Printer { /// The printer's identifier; guaranteed to be unique among printers on the /// device. external String id; @@ -197,11 +183,7 @@ extension PrinterExtension on Printer { /// recently. This value is guaranteed to be unique amongst printers. external int? recentlyUsedRank; } - -@JS() -@staticInterop -@anonymous -class GetPrinterInfoResponse { +extension type GetPrinterInfoResponse._(JSObject _) implements JSObject { external factory GetPrinterInfoResponse({ /// Printer capabilities in /// @@ -212,9 +194,7 @@ class GetPrinterInfoResponse { /// The status of the printer. PrinterStatus status, }); -} -extension GetPrinterInfoResponseExtension on GetPrinterInfoResponse { /// Printer capabilities in /// /// CDD format. diff --git a/lib/src/js/printing_metrics.dart b/lib/src/js/printing_metrics.dart index 6ac52fb..d307fcf 100644 --- a/lib/src/js/printing_metrics.dart +++ b/lib/src/js/printing_metrics.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,11 +25,7 @@ extension JSChromeJSPrintingMetricsExtension on JSChrome { } } -@JS() -@staticInterop -class JSPrintingMetrics {} - -extension JSPrintingMetricsExtension on JSPrintingMetrics { +extension type JSPrintingMetrics._(JSObject _) { /// Returns the list of the finished print jobs. external JSPromise getPrintJobs(); @@ -40,7 +37,7 @@ extension JSPrintingMetricsExtension on JSPrintingMetrics { /// The source of the print job. typedef PrintJobSource = String; -/// The final status of the print job. +/// Specifies the final status of the print job. typedef PrintJobStatus = String; /// The source of the printer. @@ -49,11 +46,7 @@ typedef PrinterSource = String; typedef ColorMode = String; typedef DuplexMode = String; - -@JS() -@staticInterop -@anonymous -class MediaSize { +extension type MediaSize._(JSObject _) implements JSObject { external factory MediaSize({ /// Width (in micrometers) of the media used for printing. int width, @@ -68,9 +61,7 @@ class MediaSize { /// IANA page . String vendorId, }); -} -extension MediaSizeExtension on MediaSize { /// Width (in micrometers) of the media used for printing. external int width; @@ -84,11 +75,7 @@ extension MediaSizeExtension on MediaSize { /// IANA page . external String vendorId; } - -@JS() -@staticInterop -@anonymous -class PrintSettings { +extension type PrintSettings._(JSObject _) implements JSObject { external factory PrintSettings({ /// The requested color mode. ColorMode color, @@ -102,9 +89,7 @@ class PrintSettings { /// The requested number of copies. int copies, }); -} -extension PrintSettingsExtension on PrintSettings { /// The requested color mode. external ColorMode color; @@ -117,11 +102,7 @@ extension PrintSettingsExtension on PrintSettings { /// The requested number of copies. external int copies; } - -@JS() -@staticInterop -@anonymous -class Printer { +extension type Printer._(JSObject _) implements JSObject { external factory Printer({ /// Displayed name of the printer. String name, @@ -133,9 +114,7 @@ class Printer { /// The source of the printer. PrinterSource source, }); -} -extension PrinterExtension on Printer { /// Displayed name of the printer. external String name; @@ -146,11 +125,7 @@ extension PrinterExtension on Printer { /// The source of the printer. external PrinterSource source; } - -@JS() -@staticInterop -@anonymous -class PrintJobInfo { +extension type PrintJobInfo._(JSObject _) implements JSObject { external factory PrintJobInfo({ /// The ID of the job. String id, @@ -185,9 +160,7 @@ class PrintJobInfo { /// The status of the printer. PrinterStatus printer_status, }); -} -extension PrintJobInfoExtension on PrintJobInfo { /// The ID of the job. external String id; diff --git a/lib/src/js/privacy.dart b/lib/src/js/privacy.dart index 266613c..ac99516 100644 --- a/lib/src/js/privacy.dart +++ b/lib/src/js/privacy.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -26,11 +27,7 @@ extension JSChromeJSPrivacyExtension on JSChrome { } } -@JS() -@staticInterop -class JSPrivacy {} - -extension JSPrivacyExtension on JSPrivacy { +extension type JSPrivacy._(JSObject _) { /// Settings that influence Chrome's handling of network connections in /// general. external PrivacyNetwork get network; @@ -46,11 +43,7 @@ extension JSPrivacyExtension on JSPrivacy { /// The IP handling policy of WebRTC. typedef IPHandlingPolicy = String; - -@JS() -@staticInterop -@anonymous -class PrivacyNetwork { +extension type PrivacyNetwork._(JSObject _) implements JSObject { external factory PrivacyNetwork({ /// If enabled, Chrome attempts to speed up your web browsing experience by /// pre-resolving DNS entries and preemptively opening TCP and SSL connections @@ -66,9 +59,7 @@ class PrivacyNetwork { /// IPHandlingPolicy, defaulting to `default`. ChromeSetting webRTCIPHandlingPolicy, }); -} -extension PrivacyNetworkExtension on PrivacyNetwork { /// If enabled, Chrome attempts to speed up your web browsing experience by /// pre-resolving DNS entries and preemptively opening TCP and SSL connections /// to servers. This preference only affects actions taken by Chrome's @@ -83,11 +74,7 @@ extension PrivacyNetworkExtension on PrivacyNetwork { /// IPHandlingPolicy, defaulting to `default`. external ChromeSetting webRTCIPHandlingPolicy; } - -@JS() -@staticInterop -@anonymous -class PrivacyServices { +extension type PrivacyServices._(JSObject _) implements JSObject { external factory PrivacyServices({ /// If enabled, Chrome uses a web service to help resolve navigation errors. /// This preference's value is a boolean, defaulting to `true`. @@ -132,9 +119,7 @@ class PrivacyServices { /// read. This preference's value is a boolean, defaulting to `true`. ChromeSetting translationServiceEnabled, }); -} -extension PrivacyServicesExtension on PrivacyServices { /// If enabled, Chrome uses a web service to help resolve navigation errors. /// This preference's value is a boolean, defaulting to `true`. external ChromeSetting alternateErrorPagesEnabled; @@ -178,23 +163,13 @@ extension PrivacyServicesExtension on PrivacyServices { /// read. This preference's value is a boolean, defaulting to `true`. external ChromeSetting translationServiceEnabled; } - -@JS() -@staticInterop -@anonymous -class PrivacyWebsites { +extension type PrivacyWebsites._(JSObject _) implements JSObject { external factory PrivacyWebsites({ /// If disabled, Chrome blocks third-party sites from setting cookies. The /// value of this preference is of type boolean, and the default value is /// `true`. ChromeSetting thirdPartyCookiesAllowed, - /// If enabled, the experimental [Privacy - /// Sandbox](https://www.chromium.org/Home/chromium-privacy/privacy-sandbox) - /// features are active. The value of this preference is of type boolean, and - /// the default value is `true`. - ChromeSetting privacySandboxEnabled, - /// If disabled, the [Topics /// API](https://developer.chrome.com/en/docs/privacy-sandbox/topics/) is /// deactivated. The value of this preference is of type boolean, and the @@ -241,21 +216,21 @@ class PrivacyWebsites { /// unique ID to plugins in order to run protected content. The value of this /// preference is of type boolean, and the default value is `true`. ChromeSetting? protectedContentEnabled, + + /// If disabled, [Related Website + /// Sets](https://developer.chrome.com/docs/privacy-sandbox/related-website-sets/) + /// is deactivated. The value of this preference is of type boolean, and the + /// default value is `true`. Extensions may only disable this API by setting + /// the value to `false`. If you try setting this API to `true`, it will throw + /// an error. + ChromeSetting relatedWebsiteSetsEnabled, }); -} -extension PrivacyWebsitesExtension on PrivacyWebsites { /// If disabled, Chrome blocks third-party sites from setting cookies. The /// value of this preference is of type boolean, and the default value is /// `true`. external ChromeSetting thirdPartyCookiesAllowed; - /// If enabled, the experimental [Privacy - /// Sandbox](https://www.chromium.org/Home/chromium-privacy/privacy-sandbox) - /// features are active. The value of this preference is of type boolean, and - /// the default value is `true`. - external ChromeSetting privacySandboxEnabled; - /// If disabled, the [Topics /// API](https://developer.chrome.com/en/docs/privacy-sandbox/topics/) is /// deactivated. The value of this preference is of type boolean, and the @@ -302,4 +277,12 @@ extension PrivacyWebsitesExtension on PrivacyWebsites { /// unique ID to plugins in order to run protected content. The value of this /// preference is of type boolean, and the default value is `true`. external ChromeSetting? protectedContentEnabled; + + /// If disabled, [Related Website + /// Sets](https://developer.chrome.com/docs/privacy-sandbox/related-website-sets/) + /// is deactivated. The value of this preference is of type boolean, and the + /// default value is `true`. Extensions may only disable this API by setting + /// the value to `false`. If you try setting this API to `true`, it will throw + /// an error. + external ChromeSetting relatedWebsiteSetsEnabled; } diff --git a/lib/src/js/processes.dart b/lib/src/js/processes.dart index 320e21f..8eb7118 100644 --- a/lib/src/js/processes.dart +++ b/lib/src/js/processes.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSProcessesExtension on JSChrome { } } -@JS() -@staticInterop -class JSProcesses {} - -extension JSProcessesExtension on JSProcesses { +extension type JSProcesses._(JSObject _) { /// Returns the ID of the renderer process for the specified tab. /// |tabId|: The ID of the tab for which the renderer process ID is to be /// returned. @@ -93,11 +90,7 @@ extension JSProcessesExtension on JSProcesses { /// The types of the browser processes. typedef ProcessType = String; - -@JS() -@staticInterop -@anonymous -class TaskInfo { +extension type TaskInfo._(JSObject _) implements JSObject { external factory TaskInfo({ /// The title of the task. String title, @@ -106,9 +99,7 @@ class TaskInfo { /// process. int? tabId, }); -} -extension TaskInfoExtension on TaskInfo { /// The title of the task. external String title; @@ -116,11 +107,7 @@ extension TaskInfoExtension on TaskInfo { /// process. external int? tabId; } - -@JS() -@staticInterop -@anonymous -class Cache { +extension type Cache._(JSObject _) implements JSObject { external factory Cache({ /// The size of the cache, in bytes. double size, @@ -128,20 +115,14 @@ class Cache { /// The part of the cache that is utilized, in bytes. double liveSize, }); -} -extension CacheExtension on Cache { /// The size of the cache, in bytes. external double size; /// The part of the cache that is utilized, in bytes. external double liveSize; } - -@JS() -@staticInterop -@anonymous -class Process { +extension type Process._(JSObject _) implements JSObject { external factory Process({ /// Unique ID of the process provided by the browser. int id, @@ -210,9 +191,7 @@ class Process { /// or onUpdatedWithMemory. Cache? cssCache, }); -} -extension ProcessExtension on Process { /// Unique ID of the process provided by the browser. external int id; diff --git a/lib/src/js/proxy.dart b/lib/src/js/proxy.dart index 743806a..3d26e16 100644 --- a/lib/src/js/proxy.dart +++ b/lib/src/js/proxy.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -15,7 +16,8 @@ extension JSChromeJSProxyExtension on JSChrome { /// Use the `chrome.proxy` API to manage Chrome's proxy settings. This API /// relies on the [ChromeSetting prototype of the type - /// API](types#ChromeSetting) for getting and setting the proxy configuration. + /// API](reference/api/types#type-ChromeSetting) for getting and setting the + /// proxy configuration. JSProxy get proxy { var proxyNullable = this.proxyNullable; if (proxyNullable == null) { @@ -25,11 +27,7 @@ extension JSChromeJSProxyExtension on JSChrome { } } -@JS() -@staticInterop -class JSProxy {} - -extension JSProxyExtension on JSProxy { +extension type JSProxy._(JSObject _) { /// Notifies about proxy errors. external Event get onProxyError; @@ -41,11 +39,7 @@ extension JSProxyExtension on JSProxy { typedef Scheme = String; typedef Mode = String; - -@JS() -@staticInterop -@anonymous -class ProxyServer { +extension type ProxyServer._(JSObject _) implements JSObject { external factory ProxyServer({ /// The scheme (protocol) of the proxy server itself. Defaults to 'http'. Scheme? scheme, @@ -58,9 +52,7 @@ class ProxyServer { /// scheme. int? port, }); -} -extension ProxyServerExtension on ProxyServer { /// The scheme (protocol) of the proxy server itself. Defaults to 'http'. external Scheme? scheme; @@ -72,11 +64,7 @@ extension ProxyServerExtension on ProxyServer { /// scheme. external int? port; } - -@JS() -@staticInterop -@anonymous -class ProxyRules { +extension type ProxyRules._(JSObject _) implements JSObject { external factory ProxyRules({ /// The proxy server to be used for all per-URL requests (that is http, https, /// and ftp). @@ -98,9 +86,7 @@ class ProxyRules { /// List of servers to connect to without a proxy server. JSArray? bypassList, }); -} -extension ProxyRulesExtension on ProxyRules { /// The proxy server to be used for all per-URL requests (that is http, https, /// and ftp). external ProxyServer? singleProxy; @@ -121,11 +107,7 @@ extension ProxyRulesExtension on ProxyRules { /// List of servers to connect to without a proxy server. external JSArray? bypassList; } - -@JS() -@staticInterop -@anonymous -class PacScript { +extension type PacScript._(JSObject _) implements JSObject { external factory PacScript({ /// URL of the PAC file to be used. String? url, @@ -137,9 +119,7 @@ class PacScript { /// back to direct connections. Defaults to false. bool? mandatory, }); -} -extension PacScriptExtension on PacScript { /// URL of the PAC file to be used. external String? url; @@ -150,11 +130,7 @@ extension PacScriptExtension on PacScript { /// back to direct connections. Defaults to false. external bool? mandatory; } - -@JS() -@staticInterop -@anonymous -class ProxyConfig { +extension type ProxyConfig._(JSObject _) implements JSObject { external factory ProxyConfig({ /// The proxy rules describing this configuration. Use this for /// 'fixed_servers' mode. @@ -171,9 +147,7 @@ class ProxyConfig { /// 'system' = Use system proxy settings Mode mode, }); -} -extension ProxyConfigExtension on ProxyConfig { /// The proxy rules describing this configuration. Use this for /// 'fixed_servers' mode. external ProxyRules? rules; @@ -189,11 +163,7 @@ extension ProxyConfigExtension on ProxyConfig { /// 'system' = Use system proxy settings external Mode mode; } - -@JS() -@staticInterop -@anonymous -class OnProxyErrorDetails { +extension type OnProxyErrorDetails._(JSObject _) implements JSObject { external factory OnProxyErrorDetails({ /// If true, the error was fatal and the network transaction was aborted. /// Otherwise, a direct connection is used instead. @@ -205,9 +175,7 @@ class OnProxyErrorDetails { /// Additional details about the error such as a JavaScript runtime error. String details, }); -} -extension OnProxyErrorDetailsExtension on OnProxyErrorDetails { /// If true, the error was fatal and the network transaction was aborted. /// Otherwise, a direct connection is used instead. external bool fatal; diff --git a/lib/src/js/runtime.dart b/lib/src/js/runtime.dart index 5c0ae25..1c61376 100644 --- a/lib/src/js/runtime.dart +++ b/lib/src/js/runtime.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -13,7 +14,7 @@ extension JSChromeJSRuntimeExtension on JSChrome { @JS('runtime') external JSRuntime? get runtimeNullable; - /// Use the `chrome.runtime` API to retrieve the background page, return + /// Use the `chrome.runtime` API to retrieve the service worker, return /// details about the manifest, and listen for and respond to events in the /// app or extension lifecycle. You can also use this API to convert the /// relative path of URLs to fully-qualified URLs. @@ -26,11 +27,7 @@ extension JSChromeJSRuntimeExtension on JSChrome { } } -@JS() -@staticInterop -class JSRuntime {} - -extension JSRuntimeExtension on JSRuntime { +extension type JSRuntime._(JSObject _) { /// Retrieves the JavaScript 'window' object for the background page running /// inside the current extension/app. If the background page is an event page, /// the system will ensure it is loaded before calling the callback. If there @@ -50,7 +47,8 @@ extension JSRuntimeExtension on JSRuntime { external JSPromise openOptionsPage(); /// Returns details about the app or extension from the manifest. The object - /// returned is a serialization of the full [manifest file](manifest.html). + /// returned is a serialization of the full [manifest + /// file](reference/manifest). external JSAny getManifest(); /// Converts a relative path within an app/extension install directory to a @@ -112,21 +110,21 @@ extension JSRuntimeExtension on JSRuntime { /// Attempts to connect listeners within an extension/app (such as the /// background page), or other extensions/apps. This is useful for content /// scripts connecting to their extension processes, inter-app/extension - /// communication, and [web messaging](manifest/externally_connectable.html). - /// Note that this does not connect to any listeners in a content script. - /// Extensions may connect to content scripts embedded in tabs via - /// [tabs.connect]. + /// communication, and [web + /// messaging](/docs/extensions/manifest/externally_connectable). Note that + /// this does not connect to any listeners in a content script. Extensions may + /// connect to content scripts embedded in tabs via [tabs.connect]. external Port connect( /// The ID of the extension or app to connect to. If omitted, a connection /// will be attempted with your own extension. Required if sending messages /// from a web page for [web - /// messaging](manifest/externally_connectable.html). + /// messaging](/docs/extensions/reference/manifest/externally-connectable). String? extensionId, ConnectInfo? connectInfo, ); /// Connects to a native application in the host machine. See [Native - /// Messaging](nativeMessaging) for more information. + /// Messaging](develop/concepts/native-messaging) for more information. external Port connectNative( /// The name of the registered application to connect to. @@ -144,7 +142,7 @@ extension JSRuntimeExtension on JSRuntime { /// The ID of the extension/app to send the message to. If omitted, the /// message will be sent to your own extension/app. Required if sending /// messages from a web page for [web - /// messaging](manifest/externally_connectable.html). + /// messaging](/docs/extensions/manifest/externally_connectable). String? extensionId, /// The message to send. This message should be a JSON-ifiable object. @@ -165,7 +163,7 @@ extension JSRuntimeExtension on JSRuntime { external JSPromise getPlatformInfo(); /// Returns a DirectoryEntry for the package directory. - external void getPackageDirectoryEntry(JSFunction callback); + external JSPromise getPackageDirectoryEntry(); /// Fetches information about active contexts associated with this extension external JSPromise getContexts( @@ -216,7 +214,7 @@ extension JSRuntimeExtension on JSRuntime { external Event get onConnect; /// Fired when a connection is made from another extension (by - /// [runtime.connect]). + /// [runtime.connect]), or from an externally connectable web site. external Event get onConnectExternal; /// Fired when a connection is made from a user script from this extension. @@ -245,7 +243,12 @@ extension JSRuntimeExtension on JSRuntime { /// fired for Chrome OS kiosk apps. external Event get onRestartRequired; - /// This will be defined during an API method callback if there was an error + /// Populated with an error message if calling an API function fails; + /// otherwise undefined. This is only defined within the scope of that + /// function's callback. If an error is produced, but `runtime.lastError` is + /// not accessed within the callback, a message is logged to the console + /// listing the API function that produced the error. API functions that + /// return promises do not set this property. external RuntimeLastError? get lastError; /// The ID of the extension/app. @@ -276,11 +279,7 @@ typedef OnInstalledReason = String; typedef OnRestartRequiredReason = String; typedef ContextType = String; - -@JS() -@staticInterop -@anonymous -class Port { +extension type Port._(JSObject _) implements JSObject { external factory Port({ /// The name of the port, as specified in the call to [runtime.connect]. String name, @@ -300,9 +299,7 @@ class Port { /// listeners. MessageSender? sender, }); -} -extension PortExtension on Port { /// The name of the port, as specified in the call to [runtime.connect]. external String name; @@ -332,11 +329,7 @@ extension PortExtension on Port { /// the other end of the port. external Event get onMessage; } - -@JS() -@staticInterop -@anonymous -class MessageSender { +extension type MessageSender._(JSObject _) implements JSObject { external factory MessageSender({ /// The [tabs.Tab] which opened the connection, if any. This property will /// *only* be present when the connection was opened from a tab (including @@ -385,9 +378,7 @@ class MessageSender { /// have changed since port creation. String? documentLifecycle, }); -} -extension MessageSenderExtension on MessageSender { /// The [tabs.Tab] which opened the connection, if any. This property will /// *only* be present when the connection was opened from a tab (including /// content scripts), and *only* if the receiver is an extension, not an app. @@ -435,11 +426,7 @@ extension MessageSenderExtension on MessageSender { /// have changed since port creation. external String? documentLifecycle; } - -@JS() -@staticInterop -@anonymous -class PlatformInfo { +extension type PlatformInfo._(JSObject _) implements JSObject { external factory PlatformInfo({ /// The operating system Chrome is running on. PlatformOs os, @@ -451,9 +438,7 @@ class PlatformInfo { /// platforms. PlatformNaclArch nacl_arch, }); -} -extension PlatformInfoExtension on PlatformInfo { /// The operating system Chrome is running on. external PlatformOs os; @@ -464,11 +449,7 @@ extension PlatformInfoExtension on PlatformInfo { /// platforms. external PlatformNaclArch nacl_arch; } - -@JS() -@staticInterop -@anonymous -class ExtensionContext { +extension type ExtensionContext._(JSObject _) implements JSObject { external factory ExtensionContext({ /// The type of context this corresponds to. ContextType contextType, @@ -503,9 +484,7 @@ class ExtensionContext { /// Whether the context is associated with an incognito profile. bool incognito, }); -} -extension ExtensionContextExtension on ExtensionContext { /// The type of context this corresponds to. external ContextType contextType; @@ -539,11 +518,7 @@ extension ExtensionContextExtension on ExtensionContext { /// Whether the context is associated with an incognito profile. external bool incognito; } - -@JS() -@staticInterop -@anonymous -class ContextFilter { +extension type ContextFilter._(JSObject _) implements JSObject { external factory ContextFilter({ JSArray? contextTypes, JSArray? contextIds, @@ -555,9 +530,7 @@ class ContextFilter { JSArray? documentOrigins, bool? incognito, }); -} -extension ContextFilterExtension on ContextFilter { external JSArray? contextTypes; external JSArray? contextIds; @@ -576,11 +549,7 @@ extension ContextFilterExtension on ContextFilter { external bool? incognito; } - -@JS() -@staticInterop -@anonymous -class OnInstalledDetails { +extension type OnInstalledDetails._(JSObject _) implements JSObject { external factory OnInstalledDetails({ /// The reason that this event is being dispatched. OnInstalledReason reason, @@ -593,9 +562,7 @@ class OnInstalledDetails { /// This is present only if 'reason' is 'shared_module_update'. String? id, }); -} -extension OnInstalledDetailsExtension on OnInstalledDetails { /// The reason that this event is being dispatched. external OnInstalledReason reason; @@ -607,26 +574,17 @@ extension OnInstalledDetailsExtension on OnInstalledDetails { /// This is present only if 'reason' is 'shared_module_update'. external String? id; } - -@JS() -@staticInterop -@anonymous -class OnUpdateAvailableDetails { +extension type OnUpdateAvailableDetails._(JSObject _) implements JSObject { external factory OnUpdateAvailableDetails( { /// The version number of the available update. String version}); -} -extension OnUpdateAvailableDetailsExtension on OnUpdateAvailableDetails { /// The version number of the available update. external String version; } - -@JS() -@staticInterop -@anonymous -class RequestUpdateCheckCallbackResult { +extension type RequestUpdateCheckCallbackResult._(JSObject _) + implements JSObject { external factory RequestUpdateCheckCallbackResult({ /// Result of the update check. RequestUpdateCheckStatus status, @@ -635,10 +593,7 @@ class RequestUpdateCheckCallbackResult { /// update. String? version, }); -} -extension RequestUpdateCheckCallbackResultExtension - on RequestUpdateCheckCallbackResult { /// Result of the update check. external RequestUpdateCheckStatus status; @@ -646,11 +601,7 @@ extension RequestUpdateCheckCallbackResultExtension /// update. external String? version; } - -@JS() -@staticInterop -@anonymous -class ConnectInfo { +extension type ConnectInfo._(JSObject _) implements JSObject { external factory ConnectInfo({ /// Will be passed into onConnect for processes that are listening for the /// connection event. @@ -660,9 +611,7 @@ class ConnectInfo { /// processes that are listening for the connection event. bool? includeTlsChannelId, }); -} -extension ConnectInfoExtension on ConnectInfo { /// Will be passed into onConnect for processes that are listening for the /// connection event. external String? name; @@ -671,35 +620,23 @@ extension ConnectInfoExtension on ConnectInfo { /// processes that are listening for the connection event. external bool? includeTlsChannelId; } - -@JS() -@staticInterop -@anonymous -class SendMessageOptions { +extension type SendMessageOptions._(JSObject _) implements JSObject { external factory SendMessageOptions( { /// Whether the TLS channel ID will be passed into onMessageExternal for /// processes that are listening for the connection event. bool? includeTlsChannelId}); -} -extension SendMessageOptionsExtension on SendMessageOptions { /// Whether the TLS channel ID will be passed into onMessageExternal for /// processes that are listening for the connection event. external bool? includeTlsChannelId; } - -@JS() -@staticInterop -@anonymous -class RuntimeLastError { +extension type RuntimeLastError._(JSObject _) implements JSObject { external factory RuntimeLastError( { /// Details about the error which occurred. String? message}); -} -extension RuntimeLastErrorExtension on RuntimeLastError { /// Details about the error which occurred. external String? message; } diff --git a/lib/src/js/scripting.dart b/lib/src/js/scripting.dart index c89f57d..56ddc3b 100644 --- a/lib/src/js/scripting.dart +++ b/lib/src/js/scripting.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,11 +25,7 @@ extension JSChromeJSScriptingExtension on JSChrome { } } -@JS() -@staticInterop -class JSScripting {} - -extension JSScriptingExtension on JSScripting { +extension type JSScripting._(JSObject _) { /// Injects a script into a target context. The script will be run at /// `document_idle`. If the script evaluates to a promise, /// the browser will wait for the promise to settle and return the @@ -102,11 +99,7 @@ typedef StyleOrigin = String; /// The JavaScript world for a script to execute within. typedef ExecutionWorld = String; - -@JS() -@staticInterop -@anonymous -class InjectionTarget { +extension type InjectionTarget._(JSObject _) implements JSObject { external factory InjectionTarget({ /// The ID of the tab into which to inject. int tabId, @@ -126,9 +119,7 @@ class InjectionTarget { /// This must not be true if `frameIds` is specified. bool? allFrames, }); -} -extension InjectionTargetExtension on InjectionTarget { /// The ID of the tab into which to inject. external int tabId; @@ -147,20 +138,16 @@ extension InjectionTargetExtension on InjectionTarget { /// This must not be true if `frameIds` is specified. external bool? allFrames; } - -@JS() -@staticInterop -@anonymous -class ScriptInjection { +extension type ScriptInjection._(JSObject _) implements JSObject { external factory ScriptInjection({ /// A JavaScript function to inject. This function will be serialized, and /// then deserialized for injection. This means that any bound parameters /// and execution context will be lost. - /// Exactly one of `files` and `func` must be + /// Exactly one of `files` or `func` must be /// specified. JSAny? func, - /// The arguments to curry into a provided function. This is only valid if + /// The arguments to pass to the provided function. This is only valid if /// the `func` parameter is specified. These arguments must be /// JSON-serializable. JSArray? args, @@ -174,7 +161,7 @@ class ScriptInjection { /// The path of the JS or CSS files to inject, relative to the extension's /// root directory. - /// Exactly one of `files` and `func` must be + /// Exactly one of `files` or `func` must be /// specified. JSArray? files, @@ -191,17 +178,15 @@ class ScriptInjection { /// script reaches the target. bool? injectImmediately, }); -} -extension ScriptInjectionExtension on ScriptInjection { /// A JavaScript function to inject. This function will be serialized, and /// then deserialized for injection. This means that any bound parameters /// and execution context will be lost. - /// Exactly one of `files` and `func` must be + /// Exactly one of `files` or `func` must be /// specified. external JSAny? func; - /// The arguments to curry into a provided function. This is only valid if + /// The arguments to pass to the provided function. This is only valid if /// the `func` parameter is specified. These arguments must be /// JSON-serializable. external JSArray? args; @@ -215,7 +200,7 @@ extension ScriptInjectionExtension on ScriptInjection { /// The path of the JS or CSS files to inject, relative to the extension's /// root directory. - /// Exactly one of `files` and `func` must be + /// Exactly one of `files` or `func` must be /// specified. external JSArray? files; @@ -232,11 +217,7 @@ extension ScriptInjectionExtension on ScriptInjection { /// script reaches the target. external bool? injectImmediately; } - -@JS() -@staticInterop -@anonymous -class CSSInjection { +extension type CSSInjection._(JSObject _) implements JSObject { external factory CSSInjection({ /// Details specifying the target into which to insert the CSS. InjectionTarget target, @@ -255,9 +236,7 @@ class CSSInjection { /// The style origin for the injection. Defaults to `'AUTHOR'`. StyleOrigin? origin, }); -} -extension CSSInjectionExtension on CSSInjection { /// Details specifying the target into which to insert the CSS. external InjectionTarget target; @@ -275,11 +254,7 @@ extension CSSInjectionExtension on CSSInjection { /// The style origin for the injection. Defaults to `'AUTHOR'`. external StyleOrigin? origin; } - -@JS() -@staticInterop -@anonymous -class InjectionResult { +extension type InjectionResult._(JSObject _) implements JSObject { external factory InjectionResult({ /// The result of the script execution. JSAny? result, @@ -290,9 +265,7 @@ class InjectionResult { /// The document associated with the injection. String documentId, }); -} -extension InjectionResultExtension on InjectionResult { /// The result of the script execution. external JSAny? result; @@ -302,25 +275,21 @@ extension InjectionResultExtension on InjectionResult { /// The document associated with the injection. external String documentId; } - -@JS() -@staticInterop -@anonymous -class RegisteredContentScript { +extension type RegisteredContentScript._(JSObject _) implements JSObject { external factory RegisteredContentScript({ /// The id of the content script, specified in the API call. Must not start /// with a '_' as it's reserved as a prefix for generated script IDs. String id, /// Specifies which pages this content script will be injected into. See - /// [Match Patterns](match_patterns) for more details on the - /// syntax of these strings. Must be specified for + /// [Match Patterns](develop/concepts/match-patterns) for more + /// details on the syntax of these strings. Must be specified for /// [registerContentScripts]. JSArray? matches, /// Excludes pages that this content script would otherwise be injected into. - /// See [Match Patterns](match_patterns) for more details on the - /// syntax of these strings. + /// See [Match Patterns](develop/concepts/match-patterns) for + /// more details on the syntax of these strings. JSArray? excludeMatches, /// The list of CSS files to be injected into matching pages. These are @@ -339,8 +308,13 @@ class RegisteredContentScript { /// frame is matched. bool? allFrames, - /// TODO(devlin): Add documentation once the implementation is complete. See - /// crbug.com/55084. + /// Indicates whether the script can be injected into frames where the URL + /// contains an unsupported scheme; specifically: about:, data:, blob:, or + /// filesystem:. In these cases, the URL's origin is checked to determine if + /// the script should be injected. If the origin is `null` (as is the case + /// for data: URLs) then the used origin is either the frame that created + /// the current frame or the frame that initiated the navigation to this + /// frame. Note that this may not be the parent frame. bool? matchOriginAsFallback, /// Specifies when JavaScript files are injected into the web page. The @@ -355,22 +329,20 @@ class RegisteredContentScript { /// `ISOLATED`. ExecutionWorld? world, }); -} -extension RegisteredContentScriptExtension on RegisteredContentScript { /// The id of the content script, specified in the API call. Must not start /// with a '_' as it's reserved as a prefix for generated script IDs. external String id; /// Specifies which pages this content script will be injected into. See - /// [Match Patterns](match_patterns) for more details on the - /// syntax of these strings. Must be specified for + /// [Match Patterns](develop/concepts/match-patterns) for more + /// details on the syntax of these strings. Must be specified for /// [registerContentScripts]. external JSArray? matches; /// Excludes pages that this content script would otherwise be injected into. - /// See [Match Patterns](match_patterns) for more details on the - /// syntax of these strings. + /// See [Match Patterns](develop/concepts/match-patterns) for + /// more details on the syntax of these strings. external JSArray? excludeMatches; /// The list of CSS files to be injected into matching pages. These are @@ -389,8 +361,13 @@ extension RegisteredContentScriptExtension on RegisteredContentScript { /// frame is matched. external bool? allFrames; - /// TODO(devlin): Add documentation once the implementation is complete. See - /// crbug.com/55084. + /// Indicates whether the script can be injected into frames where the URL + /// contains an unsupported scheme; specifically: about:, data:, blob:, or + /// filesystem:. In these cases, the URL's origin is checked to determine if + /// the script should be injected. If the origin is `null` (as is the case + /// for data: URLs) then the used origin is either the frame that created + /// the current frame or the frame that initiated the navigation to this + /// frame. Note that this may not be the parent frame. external bool? matchOriginAsFallback; /// Specifies when JavaScript files are injected into the web page. The @@ -405,19 +382,13 @@ extension RegisteredContentScriptExtension on RegisteredContentScript { /// `ISOLATED`. external ExecutionWorld? world; } - -@JS() -@staticInterop -@anonymous -class ContentScriptFilter { +extension type ContentScriptFilter._(JSObject _) implements JSObject { external factory ContentScriptFilter( { /// If specified, [getRegisteredContentScripts] will only return scripts /// with an id specified in this list. JSArray? ids}); -} -extension ContentScriptFilterExtension on ContentScriptFilter { /// If specified, [getRegisteredContentScripts] will only return scripts /// with an id specified in this list. external JSArray? ids; diff --git a/lib/src/js/search.dart b/lib/src/js/search.dart index 8a8af7f..4417bb1 100644 --- a/lib/src/js/search.dart +++ b/lib/src/js/search.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -22,11 +23,7 @@ extension JSChromeJSSearchExtension on JSChrome { } } -@JS() -@staticInterop -class JSSearch {} - -extension JSSearchExtension on JSSearch { +extension type JSSearch._(JSObject _) { /// Used to query the default search provider. /// In case of an error, /// [runtime.lastError] will be set. @@ -34,11 +31,7 @@ extension JSSearchExtension on JSSearch { } typedef Disposition = String; - -@JS() -@staticInterop -@anonymous -class QueryInfo { +extension type QueryInfo._(JSObject _) implements JSObject { external factory QueryInfo({ /// String to query with the default search provider. String text, @@ -51,9 +44,7 @@ class QueryInfo { /// `tabId` cannot be used with `disposition`. int? tabId, }); -} -extension QueryInfoExtension on QueryInfo { /// String to query with the default search provider. external String text; diff --git a/lib/src/js/sessions.dart b/lib/src/js/sessions.dart index f6b4f35..1981ac7 100644 --- a/lib/src/js/sessions.dart +++ b/lib/src/js/sessions.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -25,11 +26,7 @@ extension JSChromeJSSessionsExtension on JSChrome { } } -@JS() -@staticInterop -class JSSessions {} - -extension JSSessionsExtension on JSSessions { +extension type JSSessions._(JSObject _) { /// Gets the list of recently closed tabs and/or windows. external JSPromise getRecentlyClosed(Filter? filter); @@ -53,30 +50,20 @@ extension JSSessionsExtension on JSSessions { /// requested list. external int get MAX_SESSION_RESULTS; } - -@JS() -@staticInterop -@anonymous -class Filter { +extension type Filter._(JSObject _) implements JSObject { external factory Filter( { /// The maximum number of entries to be fetched in the requested list. Omit /// this parameter to fetch the maximum number of entries /// ([sessions.MAX_SESSION_RESULTS]). int? maxResults}); -} -extension FilterExtension on Filter { /// The maximum number of entries to be fetched in the requested list. Omit /// this parameter to fetch the maximum number of entries /// ([sessions.MAX_SESSION_RESULTS]). external int? maxResults; } - -@JS() -@staticInterop -@anonymous -class Session { +extension type Session._(JSObject _) implements JSObject { external factory Session({ /// The time when the window or tab was closed or modified, represented in /// milliseconds since the epoch. @@ -90,9 +77,7 @@ class Session { /// [sessions.Session.tab] will be set. Window? window, }); -} -extension SessionExtension on Session { /// The time when the window or tab was closed or modified, represented in /// milliseconds since the epoch. external int lastModified; @@ -105,11 +90,7 @@ extension SessionExtension on Session { /// [sessions.Session.tab] will be set. external Window? window; } - -@JS() -@staticInterop -@anonymous -class Device { +extension type Device._(JSObject _) implements JSObject { external factory Device({ String info, @@ -120,9 +101,7 @@ class Device { /// recently to least recently modified session. JSArray sessions, }); -} -extension DeviceExtension on Device { external String info; /// The name of the foreign device. diff --git a/lib/src/js/side_panel.dart b/lib/src/js/side_panel.dart index 47f3c63..4ecd748 100644 --- a/lib/src/js/side_panel.dart +++ b/lib/src/js/side_panel.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSSidePanelExtension on JSChrome { } } -@JS() -@staticInterop -class JSSidePanel {} - -extension JSSidePanelExtension on JSSidePanel { +extension type JSSidePanel._(JSObject _) { /// Configures the side panel. /// |options|: The configuration options to apply to the panel. /// |callback|: Invoked when the options have been set. @@ -54,37 +51,21 @@ extension JSSidePanelExtension on JSSidePanel { /// |callback|: Called when the side panel has been opened. external JSPromise open(OpenOptions options); } - -@JS() -@staticInterop -@anonymous -class SidePanel { +extension type SidePanel._(JSObject _) implements JSObject { external factory SidePanel( { /// Developer specified path for side panel display. String default_path}); -} -extension SidePanelExtension on SidePanel { /// Developer specified path for side panel display. external String default_path; } - -@JS() -@staticInterop -@anonymous -class ManifestKeys { +extension type ManifestKeys._(JSObject _) implements JSObject { external factory ManifestKeys({SidePanel side_panel}); -} -extension ManifestKeysExtension on ManifestKeys { external SidePanel side_panel; } - -@JS() -@staticInterop -@anonymous -class PanelOptions { +extension type PanelOptions._(JSObject _) implements JSObject { external factory PanelOptions({ /// If specified, the side panel options will only apply to the tab with /// this id. If omitted, these options set the default behavior (used for any @@ -101,9 +82,7 @@ class PanelOptions { /// value is true. bool? enabled, }); -} -extension PanelOptionsExtension on PanelOptions { /// If specified, the side panel options will only apply to the tab with /// this id. If omitted, these options set the default behavior (used for any /// tab that doesn't have specific settings). Note: if the same path is set @@ -119,53 +98,37 @@ extension PanelOptionsExtension on PanelOptions { /// value is true. external bool? enabled; } - -@JS() -@staticInterop -@anonymous -class PanelBehavior { +extension type PanelBehavior._(JSObject _) implements JSObject { external factory PanelBehavior( { /// Whether clicking the extension's icon will toggle showing the extension's /// entry in the side panel. Defaults to false. bool? openPanelOnActionClick}); -} -extension PanelBehaviorExtension on PanelBehavior { /// Whether clicking the extension's icon will toggle showing the extension's /// entry in the side panel. Defaults to false. external bool? openPanelOnActionClick; } - -@JS() -@staticInterop -@anonymous -class GetPanelOptions { +extension type GetPanelOptions._(JSObject _) implements JSObject { external factory GetPanelOptions( { /// If specified, the side panel options for the given tab will be returned. /// Otherwise, returns the default side panel options (used for any tab that /// doesn't have specific settings). int? tabId}); -} -extension GetPanelOptionsExtension on GetPanelOptions { /// If specified, the side panel options for the given tab will be returned. /// Otherwise, returns the default side panel options (used for any tab that /// doesn't have specific settings). external int? tabId; } - -@JS() -@staticInterop -@anonymous -class OpenOptions { +extension type OpenOptions._(JSObject _) implements JSObject { external factory OpenOptions({ /// The window in which to open the side panel. This is only applicable if /// the extension has a global (non-tab-specific) side panel or /// `tabId` is also specified. This will override any /// currently-active global side panel the user has open in the given - /// window. At least one of this and `tabId` must be provided. + /// window. At least one of this or `tabId` must be provided. int? windowId, /// The tab in which to open the side panel. If the corresponding tab has @@ -174,17 +137,15 @@ class OpenOptions { /// the specified tab and any other tabs without a currently-open tab- /// specific panel. This will override any currently-active side panel /// (global or tab-specific) in the corresponding tab. At least one of this - /// and `windowId` must be provided. + /// or `windowId` must be provided. int? tabId, }); -} -extension OpenOptionsExtension on OpenOptions { /// The window in which to open the side panel. This is only applicable if /// the extension has a global (non-tab-specific) side panel or /// `tabId` is also specified. This will override any /// currently-active global side panel the user has open in the given - /// window. At least one of this and `tabId` must be provided. + /// window. At least one of this or `tabId` must be provided. external int? windowId; /// The tab in which to open the side panel. If the corresponding tab has @@ -193,6 +154,6 @@ extension OpenOptionsExtension on OpenOptions { /// the specified tab and any other tabs without a currently-open tab- /// specific panel. This will override any currently-active side panel /// (global or tab-specific) in the corresponding tab. At least one of this - /// and `windowId` must be provided. + /// or `windowId` must be provided. external int? tabId; } diff --git a/lib/src/js/storage.dart b/lib/src/js/storage.dart index d50ef4b..c03687c 100644 --- a/lib/src/js/storage.dart +++ b/lib/src/js/storage.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSStorageExtension on JSChrome { } } -@JS() -@staticInterop -class JSStorage {} - -extension JSStorageExtension on JSStorage { +extension type JSStorage._(JSObject _) { /// Fired when one or more items change. external Event get onChanged; @@ -49,11 +46,7 @@ extension JSStorageExtension on JSStorage { /// The storage area's access level. typedef AccessLevel = String; - -@JS() -@staticInterop -@anonymous -class StorageChange { +extension type StorageChange._(JSObject _) implements JSObject { external factory StorageChange({ /// The old value of the item, if there was an old value. JSAny? oldValue, @@ -61,24 +54,16 @@ class StorageChange { /// The new value of the item, if there is a new value. JSAny? newValue, }); -} -extension StorageChangeExtension on StorageChange { /// The old value of the item, if there was an old value. external JSAny? oldValue; /// The new value of the item, if there is a new value. external JSAny? newValue; } - -@JS() -@staticInterop -@anonymous -class StorageArea { +extension type StorageArea._(JSObject _) implements JSObject { external factory StorageArea(); -} -extension StorageAreaExtension on StorageArea { /// Gets one or more items from storage. external JSPromise get( @@ -123,11 +108,7 @@ extension StorageAreaExtension on StorageArea { /// Fired when one or more items change. external Event get onChanged; } - -@JS() -@staticInterop -@anonymous -class StorageSync extends StorageArea { +extension type StorageSync._(JSObject _) implements JSObject, StorageArea { external factory StorageSync({ /// The maximum total amount (in bytes) of data that can be stored in sync /// storage, as measured by the JSON stringification of every value plus every @@ -163,9 +144,7 @@ class StorageSync extends StorageArea { int MAX_WRITE_OPERATIONS_PER_MINUTE, int MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE, }); -} -extension StorageSyncExtension on StorageSync { /// The maximum total amount (in bytes) of data that can be stored in sync /// storage, as measured by the JSON stringification of every value plus every /// key's length. Updates that would cause this limit to be exceeded fail @@ -201,11 +180,7 @@ extension StorageSyncExtension on StorageSync { external int MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE; } - -@JS() -@staticInterop -@anonymous -class StorageLocal extends StorageArea { +extension type StorageLocal._(JSObject _) implements JSObject, StorageArea { external factory StorageLocal( { /// The maximum amount (in bytes) of data that can be stored in local storage, @@ -214,9 +189,7 @@ class StorageLocal extends StorageArea { /// `unlimitedStorage` permission. Updates that would cause this limit to be /// exceeded fail immediately and set [runtime.lastError]. int QUOTA_BYTES}); -} -extension StorageLocalExtension on StorageLocal { /// The maximum amount (in bytes) of data that can be stored in local storage, /// as measured by the JSON stringification of every value plus every key's /// length. This value will be ignored if the extension has the @@ -224,11 +197,7 @@ extension StorageLocalExtension on StorageLocal { /// exceeded fail immediately and set [runtime.lastError]. external int QUOTA_BYTES; } - -@JS() -@staticInterop -@anonymous -class StorageSession extends StorageArea { +extension type StorageSession._(JSObject _) implements JSObject, StorageArea { external factory StorageSession( { /// The maximum amount (in bytes) of data that can be stored in memory, as @@ -236,27 +205,19 @@ class StorageSession extends StorageArea { /// value and key. Updates that would cause this limit to be exceeded fail /// immediately and set [runtime.lastError]. int QUOTA_BYTES}); -} -extension StorageSessionExtension on StorageSession { /// The maximum amount (in bytes) of data that can be stored in memory, as /// measured by estimating the dynamically allocated memory usage of every /// value and key. Updates that would cause this limit to be exceeded fail /// immediately and set [runtime.lastError]. external int QUOTA_BYTES; } - -@JS() -@staticInterop -@anonymous -class SetAccessLevelAccessOptions { +extension type SetAccessLevelAccessOptions._(JSObject _) implements JSObject { external factory SetAccessLevelAccessOptions( { /// The access level of the storage area. AccessLevel accessLevel}); -} -extension SetAccessLevelAccessOptionsExtension on SetAccessLevelAccessOptions { /// The access level of the storage area. external AccessLevel accessLevel; } diff --git a/lib/src/js/system_cpu.dart b/lib/src/js/system_cpu.dart index 2fd549c..ec2e1a2 100644 --- a/lib/src/js/system_cpu.dart +++ b/lib/src/js/system_cpu.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,19 +25,11 @@ extension JSChromeJSSystemCpuExtension on JSChromeSystem { } } -@JS() -@staticInterop -class JSSystemCpu {} - -extension JSSystemCpuExtension on JSSystemCpu { +extension type JSSystemCpu._(JSObject _) { /// Queries basic CPU information of the system. external JSPromise getInfo(); } - -@JS() -@staticInterop -@anonymous -class CpuTime { +extension type CpuTime._(JSObject _) implements JSObject { external factory CpuTime({ /// The cumulative time used by userspace programs on this processor. double user, @@ -51,9 +44,7 @@ class CpuTime { /// user + kernel + idle. double total, }); -} -extension CpuTimeExtension on CpuTime { /// The cumulative time used by userspace programs on this processor. external double user; @@ -67,26 +58,16 @@ extension CpuTimeExtension on CpuTime { /// user + kernel + idle. external double total; } - -@JS() -@staticInterop -@anonymous -class ProcessorInfo { +extension type ProcessorInfo._(JSObject _) implements JSObject { external factory ProcessorInfo( { /// Cumulative usage info for this logical processor. CpuTime usage}); -} -extension ProcessorInfoExtension on ProcessorInfo { /// Cumulative usage info for this logical processor. external CpuTime usage; } - -@JS() -@staticInterop -@anonymous -class CpuInfo { +extension type CpuInfo._(JSObject _) implements JSObject { external factory CpuInfo({ /// The number of logical processors. int numOfProcessors, @@ -111,9 +92,7 @@ class CpuInfo { /// **Currently supported on Chrome OS only.** JSArray temperatures, }); -} -extension CpuInfoExtension on CpuInfo { /// The number of logical processors. external int numOfProcessors; diff --git a/lib/src/js/system_display.dart b/lib/src/js/system_display.dart index c0d23a5..c116f4c 100644 --- a/lib/src/js/system_display.dart +++ b/lib/src/js/system_display.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,11 +25,7 @@ extension JSChromeJSSystemDisplayExtension on JSChromeSystem { } } -@JS() -@staticInterop -class JSSystemDisplay {} - -extension JSSystemDisplayExtension on JSSystemDisplay { +extension type JSSystemDisplay._(JSObject _) { /// Requests the information for all attached display devices. /// |flags|: Options affecting how the information is returned. /// |callback|: The callback to invoke with the results. @@ -155,14 +152,18 @@ extension JSSystemDisplayExtension on JSSystemDisplay { /// Layout position, i.e. edge of parent that the display is attached to. typedef LayoutPosition = String; +/// An enum to tell if the display is detected and used by the +/// system. The display is considered 'inactive', if it is not +/// detected by the system (maybe disconnected, or considered +/// disconnected due to sleep mode, etc). This state is used to keep +/// existing display when the all displays are disconnected, for +/// example. +typedef ActiveState = String; + /// Mirror mode, i.e. different ways of how a display is mirrored to other /// displays. typedef MirrorMode = String; - -@JS() -@staticInterop -@anonymous -class Bounds { +extension type Bounds._(JSObject _) implements JSObject { external factory Bounds({ /// The x-coordinate of the upper-left corner. int left, @@ -176,9 +177,7 @@ class Bounds { /// The height of the display in pixels. int height, }); -} -extension BoundsExtension on Bounds { /// The x-coordinate of the upper-left corner. external int left; @@ -191,11 +190,7 @@ extension BoundsExtension on Bounds { /// The height of the display in pixels. external int height; } - -@JS() -@staticInterop -@anonymous -class Insets { +extension type Insets._(JSObject _) implements JSObject { external factory Insets({ /// The x-axis distance from the left bound. int left, @@ -209,9 +204,7 @@ class Insets { /// The y-axis distance from the bottom bound. int bottom, }); -} -extension InsetsExtension on Insets { /// The x-axis distance from the left bound. external int left; @@ -224,11 +217,7 @@ extension InsetsExtension on Insets { /// The y-axis distance from the bottom bound. external int bottom; } - -@JS() -@staticInterop -@anonymous -class Point { +extension type Point._(JSObject _) implements JSObject { external factory Point({ /// The x-coordinate of the point. int x, @@ -236,20 +225,14 @@ class Point { /// The y-coordinate of the point. int y, }); -} -extension PointExtension on Point { /// The x-coordinate of the point. external int x; /// The y-coordinate of the point. external int y; } - -@JS() -@staticInterop -@anonymous -class TouchCalibrationPair { +extension type TouchCalibrationPair._(JSObject _) implements JSObject { external factory TouchCalibrationPair({ /// The coordinates of the display point. Point displayPoint, @@ -257,20 +240,14 @@ class TouchCalibrationPair { /// The coordinates of the touch point corresponding to the display point. Point touchPoint, }); -} -extension TouchCalibrationPairExtension on TouchCalibrationPair { /// The coordinates of the display point. external Point displayPoint; /// The coordinates of the touch point corresponding to the display point. external Point touchPoint; } - -@JS() -@staticInterop -@anonymous -class TouchCalibrationPairQuad { +extension type TouchCalibrationPairQuad._(JSObject _) implements JSObject { external factory TouchCalibrationPairQuad({ /// First pair of touch and display point required for touch calibration. TouchCalibrationPair pair1, @@ -284,9 +261,7 @@ class TouchCalibrationPairQuad { /// Fourth pair of touch and display point required for touch calibration. TouchCalibrationPair pair4, }); -} -extension TouchCalibrationPairQuadExtension on TouchCalibrationPairQuad { /// First pair of touch and display point required for touch calibration. external TouchCalibrationPair pair1; @@ -299,11 +274,7 @@ extension TouchCalibrationPairQuadExtension on TouchCalibrationPairQuad { /// Fourth pair of touch and display point required for touch calibration. external TouchCalibrationPair pair4; } - -@JS() -@staticInterop -@anonymous -class DisplayMode { +extension type DisplayMode._(JSObject _) implements JSObject { external factory DisplayMode({ /// The display mode width in device independent (user visible) pixels. int width, @@ -335,9 +306,7 @@ class DisplayMode { /// True if this mode is interlaced, false if not provided. bool? isInterlaced, }); -} -extension DisplayModeExtension on DisplayMode { /// The display mode width in device independent (user visible) pixels. external int width; @@ -368,11 +337,7 @@ extension DisplayModeExtension on DisplayMode { /// True if this mode is interlaced, false if not provided. external bool? isInterlaced; } - -@JS() -@staticInterop -@anonymous -class DisplayLayout { +extension type DisplayLayout._(JSObject _) implements JSObject { external factory DisplayLayout({ /// The unique identifier of the display. String id, @@ -388,9 +353,7 @@ class DisplayLayout { /// the topmost or leftmost corners are aligned. int offset, }); -} -extension DisplayLayoutExtension on DisplayLayout { /// The unique identifier of the display. external String id; @@ -405,11 +368,7 @@ extension DisplayLayoutExtension on DisplayLayout { /// the topmost or leftmost corners are aligned. external int offset; } - -@JS() -@staticInterop -@anonymous -class Edid { +extension type Edid._(JSObject _) implements JSObject { external factory Edid({ /// 3 character manufacturer code. See Sec. 3.4.1 page 21. Required in v1.4. String manufacturerId, @@ -420,9 +379,7 @@ class Edid { /// Year of manufacturer, Sec. 3.4.4 page 22. Required in v1.4. int yearOfManufacture, }); -} -extension EdidExtension on Edid { /// 3 character manufacturer code. See Sec. 3.4.1 page 21. Required in v1.4. external String manufacturerId; @@ -432,11 +389,7 @@ extension EdidExtension on Edid { /// Year of manufacturer, Sec. 3.4.4 page 22. Required in v1.4. external int yearOfManufacture; } - -@JS() -@staticInterop -@anonymous -class DisplayUnitInfo { +extension type DisplayUnitInfo._(JSObject _) implements JSObject { external factory DisplayUnitInfo({ /// The unique identifier of the display. String id, @@ -467,6 +420,9 @@ class DisplayUnitInfo { /// True if this display is enabled. bool isEnabled, + /// Active if the display is detected and used by the system. + ActiveState activeState, + /// True for all displays when in unified desktop mode. See documentation /// for [enableUnifiedDesktop]. bool isUnified, @@ -524,9 +480,7 @@ class DisplayUnitInfo { /// equivalent to 150% zoom. double displayZoomFactor, }); -} -extension DisplayUnitInfoExtension on DisplayUnitInfo { /// The unique identifier of the display. external String id; @@ -556,6 +510,9 @@ extension DisplayUnitInfoExtension on DisplayUnitInfo { /// True if this display is enabled. external bool isEnabled; + /// Active if the display is detected and used by the system. + external ActiveState activeState; + /// True for all displays when in unified desktop mode. See documentation /// for [enableUnifiedDesktop]. external bool isUnified; @@ -613,11 +570,7 @@ extension DisplayUnitInfoExtension on DisplayUnitInfo { /// equivalent to 150% zoom. external double displayZoomFactor; } - -@JS() -@staticInterop -@anonymous -class DisplayProperties { +extension type DisplayProperties._(JSObject _) implements JSObject { external factory DisplayProperties({ /// Chrome OS only. If set to true, changes the display mode to unified /// desktop (see [enableUnifiedDesktop] for details). If set to false, @@ -672,9 +625,7 @@ class DisplayProperties { /// performing a pixel by pixel stretch enlargement. double? displayZoomFactor, }); -} -extension DisplayPropertiesExtension on DisplayProperties { /// Chrome OS only. If set to true, changes the display mode to unified /// desktop (see [enableUnifiedDesktop] for details). If set to false, /// unified desktop mode will be disabled. This is only valid for the @@ -728,30 +679,20 @@ extension DisplayPropertiesExtension on DisplayProperties { /// performing a pixel by pixel stretch enlargement. external double? displayZoomFactor; } - -@JS() -@staticInterop -@anonymous -class GetInfoFlags { +extension type GetInfoFlags._(JSObject _) implements JSObject { external factory GetInfoFlags( { /// If set to true, only a single [DisplayUnitInfo] will be returned /// by [getInfo] when in unified desktop mode (see /// [enableUnifiedDesktop]). Defaults to false. bool? singleUnified}); -} -extension GetInfoFlagsExtension on GetInfoFlags { /// If set to true, only a single [DisplayUnitInfo] will be returned /// by [getInfo] when in unified desktop mode (see /// [enableUnifiedDesktop]). Defaults to false. external bool? singleUnified; } - -@JS() -@staticInterop -@anonymous -class MirrorModeInfo { +extension type MirrorModeInfo._(JSObject _) implements JSObject { external factory MirrorModeInfo({ /// The mirror mode that should be set. MirrorMode mode, @@ -763,9 +704,7 @@ class MirrorModeInfo { /// 'mixed'. JSArray? mirroringDestinationIds, }); -} -extension MirrorModeInfoExtension on MirrorModeInfo { /// The mirror mode that should be set. external MirrorMode mode; diff --git a/lib/src/js/system_memory.dart b/lib/src/js/system_memory.dart index 1eae945..a73d9e8 100644 --- a/lib/src/js/system_memory.dart +++ b/lib/src/js/system_memory.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,19 +25,11 @@ extension JSChromeJSSystemMemoryExtension on JSChromeSystem { } } -@JS() -@staticInterop -class JSSystemMemory {} - -extension JSSystemMemoryExtension on JSSystemMemory { +extension type JSSystemMemory._(JSObject _) { /// Get physical memory information. external JSPromise getInfo(); } - -@JS() -@staticInterop -@anonymous -class MemoryInfo { +extension type MemoryInfo._(JSObject _) implements JSObject { external factory MemoryInfo({ /// The total amount of physical memory capacity, in bytes. double capacity, @@ -44,9 +37,7 @@ class MemoryInfo { /// The amount of available capacity, in bytes. double availableCapacity, }); -} -extension MemoryInfoExtension on MemoryInfo { /// The total amount of physical memory capacity, in bytes. external double capacity; diff --git a/lib/src/js/system_network.dart b/lib/src/js/system_network.dart index d619b22..18a0fad 100644 --- a/lib/src/js/system_network.dart +++ b/lib/src/js/system_network.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,20 +25,12 @@ extension JSChromeJSSystemNetworkExtension on JSChromeSystem { } } -@JS() -@staticInterop -class JSSystemNetwork {} - -extension JSSystemNetworkExtension on JSSystemNetwork { +extension type JSSystemNetwork._(JSObject _) { /// Retrieves information about local adapters on this system. /// |callback| : Called when local adapter information is available. external JSPromise getNetworkInterfaces(); } - -@JS() -@staticInterop -@anonymous -class NetworkInterface { +extension type NetworkInterface._(JSObject _) implements JSObject { external factory NetworkInterface({ /// The underlying name of the adapter. On *nix, this will typically be /// "eth0", "wlan0", etc. @@ -49,9 +42,7 @@ class NetworkInterface { /// The prefix length int prefixLength, }); -} -extension NetworkInterfaceExtension on NetworkInterface { /// The underlying name of the adapter. On *nix, this will typically be /// "eth0", "wlan0", etc. external String name; diff --git a/lib/src/js/system_storage.dart b/lib/src/js/system_storage.dart index 89b8d13..d8c3f39 100644 --- a/lib/src/js/system_storage.dart +++ b/lib/src/js/system_storage.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -27,11 +28,7 @@ extension JSChromeJSSystemStorageExtension on JSChromeSystem { } } -@JS() -@staticInterop -class JSSystemStorage {} - -extension JSSystemStorageExtension on JSSystemStorage { +extension type JSSystemStorage._(JSObject _) { /// Get the storage information from the system. The argument passed to the /// callback is an array of StorageUnitInfo objects. external JSPromise getInfo(); @@ -53,11 +50,7 @@ extension JSSystemStorageExtension on JSSystemStorage { typedef StorageUnitType = String; typedef EjectDeviceResultCode = String; - -@JS() -@staticInterop -@anonymous -class StorageUnitInfo { +extension type StorageUnitInfo._(JSObject _) implements JSObject { external factory StorageUnitInfo({ /// The transient ID that uniquely identifies the storage device. /// This ID will be persistent within the same run of a single application. @@ -74,9 +67,7 @@ class StorageUnitInfo { /// The total amount of the storage space, in bytes. double capacity, }); -} -extension StorageUnitInfoExtension on StorageUnitInfo { /// The transient ID that uniquely identifies the storage device. /// This ID will be persistent within the same run of a single application. /// It will not be a persistent identifier between different runs of an @@ -92,11 +83,7 @@ extension StorageUnitInfoExtension on StorageUnitInfo { /// The total amount of the storage space, in bytes. external double capacity; } - -@JS() -@staticInterop -@anonymous -class StorageAvailableCapacityInfo { +extension type StorageAvailableCapacityInfo._(JSObject _) implements JSObject { external factory StorageAvailableCapacityInfo({ /// A copied |id| of getAvailableCapacity function parameter |id|. String id, @@ -104,10 +91,7 @@ class StorageAvailableCapacityInfo { /// The available capacity of the storage device, in bytes. double availableCapacity, }); -} -extension StorageAvailableCapacityInfoExtension - on StorageAvailableCapacityInfo { /// A copied |id| of getAvailableCapacity function parameter |id|. external String id; diff --git a/lib/src/js/tab_capture.dart b/lib/src/js/tab_capture.dart index 1aa1b1a..1234a3f 100644 --- a/lib/src/js/tab_capture.dart +++ b/lib/src/js/tab_capture.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSTabCaptureExtension on JSChrome { } } -@JS() -@staticInterop -class JSTabCapture {} - -extension JSTabCaptureExtension on JSTabCapture { +extension type JSTabCapture._(JSObject _) { /// Captures the visible area of the currently active tab. Capture can /// only be started on the currently active tab after the extension has been /// _invoked_, similar to the way that @@ -74,11 +71,7 @@ extension JSTabCaptureExtension on JSTabCapture { } typedef TabCaptureState = String; - -@JS() -@staticInterop -@anonymous -class CaptureInfo { +extension type CaptureInfo._(JSObject _) implements JSObject { external factory CaptureInfo({ /// The id of the tab whose status changed. int tabId, @@ -89,9 +82,7 @@ class CaptureInfo { /// Whether an element in the tab being captured is in fullscreen mode. bool fullscreen, }); -} -extension CaptureInfoExtension on CaptureInfo { /// The id of the tab whose status changed. external int tabId; @@ -101,22 +92,12 @@ extension CaptureInfoExtension on CaptureInfo { /// Whether an element in the tab being captured is in fullscreen mode. external bool fullscreen; } - -@JS() -@staticInterop -@anonymous -class MediaStreamConstraint { +extension type MediaStreamConstraint._(JSObject _) implements JSObject { external factory MediaStreamConstraint({JSAny mandatory}); -} -extension MediaStreamConstraintExtension on MediaStreamConstraint { external JSAny mandatory; } - -@JS() -@staticInterop -@anonymous -class CaptureOptions { +extension type CaptureOptions._(JSObject _) implements JSObject { external factory CaptureOptions({ bool? audio, bool? video, @@ -124,9 +105,7 @@ class CaptureOptions { MediaStreamConstraint? videoConstraints, String? presentationId, }); -} -extension CaptureOptionsExtension on CaptureOptions { external bool? audio; external bool? video; @@ -137,11 +116,7 @@ extension CaptureOptionsExtension on CaptureOptions { external String? presentationId; } - -@JS() -@staticInterop -@anonymous -class GetMediaStreamOptions { +extension type GetMediaStreamOptions._(JSObject _) implements JSObject { external factory GetMediaStreamOptions({ /// Optional tab id of the tab which will later invoke /// `getUserMedia()` to consume the stream. If not specified @@ -157,9 +132,7 @@ class GetMediaStreamOptions { /// used as the target tab. int? targetTabId, }); -} -extension GetMediaStreamOptionsExtension on GetMediaStreamOptions { /// Optional tab id of the tab which will later invoke /// `getUserMedia()` to consume the stream. If not specified /// then the resulting stream can be used only by the calling extension. diff --git a/lib/src/js/tab_groups.dart b/lib/src/js/tab_groups.dart index c397c7f..3df276b 100644 --- a/lib/src/js/tab_groups.dart +++ b/lib/src/js/tab_groups.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -25,11 +26,7 @@ extension JSChromeJSTabGroupsExtension on JSChrome { } } -@JS() -@staticInterop -class JSTabGroups {} - -extension JSTabGroupsExtension on JSTabGroups { +extension type JSTabGroups._(JSObject _) { /// Retrieves details about the specified group. external JSPromise get(int groupId); @@ -74,11 +71,7 @@ extension JSTabGroupsExtension on JSTabGroups { /// The group's color. typedef Color = String; - -@JS() -@staticInterop -@anonymous -class TabGroup { +extension type TabGroup._(JSObject _) implements JSObject { external factory TabGroup({ /// The ID of the group. Group IDs are unique within a browser session. int id, @@ -96,9 +89,7 @@ class TabGroup { /// The ID of the window that contains the group. int windowId, }); -} -extension TabGroupExtension on TabGroup { /// The ID of the group. Group IDs are unique within a browser session. external int id; @@ -115,11 +106,7 @@ extension TabGroupExtension on TabGroup { /// The ID of the window that contains the group. external int windowId; } - -@JS() -@staticInterop -@anonymous -class QueryInfo { +extension type QueryInfo._(JSObject _) implements JSObject { external factory QueryInfo({ /// Whether the groups are collapsed. bool? collapsed, @@ -134,9 +121,7 @@ class QueryInfo { /// [current window](windows#current-window). int? windowId, }); -} -extension QueryInfoExtension on QueryInfo { /// Whether the groups are collapsed. external bool? collapsed; @@ -150,11 +135,7 @@ extension QueryInfoExtension on QueryInfo { /// [current window](windows#current-window). external int? windowId; } - -@JS() -@staticInterop -@anonymous -class UpdateProperties { +extension type UpdateProperties._(JSObject _) implements JSObject { external factory UpdateProperties({ /// Whether the group should be collapsed. bool? collapsed, @@ -165,9 +146,7 @@ class UpdateProperties { /// The title of the group. String? title, }); -} -extension UpdatePropertiesExtension on UpdateProperties { /// Whether the group should be collapsed. external bool? collapsed; @@ -177,11 +156,7 @@ extension UpdatePropertiesExtension on UpdateProperties { /// The title of the group. external String? title; } - -@JS() -@staticInterop -@anonymous -class MoveProperties { +extension type MoveProperties._(JSObject _) implements JSObject { external factory MoveProperties({ /// The window to move the group to. Defaults to the window the group is /// currently in. Note that groups can only be moved to and from windows with @@ -192,9 +167,7 @@ class MoveProperties { /// of the window. int index, }); -} -extension MovePropertiesExtension on MoveProperties { /// The window to move the group to. Defaults to the window the group is /// currently in. Note that groups can only be moved to and from windows with /// [windows.WindowType] type `"normal"`. diff --git a/lib/src/js/tabs.dart b/lib/src/js/tabs.dart index 3653989..928a637 100644 --- a/lib/src/js/tabs.dart +++ b/lib/src/js/tabs.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -25,16 +26,12 @@ extension JSChromeJSTabsExtension on JSChrome { } } -@JS() -@staticInterop -class JSTabs {} - -extension JSTabsExtension on JSTabs { +extension type JSTabs._(JSObject _) { /// Retrieves details about the specified tab. external JSPromise get(int tabId); - /// Gets the tab that this script call is being made from. May be undefined if - /// called from a non-tab context (for example, a background page or popup + /// Gets the tab that this script call is being made from. Returns `undefined` + /// if called from a non-tab context (for example, a background page or popup /// view). external JSPromise getCurrent(); @@ -153,13 +150,13 @@ extension JSTabsExtension on JSTabs { /// Captures the visible area of the currently active tab in the specified /// window. In order to call this method, the extension must have either the - /// permission or the - /// [activeTab](activeTab) permission. In addition to sites that extensions - /// can normally access, this method allows extensions to capture sensitive - /// sites that are otherwise restricted, including chrome:-scheme pages, other - /// extensions' pages, and data: URLs. These sensitive sites can only be - /// captured with the activeTab permission. File URLs may be captured only if - /// the extension has been granted file access. + /// permission + /// or the [activeTab](develop/concepts/activeTab) permission. In addition to + /// sites that extensions can normally access, this method allows extensions + /// to capture sensitive sites that are otherwise restricted, including + /// chrome:-scheme pages, other extensions' pages, and data: URLs. These + /// sensitive sites can only be captured with the activeTab permission. File + /// URLs may be captured only if the extension has been granted file access. external JSPromise captureVisibleTab( /// The target window. Defaults to the [current /// window](windows#current-window). @@ -168,7 +165,8 @@ extension JSTabsExtension on JSTabs { ); /// Injects JavaScript code into a page. For details, see the [programmatic - /// injection](content_scripts#pi) section of the content scripts doc. + /// injection](develop/concepts/content-scripts#programmatic) section of the + /// content scripts doc. @Deprecated(r'Replaced by $(ref:scripting.executeScript) in Manifest V3.') external JSPromise executeScript( /// The ID of the tab in which to run the script; defaults to the active tab @@ -182,7 +180,8 @@ extension JSTabsExtension on JSTabs { /// Injects CSS into a page. Styles inserted with this method can be removed /// with [scripting.removeCSS]. For details, see the [programmatic - /// injection](content_scripts#pi) section of the content scripts doc. + /// injection](develop/concepts/content-scripts#programmatic) section of the + /// content scripts doc. @Deprecated(r'Replaced by $(ref:scripting.insertCSS) in Manifest V3.') external JSPromise insertCSS( /// The ID of the tab in which to insert the CSS; defaults to the active tab @@ -347,11 +346,7 @@ typedef ZoomSettingsScope = String; /// The type of window. typedef WindowType = String; - -@JS() -@staticInterop -@anonymous -class MutedInfo { +extension type MutedInfo._(JSObject _) implements JSObject { external factory MutedInfo({ /// Whether the tab is muted (prevented from playing sound). The tab may be /// muted even if it has not played or is not currently playing sound. @@ -366,9 +361,7 @@ class MutedInfo { /// extension was not the reason the muted state last changed. String? extensionId, }); -} -extension MutedInfoExtension on MutedInfo { /// Whether the tab is muted (prevented from playing sound). The tab may be /// muted even if it has not played or is not currently playing sound. /// Equivalent to whether the 'muted' audio indicator is showing. @@ -382,11 +375,7 @@ extension MutedInfoExtension on MutedInfo { /// extension was not the reason the muted state last changed. external String? extensionId; } - -@JS() -@staticInterop -@anonymous -class Tab { +extension type Tab._(JSObject _) implements JSObject { external factory Tab({ /// The ID of the tab. Tab IDs are unique within a browser session. Under some /// circumstances a tab may not be assigned an ID; for example, when querying @@ -411,6 +400,10 @@ class Tab { /// Whether the tab is selected. bool selected, + /// The last time the tab was accessed as the number of milliseconds since + /// epoch. + double? lastAccessed, + /// Whether the tab is highlighted. bool highlighted, @@ -474,9 +467,7 @@ class Tab { /// [sessions] API. String? sessionId, }); -} -extension TabExtension on Tab { /// The ID of the tab. Tab IDs are unique within a browser session. Under some /// circumstances a tab may not be assigned an ID; for example, when querying /// foreign tabs using the [sessions] API, in which case a session ID may be @@ -500,6 +491,10 @@ extension TabExtension on Tab { /// Whether the tab is selected. external bool selected; + /// The last time the tab was accessed as the number of milliseconds since + /// epoch. + external double? lastAccessed; + /// Whether the tab is highlighted. external bool highlighted; @@ -563,11 +558,7 @@ extension TabExtension on Tab { /// [sessions] API. external String? sessionId; } - -@JS() -@staticInterop -@anonymous -class ZoomSettings { +extension type ZoomSettings._(JSObject _) implements JSObject { external factory ZoomSettings({ /// Defines how zoom changes are handled, i.e., which entity is responsible /// for the actual scaling of the page; defaults to `automatic`. @@ -582,9 +573,7 @@ class ZoomSettings { /// tabs.getZoomSettings. double? defaultZoomFactor, }); -} -extension ZoomSettingsExtension on ZoomSettings { /// Defines how zoom changes are handled, i.e., which entity is responsible /// for the actual scaling of the page; defaults to `automatic`. external ZoomSettingsMode? mode; @@ -598,11 +587,7 @@ extension ZoomSettingsExtension on ZoomSettings { /// tabs.getZoomSettings. external double? defaultZoomFactor; } - -@JS() -@staticInterop -@anonymous -class OnUpdatedChangeInfo { +extension type OnUpdatedChangeInfo._(JSObject _) implements JSObject { external factory OnUpdatedChangeInfo({ /// The tab's loading status. TabStatus? status, @@ -634,9 +619,7 @@ class OnUpdatedChangeInfo { /// The tab's new title. String? title, }); -} -extension OnUpdatedChangeInfoExtension on OnUpdatedChangeInfo { /// The tab's loading status. external TabStatus? status; @@ -667,61 +650,38 @@ extension OnUpdatedChangeInfoExtension on OnUpdatedChangeInfo { /// The tab's new title. external String? title; } - -@JS() -@staticInterop -@anonymous -class OnMovedMoveInfo { +extension type OnMovedMoveInfo._(JSObject _) implements JSObject { external factory OnMovedMoveInfo({ int windowId, int fromIndex, int toIndex, }); -} -extension OnMovedMoveInfoExtension on OnMovedMoveInfo { external int windowId; external int fromIndex; external int toIndex; } - -@JS() -@staticInterop -@anonymous -class OnSelectionChangedSelectInfo { +extension type OnSelectionChangedSelectInfo._(JSObject _) implements JSObject { external factory OnSelectionChangedSelectInfo( { /// The ID of the window the selected tab changed inside of. int windowId}); -} -extension OnSelectionChangedSelectInfoExtension - on OnSelectionChangedSelectInfo { /// The ID of the window the selected tab changed inside of. external int windowId; } - -@JS() -@staticInterop -@anonymous -class OnActiveChangedSelectInfo { +extension type OnActiveChangedSelectInfo._(JSObject _) implements JSObject { external factory OnActiveChangedSelectInfo( { /// The ID of the window the selected tab changed inside of. int windowId}); -} -extension OnActiveChangedSelectInfoExtension on OnActiveChangedSelectInfo { /// The ID of the window the selected tab changed inside of. external int windowId; } - -@JS() -@staticInterop -@anonymous -class OnActivatedActiveInfo { +extension type OnActivatedActiveInfo._(JSObject _) implements JSObject { external factory OnActivatedActiveInfo({ /// The ID of the tab that has become active. int tabId, @@ -729,20 +689,14 @@ class OnActivatedActiveInfo { /// The ID of the window the active tab changed inside of. int windowId, }); -} -extension OnActivatedActiveInfoExtension on OnActivatedActiveInfo { /// The ID of the tab that has become active. external int tabId; /// The ID of the window the active tab changed inside of. external int windowId; } - -@JS() -@staticInterop -@anonymous -class OnHighlightChangedSelectInfo { +extension type OnHighlightChangedSelectInfo._(JSObject _) implements JSObject { external factory OnHighlightChangedSelectInfo({ /// The window whose tabs changed. int windowId, @@ -750,21 +704,14 @@ class OnHighlightChangedSelectInfo { /// All highlighted tabs in the window. JSArray tabIds, }); -} -extension OnHighlightChangedSelectInfoExtension - on OnHighlightChangedSelectInfo { /// The window whose tabs changed. external int windowId; /// All highlighted tabs in the window. external JSArray tabIds; } - -@JS() -@staticInterop -@anonymous -class OnHighlightedHighlightInfo { +extension type OnHighlightedHighlightInfo._(JSObject _) implements JSObject { external factory OnHighlightedHighlightInfo({ /// The window whose tabs changed. int windowId, @@ -772,52 +719,34 @@ class OnHighlightedHighlightInfo { /// All highlighted tabs in the window. JSArray tabIds, }); -} -extension OnHighlightedHighlightInfoExtension on OnHighlightedHighlightInfo { /// The window whose tabs changed. external int windowId; /// All highlighted tabs in the window. external JSArray tabIds; } - -@JS() -@staticInterop -@anonymous -class OnDetachedDetachInfo { +extension type OnDetachedDetachInfo._(JSObject _) implements JSObject { external factory OnDetachedDetachInfo({ int oldWindowId, int oldPosition, }); -} -extension OnDetachedDetachInfoExtension on OnDetachedDetachInfo { external int oldWindowId; external int oldPosition; } - -@JS() -@staticInterop -@anonymous -class OnAttachedAttachInfo { +extension type OnAttachedAttachInfo._(JSObject _) implements JSObject { external factory OnAttachedAttachInfo({ int newWindowId, int newPosition, }); -} -extension OnAttachedAttachInfoExtension on OnAttachedAttachInfo { external int newWindowId; external int newPosition; } - -@JS() -@staticInterop -@anonymous -class OnRemovedRemoveInfo { +extension type OnRemovedRemoveInfo._(JSObject _) implements JSObject { external factory OnRemovedRemoveInfo({ /// The window whose tab is closed. int windowId, @@ -825,29 +754,21 @@ class OnRemovedRemoveInfo { /// True when the tab was closed because its parent window was closed. bool isWindowClosing, }); -} -extension OnRemovedRemoveInfoExtension on OnRemovedRemoveInfo { /// The window whose tab is closed. external int windowId; /// True when the tab was closed because its parent window was closed. external bool isWindowClosing; } - -@JS() -@staticInterop -@anonymous -class OnZoomChangeZoomChangeInfo { +extension type OnZoomChangeZoomChangeInfo._(JSObject _) implements JSObject { external factory OnZoomChangeZoomChangeInfo({ int tabId, double oldZoomFactor, double newZoomFactor, ZoomSettings zoomSettings, }); -} -extension OnZoomChangeZoomChangeInfoExtension on OnZoomChangeZoomChangeInfo { external int tabId; external double oldZoomFactor; @@ -856,11 +777,7 @@ extension OnZoomChangeZoomChangeInfoExtension on OnZoomChangeZoomChangeInfo { external ZoomSettings zoomSettings; } - -@JS() -@staticInterop -@anonymous -class ConnectInfo { +extension type ConnectInfo._(JSObject _) implements JSObject { external factory ConnectInfo({ /// Is passed into onConnect for content scripts that are listening for the /// connection event. @@ -874,9 +791,7 @@ class ConnectInfo { /// identified by `documentId` instead of all frames in the tab. String? documentId, }); -} -extension ConnectInfoExtension on ConnectInfo { /// Is passed into onConnect for content scripts that are listening for the /// connection event. external String? name; @@ -889,11 +804,7 @@ extension ConnectInfoExtension on ConnectInfo { /// identified by `documentId` instead of all frames in the tab. external String? documentId; } - -@JS() -@staticInterop -@anonymous -class SendMessageOptions { +extension type SendMessageOptions._(JSObject _) implements JSObject { external factory SendMessageOptions({ /// Send a message to a specific [frame](webNavigation#frame_ids) identified /// by `frameId` instead of all frames in the tab. @@ -903,9 +814,7 @@ class SendMessageOptions { /// identified by `documentId` instead of all frames in the tab. String? documentId, }); -} -extension SendMessageOptionsExtension on SendMessageOptions { /// Send a message to a specific [frame](webNavigation#frame_ids) identified /// by `frameId` instead of all frames in the tab. external int? frameId; @@ -914,11 +823,7 @@ extension SendMessageOptionsExtension on SendMessageOptions { /// identified by `documentId` instead of all frames in the tab. external String? documentId; } - -@JS() -@staticInterop -@anonymous -class CreateProperties { +extension type CreateProperties._(JSObject _) implements JSObject { external factory CreateProperties({ /// The window in which to create the new tab. Defaults to the [current /// window](windows#current-window). @@ -950,9 +855,7 @@ class CreateProperties { /// be in the same window as the newly created tab. int? openerTabId, }); -} -extension CreatePropertiesExtension on CreateProperties { /// The window in which to create the new tab. Defaults to the [current /// window](windows#current-window). external int? windowId; @@ -983,11 +886,7 @@ extension CreatePropertiesExtension on CreateProperties { /// be in the same window as the newly created tab. external int? openerTabId; } - -@JS() -@staticInterop -@anonymous -class QueryInfo { +extension type QueryInfo._(JSObject _) implements JSObject { external factory QueryInfo({ /// Whether the tabs are active in their windows. bool? active, @@ -1045,9 +944,7 @@ class QueryInfo { /// The position of the tabs within their windows. int? index, }); -} -extension QueryInfoExtension on QueryInfo { /// Whether the tabs are active in their windows. external bool? active; @@ -1104,11 +1001,7 @@ extension QueryInfoExtension on QueryInfo { /// The position of the tabs within their windows. external int? index; } - -@JS() -@staticInterop -@anonymous -class HighlightInfo { +extension type HighlightInfo._(JSObject _) implements JSObject { external factory HighlightInfo({ /// The window that contains the tabs. int? windowId, @@ -1116,20 +1009,14 @@ class HighlightInfo { /// One or more tab indices to highlight. JSAny tabs, }); -} -extension HighlightInfoExtension on HighlightInfo { /// The window that contains the tabs. external int? windowId; /// One or more tab indices to highlight. external JSAny tabs; } - -@JS() -@staticInterop -@anonymous -class UpdateProperties { +extension type UpdateProperties._(JSObject _) implements JSObject { external factory UpdateProperties({ /// A URL to navigate the tab to. JavaScript URLs are not supported; use /// [scripting.executeScript] instead. @@ -1159,9 +1046,7 @@ class UpdateProperties { /// resources are low. bool? autoDiscardable, }); -} -extension UpdatePropertiesExtension on UpdateProperties { /// A URL to navigate the tab to. JavaScript URLs are not supported; use /// [scripting.executeScript] instead. external String? url; @@ -1190,11 +1075,7 @@ extension UpdatePropertiesExtension on UpdateProperties { /// resources are low. external bool? autoDiscardable; } - -@JS() -@staticInterop -@anonymous -class MoveProperties { +extension type MoveProperties._(JSObject _) implements JSObject { external factory MoveProperties({ /// Defaults to the window the tab is currently in. int? windowId, @@ -1203,9 +1084,7 @@ class MoveProperties { /// of the window. int index, }); -} -extension MovePropertiesExtension on MoveProperties { /// Defaults to the window the tab is currently in. external int? windowId; @@ -1213,26 +1092,16 @@ extension MovePropertiesExtension on MoveProperties { /// of the window. external int index; } - -@JS() -@staticInterop -@anonymous -class ReloadProperties { +extension type ReloadProperties._(JSObject _) implements JSObject { external factory ReloadProperties( { /// Whether to bypass local caching. Defaults to `false`. bool? bypassCache}); -} -extension ReloadPropertiesExtension on ReloadProperties { /// Whether to bypass local caching. Defaults to `false`. external bool? bypassCache; } - -@JS() -@staticInterop -@anonymous -class GroupOptions { +extension type GroupOptions._(JSObject _) implements JSObject { external factory GroupOptions({ /// The tab ID or list of tab IDs to add to the specified group. JSAny tabIds, @@ -1245,9 +1114,7 @@ class GroupOptions { /// specified. GroupOptionsCreateProperties? createProperties, }); -} -extension GroupOptionsExtension on GroupOptions { /// The tab ID or list of tab IDs to add to the specified group. external JSAny tabIds; @@ -1259,19 +1126,12 @@ extension GroupOptionsExtension on GroupOptions { /// specified. external GroupOptionsCreateProperties? createProperties; } - -@JS() -@staticInterop -@anonymous -class GroupOptionsCreateProperties { +extension type GroupOptionsCreateProperties._(JSObject _) implements JSObject { external factory GroupOptionsCreateProperties( { /// The window of the new group. Defaults to the current window. int? windowId}); -} -extension GroupOptionsCreatePropertiesExtension - on GroupOptionsCreateProperties { /// The window of the new group. Defaults to the current window. external int? windowId; } diff --git a/lib/src/js/top_sites.dart b/lib/src/js/top_sites.dart index fe70042..40ae338 100644 --- a/lib/src/js/top_sites.dart +++ b/lib/src/js/top_sites.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,19 +25,11 @@ extension JSChromeJSTopSitesExtension on JSChrome { } } -@JS() -@staticInterop -class JSTopSites {} - -extension JSTopSitesExtension on JSTopSites { +extension type JSTopSites._(JSObject _) { /// Gets a list of top sites. external JSPromise get(); } - -@JS() -@staticInterop -@anonymous -class MostVisitedURL { +extension type MostVisitedURL._(JSObject _) implements JSObject { external factory MostVisitedURL({ /// The most visited URL. String url, @@ -44,9 +37,7 @@ class MostVisitedURL { /// The title of the page String title, }); -} -extension MostVisitedURLExtension on MostVisitedURL { /// The most visited URL. external String url; diff --git a/lib/src/js/tts.dart b/lib/src/js/tts.dart index d36cd45..cc674d3 100644 --- a/lib/src/js/tts.dart +++ b/lib/src/js/tts.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -25,11 +26,7 @@ extension JSChromeJSTtsExtension on JSChrome { } } -@JS() -@staticInterop -class JSTts {} - -extension JSTtsExtension on JSTts { +extension type JSTts._(JSObject _) { /// Speaks text using a text-to-speech engine. external JSPromise speak( /// The text to speak, either plain text or a complete, well-formed SSML @@ -69,11 +66,7 @@ extension JSTtsExtension on JSTts { typedef EventType = String; typedef VoiceGender = String; - -@JS() -@staticInterop -@anonymous -class TtsOptions { +extension type TtsOptions._(JSObject _) implements JSObject { external factory TtsOptions({ /// If true, enqueues this utterance if TTS is already in progress. If false /// (the default), interrupts any current speech and flushes the speech queue @@ -121,9 +114,7 @@ class TtsOptions { /// the utterance. JSFunction? onEvent, }); -} -extension TtsOptionsExtension on TtsOptions { /// If true, enqueues this utterance if TTS is already in progress. If false /// (the default), interrupts any current speech and flushes the speech queue /// before speaking this new utterance. @@ -170,11 +161,7 @@ extension TtsOptionsExtension on TtsOptions { /// the utterance. external JSFunction? onEvent; } - -@JS() -@staticInterop -@anonymous -class TtsEvent { +extension type TtsEvent._(JSObject _) implements JSObject { external factory TtsEvent({ /// The type can be `start` as soon as speech has started, `word` when a word /// boundary is reached, `sentence` when a sentence boundary is reached, @@ -209,9 +196,7 @@ class TtsEvent { /// be set to -1 if not set by the speech engine. int? length, }); -} -extension TtsEventExtension on TtsEvent { /// The type can be `start` as soon as speech has started, `word` when a word /// boundary is reached, `sentence` when a sentence boundary is reached, /// `marker` when an SSML mark element is reached, `end` when the end of the @@ -245,11 +230,7 @@ extension TtsEventExtension on TtsEvent { /// be set to -1 if not set by the speech engine. external int? length; } - -@JS() -@staticInterop -@anonymous -class TtsVoice { +extension type TtsVoice._(JSObject _) implements JSObject { external factory TtsVoice({ /// The name of the voice. String? voiceName, @@ -271,9 +252,7 @@ class TtsVoice { /// All of the callback event types that this voice is capable of sending. JSArray? eventTypes, }); -} -extension TtsVoiceExtension on TtsVoice { /// The name of the voice. external String? voiceName; diff --git a/lib/src/js/tts_engine.dart b/lib/src/js/tts_engine.dart index adb30fd..5e1db15 100644 --- a/lib/src/js/tts_engine.dart +++ b/lib/src/js/tts_engine.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -29,11 +30,7 @@ extension JSChromeJSTtsEngineExtension on JSChrome { } } -@JS() -@staticInterop -class JSTtsEngine {} - -extension JSTtsEngineExtension on JSTtsEngine { +extension type JSTtsEngine._(JSObject _) { /// Called by an engine to update its list of voices. This list overrides any /// voices declared in this extension's manifest. external void updateVoices( @@ -87,11 +84,7 @@ extension JSTtsEngineExtension on JSTtsEngine { } typedef VoiceGender = String; - -@JS() -@staticInterop -@anonymous -class SpeakOptions { +extension type SpeakOptions._(JSObject _) implements JSObject { external factory SpeakOptions({ /// The name of the voice to use for synthesis. String? voiceName, @@ -119,9 +112,7 @@ class SpeakOptions { /// highest, with a default of 1.0. double? volume, }); -} -extension SpeakOptionsExtension on SpeakOptions { /// The name of the voice to use for synthesis. external String? voiceName; @@ -148,11 +139,7 @@ extension SpeakOptionsExtension on SpeakOptions { /// highest, with a default of 1.0. external double? volume; } - -@JS() -@staticInterop -@anonymous -class AudioStreamOptions { +extension type AudioStreamOptions._(JSObject _) implements JSObject { external factory AudioStreamOptions({ /// The sample rate expected in an audio buffer. int sampleRate, @@ -160,20 +147,14 @@ class AudioStreamOptions { /// The number of samples within an audio buffer. int bufferSize, }); -} -extension AudioStreamOptionsExtension on AudioStreamOptions { /// The sample rate expected in an audio buffer. external int sampleRate; /// The number of samples within an audio buffer. external int bufferSize; } - -@JS() -@staticInterop -@anonymous -class AudioBuffer { +extension type AudioBuffer._(JSObject _) implements JSObject { external factory AudioBuffer({ /// The audio buffer from the text-to-speech engine. It should have length /// exactly audioStreamOptions.bufferSize and encoded as mono, at @@ -187,9 +168,7 @@ class AudioBuffer { /// True if this audio buffer is the last for the text being spoken. bool? isLastBuffer, }); -} -extension AudioBufferExtension on AudioBuffer { /// The audio buffer from the text-to-speech engine. It should have length /// exactly audioStreamOptions.bufferSize and encoded as mono, at /// audioStreamOptions.sampleRate, and as linear pcm, 32-bit signed float i.e. diff --git a/lib/src/js/types.dart b/lib/src/js/types.dart index 8898973..4bc6aed 100644 --- a/lib/src/js/types.dart +++ b/lib/src/js/types.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -22,11 +23,7 @@ extension JSChromeJSTypesExtension on JSChrome { } } -@JS() -@staticInterop -class JSTypes {} - -extension JSTypesExtension on JSTypes {} +extension type JSTypes._(JSObject _) {} /// The scope of the ChromeSetting. One of
  • [regular]: setting for the /// regular profile (which is inherited by the incognito profile if not @@ -46,15 +43,9 @@ typedef ChromeSettingScope = String; /// controlled by this extension
  • [controlled_by_this_extension]: /// controlled by this extension
typedef LevelOfControl = String; - -@JS() -@staticInterop -@anonymous -class ChromeSetting { +extension type ChromeSetting._(JSObject _) implements JSObject { external factory ChromeSetting(); -} -extension ChromeSettingExtension on ChromeSetting { /// Gets the value of a setting. external JSPromise get( @@ -76,11 +67,7 @@ extension ChromeSettingExtension on ChromeSetting { /// Fired after the setting changes. external Event get onChange; } - -@JS() -@staticInterop -@anonymous -class GetCallbackDetails { +extension type GetCallbackDetails._(JSObject _) implements JSObject { external factory GetCallbackDetails({ /// The value of the setting. JSAny value, @@ -93,9 +80,7 @@ class GetCallbackDetails { /// [details] parameter of `get()` was true. bool? incognitoSpecific, }); -} -extension GetCallbackDetailsExtension on GetCallbackDetails { /// The value of the setting. external JSAny value; @@ -107,28 +92,18 @@ extension GetCallbackDetailsExtension on GetCallbackDetails { /// [details] parameter of `get()` was true. external bool? incognitoSpecific; } - -@JS() -@staticInterop -@anonymous -class GetDetails { +extension type GetDetails._(JSObject _) implements JSObject { external factory GetDetails( { /// Whether to return the value that applies to the incognito session (default /// false). bool? incognito}); -} -extension GetDetailsExtension on GetDetails { /// Whether to return the value that applies to the incognito session (default /// false). external bool? incognito; } - -@JS() -@staticInterop -@anonymous -class SetDetails { +extension type SetDetails._(JSObject _) implements JSObject { external factory SetDetails({ /// The value of the setting.
Note that every setting has a specific /// value type, which is described together with the setting. An extension @@ -138,9 +113,7 @@ class SetDetails { /// Where to set the setting (default: regular). ChromeSettingScope? scope, }); -} -extension SetDetailsExtension on SetDetails { /// The value of the setting.
Note that every setting has a specific /// value type, which is described together with the setting. An extension /// should _not_ set a value of a different type. @@ -149,26 +122,16 @@ extension SetDetailsExtension on SetDetails { /// Where to set the setting (default: regular). external ChromeSettingScope? scope; } - -@JS() -@staticInterop -@anonymous -class ClearDetails { +extension type ClearDetails._(JSObject _) implements JSObject { external factory ClearDetails( { /// Where to clear the setting (default: regular). ChromeSettingScope? scope}); -} -extension ClearDetailsExtension on ClearDetails { /// Where to clear the setting (default: regular). external ChromeSettingScope? scope; } - -@JS() -@staticInterop -@anonymous -class OnChangeDetails { +extension type OnChangeDetails._(JSObject _) implements JSObject { external factory OnChangeDetails({ /// The value of the setting after the change. JSAny value, @@ -181,9 +144,7 @@ class OnChangeDetails { /// the extension in incognito mode. bool? incognitoSpecific, }); -} -extension OnChangeDetailsExtension on OnChangeDetails { /// The value of the setting after the change. external JSAny value; diff --git a/lib/src/js/usb.dart b/lib/src/js/usb.dart index ccaf271..52d5d7c 100644 --- a/lib/src/js/usb.dart +++ b/lib/src/js/usb.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -30,11 +31,7 @@ extension JSChromeJSUsbExtension on JSChrome { } } -@JS() -@staticInterop -class JSUsb {} - -extension JSUsbExtension on JSUsb { +extension type JSUsb._(JSObject _) { /// Enumerates connected USB devices. /// |options|: The properties to search for on target devices. external JSPromise getDevices(EnumerateDevicesOptions options); @@ -213,11 +210,7 @@ typedef TransferType = String; typedef SynchronizationType = String; typedef UsageType = String; - -@JS() -@staticInterop -@anonymous -class Device { +extension type Device._(JSObject _) implements JSObject { external factory Device({ /// An opaque ID for the USB device. It remains unchanged until the device is /// unplugged. @@ -241,9 +234,7 @@ class Device { /// The iSerialNumber string read from the device, if available. String serialNumber, }); -} -extension DeviceExtension on Device { /// An opaque ID for the USB device. It remains unchanged until the device is /// unplugged. external int device; @@ -266,11 +257,7 @@ extension DeviceExtension on Device { /// The iSerialNumber string read from the device, if available. external String serialNumber; } - -@JS() -@staticInterop -@anonymous -class ConnectionHandle { +extension type ConnectionHandle._(JSObject _) implements JSObject { external factory ConnectionHandle({ /// An opaque handle representing this connection to the USB device and all /// associated claimed interfaces and pending transfers. A new handle is @@ -284,9 +271,7 @@ class ConnectionHandle { /// The product ID. int productId, }); -} -extension ConnectionHandleExtension on ConnectionHandle { /// An opaque handle representing this connection to the USB device and all /// associated claimed interfaces and pending transfers. A new handle is /// created each time the device is opened. The connection handle is @@ -299,11 +284,7 @@ extension ConnectionHandleExtension on ConnectionHandle { /// The product ID. external int productId; } - -@JS() -@staticInterop -@anonymous -class EndpointDescriptor { +extension type EndpointDescriptor._(JSObject _) implements JSObject { external factory EndpointDescriptor({ /// Endpoint address. int address, @@ -329,9 +310,7 @@ class EndpointDescriptor { /// Extra descriptor data associated with this endpoint. JSArrayBuffer extra_data, }); -} -extension EndpointDescriptorExtension on EndpointDescriptor { /// Endpoint address. external int address; @@ -356,11 +335,7 @@ extension EndpointDescriptorExtension on EndpointDescriptor { /// Extra descriptor data associated with this endpoint. external JSArrayBuffer extra_data; } - -@JS() -@staticInterop -@anonymous -class InterfaceDescriptor { +extension type InterfaceDescriptor._(JSObject _) implements JSObject { external factory InterfaceDescriptor({ /// The interface number. int interfaceNumber, @@ -386,9 +361,7 @@ class InterfaceDescriptor { /// Extra descriptor data associated with this interface. JSArrayBuffer extra_data, }); -} -extension InterfaceDescriptorExtension on InterfaceDescriptor { /// The interface number. external int interfaceNumber; @@ -413,11 +386,7 @@ extension InterfaceDescriptorExtension on InterfaceDescriptor { /// Extra descriptor data associated with this interface. external JSArrayBuffer extra_data; } - -@JS() -@staticInterop -@anonymous -class ConfigDescriptor { +extension type ConfigDescriptor._(JSObject _) implements JSObject { external factory ConfigDescriptor({ /// Is this the active configuration? bool active, @@ -443,9 +412,7 @@ class ConfigDescriptor { /// Extra descriptor data associated with this configuration. JSArrayBuffer extra_data, }); -} -extension ConfigDescriptorExtension on ConfigDescriptor { /// Is this the active configuration? external bool active; @@ -470,11 +437,7 @@ extension ConfigDescriptorExtension on ConfigDescriptor { /// Extra descriptor data associated with this configuration. external JSArrayBuffer extra_data; } - -@JS() -@staticInterop -@anonymous -class ControlTransferInfo { +extension type ControlTransferInfo._(JSObject _) implements JSObject { external factory ControlTransferInfo({ /// The transfer direction (`"in"` or `"out"`). Direction direction, @@ -507,9 +470,7 @@ class ControlTransferInfo { /// indicates no timeout. int? timeout, }); -} -extension ControlTransferInfoExtension on ControlTransferInfo { /// The transfer direction (`"in"` or `"out"`). external Direction direction; @@ -541,11 +502,7 @@ extension ControlTransferInfoExtension on ControlTransferInfo { /// indicates no timeout. external int? timeout; } - -@JS() -@staticInterop -@anonymous -class GenericTransferInfo { +extension type GenericTransferInfo._(JSObject _) implements JSObject { external factory GenericTransferInfo({ /// The transfer direction (`"in"` or `"out"`). Direction direction, @@ -565,9 +522,7 @@ class GenericTransferInfo { /// indicates no timeout. int? timeout, }); -} -extension GenericTransferInfoExtension on GenericTransferInfo { /// The transfer direction (`"in"` or `"out"`). external Direction direction; @@ -586,11 +541,7 @@ extension GenericTransferInfoExtension on GenericTransferInfo { /// indicates no timeout. external int? timeout; } - -@JS() -@staticInterop -@anonymous -class IsochronousTransferInfo { +extension type IsochronousTransferInfo._(JSObject _) implements JSObject { external factory IsochronousTransferInfo({ /// Transfer parameters. The transfer length or data buffer specified in this /// parameter block is split along `packetLength` boundaries to @@ -603,9 +554,7 @@ class IsochronousTransferInfo { /// The length of each of the packets in this transfer. int packetLength, }); -} -extension IsochronousTransferInfoExtension on IsochronousTransferInfo { /// Transfer parameters. The transfer length or data buffer specified in this /// parameter block is split along `packetLength` boundaries to /// form the individual packets of the transfer. @@ -617,11 +566,7 @@ extension IsochronousTransferInfoExtension on IsochronousTransferInfo { /// The length of each of the packets in this transfer. external int packetLength; } - -@JS() -@staticInterop -@anonymous -class TransferResultInfo { +extension type TransferResultInfo._(JSObject _) implements JSObject { external factory TransferResultInfo({ /// A value of `0` indicates that the transfer was a success. /// Other values indicate failure. @@ -631,9 +576,7 @@ class TransferResultInfo { /// transfers. JSArrayBuffer? data, }); -} -extension TransferResultInfoExtension on TransferResultInfo { /// A value of `0` indicates that the transfer was a success. /// Other values indicate failure. external int? resultCode; @@ -642,11 +585,7 @@ extension TransferResultInfoExtension on TransferResultInfo { /// transfers. external JSArrayBuffer? data; } - -@JS() -@staticInterop -@anonymous -class DeviceFilter { +extension type DeviceFilter._(JSObject _) implements JSObject { external factory DeviceFilter({ /// Device vendor ID. int? vendorId, @@ -663,9 +602,7 @@ class DeviceFilter { /// USB interface protocol, checked only if the interface sub-class matches. int? interfaceProtocol, }); -} -extension DeviceFilterExtension on DeviceFilter { /// Device vendor ID. external int? vendorId; @@ -681,11 +618,7 @@ extension DeviceFilterExtension on DeviceFilter { /// USB interface protocol, checked only if the interface sub-class matches. external int? interfaceProtocol; } - -@JS() -@staticInterop -@anonymous -class EnumerateDevicesOptions { +extension type EnumerateDevicesOptions._(JSObject _) implements JSObject { external factory EnumerateDevicesOptions({ int? vendorId, int? productId, @@ -694,9 +627,7 @@ class EnumerateDevicesOptions { /// will return all devices the app has permission for. JSArray? filters, }); -} -extension EnumerateDevicesOptionsExtension on EnumerateDevicesOptions { external int? vendorId; external int? productId; @@ -705,11 +636,8 @@ extension EnumerateDevicesOptionsExtension on EnumerateDevicesOptions { /// will return all devices the app has permission for. external JSArray? filters; } - -@JS() -@staticInterop -@anonymous -class EnumerateDevicesAndRequestAccessOptions { +extension type EnumerateDevicesAndRequestAccessOptions._(JSObject _) + implements JSObject { external factory EnumerateDevicesAndRequestAccessOptions({ /// The device vendor ID. int vendorId, @@ -721,10 +649,7 @@ class EnumerateDevicesAndRequestAccessOptions { /// Only available on Chrome OS. It has no effect on other platforms. int? interfaceId, }); -} -extension EnumerateDevicesAndRequestAccessOptionsExtension - on EnumerateDevicesAndRequestAccessOptions { /// The device vendor ID. external int vendorId; @@ -735,11 +660,7 @@ extension EnumerateDevicesAndRequestAccessOptionsExtension /// Only available on Chrome OS. It has no effect on other platforms. external int? interfaceId; } - -@JS() -@staticInterop -@anonymous -class DevicePromptOptions { +extension type DevicePromptOptions._(JSObject _) implements JSObject { external factory DevicePromptOptions({ /// Allow the user to select multiple devices. bool? multiple, @@ -748,9 +669,7 @@ class DevicePromptOptions { /// provided devices matching any filter will be displayed. JSArray? filters, }); -} -extension DevicePromptOptionsExtension on DevicePromptOptions { /// Allow the user to select multiple devices. external bool? multiple; diff --git a/lib/src/js/vpn_provider.dart b/lib/src/js/vpn_provider.dart index 35e79ea..b59cd87 100644 --- a/lib/src/js/vpn_provider.dart +++ b/lib/src/js/vpn_provider.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -23,11 +24,7 @@ extension JSChromeJSVpnProviderExtension on JSChrome { } } -@JS() -@staticInterop -class JSVpnProvider {} - -extension JSVpnProviderExtension on JSVpnProvider { +extension type JSVpnProvider._(JSObject _) { /// Creates a new VPN configuration that persists across multiple login /// sessions of the user. /// |name|: The name of the VPN configuration. @@ -107,11 +104,7 @@ typedef VpnConnectionState = String; /// The enum is used by the platform to indicate the event that triggered /// `onUIEvent`. typedef UIEvent = String; - -@JS() -@staticInterop -@anonymous -class Parameters { +extension type Parameters._(JSObject _) implements JSObject { external factory Parameters({ /// IP address for the VPN interface in CIDR notation. /// IPv4 is currently the only supported mode. @@ -167,9 +160,7 @@ class Parameters { /// feature based on browser support. String? reconnect, }); -} -extension ParametersExtension on Parameters { /// IP address for the VPN interface in CIDR notation. /// IPv4 is currently the only supported mode. external String address; diff --git a/lib/src/js/wallpaper.dart b/lib/src/js/wallpaper.dart index ae3a95e..ec3201a 100644 --- a/lib/src/js/wallpaper.dart +++ b/lib/src/js/wallpaper.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -22,11 +23,7 @@ extension JSChromeJSWallpaperExtension on JSChrome { } } -@JS() -@staticInterop -class JSWallpaper {} - -extension JSWallpaperExtension on JSWallpaper { +extension type JSWallpaper._(JSObject _) { /// Sets wallpaper to the image at _url_ or _wallpaperData_ with the specified /// _layout_ external JSPromise setWallpaper(SetWallpaperDetails details); @@ -34,11 +31,7 @@ extension JSWallpaperExtension on JSWallpaper { /// The supported wallpaper layouts. typedef WallpaperLayout = String; - -@JS() -@staticInterop -@anonymous -class SetWallpaperDetails { +extension type SetWallpaperDetails._(JSObject _) implements JSObject { external factory SetWallpaperDetails({ /// The jpeg or png encoded wallpaper image as an ArrayBuffer. JSArrayBuffer? data, @@ -56,9 +49,7 @@ class SetWallpaperDetails { /// supported yet. bool? thumbnail, }); -} -extension SetWallpaperDetailsExtension on SetWallpaperDetails { /// The jpeg or png encoded wallpaper image as an ArrayBuffer. external JSArrayBuffer? data; diff --git a/lib/src/js/web_authentication_proxy.dart b/lib/src/js/web_authentication_proxy.dart index da2d3aa..de8f396 100644 --- a/lib/src/js/web_authentication_proxy.dart +++ b/lib/src/js/web_authentication_proxy.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,11 +25,7 @@ extension JSChromeJSWebAuthenticationProxyExtension on JSChrome { } } -@JS() -@staticInterop -class JSWebAuthenticationProxy {} - -extension JSWebAuthenticationProxyExtension on JSWebAuthenticationProxy { +extension type JSWebAuthenticationProxy._(JSObject _) { /// Reports the result of a `navigator.credentials.create()` /// call. The extension must call this for every /// `onCreateRequest` event it has received, unless the request @@ -127,26 +124,16 @@ extension JSWebAuthenticationProxyExtension on JSWebAuthenticationProxy { /// canceled. external Event get onRequestCanceled; } - -@JS() -@staticInterop -@anonymous -class IsUvpaaRequest { +extension type IsUvpaaRequest._(JSObject _) implements JSObject { external factory IsUvpaaRequest( { /// An opaque identifier for the request. int requestId}); -} -extension IsUvpaaRequestExtension on IsUvpaaRequest { /// An opaque identifier for the request. external int requestId; } - -@JS() -@staticInterop -@anonymous -class CreateRequest { +extension type CreateRequest._(JSObject _) implements JSObject { external factory CreateRequest({ /// An opaque identifier for the request. int requestId, @@ -158,9 +145,7 @@ class CreateRequest { /// `PublicKeyCredential.parseCreationOptionsFromJSON()`. String requestDetailsJson, }); -} -extension CreateRequestExtension on CreateRequest { /// An opaque identifier for the request. external int requestId; @@ -171,11 +156,7 @@ extension CreateRequestExtension on CreateRequest { /// `PublicKeyCredential.parseCreationOptionsFromJSON()`. external String requestDetailsJson; } - -@JS() -@staticInterop -@anonymous -class GetRequest { +extension type GetRequest._(JSObject _) implements JSObject { external factory GetRequest({ /// An opaque identifier for the request. int requestId, @@ -187,9 +168,7 @@ class GetRequest { /// `PublicKeyCredential.parseRequestOptionsFromJSON()`. String requestDetailsJson, }); -} -extension GetRequestExtension on GetRequest { /// An opaque identifier for the request. external int requestId; @@ -200,27 +179,17 @@ extension GetRequestExtension on GetRequest { /// `PublicKeyCredential.parseRequestOptionsFromJSON()`. external String requestDetailsJson; } - -@JS() -@staticInterop -@anonymous -class DOMExceptionDetails { +extension type DOMExceptionDetails._(JSObject _) implements JSObject { external factory DOMExceptionDetails({ String name, String message, }); -} -extension DOMExceptionDetailsExtension on DOMExceptionDetails { external String name; external String message; } - -@JS() -@staticInterop -@anonymous -class CreateResponseDetails { +extension type CreateResponseDetails._(JSObject _) implements JSObject { external factory CreateResponseDetails({ /// The `requestId` of the `CreateRequest`. int requestId, @@ -234,9 +203,7 @@ class CreateResponseDetails { /// `PublicKeyCredential.toJSON()`. String? responseJson, }); -} -extension CreateResponseDetailsExtension on CreateResponseDetails { /// The `requestId` of the `CreateRequest`. external int requestId; @@ -249,11 +216,7 @@ extension CreateResponseDetailsExtension on CreateResponseDetails { /// `PublicKeyCredential.toJSON()`. external String? responseJson; } - -@JS() -@staticInterop -@anonymous -class GetResponseDetails { +extension type GetResponseDetails._(JSObject _) implements JSObject { external factory GetResponseDetails({ /// The `requestId` of the `CreateRequest`. int requestId, @@ -267,9 +230,7 @@ class GetResponseDetails { /// `PublicKeyCredential.toJSON()`. String? responseJson, }); -} -extension GetResponseDetailsExtension on GetResponseDetails { /// The `requestId` of the `CreateRequest`. external int requestId; @@ -282,18 +243,12 @@ extension GetResponseDetailsExtension on GetResponseDetails { /// `PublicKeyCredential.toJSON()`. external String? responseJson; } - -@JS() -@staticInterop -@anonymous -class IsUvpaaResponseDetails { +extension type IsUvpaaResponseDetails._(JSObject _) implements JSObject { external factory IsUvpaaResponseDetails({ int requestId, bool isUvpaa, }); -} -extension IsUvpaaResponseDetailsExtension on IsUvpaaResponseDetails { external int requestId; external bool isUvpaa; diff --git a/lib/src/js/web_navigation.dart b/lib/src/js/web_navigation.dart index ab172a3..5eed0c8 100644 --- a/lib/src/js/web_navigation.dart +++ b/lib/src/js/web_navigation.dart @@ -1,6 +1,7 @@ // ignore_for_file: non_constant_identifier_names // ignore_for_file: unnecessary_import +@JS() library; import 'dart:js_interop'; @@ -24,11 +25,7 @@ extension JSChromeJSWebNavigationExtension on JSChrome { } } -@JS() -@staticInterop -class JSWebNavigation {} - -extension JSWebNavigationExtension on JSWebNavigation { +extension type JSWebNavigation._(JSObject _) { /// Retrieves information about the given frame. A frame refers to an