Merge pull request #11726 from electron/faster-compare-blacklist

Make use of sorted list to speed up searching
This commit is contained in:
shelley vohr 2018-01-30 09:46:38 -05:00 committed by GitHub
commit f24eab74d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,10 +2,11 @@
// Use of this source code is governed by the MIT license that can be // Use of this source code is governed by the MIT license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <string>
#include "atom/app/command_line_args.h" #include "atom/app/command_line_args.h"
#include <algorithm>
#include <string>
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
@ -37,18 +38,36 @@ bool IsUrlArg(const base::CommandLine::CharType* arg) {
return false; return false;
} }
const char* blacklist[] = { // The blacklist of command line switches, must be sorted.
// node // Created with:
"inspect", // find ./ -name "*switches.cc" \
"inspect-brk", // | xargs grep -P --no-filename "\"\S+\";" \
// | perl -pe 's|^.*?"(\S+)";| "$1",|' \
// chromium switches: // | sort | uniq
// find ./ -name "*switches.cc" \ // then manually insert following switches into the list:
// | xargs grep -P --no-filename "\"\S+\";" \ // "inspect",
// | perl -pe 's|^.*?"(\S+)";| "$1",|' \ // "inspect-brk",
// | sort | uniq // finally write a small piece of code to print out the sorted list since
"?", // the "sort" tool may use differnt rules from C++ STL.
// std::vector<std::string> sorted(std::begin(kBlacklist),
// std::end(kBlacklist));
// std::sort(sorted.begin(), sorted.end());
// FILE* f = fopen("testlist2", "w+");
// for (auto& i : sorted)
// fprintf(f, "\"%s\",\n", i.c_str());
// fclose(f);
const char* kBlacklist[] = {
"/prefetch:1",
"/prefetch:2",
"/prefetch:3",
"/prefetch:4",
"/prefetch:5",
"/prefetch:6",
"/prefetch:8",
"0", "0",
"?",
"ChromeOSMemoryPressureHandling",
"SafeSites",
"accept-resource-provider", "accept-resource-provider",
"account-consistency", "account-consistency",
"adaboost", "adaboost",
@ -58,6 +77,7 @@ const char* blacklist[] = {
"aggressive-cache-discard", "aggressive-cache-discard",
"aggressive-tab-discard", "aggressive-tab-discard",
"all", "all",
"all-toolchains",
"allarticles", "allarticles",
"allow-cross-origin-auth-prompt", "allow-cross-origin-auth-prompt",
"allow-external-pages", "allow-external-pages",
@ -78,7 +98,6 @@ const char* blacklist[] = {
"allow-running-insecure-content", "allow-running-insecure-content",
"allow-sandbox-debugging", "allow-sandbox-debugging",
"allow-silent-push", "allow-silent-push",
"all-toolchains",
"alsa-check-close-timeout", "alsa-check-close-timeout",
"alsa-enable-upsampling", "alsa-enable-upsampling",
"alsa-fixed-output-sample-rate", "alsa-fixed-output-sample-rate",
@ -96,8 +115,8 @@ const char* blacklist[] = {
"alternative", "alternative",
"always-authorize-plugins", "always-authorize-plugins",
"always-on", "always-on",
"alwaystrue",
"always-use-complex-text", "always-use-complex-text",
"alwaystrue",
"amd-switchable", "amd-switchable",
"android-fonts-path", "android-fonts-path",
"android-stderr-port", "android-stderr-port",
@ -107,18 +126,18 @@ const char* blacklist[] = {
"app", "app",
"app-auto-launched", "app-auto-launched",
"app-id", "app-id",
"apple",
"app-mode-auth-code", "app-mode-auth-code",
"app-mode-oauth-token", "app-mode-oauth-token",
"app-mode-oem-manifest", "app-mode-oem-manifest",
"apps-gallery-download-url",
"apps-gallery-update-url",
"apps-gallery-url",
"app-shell-allow-roaming", "app-shell-allow-roaming",
"app-shell-host-window-size", "app-shell-host-window-size",
"app-shell-preferred-network", "app-shell-preferred-network",
"app-shell-refresh-token", "app-shell-refresh-token",
"app-shell-user", "app-shell-user",
"apple",
"apps-gallery-download-url",
"apps-gallery-update-url",
"apps-gallery-url",
"apps-keep-chrome-alive-in-tests", "apps-keep-chrome-alive-in-tests",
"arc-availability", "arc-availability",
"arc-available", "arc-available",
@ -155,8 +174,8 @@ const char* blacklist[] = {
"auth-spnego-account-type", "auth-spnego-account-type",
"auto", "auto",
"auto-open-devtools-for-tabs", "auto-open-devtools-for-tabs",
"autoplay-policy",
"auto-select-desktop-capture-source", "auto-select-desktop-capture-source",
"autoplay-policy",
"blink-settings", "blink-settings",
"bootstrap", "bootstrap",
"browser", "browser",
@ -178,7 +197,6 @@ const char* blacklist[] = {
"child-wallpaper-large", "child-wallpaper-large",
"child-wallpaper-small", "child-wallpaper-small",
"chrome-home-swipe-logic", "chrome-home-swipe-logic",
"ChromeOSMemoryPressureHandling",
"cipher-suite-blacklist", "cipher-suite-blacklist",
"clamshell", "clamshell",
"class", "class",
@ -202,21 +220,21 @@ const char* blacklist[] = {
"crash-dumps-dir", "crash-dumps-dir",
"crash-on-failure", "crash-on-failure",
"crash-on-hang-threads", "crash-on-hang-threads",
"crashpad-handler",
"crash-server-url", "crash-server-url",
"crash-test", "crash-test",
"crashpad-handler",
"create-browser-on-startup-for-tests", "create-browser-on-startup-for-tests",
"cros-gaia-api-v1", "cros-gaia-api-v1",
"crosh-command",
"cros-region", "cros-region",
"cros-regions-mode", "cros-regions-mode",
"crosh-command",
"cryptauth-http-host", "cryptauth-http-host",
"custom-devtools-frontend", "custom-devtools-frontend",
"custom-launcher-page", "custom-launcher-page",
"custom_summary", "custom_summary",
"d3d-support",
"d3d11", "d3d11",
"d3d9", "d3d9",
"d3d-support",
"daemon", "daemon",
"dark_muted", "dark_muted",
"dark_vibrant", "dark_vibrant",
@ -262,17 +280,17 @@ const char* blacklist[] = {
"disable-accelerated-jpeg-decoding", "disable-accelerated-jpeg-decoding",
"disable-accelerated-mjpeg-decode", "disable-accelerated-mjpeg-decode",
"disable-accelerated-video-decode", "disable-accelerated-video-decode",
"disable-appcontainer",
"disable-app-info-dialog-mac", "disable-app-info-dialog-mac",
"disable-app-list-dismiss-on-blur", "disable-app-list-dismiss-on-blur",
"disable-app-window-cycling", "disable-app-window-cycling",
"disable-appcontainer",
"disable-arc-data-wipe", "disable-arc-data-wipe",
"disable-arc-opt-in-verification", "disable-arc-opt-in-verification",
"disable-audio-support-for-desktop-share", "disable-audio-support-for-desktop-share",
"disable-avfoundation-overlays", "disable-avfoundation-overlays",
"disable-backgrounding-occluded-windows",
"disable-background-networking", "disable-background-networking",
"disable-background-timer-throttling", "disable-background-timer-throttling",
"disable-backgrounding-occluded-windows",
"disable-backing-store-limit", "disable-backing-store-limit",
"disable-blink-features", "disable-blink-features",
"disable-boot-animation", "disable-boot-animation",
@ -291,7 +309,6 @@ const char* blacklist[] = {
"disable-component-update", "disable-component-update",
"disable-composited-antialiasing", "disable-composited-antialiasing",
"disable-contextual-search", "disable-contextual-search",
"disabled",
"disable-d3d11", "disable-d3d11",
"disable-databases", "disable-databases",
"disable-datasaver-prompt", "disable-datasaver-prompt",
@ -305,7 +322,6 @@ const char* blacklist[] = {
"disable-directwrite-for-ui", "disable-directwrite-for-ui",
"disable-display-list-2d-canvas", "disable-display-list-2d-canvas",
"disable-distance-field-text", "disable-distance-field-text",
"disabled-new-style-notification",
"disable-domain-blocking-for-3d-apis", "disable-domain-blocking-for-3d-apis",
"disable-domain-reliability", "disable-domain-reliability",
"disable-drive-search-in-app-launcher", "disable-drive-search-in-app-launcher",
@ -352,8 +368,8 @@ const char* blacklist[] = {
"disable-histogram-customizer", "disable-histogram-customizer",
"disable-hosted-app-shim-creation", "disable-hosted-app-shim-creation",
"disable-hosted-apps-in-windows", "disable-hosted-apps-in-windows",
"disable-infobars",
"disable-in-process-stack-traces", "disable-in-process-stack-traces",
"disable-infobars",
"disable-input-ime-api", "disable-input-ime-api",
"disable-input-view", "disable-input-view",
"disable-ios-password-suggestions", "disable-ios-password-suggestions",
@ -370,9 +386,9 @@ const char* blacklist[] = {
"disable-low-end-device-mode", "disable-low-end-device-mode",
"disable-low-latency-dxva", "disable-low-latency-dxva",
"disable-low-res-tiling", "disable-low-res-tiling",
"disable-machine-cert-request",
"disable-mac-overlays", "disable-mac-overlays",
"disable-mac-views-native-app-windows", "disable-mac-views-native-app-windows",
"disable-machine-cert-request",
"disable-main-frame-before-activation", "disable-main-frame-before-activation",
"disable-md-error-screen", "disable-md-error-screen",
"disable-md-oobe", "disable-md-oobe",
@ -405,9 +421,9 @@ const char* blacklist[] = {
"disable-password-generation", "disable-password-generation",
"disable-pepper-3d", "disable-pepper-3d",
"disable-pepper-3d-image-chromium", "disable-pepper-3d-image-chromium",
"disable-per-user-timezone",
"disable-permission-action-reporting", "disable-permission-action-reporting",
"disable-permissions-api", "disable-permissions-api",
"disable-per-user-timezone",
"disable-physical-keyboard-autocorrect", "disable-physical-keyboard-autocorrect",
"disable-pinch", "disable-pinch",
"disable-pnacl-crash-throttling", "disable-pnacl-crash-throttling",
@ -439,8 +455,8 @@ const char* blacklist[] = {
"disable-signin-scoped-device-id", "disable-signin-scoped-device-id",
"disable-single-click-autofill", "disable-single-click-autofill",
"disable-skia-runtime-opts", "disable-skia-runtime-opts",
"disable-slimming-paint-invalidation",
"disable-slim-navigation-manager", "disable-slim-navigation-manager",
"disable-slimming-paint-invalidation",
"disable-smooth-scrolling", "disable-smooth-scrolling",
"disable-software-rasterizer", "disable-software-rasterizer",
"disable-speech-api", "disable-speech-api",
@ -466,18 +482,20 @@ const char* blacklist[] = {
"disable-voice-input", "disable-voice-input",
"disable-volume-adjust-sound", "disable-volume-adjust-sound",
"disable-wake-on-wifi", "disable-wake-on-wifi",
"disable-web-notification-custom-layouts",
"disable-web-security",
"disable-webgl", "disable-webgl",
"disable-webgl-image-chromium", "disable-webgl-image-chromium",
"disable-web-notification-custom-layouts",
"disable-webrtc-encryption", "disable-webrtc-encryption",
"disable-webrtc-hw-decoding", "disable-webrtc-hw-decoding",
"disable-webrtc-hw-encoding", "disable-webrtc-hw-encoding",
"disable-web-security",
"disable-win32k-lockdown", "disable-win32k-lockdown",
"disable-xss-auditor", "disable-xss-auditor",
"disable-zero-browsers-open-for-tests", "disable-zero-browsers-open-for-tests",
"disable-zero-copy", "disable-zero-copy",
"disable-zero-copy-dxgi-video", "disable-zero-copy-dxgi-video",
"disabled",
"disabled-new-style-notification",
"disallow-non-exact-resource-reuse", "disallow-non-exact-resource-reuse",
"disk-cache-dir", "disk-cache-dir",
"disk-cache-size", "disk-cache-size",
@ -508,10 +526,10 @@ const char* blacklist[] = {
"enable-adaptive-selection-handle-orientation", "enable-adaptive-selection-handle-orientation",
"enable-aggressive-domstorage-flushing", "enable-aggressive-domstorage-flushing",
"enable-android-wallpapers-app", "enable-android-wallpapers-app",
"enable-appcontainer",
"enable-app-info-dialog-mac", "enable-app-info-dialog-mac",
"enable-app-list", "enable-app-list",
"enable-app-window-cycling", "enable-app-window-cycling",
"enable-appcontainer",
"enable-arc", "enable-arc",
"enable-arc-oobe-optin", "enable-arc-oobe-optin",
"enable-async-event-targeting", "enable-async-event-targeting",
@ -536,9 +554,6 @@ const char* blacklist[] = {
"enable-crash-reporter", "enable-crash-reporter",
"enable-crash-reporter-for-testing", "enable-crash-reporter-for-testing",
"enable-crx-hash-check", "enable-crx-hash-check",
"enabled",
"enabled-2g",
"enabled-3g",
"enable-data-reduction-proxy-bypass-warning", "enable-data-reduction-proxy-bypass-warning",
"enable-data-reduction-proxy-force-pingback", "enable-data-reduction-proxy-force-pingback",
"enable-data-reduction-proxy-lite-page", "enable-data-reduction-proxy-lite-page",
@ -550,12 +565,10 @@ const char* blacklist[] = {
"enable-display-list-2d-canvas", "enable-display-list-2d-canvas",
"enable-distance-field-text", "enable-distance-field-text",
"enable-distillability-service", "enable-distillability-service",
"enabled-new-style-notification",
"enable-domain-reliability",
"enable-dom-distiller", "enable-dom-distiller",
"enable-domain-reliability",
"enable-drive-search-in-app-launcher", "enable-drive-search-in-app-launcher",
"enable-drm-atomic", "enable-drm-atomic",
"enabled-slow2g",
"enable-embedded-extension-options", "enable-embedded-extension-options",
"enable-encryption-migration", "enable-encryption-migration",
"enable-encryption-selection", "enable-encryption-selection",
@ -567,8 +580,8 @@ const char* blacklist[] = {
"enable-experimental-fullscreen-exit-ui", "enable-experimental-fullscreen-exit-ui",
"enable-experimental-input-view-features", "enable-experimental-input-view-features",
"enable-experimental-web-platform-features", "enable-experimental-web-platform-features",
"enable-extension-activity-logging",
"enable-extension-activity-log-testing", "enable-extension-activity-log-testing",
"enable-extension-activity-logging",
"enable-extension-assets-sharing", "enable-extension-assets-sharing",
"enable-external-drive-rename", "enable-external-drive-rename",
"enable-fast-unload", "enable-fast-unload",
@ -672,9 +685,9 @@ const char* blacklist[] = {
"enable-single-click-autofill", "enable-single-click-autofill",
"enable-site-settings", "enable-site-settings",
"enable-skia-benchmarking", "enable-skia-benchmarking",
"enable-slim-navigation-manager",
"enable-slimming-paint-invalidation", "enable-slimming-paint-invalidation",
"enable-slimming-paint-v2", "enable-slimming-paint-v2",
"enable-slim-navigation-manager",
"enable-smooth-scrolling", "enable-smooth-scrolling",
"enable-spatial-navigation", "enable-spatial-navigation",
"enable-spdy-proxy-auth", "enable-spdy-proxy-auth",
@ -708,9 +721,9 @@ const char* blacklist[] = {
"enable-tracing-output", "enable-tracing-output",
"enable-translate-new-ux", "enable-translate-new-ux",
"enable-ui-devtools", "enable-ui-devtools",
"enable-usermedia-screen-capturing",
"enable-user-metrics",
"enable-use-zoom-for-dsf", "enable-use-zoom-for-dsf",
"enable-user-metrics",
"enable-usermedia-screen-capturing",
"enable-video-player-chromecast-support", "enable-video-player-chromecast-support",
"enable-viewport", "enable-viewport",
"enable-virtual-keyboard", "enable-virtual-keyboard",
@ -718,11 +731,11 @@ const char* blacklist[] = {
"enable-vtune-support", "enable-vtune-support",
"enable-vulkan", "enable-vulkan",
"enable-wayland-server", "enable-wayland-server",
"enable-web-notification-custom-layouts",
"enable-webfonts-intervention-trigger", "enable-webfonts-intervention-trigger",
"enable-webfonts-intervention-v2", "enable-webfonts-intervention-v2",
"enable-webgl-draft-extensions", "enable-webgl-draft-extensions",
"enable-webgl-image-chromium", "enable-webgl-image-chromium",
"enable-web-notification-custom-layouts",
"enable-webrtc-event-logging-from-extension", "enable-webrtc-event-logging-from-extension",
"enable-webrtc-srtp-aes-gcm", "enable-webrtc-srtp-aes-gcm",
"enable-webrtc-srtp-encrypted-headers", "enable-webrtc-srtp-encrypted-headers",
@ -733,11 +746,16 @@ const char* blacklist[] = {
"enable-win7-webrtc-hw-h264-decoding", "enable-win7-webrtc-hw-h264-decoding",
"enable-zero-copy", "enable-zero-copy",
"enable-zip-archiver-on-file-manager", "enable-zip-archiver-on-file-manager",
"enabled",
"enabled-2g",
"enabled-3g",
"enabled-new-style-notification",
"enabled-slow2g",
"encode-binary", "encode-binary",
"enforce", "enforce",
"enforce-gl-minimums", "enforce-gl-minimums",
"enforce_strict",
"enforce-webrtc-ip-permission-check", "enforce-webrtc-ip-permission-check",
"enforce_strict",
"enterprise-disable-arc", "enterprise-disable-arc",
"enterprise-enable-forced-re-enrollment", "enterprise-enable-forced-re-enrollment",
"enterprise-enable-license-type-selection", "enterprise-enable-license-type-selection",
@ -745,8 +763,8 @@ const char* blacklist[] = {
"enterprise-enrollment-initial-modulus", "enterprise-enrollment-initial-modulus",
"enterprise-enrollment-modulus-limit", "enterprise-enrollment-modulus-limit",
"error-console", "error-console",
"evaluate_capability",
"evaluate-type", "evaluate-type",
"evaluate_capability",
"experiment", "experiment",
"explicitly-allowed-ports", "explicitly-allowed-ports",
"expose-internals-for-testing", "expose-internals-for-testing",
@ -774,8 +792,8 @@ const char* blacklist[] = {
"force-clamshell-power-button", "force-clamshell-power-button",
"force-color-profile", "force-color-profile",
"force-desktop-ios-promotion", "force-desktop-ios-promotion",
"force-device-scale-factor",
"force-dev-mode-highlighting", "force-dev-mode-highlighting",
"force-device-scale-factor",
"force-display-list-2d-canvas", "force-display-list-2d-canvas",
"force-effective-connection-type", "force-effective-connection-type",
"force-enable-metrics-reporting", "force-enable-metrics-reporting",
@ -814,8 +832,8 @@ const char* blacklist[] = {
"generate-accessibility-test-expectations", "generate-accessibility-test-expectations",
"gl", "gl",
"gl-composited-overlay-candidate-quad-border", "gl-composited-overlay-candidate-quad-border",
"gles",
"gl-shader-interm-output", "gl-shader-interm-output",
"gles",
"golden-screenshots-dir", "golden-screenshots-dir",
"google-apis-url", "google-apis-url",
"google-base-url", "google-base-url",
@ -875,9 +893,11 @@ const char* blacklist[] = {
"ignore-gpu-blacklist", "ignore-gpu-blacklist",
"ignore-urlfetcher-cert-requests", "ignore-urlfetcher-cert-requests",
"ignore-user-profile-mapping-for-tests", "ignore-user-profile-mapping-for-tests",
"incognito",
"in-process-gpu", "in-process-gpu",
"incognito",
"input", "input",
"inspect",
"inspect-brk",
"install-chrome-app", "install-chrome-app",
"install-supervised-user-whitelists", "install-supervised-user-whitelists",
"instant-process", "instant-process",
@ -885,9 +905,9 @@ const char* blacklist[] = {
"ipc-connection-timeout", "ipc-connection-timeout",
"ipc-dump-directory", "ipc-dump-directory",
"ipc-fuzzer-testcase", "ipc-fuzzer-testcase",
"is-running-in-mash",
"isolate-origins", "isolate-origins",
"isolate-sites-for-testing", "isolate-sites-for-testing",
"is-running-in-mash",
"javascript-harmony", "javascript-harmony",
"js-flags", "js-flags",
"keep-alive-for-test", "keep-alive-for-test",
@ -907,11 +927,11 @@ const char* blacklist[] = {
"local-ntp-reload", "local-ntp-reload",
"local-sync-backend-dir", "local-sync-backend-dir",
"log-gpu-control-list-decisions", "log-gpu-control-list-decisions",
"log-level",
"log-net-log",
"login-manager", "login-manager",
"login-profile", "login-profile",
"login-user", "login-user",
"log-level",
"log-net-log",
"loopback-i2s-bits", "loopback-i2s-bits",
"loopback-i2s-bus-name", "loopback-i2s-bus-name",
"loopback-i2s-channels", "loopback-i2s-channels",
@ -923,9 +943,9 @@ const char* blacklist[] = {
"make-default-browser", "make-default-browser",
"managed-user-id", "managed-user-id",
"managed-user-sync-token", "managed-user-sync-token",
"mark-non-secure-as",
"markdown", "markdown",
"market-url-for-testing", "market-url-for-testing",
"mark-non-secure-as",
"mash", "mash",
"material", "material",
"material-design-ink-drop-animation-speed", "material-design-ink-drop-animation-speed",
@ -935,11 +955,11 @@ const char* blacklist[] = {
"max-untiled-layer-height", "max-untiled-layer-height",
"max-untiled-layer-width", "max-untiled-layer-width",
"media-cache-size", "media-cache-size",
"mem-pressure-system-reserved-kb",
"memlog", "memlog",
"memory-pressure-off", "memory-pressure-off",
"memory-pressure-thresholds", "memory-pressure-thresholds",
"memory-pressure-thresholds-mb", "memory-pressure-thresholds-mb",
"mem-pressure-system-reserved-kb",
"message-center-changes-while-open", "message-center-changes-while-open",
"method", "method",
"metrics-client-id", "metrics-client-id",
@ -965,37 +985,37 @@ const char* blacklist[] = {
"native", "native",
"native-crx-bindings", "native-crx-bindings",
"need-arc-migration-policy-check", "need-arc-migration-policy-check",
"netifs-to-ignore",
"net-log-capture-mode", "net-log-capture-mode",
"netifs-to-ignore",
"network-country-iso", "network-country-iso",
"network-settings-config", "network-settings-config",
"new-window", "new-window",
"nocolor",
"no-default-browser-check", "no-default-browser-check",
"noerrdialogs",
"no-experiments", "no-experiments",
"no-first-run", "no-first-run",
"no-managed-user-acknowledgment-check", "no-managed-user-acknowledgment-check",
"none",
"no-network-profile-warning", "no-network-profile-warning",
"no-pings",
"no-proxy-server",
"no-referrers",
"no-sandbox",
"no-service-autorun",
"no-session-id",
"no-startup-window",
"no-user-gesture-required",
"no-wifi",
"no-zygote",
"nocolor",
"noerrdialogs",
"non-material", "non-material",
"non-secure", "non-secure",
"non-secure-after-editing", "non-secure-after-editing",
"non-secure-while-incognito", "non-secure-while-incognito",
"non-secure-while-incognito-or-editing", "non-secure-while-incognito-or-editing",
"no-pings", "none",
"no-proxy-server",
"no-referrers",
"normal_muted", "normal_muted",
"normal_vibrant", "normal_vibrant",
"no-sandbox",
"no-service-autorun",
"no-session-id",
"no-startup-window",
"note-taking-app-ids", "note-taking-app-ids",
"no-user-gesture-required",
"no-wifi",
"no-zygote",
"ntp-snippets-add-incomplete", "ntp-snippets-add-incomplete",
"null", "null",
"num-raster-threads", "num-raster-threads",
@ -1010,10 +1030,10 @@ const char* blacklist[] = {
"oobe-timer-interval", "oobe-timer-interval",
"open-ash", "open-ash",
"opengraph", "opengraph",
"original-process-start-time",
"origin-trial-disabled-features", "origin-trial-disabled-features",
"origin-trial-disabled-tokens", "origin-trial-disabled-tokens",
"origin-trial-public-key", "origin-trial-public-key",
"original-process-start-time",
"osmesa", "osmesa",
"output", "output",
"override", "override",
@ -1042,13 +1062,6 @@ const char* blacklist[] = {
"ppapi-plugin-launcher", "ppapi-plugin-launcher",
"ppapi-startup-dialog", "ppapi-startup-dialog",
"ppapi-subpixel-rendering-setting", "ppapi-subpixel-rendering-setting",
"/prefetch:1",
"/prefetch:2",
"/prefetch:3",
"/prefetch:4",
"/prefetch:5",
"/prefetch:6",
"/prefetch:8",
"previous-app", "previous-app",
"primary", "primary",
"print-to-pdf", "print-to-pdf",
@ -1075,8 +1088,8 @@ const char* blacklist[] = {
"reader-mode-heuristics", "reader-mode-heuristics",
"rebaseline-pixel-tests", "rebaseline-pixel-tests",
"record-type", "record-type",
"reduced-referrer-granularity",
"reduce-security-for-testing", "reduce-security-for-testing",
"reduced-referrer-granularity",
"register-font-files", "register-font-files",
"register-pepper-plugins", "register-pepper-plugins",
"relauncher", "relauncher",
@ -1108,7 +1121,6 @@ const char* blacklist[] = {
"safebrowsing-disable-download-protection", "safebrowsing-disable-download-protection",
"safebrowsing-disable-extension-blacklist", "safebrowsing-disable-extension-blacklist",
"safebrowsing-manual-download-blacklist", "safebrowsing-manual-download-blacklist",
"SafeSites",
"sandbox-ipc", "sandbox-ipc",
"save-page-as-mhtml", "save-page-as-mhtml",
"screen-config", "screen-config",
@ -1178,10 +1190,10 @@ const char* blacklist[] = {
"ssl-version-max", "ssl-version-max",
"ssl-version-min", "ssl-version-min",
"stable-release-mode", "stable-release-mode",
"started",
"start-fullscreen", "start-fullscreen",
"start-maximized", "start-maximized",
"start-stack-profiler", "start-stack-profiler",
"started",
"stub", "stub",
"stub-cros-settings", "stub-cros-settings",
"surface", "surface",
@ -1209,8 +1221,6 @@ const char* blacklist[] = {
"test-do-not-initialize-icu", "test-do-not-initialize-icu",
"test-encryption-migration-ui", "test-encryption-migration-ui",
"test-gl-lib", "test-gl-lib",
"testing-fixed-http-port",
"testing-fixed-https-port",
"test-launcher-batch-limit", "test-launcher-batch-limit",
"test-launcher-bot-mode", "test-launcher-bot-mode",
"test-launcher-debug-launcher", "test-launcher-debug-launcher",
@ -1231,6 +1241,8 @@ const char* blacklist[] = {
"test-name", "test-name",
"test-tiny-timeout", "test-tiny-timeout",
"test-type", "test-type",
"testing-fixed-http-port",
"testing-fixed-https-port",
"tether-stub", "tether-stub",
"third-party-doodle-url", "third-party-doodle-url",
"threads", "threads",
@ -1252,7 +1264,6 @@ const char* blacklist[] = {
"touch_view", "touch_view",
"trace-config-file", "trace-config-file",
"trace-export-events-to-etw", "trace-export-events-to-etw",
"tracelog",
"trace-shutdown", "trace-shutdown",
"trace-shutdown-file", "trace-shutdown-file",
"trace-startup", "trace-startup",
@ -1262,6 +1273,7 @@ const char* blacklist[] = {
"trace-to-file", "trace-to-file",
"trace-to-file-name", "trace-to-file-name",
"trace-upload-url", "trace-upload-url",
"tracelog",
"translate-ranker-model-url", "translate-ranker-model-url",
"translate-script-url", "translate-script-url",
"translate-security-origin", "translate-security-origin",
@ -1287,9 +1299,9 @@ const char* blacklist[] = {
"ui-test-action-timeout", "ui-test-action-timeout",
"uninstall", "uninstall",
"unlimited-storage", "unlimited-storage",
"unsafe-pac-url",
"unsafely-allow-protected-media-identifier-for-domain", "unsafely-allow-protected-media-identifier-for-domain",
"unsafely-treat-insecure-origin-as-secure", "unsafely-treat-insecure-origin-as-secure",
"unsafe-pac-url",
"use-angle", "use-angle",
"use-cras", "use-cras",
"use-fake-device-for-media-stream", "use-fake-device-for-media-stream",
@ -1304,15 +1316,15 @@ const char* blacklist[] = {
"use-mobile-user-agent", "use-mobile-user-agent",
"use-mock-keychain", "use-mock-keychain",
"use-passthrough-cmd-decoder", "use-passthrough-cmd-decoder",
"use-skia-renderer",
"use-system-default-printer",
"use-test-config",
"use-viz-hit-test",
"user-agent", "user-agent",
"user-always-affiliated", "user-always-affiliated",
"user-data-dir", "user-data-dir",
"user-gesture-required", "user-gesture-required",
"user-gesture-required-for-cross-origin", "user-gesture-required-for-cross-origin",
"use-skia-renderer",
"use-system-default-printer",
"use-test-config",
"use-viz-hit-test",
"utility", "utility",
"utility-allowed-dir", "utility-allowed-dir",
"utility-cmd-prefix", "utility-cmd-prefix",
@ -1346,16 +1358,16 @@ const char* blacklist[] = {
"webview-enable-safebrowsing-support", "webview-enable-safebrowsing-support",
"webview-sandboxed-renderer", "webview-sandboxed-renderer",
"whitelisted-extension-id", "whitelisted-extension-id",
"win-jumplist-action",
"window-position", "window-position",
"windows10-custom-titlebar",
"window-size", "window-size",
"window-workspace", "window-workspace",
"windows10-custom-titlebar",
"winhttp-proxy-resolver", "winhttp-proxy-resolver",
"win-jumplist-action",
"wm-window-animations-disabled", "wm-window-animations-disabled",
"yield-between-content-script-runs", "yield-between-content-script-runs",
"zygote", "zygote",
"zygote-cmd-prefix" "zygote-cmd-prefix",
}; };
bool IsBlacklistedArg(const base::CommandLine::CharType* arg) { bool IsBlacklistedArg(const base::CommandLine::CharType* arg) {
@ -1379,9 +1391,10 @@ bool IsBlacklistedArg(const base::CommandLine::CharType* arg) {
if (prefix_length > 0) { if (prefix_length > 0) {
a += prefix_length; a += prefix_length;
std::string switch_name(a, strcspn(a, "=")); std::string switch_name(a, strcspn(a, "="));
for (auto& item : blacklist) { auto* iter = std::lower_bound(std::begin(kBlacklist), std::end(kBlacklist),
if (switch_name == item) switch_name);
return true; if (iter != std::end(kBlacklist) && switch_name == *iter) {
return true;
} }
} }
@ -1393,6 +1406,16 @@ bool IsBlacklistedArg(const base::CommandLine::CharType* arg) {
namespace atom { namespace atom {
bool CheckCommandLineArguments(int argc, base::CommandLine::CharType** argv) { bool CheckCommandLineArguments(int argc, base::CommandLine::CharType** argv) {
DCHECK(std::is_sorted(std::begin(kBlacklist), std::end(kBlacklist),
[](const char* a, const char* b) {
return base::StringPiece(a) < base::StringPiece(b);
}))
<< "The kBlacklist must be in sorted order";
DCHECK_NE(std::find(std::begin(kBlacklist), std::end(kBlacklist),
base::StringPiece("inspect")),
std::end(kBlacklist))
<< "Do not forget to add Node command line flags to kBlacklist";
const base::CommandLine::StringType dashdash(2, '-'); const base::CommandLine::StringType dashdash(2, '-');
bool block_blacklisted_args = false; bool block_blacklisted_args = false;
for (int i = 0; i < argc; ++i) { for (int i = 0; i < argc; ++i) {