Skip to content

Commit

Permalink
Merge branch 'GoogleChrome:main' into offscreen-user-media-sample
Browse files Browse the repository at this point in the history
  • Loading branch information
aakash232 authored May 27, 2024
2 parents 82ebe1d + 3822f88 commit 9b0ec54
Show file tree
Hide file tree
Showing 154 changed files with 19,821 additions and 3,185 deletions.
7 changes: 0 additions & 7 deletions .eslintignore

This file was deleted.

28 changes: 0 additions & 28 deletions .eslintrc.js

This file was deleted.

10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install modules
run: npm ci
- name: Run ESLint
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sample-list-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand All @@ -26,7 +26,7 @@ jobs:
run: npm run start

- name: Upload to artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: extension-samples.json
path: ./.repo/sample-list-generator/extension-samples.json
Expand Down
43 changes: 41 additions & 2 deletions .repo/sample-list-generator/extension-apis.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@
"autoVerify",
"automaticDownloads",
"camera",
"clipboard",
"cookies",
"fullscreen",
"images",
Expand All @@ -399,6 +400,7 @@
"ResourceIdentifier",
"AutoVerifyContentSetting",
"CameraContentSetting",
"ClipboardContentSetting",
"CookiesContentSetting",
"FullscreenContentSetting",
"ImagesContentSetting",
Expand Down Expand Up @@ -427,6 +429,7 @@
"types": [
"Cookie",
"CookieDetails",
"CookiePartitionKey",
"CookieStore",
"OnChangedCause",
"SameSiteStatus"
Expand Down Expand Up @@ -464,14 +467,18 @@
"GETMATCHEDRULES_QUOTA_INTERVAL",
"GUARANTEED_MINIMUM_STATIC_RULES",
"MAX_GETMATCHEDRULES_CALLS_PER_INTERVAL",
"MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES",
"MAX_NUMBER_OF_DYNAMIC_RULES",
"MAX_NUMBER_OF_ENABLED_STATIC_RULESETS",
"MAX_NUMBER_OF_REGEX_RULES",
"MAX_NUMBER_OF_SESSION_RULES",
"MAX_NUMBER_OF_STATIC_RULESETS",
"MAX_NUMBER_OF_UNSAFE_DYNAMIC_RULES",
"MAX_NUMBER_OF_UNSAFE_SESSION_RULES",
"SESSION_RULESET_ID"
],
"methods": [
"getAvailableStaticRuleCount",
"getDisabledRuleIds",
"getDynamicRules",
"getEnabledRulesets",
"getMatchedRules",
Expand All @@ -481,7 +488,8 @@
"testMatchOutcome",
"updateDynamicRules",
"updateEnabledRulesets",
"updateSessionRules"
"updateSessionRules",
"updateStaticRules"
],
"types": [
"ExtensionActionOptions",
Expand Down Expand Up @@ -791,6 +799,7 @@
"AddWatcherRequestedOptions",
"Change",
"CloseFileRequestedOptions",
"CloudIdentifier",
"ConfigureRequestedOptions",
"CopyEntryRequestedOptions",
"CreateDirectoryRequestedOptions",
Expand Down Expand Up @@ -1341,6 +1350,18 @@
],
"events": ["onProxyError"]
},
"readingList": {
"properties": [],
"methods": ["addEntry", "query", "removeEntry", "updateEntry"],
"types": [
"AddEntryOptions",
"QueryInfo",
"ReadingListEntry",
"RemoveOptions",
"UpdateEntryOptions"
],
"events": ["onEntryAdded", "onEntryRemoved", "onEntryUpdated"]
},
"runtime": {
"properties": ["id", "lastError"],
"methods": [
Expand Down Expand Up @@ -1855,6 +1876,24 @@
],
"events": ["onDeviceAdded", "onDeviceRemoved"]
},
"userScripts": {
"properties": [],
"methods": [
"configureWorld",
"getScripts",
"register",
"unregister",
"update"
],
"types": [
"RegisteredUserScript",
"ScriptSource",
"UserScriptFilter",
"WorldProperties",
"ExecutionWorld"
],
"events": []
},
"virtualKeyboard": {
"properties": [],
"methods": ["restrictFeatures"],
Expand Down
10 changes: 9 additions & 1 deletion .repo/sample-list-generator/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ export interface ApiItemWithType extends ApiItem {
}

export interface ManifestData {
[key: string]: string;
name: string;
description: string;
permissions: string[];
}

export interface LocaleData {
[key: string]: {
message: string;
description: string;
};
}

export type SampleItem = {
type: FolderTypes;
name: string;
Expand All @@ -37,4 +45,4 @@ export type ApiTypeResult =
| 'type'
| 'unknown';

export type ExtensionApiMap = Record<string, Record<string, string[]>>
export type ExtensionApiMap = Record<string, Record<string, string[]>>
35 changes: 34 additions & 1 deletion .repo/sample-list-generator/src/utils/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
import fs from 'fs/promises';
import { ManifestData } from '../types';
import { dirname } from 'path';
import { ManifestData, LocaleData } from '../types';
const localeRegex = /__MSG_([^_]*)__/

function usesLocaleFiles(obj: object): boolean {
// recursively check if any value in a supplied object
// is a string that starts with __MSG_. If found, it
// means that the extension uses locale files.
return Object.values(obj).some((value) => {
if (Object.prototype.toString.call(value) === '[object Object]') {
return usesLocaleFiles(value);
}
return typeof value === 'string' && value.startsWith('__MSG_')
});
}

export const getManifest = async (
manifestPath: string
): Promise<ManifestData> => {
const manifest = await fs.readFile(manifestPath, 'utf8');
const parsedManifest = JSON.parse(manifest);

if (usesLocaleFiles(parsedManifest)) {
const directory = dirname(manifestPath);
const localeFile: string = await fs.readFile(`${directory}/_locales/en/messages.json`, 'utf8')
const localeData: LocaleData = JSON.parse(localeFile);

for (const [key, value] of Object.entries(parsedManifest)) {
if (typeof value === 'string' && value.startsWith('__MSG_')) {
const localeKey: string | undefined = value.match(localeRegex)?.[1];

if (localeKey) {
const localeKeyData = localeData[localeKey]
const localeMessage: string = localeKeyData?.message;

parsedManifest[key] = localeMessage;
}
}
}
}

return parsedManifest;
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ messaging API that allows to communicate with a native application.
In order for this example to work you must first install the native messaging
host from the host directory.

To install the host:
## To install the host:


**On Windows:**

On Windows:
Run install_host.bat script in the host directory.
This script installs the native messaging host for the current user, by
creating a registry key
Expand All @@ -17,7 +19,8 @@ On Windows:
HKLM.
Note that you need to have python installed.

On Mac and Linux:
**On Mac and Linux:**

Run install_host.sh script in the host directory:
host/install_host.sh
By default the host is installed only for the user who runs the script, but if
Expand Down
12 changes: 7 additions & 5 deletions _archive/mv2/api/nativeMessaging/host/install_host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
set -e

DIR="$( cd "$( dirname "$0" )" && pwd )"
if [ "$(uname -s)" = "Darwin" ]; then
if [ "$(whoami)" = "root" ]; then
if [ $(uname -s) == 'Darwin' ]; then
if [ "$(whoami)" == "root" ]; then
TARGET_DIR="/Library/Google/Chrome/NativeMessagingHosts"
chmod a+x "$DIR/native-messaging-example-host"
else
TARGET_DIR="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts"
fi
else
if [ "$(whoami)" = "root" ]; then
if [ "$(whoami)" == "root" ]; then
TARGET_DIR="/etc/opt/chrome/native-messaging-hosts"
chmod a+x "$DIR/native-messaging-example-host"
else
TARGET_DIR="$HOME/.config/google-chrome/NativeMessagingHosts"
fi
Expand All @@ -29,11 +31,11 @@ mkdir -p "$TARGET_DIR"
cp "$DIR/$HOST_NAME.json" "$TARGET_DIR"

# Update host path in the manifest.
HOST_PATH=$DIR/native-messaging-example-host
HOST_PATH="$DIR/native-messaging-example-host"
ESCAPED_HOST_PATH=${HOST_PATH////\\/}
sed -i -e "s/HOST_PATH/$ESCAPED_HOST_PATH/" "$TARGET_DIR/$HOST_NAME.json"

# Set permissions for the manifest so that all users can read it.
chmod o+r "$TARGET_DIR/$HOST_NAME.json"

echo "Native messaging host $HOST_NAME has been installed."
echo Native messaging host $HOST_NAME has been installed.
Loading

0 comments on commit 9b0ec54

Please sign in to comment.